DataCell Base Class

Overview

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)

Methods

Constructor

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.

getField

This method has no arguments and returns the contents of the Cell Buffer and the value of the Buffer Length.

putByte

This method has a single argument of a byte of data. It appends the passed byte to the Cell Buffer.

putField

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.

toElement

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.

Logic for the DataCell toElement Method
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

trim

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.

Derived Class Methods

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.

fromXML

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.

prepareOutput

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.

toXML

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset