Class AbstractTextFormatWriter
java.lang.Object
org.apache.commons.geometry.io.core.utils.AbstractTextFormatWriter
- All Implemented Interfaces:
Closeable, AutoCloseable
- Direct Known Subclasses:
ObjWriter, TextFacetDefinitionWriter, TextStlWriter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringThe default line separator value.private DoubleFunction<String> Double format function.private StringLine separator string.private final WriterUnderlying writer instance. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractTextFormatWriter(Writer writer) Construct a new instance that writes content to the given writer.protectedAbstractTextFormatWriter(Writer writer, DoubleFunction<String> doubleFormat) Construct a new instance that writes content to the given writer and uses the decimal format instance for creating floating-point string representations. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Get the function used to format floating point output.Get the current line separator.protected WriterGet the underlying writer instance.voidsetDoubleFormat(DoubleFunction<String> doubleFormat) Set the function used to format floating point output.voidsetLineSeparator(String lineSeparator) Set the line separator.protected voidwrite(char c) Write a char value.protected voidwrite(double d) Write a double value formatted using the configured decimal format function.protected voidwrite(int n) Write an integer value.protected voidWrite a string.protected voidWrite the configured line separator to the output.
-
Field Details
-
DEFAULT_LINE_SEPARATOR
-
writer
Underlying writer instance. -
lineSeparator
Line separator string. -
doubleFormat
Double format function.
-
-
Constructor Details
-
AbstractTextFormatWriter
Construct a new instance that writes content to the given writer.- Parameters:
writer- writer instance
-
AbstractTextFormatWriter
Construct a new instance that writes content to the given writer and uses the decimal format instance for creating floating-point string representations.- Parameters:
writer- writer instancedoubleFormat- double format function
-
-
Method Details
-
getLineSeparator
-
setLineSeparator
Set the line separator.- Parameters:
lineSeparator- the line separator to use
-
getDoubleFormat
Get the function used to format floating point output.- Returns:
- the double format function
-
setDoubleFormat
Set the function used to format floating point output.- Parameters:
doubleFormat- double format function
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getWriter
-
write
protected void write(double d) Write a double value formatted using the configured decimal format function.- Parameters:
d- value to write- Throws:
UncheckedIOException- if an I/O error occurs
-
write
protected void write(int n) Write an integer value.- Parameters:
n- value to write- Throws:
UncheckedIOException- if an I/O error occurs
-
write
protected void write(char c) Write a char value.- Parameters:
c- character to write- Throws:
UncheckedIOException- if an I/O error occurs
-
write
Write a string.- Parameters:
str- string to write- Throws:
UncheckedIOException- if an I/O error occurs
-
writeNewLine
protected void writeNewLine()Write the configured line separator to the output.- Throws:
UncheckedIOException- if an I/O error occurs
-