com.americancoders.edi
Class SegmentContainer

java.lang.Object
  |
  +--com.americancoders.edi.SegmentContainer
Direct Known Subclasses:
Segment, Table

public abstract class SegmentContainer
extends java.lang.Object

Segment Container

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[] segmentArray
           
protected  java.util.Vector templateSegmentVector
           
 
Constructor Summary
SegmentContainer()
           
 
Method Summary
 void addSegment(Segment inSegment)
           
 void addSegment(Segment inSegment, int inPosition)
          adds a Segment to the segmentArray by its predefined sequence
 void addSegmentToVector(Segment inSegment, int inPosition)
          adds a Segment to a vectorized segment in the segmentArray at a predefined sequence
 void addTemplateSegment(TemplateSegment inTemplateSegment)
          adds a templatesegment to the vector
 Segment createSegment(java.lang.String id)
          creates a static segment
 void defineSegmentArray()
          simple routine to build the array based on the number of entries in the template segment vector
abstract  java.lang.String getID()
           
 Segment getSegment(int inPosition)
          returns a Segment by its position
 Segment getSegment(int inPosition, int inVectorPosition)
          returns the Segment inside the subsegment Vector by its position
 Segment getSegment(java.lang.String ID)
          returns a Segment by its ID
 int getSubsegmentCount(int inPosition)
          returns the number of subsegments in a vector position
 TemplateSegment getTemplateSegment(int inPosition)
          gets a templatesegment from the vector
 TemplateSegment getTemplateSegment(java.lang.String inID)
          gets a templatesegment from the vector
 int getTemplateSegmentSize()
          returns the number of template segments
 boolean isSegment(int inPosition)
          returns true if subsegment type is a segment if false the subsegment is a vector or position specified is outside range of array
 boolean isVector(int inPosition)
          returns true if subsegment type is a vector if true the subsegment is a segment or position specified is outside range of array
 void removeSegment(int inPosition)
          removes a Segment from the segmentArray 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 segmentArray at a particular position in the subsegment Vector
 void removeSegment(java.lang.String inID)
          removes a Segment from the segmentArray 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 segmentArray by its ID from the subsegment Vector
 void setSegmentAt(Segment inSegment, int inPosition)
          sets a Segment to the segmentArray at position in the array, if the Segment is part of the vectorized segment throw exception
 void setSegmentAt(Segment inSegment, int inPosition, int inVectorPosition)
          sets a Segment to the vector at a position segmentArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

templateSegmentVector

protected java.util.Vector templateSegmentVector

segmentArray

protected java.lang.Object[] segmentArray
Constructor Detail

SegmentContainer

public SegmentContainer()
Method Detail

getID

public abstract java.lang.String getID()

defineSegmentArray

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

addSegment

public void addSegment(Segment inSegment)
                throws OBOEException

addSegment

public void addSegment(Segment inSegment,
                       int inPosition)
                throws OBOEException
adds a Segment to the segmentArray by its predefined sequence
Parameters:
Segment - segment to add
int - sequence number
Throws:
OBOEException - Subsegment not defined at sequence Subsegment sequence not defined

addSegmentToVector

public void addSegmentToVector(Segment inSegment,
                               int inPosition)
                        throws OBOEException
adds a Segment to a vectorized segment in the segmentArray at a predefined sequence
Parameters:
Segment - segment to add
int - sequence number
Throws:
OBOEException - segment postion not vectorized

setSegmentAt

public void setSegmentAt(Segment inSegment,
                         int inPosition)
                  throws OBOEException
sets a Segment to the segmentArray at position in the array, if the Segment is part of the vectorized segment throw exception
Parameters:
Segment - segment to add
int - sequence number
Throws:
OBOEException - out of range Subsegment vectorized Subsegment not defined at sequence

setSegmentAt

public void setSegmentAt(Segment inSegment,
                         int inPosition,
                         int inVectorPosition)
                  throws OBOEException
sets a Segment to the vector at a position segmentArray
Parameters:
Segment - segment to add
int - sequence number
int - position in Vector
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 segmentArray by id, does this by setting array entry to null can be used to remove all segments with same id at a vectorized position
Parameters:
int - position
Throws:
OBOEException - unknown segment id

removeSegment

public void removeSegment(java.lang.String inID,
                          int inPosition)
                   throws OBOEException
removes a Segment from the segmentArray by its ID from the subsegment Vector
Parameters:
int - sequence number
int - pos
Throws:
OBOEException - Subsegment not vectorized unknown segment id

removeSegment

public void removeSegment(int inPosition)
                   throws OBOEException
removes a Segment from the segmentArray at a particular position can be used to remove all segments with same id at a vectorized position
Parameters:
int - sequence number
Throws:
OBOEException - position number out of range

removeSegment

public void removeSegment(int inPosition,
                          int inVectorPosition)
                   throws OBOEException
removes a Segment from the segmentArray at a particular position in the subsegment Vector
Parameters:
int - sequence in array
int - pos in vector
Throws:
OBOEException - position number out of range Subsegment not vectorized Subsegment sequence not defined

getSegment

public Segment getSegment(int inPosition)
returns a Segment by its position
Parameters:
int - position of the segment
Returns:
Segment objects - null indicates segment not set
Throws:
OBOEException - no or not a segment at the position

getSegment

public Segment getSegment(int inPosition,
                          int inVectorPosition)
                   throws OBOEException
returns the Segment inside the subsegment Vector by its position
Parameters:
int - position of the segment
int - position in the vector
Returns:
Vector of Segment objects - null indicates segment not set
Throws:
java.lang.Exception - ID

getSegment

public Segment getSegment(java.lang.String ID)
                   throws java.lang.Exception
returns a Segment by its ID
Parameters:
String - id of the segment
Returns:
Segment objects - null indicates segment not set
Throws:
OBOEExcetpion - no or not a segment at the position

getSubsegmentCount

public int getSubsegmentCount(int inPosition)
returns the number of subsegments in a vector position
Returns:
int a count - zero if position is not held by a vector

isSegment

public boolean isSegment(int inPosition)
returns true if subsegment type is a segment if false the subsegment is a vector or position specified is outside range of array
Parameters:
int - position
Returns:
boolean

isVector

public boolean isVector(int inPosition)
returns true if subsegment type is a vector if true the subsegment is a segment or position specified is outside range of array
Parameters:
int - position
Returns:
boolean

addTemplateSegment

public void addTemplateSegment(TemplateSegment inTemplateSegment)
adds a templatesegment to the vector
Parameters:
TemplateSegment - input template

getTemplateSegmentSize

public int getTemplateSegmentSize()
returns the number of template segments
Returns:
int

createSegment

public Segment createSegment(java.lang.String id)
                      throws java.lang.Exception
creates a static segment
Parameters:
String - id
Returns:
Segment based on this Template

getTemplateSegment

public TemplateSegment getTemplateSegment(int inPosition)
gets a templatesegment from the vector
Parameters:
int - pos of the templateSegment
Returns:
TemplateSegment

getTemplateSegment

public TemplateSegment getTemplateSegment(java.lang.String inID)
gets a templatesegment from the vector
Parameters:
String - id of the templateSegment
Returns:
TemplateSegment