Class TextLineFormatter
- java.lang.Object
-
- de.iip_ecosphere.platform.connectors.formatter.TextLineFormatter
-
- All Implemented Interfaces:
OutputFormatter<java.lang.String>
@MachineFormatter public class TextLineFormatter extends java.lang.Object implements OutputFormatter<java.lang.String>
A simple text line formatter for given separators. Field names are ignored.- Author:
- Holger Eichelberger, SSE
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTextLineFormatter.TextLineFormatterConverterOwn parser converter type to hide implementing class for future modifications.-
Nested classes/interfaces inherited from interface de.iip_ecosphere.platform.connectors.formatter.OutputFormatter
OutputFormatter.OutputConverter<T>
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringcharsetstatic TextLineFormatter.TextLineFormatterConverterCONVERTERprivate java.lang.Stringseparatorprivate java.lang.StringBuildertmp-
Fields inherited from interface de.iip_ecosphere.platform.connectors.formatter.OutputFormatter
SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description TextLineFormatter(java.lang.String charset, java.lang.String separator)Creates a new text line formatter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.String name, java.lang.String data)Adds information to one chunk of output.byte[]chunkCompleted()Completes a chunk of output data.voidendStructure()Ends a structure started before.TextLineFormatter.TextLineFormatterConvertergetConverter()Returns the output converter.voidstartArrayStructure(java.lang.String name)Starts an array structure.voidstartObjectStructure(java.lang.String name)Starts an object structure.
-
-
-
Field Detail
-
CONVERTER
public static final TextLineFormatter.TextLineFormatterConverter CONVERTER
-
charset
private java.lang.String charset
-
separator
private java.lang.String separator
-
tmp
private java.lang.StringBuilder tmp
-
-
Method Detail
-
add
public void add(java.lang.String name, java.lang.String data) throws java.io.IOExceptionDescription copied from interface:OutputFormatterAdds information to one chunk of output. Hierarchical names separated byOutputFormatter.SEPARATORcan be used, but nested values for the same parent (object) field must be named in sequence.- Specified by:
addin interfaceOutputFormatter<java.lang.String>- Parameters:
name- optional data name field (may be null for none)data- the data to be added- Throws:
java.io.IOException- if adding the data fails for some reason
-
chunkCompleted
public byte[] chunkCompleted() throws java.io.IOExceptionDescription copied from interface:OutputFormatterCompletes a chunk of output data.- Specified by:
chunkCompletedin interfaceOutputFormatter<java.lang.String>- Returns:
- the chunk
- Throws:
java.io.IOException- if creating the chunk fails for some reason
-
getConverter
public TextLineFormatter.TextLineFormatterConverter getConverter()
Description copied from interface:OutputFormatterReturns the output converter.- Specified by:
getConverterin interfaceOutputFormatter<java.lang.String>- Returns:
- the output converter
-
startArrayStructure
public void startArrayStructure(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:OutputFormatterStarts an array structure. FollowingOutputFormatter.add(String, Object)calls will add elements to the array. Must be closed withOutputFormatter.endStructure()- Specified by:
startArrayStructurein interfaceOutputFormatter<java.lang.String>- Parameters:
name- optional data name field holding the array (may be null for none)- Throws:
java.io.IOException- if starting this structure fails
-
startObjectStructure
public void startObjectStructure(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:OutputFormatterStarts an object structure. FollowingOutputFormatter.add(String, Object)calls will add elements to the object. Must be closed withOutputFormatter.endStructure()- Specified by:
startObjectStructurein interfaceOutputFormatter<java.lang.String>- Parameters:
name- optional data name field holding the array (may be null for none)- Throws:
java.io.IOException- if starting this structure fails
-
endStructure
public void endStructure() throws java.io.IOExceptionDescription copied from interface:OutputFormatterEnds a structure started before.- Specified by:
endStructurein interfaceOutputFormatter<java.lang.String>- Throws:
java.io.IOException- if ending the actual structure fails
-
-