Package com.adaptris.edi.model
Class Segment
java.lang.Object
com.adaptris.edi.model.Segment
- All Implemented Interfaces:
DataModelPart,SearchableListItem
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(DataModelPart child) Add a child DataModelPart to this treeprotected voidcheckType(ContainerPart container, String expectedType) protected StringconvertNull(String s, boolean toEmptyString) voiddocument(StringBuffer sb, int indent) protected byte[]escapeCharacters(byte[] bytes, char character, char escape, String charset) getChild(int index) Return the child DataModelPart held at the specified indexintReturns the number of child DataModelParts held by this DataModelPartArrayList<?>getChildList(String type, String id) Method to retrieve child elements keyed by Type and ID valuesgetId()Gets the ID of this DataModelPartGets the parent of this DataModelPartintreturns the number of times that the data represented by this DataModelPart may repeat in a file.getRoot()Gets the Root DataModelPart of this treegetType()Returns the type of this DataModelPartparse(StreamParser input, Options options) Parses a section of an input file provided in the supplied StreamParser.voidproduce(OutputStream output, ContainerPart container, String charset, Options options) voidresort()method to re-sort the child DataModelParts, useful if either ID or or Type values have changedvoidSets the ID of this DataModelPartvoidsetParent(DataModelPart parent) Sets the parent of this DataModelPartvoidsetRepetitions(int repetitions) sets the number of times that the data represented by this DataModelPart may repeat in a file.voidsetRoot(DataModelPart root) Sets the Root DataModelPart of this tree recursively.voidSets the type of this DataModelPartprotected byte[]stripCharacters(byte[] bytes, char character, char escape, String charset) booleansupportsChild(int dataModelType) Segment supports type of 'Segment' and 'Record'voidvalidate(ContainerPart container) dummy method - functionality not yet presentvoidwriteXML(OutputStream out, int indent) void
-
Field Details
-
log
protected transient org.slf4j.Logger log
-
-
Constructor Details
-
Segment
public Segment()Creates a new instance of Segment
-
-
Method Details
-
produce
public void produce(OutputStream output, ContainerPart container, String charset, Options options) throws ModelException - Throws:
ModelException
-
parse
Parses a section of an input file provided in the supplied StreamParser.- Parameters:
input- the StreamParser to parse- Returns:
- ContainerPart tree containing the structure of the parsed data
- Throws:
ModelException- if an error is encountered
-
validate
dummy method - functionality not yet present- Throws:
ModelException
-
supportsChild
public boolean supportsChild(int dataModelType) Segment supports type of 'Segment' and 'Record' -
getParent
Gets the parent of this DataModelPart- Specified by:
getParentin interfaceDataModelPart- Returns:
- parent DataModelPart
- Throws:
ModelException
-
setParent
Sets the parent of this DataModelPart- Specified by:
setParentin interfaceDataModelPart- Parameters:
parent- DataModelPart- Throws:
ModelException
-
getId
Gets the ID of this DataModelPart- Specified by:
getIdin interfaceDataModelPart- Specified by:
getIdin interfaceSearchableListItem- Returns:
- ID
-
getRoot
Gets the Root DataModelPart of this tree- Specified by:
getRootin interfaceDataModelPart- Returns:
- root DataModelPart
-
setRoot
Sets the Root DataModelPart of this tree recursively. Will propogate the root element to all child DataModelParts.- Specified by:
setRootin interfaceDataModelPart- Parameters:
root- DataModelPart
-
addChild
Add a child DataModelPart to this tree- Specified by:
addChildin interfaceDataModelPart- Parameters:
child- DataModelPart to be added- Throws:
ModelException
-
getChild
Return the child DataModelPart held at the specified index- Specified by:
getChildin interfaceDataModelPart- Parameters:
index- the position of the child to be returned- Returns:
- the child DataModelPart
- Throws:
ModelException
-
getChildCount
public int getChildCount()Returns the number of child DataModelParts held by this DataModelPart- Specified by:
getChildCountin interfaceDataModelPart
-
getType
Returns the type of this DataModelPart- Specified by:
getTypein interfaceDataModelPart- Specified by:
getTypein interfaceSearchableListItem
-
setId
Sets the ID of this DataModelPart- Specified by:
setIdin interfaceDataModelPart
-
setType
Sets the type of this DataModelPart- Specified by:
setTypein interfaceDataModelPart
-
getRepetitions
public int getRepetitions()returns the number of times that the data represented by this DataModelPart may repeat in a file. E.g. a DataModelPart representing a Line Record in a file would probably specify a repetitions value of zero, indicating that unlimited repetitions may ocur- Specified by:
getRepetitionsin interfaceDataModelPart
-
setRepetitions
public void setRepetitions(int repetitions) sets the number of times that the data represented by this DataModelPart may repeat in a file.- Specified by:
setRepetitionsin interfaceDataModelPart
-
document
- Specified by:
documentin interfaceDataModelPart
-
writeXML
- Specified by:
writeXMLin interfaceDataModelPart- Throws:
EdiExceptionIOException
-
writeXML
- Specified by:
writeXMLin interfaceDataModelPart- Throws:
EdiExceptionIOException
-
getChildList
Method to retrieve child elements keyed by Type and ID values- Specified by:
getChildListin interfaceDataModelPart- Parameters:
type- the type of element to retrieveid- the id of the element to retrieve- Returns:
- ArrayList containing the retrieved elements
- Throws:
ModelException
-
resort
public void resort()method to re-sort the child DataModelParts, useful if either ID or or Type values have changed- Specified by:
resortin interfaceDataModelPart
-
checkType
- Throws:
ModelException
-
stripCharacters
-
escapeCharacters
-
convertNull
-