Open Business Objects for EDI
v3.6.0

com.americancoders.edi
Class LoopAndSegmentContainer

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

public abstract class LoopAndSegmentContainer
extends SegmentContainer

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
 
Fields inherited from class com.americancoders.edi.SegmentContainer
container, dupSegment, myTemplateContainer
 
Constructor Summary
LoopAndSegmentContainer()
           
 
Method Summary
 void addLoop(com.americancoders.edi.Loop inLoop)
          add a Loop to the array
 void addLoopToVector(com.americancoders.edi.Loop inLoop, int inPosition)
          adds a Loop to a vectorized Loop in the container at a predefined sequence
 boolean continueParse(com.americancoders.edi.SegmentContainer inContainer, com.americancoders.edi.ITokenizer TransactionSetTokenizer)
          continues to parse an EDI Document after an error.
 com.americancoders.edi.Loop createLoop(java.lang.String id)
          creates a Loop by ID
 void defineContainer()
          simple routine to build the array based on the number of entries in the template segment vector
 boolean doYouWantThisNode(org.w3c.dom.Node node)
          tests if the node is part of this container
 boolean doYouWantThisSegment(java.lang.String inID)
          tests if the seg id is part of this container
protected  boolean equivalentLoops(int i)
           
 int getContainerSize()
          returns the size of the segment array
-1 if array is undefined
 int getCount(int inPosition)
          returns the number of elements in a vector position
 int getCount(java.lang.String ID)
          returns the number of elements by id
 com.americancoders.edi.Loop getLoop(int inPosition)
          returns a Loop by its position
 com.americancoders.edi.Loop getLoop(int inPosition, int inVectorPosition)
          returns the Loop inside the subLoop Vector by its position
 com.americancoders.edi.Loop getLoop(java.lang.String ID)
          returns a Loop by its ID
 com.americancoders.edi.Loop getLoop(java.lang.String ID, int inVectorPosition)
          returns a Loop by its ID and its position in the vector
You must use this method call to get to floating Loops
 int getLoopAndSegmentCount()
          returns the number of sub componenets (loops and segments)
 com.americancoders.edi.Loop getLoopByDataElementValue(java.lang.String ID, int inSequence, java.lang.String inValue)
          returns a Loop by its id and the contents of a data field
Used for Loops that repeat, useful with IDDE type fields.
 int getLoopCount()
          returns the number of subloops
 int getLoopCount(java.lang.String ID)
          returns the number of subLoops by Loop id
 int getSegmentCount()
          returns the number of subsegments
 int getSegmentCount(int inPosition)
          returns the number of subLoops in a vector position
 com.americancoders.edi.TemplateLoopContainer getTemplateLoopContainer()
          returns the template loop container
 java.util.Vector getVector(int inPosition)
          returns the vector in the container
 boolean isLoop(int inPosition)
          returns true if object in container is a Loop at reqqeusted position if false the subLoop is a vector or position specified is outside range of array
 boolean isLoop(int inPosition, int inVectorPosition)
          returns true if object in container is a Loop at reqqeusted position if false the subLoop is a vector or position specified is outside range of array
 boolean isNull(int inPosition)
          returns true if there is no object in container at reqqeusted position
 boolean isVector(int inPosition)
          returns true if object in container is a vector at reqqeusted position if true the subLoop is a Loop 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 parse(org.w3c.dom.Node node)
          parses a XML EDI Document adds to datalement vector or compositeDE and adds to secondary Segment vector
 void parse(java.io.PushbackInputStream pis)
          parses a Fixed Length EDI Document
 void removeLoop(int inPosition)
          removes a Loop from the container at a particular position can be used to remove all Loops with same id at a vectorized position
 void removeLoop(int inPosition, int inVectorPosition)
          removes a Loop from the container at a particular position in the subLoop Vector
 void removeLoop(java.lang.String inID)
          removes a Loop from the container by id, does this by setting array entry to null can be used to remove all Loops with same id at a vectorized position
 void removeLoop(java.lang.String inID, int inPosition)
          removes a Loop from the container by its ID from the subLoop Vector
protected  int resetToFirstEquivalentLoop(int i)
           
 void setLoopAt(com.americancoders.edi.Loop inLoop, int inPosition)
          sets a Loop to the container at position in the array, if the Loop is part of the vectorized Loop throw exception
 void setLoopAt(com.americancoders.edi.Loop inLoop, int inPosition, int inVectorPosition)
          sets a Loop to the vector at a position container
 void setTemplateLoopContainer(com.americancoders.edi.TemplateLoopContainer inTLC)
          sets the template loop container
 int trim()
          removes unused Loops and return the number of subLoops in container
 boolean validate()
          validates if the contianer is defined correctly
 boolean validate(com.americancoders.edi.DocumentErrors inDErr)
          validates if the container is defined correctly
doesn't throw exception, places error messages in DocumentErrors object
 void whyNotUsed(com.americancoders.edi.Tokenizer et)
          asks the container why it didn't use the current token
 
Methods inherited from class com.americancoders.edi.SegmentContainer
addSegment, addSegment, addSegment, addSegmentToVector, createSegment, createSegment, createSegmentByIDAndName, equivalentSegments, getID, getSegment, getSegment, getSegment, getSegment, getSegment, getSegment, getSegmentByDataElementValue, getSegmentCount, isSegment, isSegment, removeSegment, removeSegment, removeSegment, removeSegment, resetToFirstEquivalentSegment, setSegmentAt, setSegmentAt
 
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
 

Constructor Detail

LoopAndSegmentContainer

public LoopAndSegmentContainer()
Method Detail

doYouWantThisSegment

public boolean doYouWantThisSegment(java.lang.String inID)
                             throws OBOEException
tests if the seg id is part of this container

Parameters:
inID - String seg id
Returns:
boolean true it is part of this container
Throws:
OBOEException - thrown when an unknown segment id string is found

parse

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

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

parse

public void 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 void parse(java.io.PushbackInputStream pis)
           throws OBOEException,
                  java.io.IOException
parses a Fixed Length EDI Document

Parameters:
pis - PushbackInputStream
Throws:
OBOEException - thrown when the transaction id string is incorrect
OBOEException - thrown when an unknown segment id string is foundi
java.io.IOException

whyNotUsed

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

Overrides:
whyNotUsed in class SegmentContainer
Parameters:
et - Tokenizer object to get TransactionTokenizedString incoming tokenized string

getContainerSize

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

Overrides:
getContainerSize in class SegmentContainer
Returns:
int

defineContainer

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

Overrides:
defineContainer in class SegmentContainer

addLoop

public void addLoop(com.americancoders.edi.Loop inLoop)
             throws OBOEException
add a Loop to the array

Parameters:
inLoop - Segmemt to add to vector
Throws:
OBOEException - Loop doesn't belong

addLoopToVector

public void addLoopToVector(com.americancoders.edi.Loop inLoop,
                            int inPosition)
                     throws OBOEException
adds a Loop to a vectorized Loop in the container at a predefined sequence

Parameters:
inLoop - Loop
inPosition - int position
Throws:
OBOEException - Loop postion not vectorized

setLoopAt

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

Parameters:
inLoop - Loop
inPosition - int position
Throws:
OBOEException - out of range SubLoop vectorized SubLoop not defined at sequence

setLoopAt

public void setLoopAt(com.americancoders.edi.Loop inLoop,
                      int inPosition,
                      int inVectorPosition)
               throws OBOEException
sets a Loop to the vector at a position container

Parameters:
inLoop - Loop
inPosition - int position in array
inVectorPosition - int position with vector at inPosition
Throws:
OBOEException - out of range SubLoop not vectorized SubLoop not defined at sequence

removeLoop

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

Parameters:
inID - String id
Throws:
OBOEException - unknown Loop id

removeLoop

public void removeLoop(java.lang.String inID,
                       int inPosition)
                throws OBOEException
removes a Loop from the container by its ID from the subLoop Vector

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

removeLoop

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

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

removeLoop

public void removeLoop(int inPosition,
                       int inVectorPosition)
                throws OBOEException
removes a Loop from the container at a particular position in the subLoop Vector

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

getLoop

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

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

getLoop

public com.americancoders.edi.Loop getLoop(int inPosition,
                                           int inVectorPosition)
                                    throws OBOEException
returns the Loop inside the subLoop Vector by its position

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

getLoop

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

Parameters:
ID - String id of Loop to get
Returns:
Loop objects - null indicates Loop not set
Throws:
OBOEException - "ID is unknown to Loop "

getLoop

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

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

getLoopByDataElementValue

public com.americancoders.edi.Loop getLoopByDataElementValue(java.lang.String ID,
                                                             int inSequence,
                                                             java.lang.String inValue)
                                                      throws OBOEException
returns a Loop by its id and the contents of a data field
Used for Loops 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:
Loop objects - null not found
Throws:
OBOEException - Loop with ID not within a Vector.

getVector

public java.util.Vector getVector(int inPosition)
returns the vector in the container

Parameters:
inPosition -
Returns:
Vector

getLoopAndSegmentCount

public int getLoopAndSegmentCount()
returns the number of sub componenets (loops and segments)

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

getSegmentCount

public int getSegmentCount()
returns the number of subsegments

Returns:
int a count - zero if position is not held by a vector
Throws:
java.lang.ArrayOutOfBounds - is possibl

getLoopCount

public int getLoopCount()
returns the number of subloops

Returns:
int a count - zero if position is not held by a vector
Throws:
java.lang.ArrayOutOfBounds - is possibl

getSegmentCount

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

Overrides:
getSegmentCount in class SegmentContainer
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.

getLoopCount

public int getLoopCount(java.lang.String ID)
returns the number of subLoops by Loop id

Parameters:
ID - String id of Loop to count
Returns:
int
Throws:
OBOEException - Loop with ID unknown.

getCount

public int getCount(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.

getCount

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

Parameters:
ID - String id to count
Returns:
int
Throws:
OBOEException - ID unknown.

isLoop

public boolean isLoop(int inPosition)
returns true if object in container is a Loop at reqqeusted position if false the subLoop is a vector or position specified is outside range of array

Parameters:
inPosition - int position inarray
Returns:
boolean

isLoop

public boolean isLoop(int inPosition,
                      int inVectorPosition)
returns true if object in container is a Loop at reqqeusted position if false the subLoop 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 reqqeusted position if true the subLoop is a Loop or position specified is outside range of array

Overrides:
isVector in class SegmentContainer
Parameters:
inPosition - int position in array
Returns:
boolean

isNull

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

Overrides:
isNull in class SegmentContainer
Parameters:
inPosition - int position in array
Returns:
boolean

createLoop

public com.americancoders.edi.Loop createLoop(java.lang.String id)
                                       throws OBOEException
creates a Loop by ID

Parameters:
id - String id of subLoop to create
Returns:
Loop based on this Template
Throws:
OBOEException - unknown id

doYouWantThisNode

public boolean doYouWantThisNode(org.w3c.dom.Node node)
                          throws OBOEException
tests if the node is part of this container

Parameters:
node - DOM node of transaction data
Returns:
boolean true it is part
Throws:
OBOEException - thrown when the transaction id string is incorrect
OBOEException - thrown when an unknown segment id string is foundi

trim

public int trim()
removes unused Loops and return the number of subLoops in container

Overrides:
trim in class SegmentContainer
Returns:
int

continueParse

public boolean continueParse(com.americancoders.edi.SegmentContainer inContainer,
                             com.americancoders.edi.ITokenizer TransactionSetTokenizer)
                      throws OBOEException
continues to parse an EDI Document after an error. Searches through the containers until last one container to make a good request is found. If it is this container then we know we can restart parsing

Parameters:
inContainer - last container used.
TransactionSetTokenizer - tokenizer hold transaction strings
Returns:
boolean - reparse started
Throws:
OBOEException - thrown when the transaction id string is incorrect
OBOEException - thrown when an unknown Segment id string is foundi

validate

public boolean validate()
validates if the contianer is defined correctly

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

validate

public boolean validate(com.americancoders.edi.DocumentErrors inDErr)
validates if the container is defined correctly
doesn't throw exception, places error messages in DocumentErrors object

Returns:
boolean true if built correctly

setTemplateLoopContainer

public void setTemplateLoopContainer(com.americancoders.edi.TemplateLoopContainer inTLC)
sets the template loop container

Parameters:
inTLC -

getTemplateLoopContainer

public com.americancoders.edi.TemplateLoopContainer getTemplateLoopContainer()
returns the template loop container

Returns:
TemplateLoopContainer

resetToFirstEquivalentLoop

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

equivalentLoops

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

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.