Open Business Objects for EDI
v3.6.0

com.americancoders.edi
Class SegmentContainer

java.lang.Object
  |
  +--com.americancoders.edi.SegmentContainer
All Implemented Interfaces:
IContainedObject, IIdentifier, ISegmentContainer
Direct Known Subclasses:
Envelope, FunctionalGroup, LoopAndSegmentContainer, TransactionSet

public abstract class SegmentContainer
extends java.lang.Object
implements IContainedObject, ISegmentContainer

Segment Container

OBOE - Open Business Objects for EDI

Part of the OBOE Basic Extended Package
An EDI and XML Translator Written In Java
Copyright 1998-2009 - 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.6.0
Author:
Joe McVerry - American Coders, Ltd.

Field Summary
protected  java.lang.Object[] container
          storage for data elements
protected  boolean dupSegment
          used by edi parser to test for duplicate segment entries
 com.americancoders.edi.TemplateSegmentContainer myTemplateContainer
          this segments template
 
Constructor Summary
SegmentContainer()
           
 
Method Summary
 void addSegment(com.americancoders.edi.Segment inSegment)
          add a segment to the array
 void addSegment(com.americancoders.edi.Segment inSegment, int inPosition)
          adds a Segment to the container by its predefined sequence
protected  void addSegment(com.americancoders.edi.Segment inSegment, java.lang.Integer inI)
          add a segment to the array
 void addSegmentToVector(com.americancoders.edi.Segment inSegment, int inPosition)
          adds a Segment to a vectorized segment in the container at a predefined sequence
 com.americancoders.edi.Segment createSegment(java.lang.String id)
          creates a segment by ID
 com.americancoders.edi.Segment createSegment(java.lang.String id, java.lang.String primaryIDValue)
          creates a segment by ID and its primary id value
Written for the HIPAA package, but you may find it useful
 com.americancoders.edi.Segment createSegmentByIDAndName(java.lang.String code, java.lang.String name)
          creates a segment by ID and its name
Written for the HIPAA package, but you may find it useful
 void defineContainer()
          simple routine to build the array based on the number of entries in the template segment vector
protected  boolean equivalentSegments(int i)
           
 int getContainerSize()
          returns the size of the segment array
-1 if array is undefined
abstract  java.lang.String getID()
          get the segment id
 com.americancoders.edi.Segment getSegment(int inPosition)
          returns a Segment by its position
 com.americancoders.edi.Segment getSegment(int inPosition, int inVectorPosition)
          returns the Segment inside the subsegment Vector by its position
 com.americancoders.edi.Segment getSegment(java.lang.String ID)
          returns a Segment by its ID
 com.americancoders.edi.Segment getSegment(java.lang.String ID, int inVectorPosition)
          returns a Segment by its ID and its position in the vector
You must use this method call to get to floating segments
 com.americancoders.edi.Segment getSegment(java.lang.String ID, java.lang.String primaryIDValue)
          returns a Segment by its ID and its primaryIDValue
Written for the HIPAA package, but you may find it useful
 com.americancoders.edi.Segment getSegment(java.lang.String ID, java.lang.String primaryIDValue, int inPosition)
          returns one of a multiple set of Segments by its ID, its primaryIDValue and its relative position with relation to its primaryIDValue
Written for the HIPAA package, but you may find it useful
 com.americancoders.edi.Segment getSegmentByDataElementValue(java.lang.String ID, int inSequence, java.lang.String inValue)
          returns a Segment by its id and the contents of a data field
Used for segments that repeat, useful with IDDE type fields.
 int getSegmentCount(int inPosition)
          returns the number of elements in a vector position
 int getSegmentCount(java.lang.String ID)
          returns the number of elements by id
 boolean isNull(int inPosition)
          returns true if there is no object in container at requested position
 boolean isSegment(int inPosition)
          returns true if object in container is a segment at requested position if false the subsegment is a vector or position specified is outside range of array
 boolean isSegment(int inPosition, int inVectorPosition)
          returns true if object in container is a Segment at requested position if false the subSegment is a vector or position specified is outside range of array
 boolean isVector(int inPosition)
          returns true if object in container is a vector at requested position if true the subsegment is a segment or position specified is outside range of array
 boolean parse(com.americancoders.edi.ITokenizer TransactionTokenizedString)
          parses the segment portion of an EDI Document, adds to segment vector
 void removeSegment(int inPosition)
          removes a Segment from the container at a particular position can be used to remove all segments with same id at a vectorized position
 void removeSegment(int inPosition, int inVectorPosition)
          removes a Segment from the container at a particular position in the subsegment Vector
 void removeSegment(java.lang.String inID)
          removes a Segment from the container by id, does this by setting array entry to null can be used to remove all segments with same id at a vectorized position
 void removeSegment(java.lang.String inID, int inPosition)
          removes a Segment from the container by its ID from the subsegment Vector
protected  int resetToFirstEquivalentSegment(int i)
           
 void setSegmentAt(com.americancoders.edi.Segment inSegment, int inPosition)
          sets a Segment to the container at position in the array, if the Segment is part of the vectorized segment throw exception
 void setSegmentAt(com.americancoders.edi.Segment inSegment, int inPosition, int inVectorPosition)
          sets a Segment to the vector at a position container
 int trim()
          removes unused Segments and return the number of subsegments in container
 void whyNotUsed(com.americancoders.edi.Tokenizer et)
          asks the container why it didn't use the current token
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.americancoders.edi.IContainedObject
getParent, setParent
 
Methods inherited from interface com.americancoders.edi.IIdentifier
getXMLTag
 
Methods inherited from interface com.americancoders.edi.ISegmentContainer
getTemplateSegmentContainer
 

Field Detail

container

protected java.lang.Object[] container
storage for data elements


myTemplateContainer

public com.americancoders.edi.TemplateSegmentContainer myTemplateContainer
this segments template


dupSegment

protected boolean dupSegment
used by edi parser to test for duplicate segment entries

Constructor Detail

SegmentContainer

public SegmentContainer()
Method Detail

getID

public abstract java.lang.String getID()
get the segment id

Specified by:
getID in interface IIdentifier
Returns:
String segment id

parse

public boolean parse(com.americancoders.edi.ITokenizer TransactionTokenizedString)
              throws OBOEException
parses the segment portion of an EDI Document, adds to segment vector

Parameters:
TransactionTokenizedString - incoming tokenized string
Returns:
boolean - true if tts was used
Throws:
OBOEException - as thrown, can't process subsegment maybe

resetToFirstEquivalentSegment

protected int resetToFirstEquivalentSegment(int i)
Parameters:
i - position where segment was placed
Returns:
int first position of equivalent segment.

equivalentSegments

protected boolean equivalentSegments(int i)
Parameters:
i - position where segment was placed
Returns:
boolean, true if other segments with same id and sequence.

whyNotUsed

public void whyNotUsed(com.americancoders.edi.Tokenizer et)
asks the container why it didn't use the current token

Parameters:
et - Tokenizer incoming tokenized string

getContainerSize

public int getContainerSize()
returns the size of the segment array
-1 if array is undefined

Returns:
int

defineContainer

public void defineContainer()
simple routine to build the array based on the number of entries in the template segment vector


addSegment

public void addSegment(com.americancoders.edi.Segment inSegment)
                throws OBOEException
add a segment to the array

Specified by:
addSegment in interface ISegmentContainer
Parameters:
inSegment - Segmemt to add to vector
Throws:
OBOEException - segment doesn't belong

addSegment

protected void addSegment(com.americancoders.edi.Segment inSegment,
                          java.lang.Integer inI)
                   throws OBOEException
add a segment to the array

Parameters:
inSegment - Segmemt to add to vector
Throws:
OBOEException - segment doesn't belong

addSegment

public void addSegment(com.americancoders.edi.Segment inSegment,
                       int inPosition)
                throws OBOEException
adds a Segment to the container by its predefined sequence

Parameters:
inSegment - Segment to Add
inPosition - int position to add at
Throws:
OBOEException - Subsegment not defined at sequence Subsegment sequence not defined

addSegmentToVector

public void addSegmentToVector(com.americancoders.edi.Segment inSegment,
                               int inPosition)
                        throws OBOEException
adds a Segment to a vectorized segment in the container at a predefined sequence

Parameters:
inSegment - Segment
inPosition - int position
Throws:
OBOEException - segment postion not vectorized

setSegmentAt

public void setSegmentAt(com.americancoders.edi.Segment inSegment,
                         int inPosition)
                  throws OBOEException
sets a Segment to the container at position in the array, if the Segment is part of the vectorized segment throw exception

Parameters:
inSegment - Segment
inPosition - int position
Throws:
OBOEException - out of range Subsegment vectorized Subsegment not defined at sequence

setSegmentAt

public void setSegmentAt(com.americancoders.edi.Segment inSegment,
                         int inPosition,
                         int inVectorPosition)
                  throws OBOEException
sets a Segment to the vector at a position container

Parameters:
inSegment - Segment
inPosition - int position in array
inVectorPosition - int position with vector at inPosition
Throws:
OBOEException - out of range Subsegment not vectorized Subsegment not defined at sequence

removeSegment

public void removeSegment(java.lang.String inID)
                   throws OBOEException
removes a Segment from the container by id, does this by setting array entry to null can be used to remove all segments with same id at a vectorized position

Specified by:
removeSegment in interface ISegmentContainer
Parameters:
inID - String id
Throws:
OBOEException - unknown segment id

removeSegment

public void removeSegment(java.lang.String inID,
                          int inPosition)
                   throws OBOEException
removes a Segment from the container by its ID from the subsegment Vector

Parameters:
inID - String ID
inPosition - int position in array
Throws:
OBOEException - Subsegment not vectorized unknown segment id

removeSegment

public void removeSegment(int inPosition)
                   throws OBOEException
removes a Segment from the container at a particular position can be used to remove all segments with same id at a vectorized position

Parameters:
inPosition - int position in array
Throws:
OBOEException - position number out of range

removeSegment

public void removeSegment(int inPosition,
                          int inVectorPosition)
                   throws OBOEException
removes a Segment from the container at a particular position in the subsegment Vector

Parameters:
inPosition - int position in array
inVectorPosition - int position in Vector at inPosition in array
Throws:
OBOEException - position number out of range Subsegment not vectorized Subsegment sequence not defined

getSegment

public com.americancoders.edi.Segment getSegment(int inPosition)
                                          throws OBOEException
returns a Segment by its position

Parameters:
inPosition - int position in array
Returns:
Segment objects - will return null if segment not defined
Throws:
OBOException - "No segment at this position" - it is a Vector of segments
OBOEException

getSegment

public com.americancoders.edi.Segment getSegment(int inPosition,
                                                 int inVectorPosition)
                                          throws OBOEException
returns the Segment inside the subsegment Vector by its position

Parameters:
inPosition - int position in array
inVectorPosition - int position in Vector at inPosition in array
Returns:
Vector of Segment objects - null indicates segment not set
Throws:
OBOEException - bad position specified, position is negative, larger than Vector or object at position specified by first parameter is a segment.

getSegment

public com.americancoders.edi.Segment getSegment(java.lang.String ID)
                                          throws OBOEException
returns a Segment by its ID

Specified by:
getSegment in interface ISegmentContainer
Parameters:
ID - String id of segment to get
Returns:
Segment objects - null indicates segment not set
Throws:
OBOEException - "ID is unknown to segment "

getSegment

public com.americancoders.edi.Segment getSegment(java.lang.String ID,
                                                 int inVectorPosition)
                                          throws OBOEException
returns a Segment by its ID and its position in the vector
You must use this method call to get to floating segments

Specified by:
getSegment in interface ISegmentContainer
Parameters:
ID - String id of segment to get
inVectorPosition - int position in Vector at position in array identified by id
Returns:
Segment objects - null indicates position of segment not set
Throws:
OBOEException - Segment with ID not within a Vector.

getSegment

public com.americancoders.edi.Segment getSegment(java.lang.String ID,
                                                 java.lang.String primaryIDValue)
                                          throws OBOEException
returns a Segment by its ID and its primaryIDValue
Written for the HIPAA package, but you may find it useful

Parameters:
ID - String id of segment to get
primaryIDValue - String - primary IDs are the values in an mandatory IDDE field value list, any value in the IDList will find this segment
Returns:
Segment objects - null indicates position of segment not set
Throws:
OBOEException - Segment with ID not within a Vector.

getSegment

public com.americancoders.edi.Segment getSegment(java.lang.String ID,
                                                 java.lang.String primaryIDValue,
                                                 int inPosition)
                                          throws OBOEException
returns one of a multiple set of Segments by its ID, its primaryIDValue and its relative position with relation to its primaryIDValue
Written for the HIPAA package, but you may find it useful

Parameters:
ID - String id of segment to get
primaryIDValue - String - primary IDs are the values in an mandatory
inPosition - int - relative position of segment with relation to its primaryIDValue offset by 0 withing IDDE field value list, any value in the IDList will find this segment
Returns:
Segment objects - null indicates position of segment not set
Throws:
OBOEException - Segment with ID not within a Vector.

getSegmentByDataElementValue

public com.americancoders.edi.Segment getSegmentByDataElementValue(java.lang.String ID,
                                                                   int inSequence,
                                                                   java.lang.String inValue)
                                                            throws OBOEException
returns a Segment by its id and the contents of a data field
Used for segments that repeat, useful with IDDE type fields.
Will NOT work for Composite DE fields.

Parameters:
ID - String id of loop
inSequence - int DataElement sequence number relative to 1
inValue - String value to test
Returns:
Segment objects - null not found
Throws:
OBOEException - Segment with ID not within a Vector.

getSegmentCount

public int getSegmentCount(int inPosition)
returns the number of elements in a vector position

Parameters:
inPosition - int position in array
Returns:
int a count - zero if position is not held by a vector
Throws:
java.lang.ArrayOutOfBounds - is possible.

getSegmentCount

public int getSegmentCount(java.lang.String ID)
returns the number of elements by id

Specified by:
getSegmentCount in interface ISegmentContainer
Parameters:
ID - String id to count
Returns:
int
Throws:
OBOEException - ID unknown.

isSegment

public boolean isSegment(int inPosition)
returns true if object in container is a segment at requested position if false the subsegment is a vector or position specified is outside range of array

Parameters:
inPosition - int position inarray
Returns:
boolean

isSegment

public boolean isSegment(int inPosition,
                         int inVectorPosition)
returns true if object in container is a Segment at requested position if false the subSegment is a vector or position specified is outside range of array

Parameters:
inPosition - int position inarray
Returns:
boolean

isVector

public boolean isVector(int inPosition)
returns true if object in container is a vector at requested position if true the subsegment is a segment or position specified is outside range of array

Parameters:
inPosition - int position in array
Returns:
boolean

isNull

public boolean isNull(int inPosition)
returns true if there is no object in container at requested position

Parameters:
inPosition - int position in array
Returns:
boolean

createSegment

public com.americancoders.edi.Segment createSegment(java.lang.String id)
                                             throws OBOEException
creates a segment by ID

Specified by:
createSegment in interface ISegmentContainer
Parameters:
id - String id of subsegment to create
Returns:
Segment based on this Template
Throws:
OBOEException - unknown id

createSegment

public com.americancoders.edi.Segment createSegment(java.lang.String id,
                                                    java.lang.String primaryIDValue)
                                             throws OBOEException
creates a segment by ID and its primary id value
Written for the HIPAA package, but you may find it useful

Parameters:
id - String id of subsegment to create
primaryIDValue - String - primary IDs are the values in an mandatory IDDE field value list, any value in the IDList will create this segment
Returns:
Segment based on this Template
Throws:
OBOEException - unknown id

createSegmentByIDAndName

public com.americancoders.edi.Segment createSegmentByIDAndName(java.lang.String code,
                                                               java.lang.String name)
creates a segment by ID and its name
Written for the HIPAA package, but you may find it useful

Returns:
Segment based on this Template
Throws:
OBOEException - unknown id

trim

public int trim()
removes unused Segments and return the number of subsegments in container

Returns:
int

Open Business Objects for EDI
v3.6.0


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.