Package com.compomics.util.io.export.xml
Class SimpleXmlWriter
java.lang.Object
com.compomics.util.io.export.xml.SimpleXmlWriter
- All Implemented Interfaces:
AutoCloseable
Simple writer for xml files.
- Author:
- Marc Vaudel
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intInteger keeping track of the number of indents to include at the beginning of each line. -
Constructor Summary
ConstructorsConstructorDescriptionEmpty default constructorConstructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidDecreases the indent counter.Returns the indent string to use, e.g.voidIncreases the indent counter.voidnewLine()Adds an end of line character.voidsetIndentString(String indentString) Sets the indent string to use, e.g.voidWrites the content to the file.voidWrites the current indent.voidWrites the given line.voidWrites the given line with a decreased indent.voidWrites 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:
closein interfaceAutoCloseable- Throws:
IOException
-