Package org.apache.maven.doxia.util
Class LineBreaker
java.lang.Object
org.apache.maven.doxia.util.LineBreaker
Allows to specify the line-length of an output writer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The default maximal line length.private Writer
The destination writer.private static final String
The system dependent EOL.private int
The current line length.private int
The maximal line length.private StringBuilder
The string buffer to store the current text.private BufferedWriter
The writer to use. -
Constructor Summary
ConstructorsConstructorDescriptionLineBreaker
(Writer out) Constructs a new LineBreaker with DEFAULT_MAX_LINE_LENGTH.LineBreaker
(Writer out, int max) Constructs a new LineBreaker with the given max line length. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the writer.void
flush()
Write out the current StringBuilder and flush the writer.Returns the current destination writer.void
Writes the given text to the writer.void
Writes the given text to the writer.private void
Writes the current StringBuilder to the writer.
-
Field Details
-
DEFAULT_MAX_LINE_LENGTH
public static final int DEFAULT_MAX_LINE_LENGTHThe default maximal line length.- See Also:
-
EOL
The system dependent EOL. -
destination
The destination writer. -
writer
The writer to use. -
maxLineLength
private int maxLineLengthThe maximal line length. -
lineLength
private int lineLengthThe current line length. -
word
The string buffer to store the current text.
-
-
Constructor Details
-
LineBreaker
Constructs a new LineBreaker with DEFAULT_MAX_LINE_LENGTH.- Parameters:
out
- The writer to use.
-
LineBreaker
Constructs a new LineBreaker with the given max line length.- Parameters:
out
- The writer to use.max
- The maximal line length.
-
-
Method Details
-
getDestination
Returns the current destination writer.- Returns:
- The destination.
-
write
Writes the given text to the writer. White space is not preserved.- Parameters:
text
- The text to write.- Throws:
IOException
- if there's a problem writing the text.
-
write
Writes the given text to the writer.- Parameters:
text
- The text to write.preserveSpace
- True to preserve white space.
-
flush
public void flush()Write out the current StringBuilder and flush the writer. Any IOException will be swallowed. -
writeWord
Writes the current StringBuilder to the writer.- Throws:
IOException
- if an exception occurs during writing.
-
close
public void close()Close the writer.
-