Package com.adaptris.edi.model
Class Field
- java.lang.Object
-
- com.adaptris.edi.model.Field
-
- All Implemented Interfaces:
DataModelPart,SearchableListItem
public class Field extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Field(CharacterSet set)Creates a new instance of Field
-
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()Always returns 0 as CompositeFields cannot contain childrenjava.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 changedvoidsetEscapeData(boolean escapeData)voidsetId(java.lang.String id)Sets the ID of this DataModelPartvoidsetMaxLength(int len)Method to set the maximum length allowed for output.voidsetParent(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 CompositeFields cannot contain child partsvoidvalidate(ContainerPart container)dummy method - functionality not yet presentvoidwriteXML(java.io.OutputStream out, int indent)voidwriteXML(java.io.Writer out, int indent)
-
-
-
Constructor Detail
-
Field
public Field(CharacterSet set) throws java.lang.Exception
Creates a new instance of Field- Throws:
java.lang.Exception
-
-
Method Detail
-
setMaxLength
public void setMaxLength(int len)
Method to set the maximum length allowed for output. If the contents of this field exceed the maximum length, they will simply be truncated.
-
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- as Fields cannot contain children
-
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- as Fields cannot contain children
-
getChildCount
public int getChildCount()
Always returns 0 as CompositeFields cannot contain children- Specified by:
getChildCountin interfaceDataModelPart
-
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
-
produce
public void produce(java.io.OutputStream output, ContainerPart container, java.lang.String charset, Options options) throws ModelException- Throws:
ModelException
-
validate
public void validate(ContainerPart container) throws ModelException
dummy method - functionality not yet present- Throws:
ModelException
-
supportsChild
public boolean supportsChild(int dataModelPartType)
always returns false as CompositeFields cannot contain child parts
-
setEscapeData
public void setEscapeData(boolean escapeData)
-
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
-
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)
-
-