com.americancoders.edi
Class Segment

java.lang.Object
  |
  +--com.americancoders.edi.SegmentContainer
        |
        +--com.americancoders.edi.Segment

public class Segment
extends SegmentContainer
implements IDataElementContainer, ICompositeDEContainer

class for Segments OBOE - Open Business Objects for EDI

An EDI and XML Translator Written In Java

Copyright 1998-2000 - 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:
1.4.1
Author:
Joe McVerry, American Coders Ltd.

Field Summary
protected  java.lang.Object[] deArray
           
protected  java.lang.String description
           
protected  java.lang.String id
           
protected  TemplateSegment myTemplate
           
protected  int occurs
           
protected  char required
           
protected  int sequence
           
protected  java.lang.String xmlTag
           
 
Fields inherited from class com.americancoders.edi.SegmentContainer
segmentArray, templateSegmentVector
 
Constructor Summary
Segment(java.lang.String inId, int inSequence, java.lang.String inShortDescription, int inOccurs, char inRequired)
          create a Segment, defaults the xmltag to the field id value
Segment(java.lang.String inId, int inSequence, java.lang.String inShortDescription, int inOccurs, char inRequired, java.lang.String inXMLTag)
          create a Segment
Segment(TemplateSegment inTemplateSegment)
          create a Segment based on its template
 
Method Summary
 void addCompositeDE(CompositeDE inCDE)
          adds a composite DE to vector
 void addDataElement(DataElement inDE)
          adds a DE to vector
 java.lang.Object buildDE(int pos)
          defines a dataelement by the predefined templateDE array
 Segment createSegment(java.lang.String ID)
          this is here as a stub because of the segment container interface
 java.lang.String get()
          returns all the data associated with the Segment
 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
 int getDataElementSize()
          returns the number of defined data element
 java.lang.String getDescription()
          returns the Short Description for the Segment
 java.lang.String getFormattedText(int formatType)
          returns the formatted text
 java.lang.String getID()
          gets the segment id
 int getOccurs()
          returns the occurs value
 char getRequired()
          returns the required flag
 int getSegmentCount()
          returns the number of subsegments and itself
 int getSegmentSize()
          returns the number of segments within this segment
 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
 ITokenizer parse(ITokenizer TransactionTokenizedString)
          parses a EDI Document, this maybe x12 dependent.
 void parse(org.w3c.dom.Node node)
          parses a XML EDI Document adds to datalement vector or compositeDE and adds to secondary segment vector
 void setDescription(java.lang.String inDesc)
          sets Description for the Segmemt param String description
 void setID(java.lang.String inId)
          sets the segment id
 void setOccurs(int inOccurs)
          sets the occurs value
 void setRequired(char inRequired)
          sets the required flag
 void setSequence(int inSequence)
          sets the segment sequence
 void setXMLTag(java.lang.String inXMLTag)
          sets the xmltag field
 boolean validate()
          used to verify if the segment is built correctly.
 
Methods inherited from class com.americancoders.edi.SegmentContainer
addSegment, addSegment, addSegmentToVector, addTemplateSegment, defineSegmentArray, getSegment, getSegment, getSegment, getSubsegmentCount, getTemplateSegment, getTemplateSegment, getTemplateSegmentSize, isSegment, isVector, removeSegment, removeSegment, removeSegment, removeSegment, setSegmentAt, setSegmentAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected java.lang.String id

sequence

protected int sequence

description

protected java.lang.String description

deArray

protected java.lang.Object[] deArray

myTemplate

protected TemplateSegment myTemplate

occurs

protected int occurs

required

protected char required

xmlTag

protected java.lang.String xmlTag
Constructor Detail

Segment

public Segment(TemplateSegment inTemplateSegment)
        throws java.lang.Exception
create a Segment based on its template
Parameters:
TemplateSegment - predefined template

Segment

public Segment(java.lang.String inId,
               int inSequence,
               java.lang.String inShortDescription,
               int inOccurs,
               char inRequired,
               java.lang.String inXMLTag)
        throws java.lang.Exception
create a Segment
Parameters:
String - id
int - sequence
String - description
int - occurs
char - required
String - xmltag

Segment

public Segment(java.lang.String inId,
               int inSequence,
               java.lang.String inShortDescription,
               int inOccurs,
               char inRequired)
        throws java.lang.Exception
create a Segment, defaults the xmltag to the field id value
Parameters:
String - id
int - sequence
String - description
int - occurs 8 @param char required
Method Detail

getTemplate

public TemplateSegment getTemplate()
returns the TemplateSegment used to build the Segment
Parameters:
TemplateSegment -  

setID

public void setID(java.lang.String inId)
sets the segment id
Parameters:
String - id

getID

public java.lang.String getID()
gets the segment id
Overrides:
getID in class SegmentContainer
Returns:
String id

setOccurs

public void setOccurs(int inOccurs)
sets the occurs value
Parameters:
int - occurance value

getOccurs

public int getOccurs()
returns the occurs value
Returns:
int occurance value

setRequired

public void setRequired(char inRequired)
sets the required flag
Parameters:
char - required flag

getRequired

public char getRequired()
returns the required flag
Returns:
char required

setXMLTag

public void setXMLTag(java.lang.String inXMLTag)
sets the xmltag field
Parameters:
String - xmltag

getXMLTag

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

setSequence

public void setSequence(int inSequence)
sets the segment sequence
Parameters:
int - sequence number

getSequence

public int getSequence()
gets the segment sequence
Returns:
int sequence number

createSegment

public Segment createSegment(java.lang.String ID)
                      throws java.lang.Exception
this is here as a stub because of the segment container interface
Overrides:
createSegment in class SegmentContainer
Parameters:
String - id
Returns:
Segment

setDescription

public void setDescription(java.lang.String inDesc)
sets Description for the Segmemt param String description

getDescription

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

parse

public ITokenizer parse(ITokenizer TransactionTokenizedString)
                 throws java.lang.Exception
parses a EDI Document, this maybe x12 dependent. adds to datalement vector and adds to secondary segment vector
Parameters:
ITokenizer - input tokenized string
ITokenizer - what is left

parse

public void parse(org.w3c.dom.Node node)
           throws java.lang.Exception
parses a XML EDI Document adds to datalement vector or compositeDE and adds to secondary segment vector
Parameters:
Node - input XML node

buildDE

public java.lang.Object buildDE(int pos)
defines a dataelement by the predefined templateDE array
Parameters:
int - position in templateDE array
Throws:
java.lang.Exception - thrown by data element instantiation.

addCompositeDE

public void addCompositeDE(CompositeDE inCDE)
adds a composite DE to vector
Specified by:
addCompositeDE in interface ICompositeDEContainer
Parameters:
compositeDE -  

addDataElement

public void addDataElement(DataElement inDE)
adds a DE to vector
Specified by:
addDataElement in interface IDataElementContainer
Parameters:
DataElement -  

validate

public boolean validate()
used to verify if the segment is built correctly. currently not working
Returns:
boolean true if segment built correctly

getSegmentCount

public int getSegmentCount()
returns the number of subsegments and itself
Returns:
int count

getSegmentSize

public int getSegmentSize()
returns the number of segments within this segment
Returns:
int subsegment count

getFormattedText

public java.lang.String getFormattedText(int formatType)
returns the formatted text
Parameters:
int -
  • TransactionSet.XML_FORMAT:
  • TransactionSet.X12_FORMAT:
  • TransactionSet.EDIFACT_FORMAT:
  • otherwise "description: value"

get

public java.lang.String get()
                     throws java.lang.Exception
returns all the data associated with the Segment
Specified by:
get in interface IDataElementContainer
Returns:
String for all segments and deArray within the Segment
Throws:
java.lang.Exception - thrown when data is missing from a required segment or data element

getDataElementSize

public int getDataElementSize()
returns the number of defined data element
Returns:
int DataElement count

getDataElement

public DataElement getDataElement(java.lang.String inID)
returns a data element by its id
Specified by:
getDataElement in interface IDataElementContainer
Parameters:
String - id of the data element
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:
int - sequence number of data element
Returns:
DataElement

getCompositeDE

public CompositeDE getCompositeDE(java.lang.String inID)
returns a compositeDE by its id
Specified by:
getCompositeDE in interface ICompositeDEContainer
Parameters:
String - id of the composite
Returns:
CompositeDataElement

getCompositeDE

public CompositeDE getCompositeDE(int inSequence)
returns a compositeDE by its position
Specified by:
getCompositeDE in interface ICompositeDEContainer
Parameters:
int - position of the composite
Returns:
CompositeDataElement

isDataElement

public boolean isDataElement(int inSequence)
returns a boolean if vector position held by a data element
Parameters:
int - sequence number of vector element
Returns:
DataElement

isCompositeDE

public boolean isCompositeDE(int inSequence)
returns a boolean if vector position held by a composite
Parameters:
int - sequence number of vector element
Returns:
DataElement