Class EdiModelUtils


  • public class EdiModelUtils
    extends java.lang.Object
    Utilities and static data that aid the processing and setup of EdiElement model objects.
    • Constructor Detail

      • EdiModelUtils

        public EdiModelUtils()
    • Method Detail

      • hasMatchingIDs

        public static boolean hasMatchingIDs​(EdiElement ruleElement,
                                             EdiElement dataElement)
        Determines if the two EdiElement have the same name or not, adding defensive code in the process.
        Parameters:
        ruleElement -
        dataElement -
        Returns:
        true if they have the same ID/name and are of the same type.
      • hasMatchingIDsHandleNullID

        public static boolean hasMatchingIDsHandleNullID​(EdiElement ruleElement,
                                                         EdiElement dataElement)
      • getIterator

        public static java.util.Iterator<EdiElement> getIterator​(EdiElement dataElement)
        Returns a new child iterator for the given EdiElement, adding defensive code.
        Parameters:
        dataElement - - parent EdiElement
        Returns:
        new Iterator or null
      • getNext

        public static EdiElement getNext​(java.util.Iterator<EdiElement> dataChildrenIter)
        Gets the next item from the given iterator, adding defensive code
        Parameters:
        dataChildrenIter - - Iterator child iterator
        Returns:
        next iterator item or null.
      • hasData

        public static boolean hasData​(EdiElement element)
        Determines if the given EdiElement has any data set, note at present this only applies to the basic objects of Field and Composite.
        Parameters:
        element - - EdiElement to check
        Returns:
        True if the object has any data set within it.
      • convertFieldToCompositeIfReq

        public static EdiElement convertFieldToCompositeIfReq​(EdiElement ruleElement,
                                                              EdiElement dataElement)
        When we parse in EDI data sometimes a composite can be made into a simple field, this is true where the composite only had a single data value present and no composite separator. In such cases we need to convert the field into a composite to ensure we don't throw a spanner in the works
        Parameters:
        ruleElement - - the rule element that we trust and use as a guide
        dataElement - - the suspect data element
        Returns:
        the original data element if it is ok, or a new Composite which contains it.
      • getUNASegmentDataValue

        public static java.lang.String getUNASegmentDataValue​(Message messageObj)
        Gets the UNA segment data from the given Message object
        Parameters:
        messageObj -
      • getUNASegmentDataValue

        public static java.lang.String getUNASegmentDataValue​(Segment unaSegment)
        Gets the UNA segment data from the given Segment object
        Parameters:
        unaSegment -
      • getEdifactCodesetFromUNB

        public static java.nio.charset.Charset getEdifactCodesetFromUNB​(java.lang.String unbSyntaxIdentifier)
        Returns the charset that matches the given syntax identifier from an EDIFACT UNB segment.
        Parameters:
        unbSyntaxIdentifier -
        Throws:
        java.nio.charset.UnsupportedCharsetException - - if charset is not found