- All Superinterfaces:
AutoCloseable
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this writer and free any resources associated with the writer.Complete a component of a composite element.Complete an element.Completes an interchange and returns the writer to its initial state.voidflush()Write any cached data to the underlying output mechanism.Returns the control schema currently set on the reader.Retrieve a read-only map of delimiters in use for the stream being written.Return the current location of the writer.getProperty(String name) Get the value of a feature/property from the underlying implementationGet the EDI standard name.voidsetControlSchema(Schema controlSchema) Sets the schema to be used for validation of the control structure for this stream writer.voidsetTransactionSchema(Schema transactionSchema) Sets the schema to be used for validation of the business transaction for this stream writer.Start a component of a composite element.Initialize this writer to begin writing an interchange.writeBinaryData(byte[] binary, int start, int end) Write binary data from the given byte array to the output.writeBinaryData(InputStream stream) Write binary data from the given InputStream to the output.writeBinaryData(ByteBuffer buffer) Write binary data from the given buffer to the output.writeComponent(char[] text, int start, int end) Begin a component element, write text data from the given char array to the output, and end the element.writeComponent(CharSequence text) Begin a component element, write text data from the given CharSequence to the output, and end the element.writeElement(char[] text, int start, int end) Begin an element, write text data from the given char array to the output, and end the element.writeElement(CharSequence text) Begin an element, write text data from the given CharSequence to the output, and end the element.writeElementData(char[] text, int start, int end) Write text data from the given char array to the output.writeElementData(CharSequence text) Write text data from the given CharSequence to the output.Write an empty componentWrite an empty simple element.Complete a segment by writing the segment terminator to the underlying output.Write an element repeat delimiter/separator to the output stream.Start a new element, composite or simple.Start a new element for binary data.writeStartSegment(String name) Begin a new segment with the given name and write the tag to the underlying output.
-
Method Details
-
getProperty
Get the value of a feature/property from the underlying implementation- Parameters:
name- - The name of the property, may not be null- Returns:
- The value of the property
- Throws:
IllegalArgumentException- if name is null
-
close
Close this writer and free any resources associated with the writer. This must not close the underlying output stream.- Specified by:
closein interfaceAutoCloseable- Throws:
EDIStreamException- if there are errors freeing associated resources
-
flush
Write any cached data to the underlying output mechanism.- Throws:
EDIStreamException- if there are errors flushing the cache
-
getControlSchema
Schema getControlSchema()Returns the control schema currently set on the reader. If none has been set, then null will be returned.- Returns:
- the control schema current set on this reader, may be null
- Since:
- 1.8
-
setControlSchema
Sets the schema to be used for validation of the control structure for this stream writer. This schema will be used to validate interchange, group, and transaction/message envelopes.
Calls to this method are only valid before the interchange is started.
A built-in control schema may be obtained from
SchemaFactory#getControlSchemato pass to this method.- Parameters:
controlSchema- the schema instance to use for validation of control structures- Throws:
IllegalStateException- when the writer is not in its initial state- Since:
- 1.1
- See Also:
-
setTransactionSchema
Sets the schema to be used for validation of the business transaction for this stream writer. This schema will be used to validate only the contents of a transaction/message, not including the begin/end control structures.
This method may be called at any time. However, when non-null, the writer will make use of the transaction schema for output validation. It is the responsibility of the caller to set the transaction schema to null at the end of the business transaction.
- Parameters:
transactionSchema- the schema instance to use for validation of business transaction structures- Since:
- 1.1
-
getLocation
Location getLocation()Return the current location of the writer. If the Location is unknown the processor should return an implementation of Location that returns -1 for the location values. The location information is only valid until the next item is written to the output.- Returns:
- current location of the writer
- Since:
- 1.1
-
getStandard
String getStandard()Get the EDI standard name. Calls to this method are only valid when the interchange type has been determined, after the full interchange header segment has been written.- Returns:
- the name of the EDI standard
- Throws:
IllegalStateException- when the standard has not yet been determined, prior to the start of an interchange header segment being fully written- Since:
- 1.7
-
getDelimiters
Retrieve a read-only map of delimiters in use for the stream being written.- Returns:
- The value of the property
- Throws:
IllegalStateException- when the standard has not yet been determined, prior to the start of an interchange header segment being fully written- Since:
- 1.8
-
startInterchange
Initialize this writer to begin writing an interchange. This method does not write any output to the underlying stream.- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- is not thrown and will be removed in the next major version of StAEDI.IllegalStateException- when the writer is in any state other than the initial state
-
endInterchange
Completes an interchange and returns the writer to its initial state. Any data pending output will be flushed.- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is in a state writing a segment, element, composite
-
writeStartSegment
Begin a new segment with the given name and write the tag to the underlying output.- Parameters:
name- name of the segment (i.e. the segment tag)- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state to begin a segment
-
writeEndSegment
Complete a segment by writing the segment terminator to the underlying output.- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state to end a segment
-
writeStartElement
Start a new element, composite or simple.- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when a segment has not been started withwriteStartSegment(String)
-
writeStartElementBinary
Start a new element for binary data.- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the a segment has not been started withwriteStartSegment(String)
-
endElement
Complete an element. A delimiter will not be written immediately.- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in the state of writing an element
-
writeRepeatElement
Write an element repeat delimiter/separator to the output stream. Following this method being called, the writer will be in a state to accept element data usingwriteElementData(CharSequence)orwriteElementData(char[], int, int).- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing element data. A segment must have already been started.
-
startComponent
Start a component of a composite element.- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when an element has not been started withwriteStartElement()
-
endComponent
Complete a component of a composite element.- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in the state of writing an component element
-
writeEmptyElement
Write an empty simple element.Shorthand for calling
writeStartElement()immediately followed byendElement().- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing simple element data
-
writeElement
Begin an element, write text data from the given CharSequence to the output, and end the element.Shorthand for calling
writeStartElement(),writeElementData(CharSequence), andendElement(), in that order.- Parameters:
text- CharSequence containing element's full text data- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing simple element data
-
writeElement
Begin an element, write text data from the given char array to the output, and end the element. Data will be read from the offset given by start (inclusive) to the offset given by end (exclusive).Shorthand for calling
writeStartElement(),writeElementData(char[], int, int), andendElement(), in that order.- Parameters:
text- char array containing element's full text datastart- the start index, inclusiveend- the end index, exclusive- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing simple element data
-
writeEmptyComponent
Write an empty componentShorthand for calling
startComponent()immediately followed byendComponent().- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing component element data
-
writeComponent
Begin a component element, write text data from the given CharSequence to the output, and end the element.Shorthand for calling
startComponent(),writeElementData(CharSequence), andendComponent(), in that order.- Parameters:
text- CharSequence containing component's full text data- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing component element data
-
writeComponent
Begin a component element, write text data from the given char array to the output, and end the element. Data will be read from the offset given by start (inclusive) to the offset given by end (exclusive).Shorthand for calling
startComponent(),writeElementData(char[], int, int), andendComponent(), in that order.- Parameters:
text- char array containing component's full text datastart- the start index, inclusiveend- the end index, exclusive- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing component element data
-
writeElementData
Write text data from the given CharSequence to the output.- Parameters:
text- CharSequence containing element text data- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing element data. See writeStartElement()
-
writeElementData
Write text data from the given char array to the output. Data will be read from the offset given by start (inclusive) to the offset given by end (exclusive).- Parameters:
text- char array containing element text datastart- the start index, inclusiveend- the end index, exclusive- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing element data. See writeStartElement()
-
writeBinaryData
Write binary data from the given InputStream to the output. The stream will be read fully, until the byte returned by InputStream.read() is-1. Any data pending output will first be flushed.- Parameters:
stream- InputStream containing binary data to be consumed by the reader and written to the underlying output- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing binary element data. See writeStartElementBinary()
-
writeBinaryData
Write binary data from the given byte array to the output. Data will be read from the offset given by start (inclusive) to the offset given by end (exclusive). Any data pending output will first be flushed.- Parameters:
binary- byte array containing binary datastart- the start index, inclusiveend- the end index, exclusive- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing binary element data. See writeStartElementBinary()
-
writeBinaryData
Write binary data from the given buffer to the output. Any data pending output will first be flushed.- Parameters:
buffer- data buffer containing binary data- Returns:
- this EDI stream writer
- Throws:
EDIStreamException- if an error occursIllegalStateException- when the writer is not in a state for writing binary element data. See writeStartElementBinary()
-