Class EdiElement

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.tree.TreeNode
    Direct Known Subclasses:
    Composite, ElementCode, Field, LoopSegment, Message, Segment, StandardCodes

    public abstract class EdiElement
    extends java.lang.Object
    implements javax.swing.tree.TreeNode, java.io.Serializable
    Abstract Parent class of all Elements that are used to represent Edi Data internally as a tree structure.
    The following asci image shows the structure of an EDI document, and this class aims to be the base node for all other nodes that will represent it internally.
    The diagram shows a Msg which has four child nodes, the third of which is a Group node that itself has two segment nodes. Segment nodes themselves can be made up of composite and element nodes, that are not shown in the diagram. +--------+ | MSG | | | +----+---+ | v +-------------+--------------+---------------+ v v v v +-----+ +-----+ +-----+ +-----+ | REF | | QTY | |GROUP| | LDD | | M1 | | C5 | | C99 | | M1 | +-----+ +-----+ +-----+ +-----+ + | v +-------------+ v v +-----+ +-----+ | FFF | | TXT | | M1 | | M1 | +-----+ +-----+
    See Also:
    Serialized Form
    • Constructor Detail

      • EdiElement

        public EdiElement()
      • EdiElement

        public EdiElement​(java.lang.String name,
                          boolean mandatory,
                          int repetitions)
    • Method Detail

      • getName

        public java.lang.String getName()
      • setName

        public void setName​(java.lang.String name)
      • isMandatory

        public boolean isMandatory()
      • setMandatory

        public void setMandatory​(boolean mandatory)
      • getRepetitions

        public int getRepetitions()
      • setRepetitions

        public void setRepetitions​(int repetitions)
      • getMaxRepetitions

        public int getMaxRepetitions()
      • setMaxRepetitions

        public void setMaxRepetitions​(int maxRepetitions)
      • setSegmentReps

        public static void setSegmentReps​(EdiElement elementRule,
                                          java.lang.String repsStr)
        Sets the repetition value for an Element. It is possible for the value to be ">1" So we need to set this appropriately.
        Parameters:
        elementRule -
        repsStr - - original string value from the gxml file
      • getChildren

        public java.util.List<EdiElement> getChildren()
      • children

        public java.util.Enumeration<EdiElement> children()
        Specified by:
        children in interface javax.swing.tree.TreeNode
      • getChild

        public EdiElement getChild​(int position)
      • getIndex

        public int getIndex​(javax.swing.tree.TreeNode node)
        Specified by:
        getIndex in interface javax.swing.tree.TreeNode
      • getChildAt

        public javax.swing.tree.TreeNode getChildAt​(int childIndex)
        Specified by:
        getChildAt in interface javax.swing.tree.TreeNode
      • setChildren

        public void setChildren​(java.util.List<EdiElement> children)
      • addChild

        public void addChild​(EdiElement child)
      • hasChildren

        public boolean hasChildren()
      • getChildCount

        public int getChildCount()
        Specified by:
        getChildCount in interface javax.swing.tree.TreeNode
      • getAllowsChildren

        public boolean getAllowsChildren()
        Specified by:
        getAllowsChildren in interface javax.swing.tree.TreeNode
      • isLeaf

        public boolean isLeaf()
        Specified by:
        isLeaf in interface javax.swing.tree.TreeNode
      • getParent

        public javax.swing.tree.TreeNode getParent()
        Specified by:
        getParent in interface javax.swing.tree.TreeNode
      • setParent

        public void setParent​(EdiElement parent)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • equalsStr

        public boolean equalsStr​(java.lang.String str1,
                                 java.lang.String str2)
      • childrenEquals

        protected boolean childrenEquals​(EdiElement compareItem)
        Returns true if the children of the given object match this instance's.
        Parameters:
        compareItem -
        Returns:
        true if both sets of children are equal
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getChildrenAsString

        protected java.lang.String getChildrenAsString()