This class is the base for all the classes we use to represent the various data types. With a few minor variations, for each specific data type that we support in a non-XML format we provide a derived class that handles converting that type to and from the corresponding Schema data type.
Attributes:
Byte or Character Array Cell Buffer
DOM Element Field Grammar
Integer Buffer Length
Integer Field Number
Integer Subfield Number
The Subfield Number attribute is used only for EDI, but we include it in the base class to make processing and class derivation a bit easier. This is a pragmatic approach, not a purist one!
Methods:
The most important methods are listed here. Other various minor methods set and get single class attributes or Attributes of the Grammar Element.
Constructor
fromXML (overridden in derived classes)
getField
prepareOutput (overridden in derived classes)
putByte
putField
toElement
toXML (overridden in derived classes)
trim (C++ only)
The constructor method is very basic. It takes two arguments: the Field Number and the Field Grammar Element. It stores these passed arguments in the appropriate attributes of the class and initializes the other class attributes.
This method has no arguments and returns the contents of the Cell Buffer and the value of the Buffer Length.
This method has a single argument of a byte of data. It appends the passed byte to the Cell Buffer.
This method takes two arguments: a byte or char array of the contents of a legacy format field and the length of the field passed as an integer. It stores the passed field contents in the Cell Buffer.
This method creates a new Element using the passed name, adds text from the Field Contents, and attaches the Element to the passed parent Element. If the Cell Buffer contents are empty a new Element is not created.
Arguments: DOM Element Parent DOM Document Output Document Returns: Void IF Buffer Length = 0 Return ENDIF Element Name <- Get "ElementName" Attribute from Grammar Element New Element <- call Output Document's createElement method Parent <- append New Element to Parent Text Node <- call Output Document's createTextNode method, Passing Cell Buffer contents New Element <- append Text Node to New Element |
This is a C++ function only since Java provides a trim method for its String class. It trims leading and trailing whitespace (all characters with an integer value less than or equal to the space character) from the Cell Buffer.
As with the RecordHandler classes, these methods are overridden in the derived classes. Base versions with minimal functionality are provided here. None of these methods takes any arguments, and all either return a completion status or throw an exception.
This method converts the buffer contents from the schema language data type format to the non-XML format. The base class version returns with no action and is appropriate for data types that require no conversion.
After format conversion with fromXML, this routine performs additional formatting tasks that are required before the data can be written to the output. Specific operations are dependent on the data type. Typical tasks include space filling to the minimum field length, adding or removing leading zeroes, and truncating.
This method converts the buffer contents from the non-XML format to the format required by the corresponding schema language data type. This base class version returns with no action. It is appropriate for data types such as alphanumeric text or decimal numbers that require no conversion.