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 until
chunkCompleted() 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 for
getConverter() to reduce dependencies on <T>. Moreover, add(String, Object) shall
be directly used in combination with InputParser.InputConverter to avoid exposing <T> unless explicitly
necessary.
This interface is used to generate connector code against.- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceConverts primitive types to the output format. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds information to one chunk of output.byte[]Completes a chunk of output data.voidEnds a structure started before.Returns the output converter.voidstartArrayStructure(String name) Starts an array structure.voidstartObjectStructure(String name) Starts an object structure.
-
Field Details
-
SEPARATOR
static final char SEPARATORSeparator for hierarchical names.- See Also:
-
-
Method Details
-
add
Adds 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:
IOException- if adding the data fails for some reason
-
startArrayStructure
Starts 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:
IOException- if starting this structure fails
-
startObjectStructure
Starts 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:
IOException- if starting this structure fails
-
endStructure
Ends a structure started before.- Throws:
IOException- if ending the actual structure fails
-
chunkCompleted
Completes a chunk of output data.- Returns:
- the chunk
- Throws:
IOException- if creating the chunk fails for some reason
-
getConverter
OutputFormatter.OutputConverter<T> getConverter()Returns the output converter.- Returns:
- the output converter
-