Class Field

    • 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
      void addChild​(DataModelPart child)
      Add a child DataModelPart to this tree
      protected void checkType​(ContainerPart container, java.lang.String expectedType)  
      protected java.lang.String convertNull​(java.lang.String s, boolean toEmptyString)  
      void document​(java.lang.StringBuffer sb, int indent)  
      protected byte[] escapeCharacters​(byte[] bytes, char character, char escape, java.lang.String charset)  
      DataModelPart getChild​(int index)
      Return the child DataModelPart held at the specified index
      int getChildCount()
      Always returns 0 as CompositeFields cannot contain children
      java.util.ArrayList getChildList​(java.lang.String type, java.lang.String id)
      Method to retrieve child elements keyed by Type and ID values
      java.lang.String getId()
      Gets the ID of this DataModelPart
      DataModelPart getParent()
      Gets the parent of this DataModelPart
      int getRepetitions()
      returns the number of times that the data represented by this DataModelPart may repeat in a file.
      DataModelPart getRoot()
      Gets the Root DataModelPart of this tree
      java.lang.String getType()
      Returns the type of this DataModelPart
      ContainerPart parse​(StreamParser input, Options options)
      Parses a section of an input file provided in the supplied StreamParser.
      void produce​(java.io.OutputStream output, ContainerPart container, java.lang.String charset, Options options)  
      void resort()
      method to re-sort the child DataModelParts, useful if either ID or or Type values have changed
      void setEscapeData​(boolean escapeData)  
      void setId​(java.lang.String id)
      Sets the ID of this DataModelPart
      void setMaxLength​(int len)
      Method to set the maximum length allowed for output.
      void setParent​(DataModelPart parent)
      Sets the parent of this DataModelPart
      void setRepetitions​(int repetitions)
      sets the number of times that the data represented by this DataModelPart may repeat in a file.
      void setRoot​(DataModelPart root)
      Sets the Root DataModelPart of this tree recursively.
      void setType​(java.lang.String type)
      Sets the type of this DataModelPart
      protected byte[] stripCharacters​(byte[] bytes, char character, char escape, java.lang.String charset)  
      boolean supportsChild​(int dataModelPartType)
      always returns false as CompositeFields cannot contain child parts
      void validate​(ContainerPart container)
      dummy method - functionality not yet present
      void writeXML​(java.io.OutputStream out, int indent)  
      void writeXML​(java.io.Writer out, int indent)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log

        protected transient org.slf4j.Logger log
    • 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.
      • getChild

        public DataModelPart getChild​(int index)
                               throws ModelException
        Return the child DataModelPart held at the specified index
        Specified by:
        getChild in interface DataModelPart
        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:
        getChildCount in interface DataModelPart
      • 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
      • supportsChild

        public boolean supportsChild​(int dataModelPartType)
        always returns false as CompositeFields cannot contain child parts
      • setEscapeData

        public void setEscapeData​(boolean escapeData)
      • 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:
        setRoot in interface DataModelPart
        Parameters:
        root - DataModelPart
      • setId

        public void setId​(java.lang.String id)
        Sets the ID of this DataModelPart
        Specified by:
        setId in interface DataModelPart
      • setType

        public void setType​(java.lang.String type)
        Sets the type of this DataModelPart
        Specified by:
        setType in interface DataModelPart
      • 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:
        getRepetitions in interface DataModelPart
      • 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:
        setRepetitions in interface DataModelPart
      • document

        public void document​(java.lang.StringBuffer sb,
                             int indent)
        Specified by:
        document in interface DataModelPart
      • getChildList

        public java.util.ArrayList getChildList​(java.lang.String type,
                                                java.lang.String id)
                                         throws ModelException
        Method to retrieve child elements keyed by Type and ID values
        Specified by:
        getChildList in interface DataModelPart
        Parameters:
        type - the type of element to retrieve
        id - 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:
        resort in interface DataModelPart
      • 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)