Package com.adaptris.edi.model
Class Id
- java.lang.Object
-
- com.adaptris.edi.model.Id
-
- All Implemented Interfaces:
DataModelPart,SearchableListItem
public class Id extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Id(CharacterSet set)Creates a new instance of Id
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(DataModelPart child)Add a child DataModelPart to this treeprotected voidcheckType(ContainerPart container, java.lang.String expectedType)protected java.lang.StringconvertNull(java.lang.String s, boolean toEmptyString)voiddocument(java.lang.StringBuffer sb, int indent)protected byte[]escapeCharacters(byte[] bytes, char character, char escape, java.lang.String charset)DataModelPartgetChild(int index)Return the child DataModelPart held at the specified indexintgetChildCount()Returns the number of child DataModelParts held by this DataModelPartjava.util.ArrayListgetChildList(java.lang.String type, java.lang.String id)Method to retrieve child elements keyed by Type and ID valuesjava.lang.StringgetId()Gets the ID of this DataModelPartDataModelPartgetParent()Gets the parent of this DataModelPartintgetRepetitions()returns the number of times that the data represented by this DataModelPart may repeat in a file.DataModelPartgetRoot()Gets the Root DataModelPart of this treejava.lang.StringgetType()Returns the type of this DataModelPartContainerPartparse(StreamParser input, Options options)Parses a section of an input file provided in the supplied StreamParser.voidproduce(java.io.OutputStream output, ContainerPart container, java.lang.String charset, Options options)voidresort()method to re-sort the child DataModelParts, useful if either ID or or Type values have changedvoidsetId(java.lang.String id)Sets 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.voidsetType(java.lang.String type)Sets the type of this DataModelPartprotected byte[]stripCharacters(byte[] bytes, char character, char escape, java.lang.String charset)booleansupportsChild(int dataModelPartType)always returns false as Id cannot support childrenvoidundoRead()returns the read section to the StreamParser for re-readingvoidvalidate(ContainerPart container)dummy method - not yet implementedvoidwriteXML(java.io.OutputStream out, int indent)voidwriteXML(java.io.Writer out, int indent)
-
-
-
Constructor Detail
-
Id
public Id(CharacterSet set) throws java.lang.Exception
Creates a new instance of Id- Throws:
java.lang.Exception
-
-
Method Detail
-
parse
public ContainerPart parse(StreamParser input, Options options) throws ModelException
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
-
undoRead
public void undoRead() throws ParserExceptionreturns the read section to the StreamParser for re-reading- Throws:
ParserException
-
produce
public void produce(java.io.OutputStream output, ContainerPart container, java.lang.String charset, Options options) throws ModelException- Throws:
ModelException
-
supportsChild
public boolean supportsChild(int dataModelPartType)
always returns false as Id cannot support children
-
validate
public void validate(ContainerPart container) throws ModelException
dummy method - not yet implemented- Throws:
ModelException
-
getParent
public DataModelPart getParent() throws ModelException
Gets the parent of this DataModelPart- Specified by:
getParentin interfaceDataModelPart- Returns:
- parent DataModelPart
- Throws:
ModelException
-
setParent
public void setParent(DataModelPart parent) throws ModelException
Sets the parent of this DataModelPart- Specified by:
setParentin interfaceDataModelPart- Parameters:
parent- DataModelPart- Throws:
ModelException
-
getId
public java.lang.String getId()
Gets the ID of this DataModelPart- Specified by:
getIdin interfaceDataModelPart- Specified by:
getIdin interfaceSearchableListItem- Returns:
- ID
-
getRoot
public DataModelPart getRoot()
Gets the Root DataModelPart of this tree- Specified by:
getRootin interfaceDataModelPart- Returns:
- root DataModelPart
-
setRoot
public void setRoot(DataModelPart root)
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
public void addChild(DataModelPart child) throws ModelException
Add a child DataModelPart to this tree- Specified by:
addChildin interfaceDataModelPart- Parameters:
child- DataModelPart to be added- Throws:
ModelException
-
getChild
public DataModelPart getChild(int index) throws ModelException
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
public java.lang.String getType()
Returns the type of this DataModelPart- Specified by:
getTypein interfaceDataModelPart- Specified by:
getTypein interfaceSearchableListItem
-
setId
public void setId(java.lang.String id)
Sets the ID of this DataModelPart- Specified by:
setIdin interfaceDataModelPart
-
setType
public void setType(java.lang.String type)
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
public void document(java.lang.StringBuffer sb, int indent)- Specified by:
documentin interfaceDataModelPart
-
writeXML
public void writeXML(java.io.OutputStream out, int indent) throws EdiException, java.io.IOException- Specified by:
writeXMLin interfaceDataModelPart- Throws:
EdiExceptionjava.io.IOException
-
writeXML
public void writeXML(java.io.Writer out, int indent) throws EdiException, java.io.IOException- Specified by:
writeXMLin interfaceDataModelPart- Throws:
EdiExceptionjava.io.IOException
-
getChildList
public java.util.ArrayList getChildList(java.lang.String type, java.lang.String id) throws ModelExceptionMethod 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
protected void checkType(ContainerPart container, java.lang.String expectedType) throws ModelException
- Throws:
ModelException
-
stripCharacters
protected byte[] stripCharacters(byte[] bytes, char character, char escape, java.lang.String charset)
-
escapeCharacters
protected byte[] escapeCharacters(byte[] bytes, char character, char escape, java.lang.String charset)
-
convertNull
protected java.lang.String convertNull(java.lang.String s, boolean toEmptyString)
-
-