Open Business Objects for EDI
v3.5.2

com.americancoders.edi
Class Segment

java.lang.Object
  extended bycom.americancoders.edi.Segment
All Implemented Interfaces:
ICompositeDEContainer, IContainedObject, IDataElementContainer, IDelimiterFetcher, IIdentifier

public class Segment
extends java.lang.Object
implements IDataElementContainer, ICompositeDEContainer, IContainedObject, IDelimiterFetcher

class for Segments OBOE - Open Business Objects for EDI

An EDI and XML Translator Written In Java

Copyright 1998-2007 - American Coders, LTD - Raleigh NC USA

All rights reserved

American Coders, Ltd
P. O. Box 97462
Raleigh, NC 27624 USA
1-919-846-2014
http://www.americancoders.com

Version:
3.5.2
Author:
Joe McVerry - American Coders, Ltd.

Field Summary
protected  int byteOffsetPositionInIncomingDocument
           
protected  java.lang.Object[] deArray
          array of owned datalements
protected  TemplateSegment myTemplate
          TemplateSegment that can build this segment
protected  IContainedObject parent
           
protected  int positionInIncomingDocument
          position within the X12 or EDIFACT document
 
Constructor Summary
Segment(TemplateSegment inTemplateSegment, IContainedObject inParent)
          create a Segment based on its template
 
Method Summary
 java.lang.Object buildDE(int pos)
          defines a dataelement by the predefined templateDE array
 int doIUseThisXMLElement(java.lang.String inTag, int startAt)
          routine to ask if it uses a dataelement
 java.lang.String get()
          returns all the data associated with the Segment
dataelements separated by '*'
composites separated by '<', note data elements within composites are seperated by ':'
 int getByteOffsetPositionInIncomingDocument()
           
 CompositeDE getCompositeDE(int inSequence)
          returns a compositeDE by its position
 CompositeDE getCompositeDE(java.lang.String inID)
          returns a compositeDE by its id
 DataElement getDataElement(int inSequence)
          returns a data element by its sequence number, not location within vector
 DataElement getDataElement(java.lang.String inID)
          returns a data element by its id
 DataElement getDataElement(java.lang.String inID, int inoffset)
          returns a data element by its id, from an offset
 DataElement getDataElementByName(java.lang.String inName, int inoffset)
          returns a data element by its id off of an offset
 int getDataElementLength()
          returns the length of the data in the data elements
 int getDataElementSize()
          returns the number of defined data element
 char getDelimiter(char inOriginal)
          returns the new delimiter based on the old delimiter
 java.lang.String getDescription()
          returns the Short Description for the Segment
 java.lang.String getFixedLengthFormattedText()
          returns fixed length formatted text
 java.lang.String getFormattedText(int formatType)
          returns the formatted text
 java.lang.String getID()
          gets the segment id
 java.lang.String getName()
          gets the segment Name
 int getObjectPosition(java.lang.Object inObject)
          returns an objects position in array
 int getOccurs()
          returns the occurs value
 IContainedObject getParent()
          gets parent attribute
 int getPositionInIncomingDocument()
          gets the x12 or edifact position for incoming documnents
 DataElement getPrimaryIDDE()
          returns the data element associated with being known as making this segment unique
 char getRequired()
          returns the required flag
 int getSequence()
          gets the segment sequence
 TemplateSegment getTemplate()
          returns the TemplateSegment used to build the Segment
 java.lang.String getXMLTag()
          returns the xml tag field
 boolean isCompositeDE(int inSequence)
          returns a boolean if vector position held by a composite
 boolean isDataElement(int inSequence)
          returns a boolean if vector position held by a data element
 boolean isUsed()
          returns the used indicator
 boolean parse(ITokenizer TransactionSetTokenizer)
          parses an EDI Document adds to datalement vector and adds to secondary segment vector
 int parse(org.w3c.dom.Node node)
          parses a XML EDI Document adds to datalement vector or compositeDE and adds to secondary segment vector
 boolean parse(java.io.PushbackInputStream pis)
          parses a Fixed Length EDI Document adds to datalement vector or compositeDE and adds to secondary segment vector
 void setByteOffsetPositionInIncomingDocument(int byteOffsetPositionInIncomingDocument)
           
 void setParent(IContainedObject inParent)
          sets parent attribute
 void setPosition(int inPos)
          sets the x12 or edifact position for incoming documnents
 java.lang.String toString()
          the toString method
 int trim()
          removes empty trailing data elements and returns the number of used dataelements
 void useDefault()
          sets the default value for the data elements
Part of Extended Edition Package
will create mandatory subsegments.
 boolean validate()
          used to verify if the segment is built correctly.
 boolean validate(DocumentErrors inDErr)
          used to verify if the segment is built correctly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

deArray

protected java.lang.Object[] deArray
array of owned datalements


myTemplate

protected TemplateSegment myTemplate
TemplateSegment that can build this segment


positionInIncomingDocument

protected int positionInIncomingDocument
position within the X12 or EDIFACT document


byteOffsetPositionInIncomingDocument

protected int byteOffsetPositionInIncomingDocument

parent

protected IContainedObject parent
Constructor Detail

Segment

public Segment(TemplateSegment inTemplateSegment,
               IContainedObject inParent)
        throws OBOEException
create a Segment based on its template

Parameters:
inTemplateSegment - predefined TemplateSegment
inParent - owning Object
Throws:
OBOEException - unknown segment
Method Detail

getTemplate

public TemplateSegment getTemplate()
returns the TemplateSegment used to build the Segment

Returns:
TemplateSegment

getID

public java.lang.String getID()
gets the segment id

Specified by:
getID in interface IIdentifier
Returns:
String id

getName

public java.lang.String getName()
gets the segment Name

Returns:
String Name

getOccurs

public int getOccurs()
returns the occurs value

Returns:
int occurance value

getRequired

public char getRequired()
returns the required flag

Returns:
char required

getXMLTag

public java.lang.String getXMLTag()
returns the xml tag field

Specified by:
getXMLTag in interface IIdentifier
Returns:
String tag value

isUsed

public boolean isUsed()
returns the used indicator

Returns:
boolean

getSequence

public int getSequence()
gets the segment sequence

Returns:
int sequence number

getDescription

public java.lang.String getDescription()
returns the Short Description for the Segment

Returns:
String

parse

public boolean parse(ITokenizer TransactionSetTokenizer)
              throws OBOEException
parses an EDI Document adds to datalement vector and adds to secondary segment vector

Parameters:
TransactionSetTokenizer - tokenizer hold string data
Throws:
OBOEException - as thrown, can't process subsegment maybe

parse

public int parse(org.w3c.dom.Node node)
          throws OBOEException
parses a XML EDI Document adds to datalement vector or compositeDE and adds to secondary segment vector

Parameters:
node - Incoming DOM node
Throws:
OBOEException - as thrown

parse

public boolean parse(java.io.PushbackInputStream pis)
              throws OBOEException,
                     java.io.IOException
parses a Fixed Length EDI Document adds to datalement vector or compositeDE and adds to secondary segment vector

Parameters:
pis - PushbackInputStream
Throws:
OBOEException - as thrown
java.io.IOException

buildDE

public java.lang.Object buildDE(int pos)
defines a dataelement by the predefined templateDE array

Specified by:
buildDE in interface IDataElementContainer
Parameters:
pos - int
position is relative to 1.
Returns:
DataElement or Composite

validate

public boolean validate()
used to verify if the segment is built correctly.

Returns:
boolean true if segment built correctly
Basic Edition always returns true

validate

public boolean validate(DocumentErrors inDErr)
used to verify if the segment is built correctly

Parameters:
inDErr - DocumentErrorsObject
Returns:
boolean true if segment built correctly

getFormattedText

public java.lang.String getFormattedText(int formatType)
returns the formatted text

Parameters:
formatType - int indicating x12, edificact...
Returns:
String

getFixedLengthFormattedText

public java.lang.String getFixedLengthFormattedText()
returns fixed length formatted text

Returns:
String

getDataElementSize

public int getDataElementSize()
returns the number of defined data element

Specified by:
getDataElementSize in interface IDataElementContainer
Returns:
int DataElement count

get

public java.lang.String get()
returns all the data associated with the Segment
dataelements separated by '*'
composites separated by '<', note data elements within composites are seperated by ':'

Specified by:
get in interface ICompositeDEContainer
Returns:
String for all segments and deArray within the Segment

getDataElementLength

public int getDataElementLength()
returns the length of the data in the data elements

Specified by:
getDataElementLength in interface ICompositeDEContainer
Returns:
int

getDataElement

public DataElement getDataElement(java.lang.String inID)
returns a data element by its id

Specified by:
getDataElement in interface IDataElementContainer
Parameters:
inID - ID of dataelement to find
Returns:
DataElement

getDataElement

public DataElement getDataElement(java.lang.String inID,
                                  int inoffset)
returns a data element by its id, from an offset

Parameters:
inID - ID of dataelement to find
inoffset - int
Returns:
DataElement

getDataElementByName

public DataElement getDataElementByName(java.lang.String inName,
                                        int inoffset)
returns a data element by its id off of an offset

Parameters:
inName - name of dataelement to find
inoffset - int
Returns:
DataElement

getDataElement

public DataElement getDataElement(int inSequence)
returns a data element by its sequence number, not location within vector

Specified by:
getDataElement in interface IDataElementContainer
Parameters:
inSequence - int position of dataelement
position is relative to 1.
Returns:
DataElement

getCompositeDE

public CompositeDE getCompositeDE(java.lang.String inID)
returns a compositeDE by its id

Specified by:
getCompositeDE in interface ICompositeDEContainer
Parameters:
inID - String id of composite
Returns:
CompositeDataElement

getCompositeDE

public CompositeDE getCompositeDE(int inSequence)
returns a compositeDE by its position

Specified by:
getCompositeDE in interface ICompositeDEContainer
Parameters:
inSequence - int position of CompositeDE
position is relative to 1.
Returns:
CompositeDataElement

getObjectPosition

public int getObjectPosition(java.lang.Object inObject)
returns an objects position in array

Parameters:
inObject - object that may be in the array
Returns:
int

isDataElement

public boolean isDataElement(int inSequence)
returns a boolean if vector position held by a data element

Parameters:
inSequence - is object in the array a dataelement
position is relative to 1.
Returns:
boolean

isCompositeDE

public boolean isCompositeDE(int inSequence)
returns a boolean if vector position held by a composite

Parameters:
inSequence - int is object in array at this position a composite
position is relative to 1.
Returns:
boolean

trim

public int trim()
removes empty trailing data elements and returns the number of used dataelements

Returns:
int

doIUseThisXMLElement

public int doIUseThisXMLElement(java.lang.String inTag,
                                int startAt)
routine to ask if it uses a dataelement

Parameters:
inTag - String id
startAt - prepositioning
Returns:
int position of data element

useDefault

public void useDefault()
sets the default value for the data elements
Part of Extended Edition Package
will create mandatory subsegments.
if mandatory subsegment is part of vector (collection) will create the first one


setParent

public void setParent(IContainedObject inParent)
sets parent attribute

Specified by:
setParent in interface IContainedObject
Parameters:
inParent - TemplateSegmentContainer

getParent

public IContainedObject getParent()
gets parent attribute

Specified by:
getParent in interface IContainedObject
Returns:
TemplateSegmentContainer

getPrimaryIDDE

public DataElement getPrimaryIDDE()
returns the data element associated with being known as making this segment unique

Returns:
DataElement

setPosition

public void setPosition(int inPos)
sets the x12 or edifact position for incoming documnents

Parameters:
inPos -

getByteOffsetPositionInIncomingDocument

public int getByteOffsetPositionInIncomingDocument()

setByteOffsetPositionInIncomingDocument

public void setByteOffsetPositionInIncomingDocument(int byteOffsetPositionInIncomingDocument)

getPositionInIncomingDocument

public int getPositionInIncomingDocument()
gets the x12 or edifact position for incoming documnents

Returns:
int

toString

public java.lang.String toString()
the toString method


getDelimiter

public char getDelimiter(char inOriginal)
Description copied from interface: IContainedObject
returns the new delimiter based on the old delimiter

Specified by:
getDelimiter in interface IContainedObject
Parameters:
inOriginal -
Returns:
newDelimiter character

Open Business Objects for EDI
v3.5.2


OBOE is a trademark or registered trademark of American Coders, Ltd. in the US and other countries.
Copyright 1999-2004 American Coders, Ltd.
POB 97462
Raleigh NC 27624 USA
All Rights Reserved.