| java.lang.Object com.bostechcorp.cbesb.runtime.parser.VariableElementParser
All known Subclasses: com.bostechcorp.cbesb.runtime.parser.VariableTaggedElementParser, com.bostechcorp.cbesb.runtime.parser.VariablePositionElementParser,
VariableElementParser | abstract public class VariableElementParser implements IElementParser(Code) | | The VariableElementParser class implements ElementParser. It is used to parse
elements defined as variable format.
Basic flow of the parse method: 1. Set the variable format attributes in the
VariableDataScanner (delimiter, escape character, etc). 2. If the
VariableFormatDefinition specifies an IDMethod = tag, call parseTag, if the
IDMethod = position, call parsePosition.
Basic flow of parseTag method: 1. Create a new Element with the name and
namespace provided in the ElementDefinition. 2. Initialize Finite State
Machine with content model defined by tags in ElementDefinition. 3. Call
getNextElement in the VariableDataScanner to retrieve the next piece of data
from the InputStream. 4. Repeatedly feed in the element data to the FSM until
the end of the InputStream is reached. 5. If the FSM matches all elements
successfully, then do the following for each successfully matched element: a.
Create a new InputStream containing this data only. b. Get the
ElementDefinition from the ContentElement that defines the child. c. Get an
instance of ElementParser from ElementParserFactory using the child
ElementDefinition as input. d. Call the parse method of this ElementParser
passing in the new InputStream and child ElementDefinition. e. Append the
returned DOM Element to the Element created in step 1.
Basic flow of parsePosition method: 1. Create a new Element with the name and
namespace provided in the ElementDefinition. 2. Loop over all of the child
ContentElement nodes defined in the ElementDefinition. For each child, do the
following: a. Call getNextElement in the VariableDataScanner to retrieve the
next piece of data from the InputStream. b. If the getNextElement method
returned multiple strings, then there were multiple occurrences of this
element in the data. For each Occurrence, do the following: i. Create a new
InputStream containing this data only. ii. Get the ElementDefinition from the
ContentElement that defines the child. iii. Get an instance of ElementParser
from ElementParserFactory using the child ElementDefinition as input. iv.
Call the parse method of this ElementParser passing in the new InputStream
and child ElementDefinition. v. Append the returned DOM Element to the
Element created in step 1.
|
|
|