Interface OutputFormatter<T>
-
- Type Parameters:
T- the output format type
- All Known Implementing Classes:
DummyFormatter,JsonOutputFormatter,TextLineFormatter
public interface OutputFormatter<T>Generic output formatter. You may add information to one chunk untilchunkCompleted()is called. Custom implementations must have a constructor with a single String argument, the character encoding name. Implementing classes shall use their specific rather than generic return types forgetConverter()to reduce dependencies on<T>. Moreover,add(String, Object)shall be directly used in combination withInputParser.InputConverterto avoid exposing<T>unless explicitly necessary. This interface is used to generate connector code against.- Author:
- Holger Eichelberger, SSE
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceOutputFormatter.OutputConverter<T>Converts primitive types to the output format.
-
Field Summary
Fields Modifier and Type Field Description static charSEPARATORSeparator for hierarchical names.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadd(java.lang.String name, T data)Adds information to one chunk of output.byte[]chunkCompleted()Completes a chunk of output data.voidendStructure()Ends a structure started before.OutputFormatter.OutputConverter<T>getConverter()Returns the output converter.voidstartArrayStructure(java.lang.String name)Starts an array structure.voidstartObjectStructure(java.lang.String name)Starts an object structure.
-
-
-
Field Detail
-
SEPARATOR
static final char SEPARATOR
Separator for hierarchical names.- See Also:
- Constant Field Values
-
-
Method Detail
-
add
void add(java.lang.String name, T data) throws java.io.IOExceptionAdds information to one chunk of output. Hierarchical names separated bySEPARATORcan be used, but nested values for the same parent (object) field must be named in sequence.- 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
-
startArrayStructure
void startArrayStructure(java.lang.String name) throws java.io.IOExceptionStarts an array structure. Followingadd(String, Object)calls will add elements to the array. Must be closed withendStructure()- Parameters:
name- optional data name field holding the array (may be null for none)- Throws:
java.io.IOException- if starting this structure fails
-
startObjectStructure
void startObjectStructure(java.lang.String name) throws java.io.IOExceptionStarts an object structure. Followingadd(String, Object)calls will add elements to the object. Must be closed withendStructure()- Parameters:
name- optional data name field holding the array (may be null for none)- Throws:
java.io.IOException- if starting this structure fails
-
endStructure
void endStructure() throws java.io.IOExceptionEnds a structure started before.- Throws:
java.io.IOException- if ending the actual structure fails
-
chunkCompleted
byte[] chunkCompleted() throws java.io.IOExceptionCompletes a chunk of output data.- Returns:
- the chunk
- Throws:
java.io.IOException- if creating the chunk fails for some reason
-
getConverter
OutputFormatter.OutputConverter<T> getConverter()
Returns the output converter.- Returns:
- the output converter
-
-