Class EdiModelUtils
- java.lang.Object
-
- com.adaptris.adapter.edistream.utils.EdiModelUtils
-
public class EdiModelUtils extends java.lang.Object
Utilities and static data that aid the processing and setup of EdiElement model objects.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
EDI_UNA_SEGMENT
static java.lang.String
EDI_UNB_SEGMENT
static java.lang.String
EDI_UNH_SEGMENT
static java.lang.String
EDI_UNT_SEGMENT
static java.lang.String
X12_ISA_SEGMENT
-
Constructor Summary
Constructors Constructor Description EdiModelUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.static java.nio.charset.Charset
getEdifactCodesetFromUNB(java.lang.String unbSyntaxIdentifier)
Returns the charset that matches the given syntax identifier from an EDIFACT UNB segment.static java.util.Iterator<EdiElement>
getIterator(EdiElement dataElement)
Returns a new child iterator for the given EdiElement, adding defensive code.static EdiElement
getNext(java.util.Iterator<EdiElement> dataChildrenIter)
Gets the next item from the given iterator, adding defensive codestatic java.lang.String
getUNASegmentDataValue(Message messageObj)
Gets the UNA segment data from the given Message objectstatic java.lang.String
getUNASegmentDataValue(Segment unaSegment)
Gets the UNA segment data from the given Segment objectstatic 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.static boolean
hasMatchingIDs(EdiElement ruleElement, EdiElement dataElement)
Determines if the two EdiElement have the same name or not, adding defensive code in the process.static boolean
hasMatchingIDsHandleNullID(EdiElement ruleElement, EdiElement dataElement)
-
-
-
Field Detail
-
EDI_UNA_SEGMENT
public static final java.lang.String EDI_UNA_SEGMENT
- See Also:
- Constant Field Values
-
EDI_UNB_SEGMENT
public static final java.lang.String EDI_UNB_SEGMENT
- See Also:
- Constant Field Values
-
EDI_UNH_SEGMENT
public static final java.lang.String EDI_UNH_SEGMENT
- See Also:
- Constant Field Values
-
EDI_UNT_SEGMENT
public static final java.lang.String EDI_UNT_SEGMENT
- See Also:
- Constant Field Values
-
X12_ISA_SEGMENT
public static final java.lang.String X12_ISA_SEGMENT
- See Also:
- Constant Field Values
-
-
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
- - Iteratorchild 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 guidedataElement
- - 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
-
-