Package com.compomics.util.io.export.xml
Class SimpleXmlWriter
java.lang.Object
com.compomics.util.io.export.xml.SimpleXmlWriter
- All Implemented Interfaces:
AutoCloseable
public class SimpleXmlWriter extends Object implements AutoCloseable
Simple writer for xml files.
- Author:
- Marc Vaudel
-
Field Summary
Fields Modifier and Type Field Description protected int
indentCounter
Integer keeping track of the number of indents to include at the beginning of each line. -
Constructor Summary
Constructors Constructor Description SimpleXmlWriter()
Empty default constructorSimpleXmlWriter(BufferedWriter bw)
Constructor. -
Method Summary
Modifier and Type Method Description void
close()
void
decreaseIndent()
Decreases the indent counter.String
getIndentString()
Returns the indent string to use, e.g.void
increaseIndent()
Increases the indent counter.void
newLine()
Adds an end of line character.void
setIndentString(String indentString)
Sets the indent string to use, e.g.void
write(String content)
Writes the content to the file.void
writeIndent()
Writes the current indent.void
writeLine(String line)
Writes the given line.void
writeLineDecreasedIndent(String line)
Writes the given line with a decreased indent.void
writeLineIncreasedIndent(String line)
Writes the given line with an increased indent.
-
Field Details
-
indentCounter
protected int indentCounterInteger keeping track of the number of indents to include at the beginning of each line.
-
-
Constructor Details
-
SimpleXmlWriter
public SimpleXmlWriter()Empty default constructor -
SimpleXmlWriter
Constructor.- Parameters:
bw
- the buffered writer to use.
-
-
Method Details
-
getIndentString
Returns the indent string to use, e.g. tab or space.- Returns:
- the indent string to use
-
setIndentString
Sets the indent string to use, e.g. tab or space.- Parameters:
indentString
- the indent string to use
-
writeIndent
Writes the current indent.- Throws:
IOException
- exception thrown whenever an error occurs while writing
-
write
Writes the content to the file.- Parameters:
content
- the content as String- Throws:
IOException
- exception thrown whenever an error occurs while writing
-
writeLine
Writes the given line.- Parameters:
line
- the line to write- Throws:
IOException
- exception thrown whenever an error occurs while writing
-
writeLineIncreasedIndent
Writes the given line with an increased indent.- Parameters:
line
- the line to write- Throws:
IOException
- exception thrown whenever an error occurs while writing
-
writeLineDecreasedIndent
Writes the given line with a decreased indent.- Parameters:
line
- the line to write- Throws:
IOException
- exception thrown whenever an error occurs while writing
-
newLine
Adds an end of line character.- Throws:
IOException
- exception thrown whenever an error occurs while writing
-
increaseIndent
public void increaseIndent()Increases the indent counter. -
decreaseIndent
public void decreaseIndent()Decreases the indent counter. -
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-