DataCellX12R Class (Extends DataCellReal)

As noted above, this class is derived from the DataCellReal class developed in Chapter 8. It uses that class's toXML method but provides its own fromXML and prepareOutput methods.

Logic for the DataCellX12R fromXML Method
Arguments:
  None

Returns:
  Error status or throws exception

Trim Spaces
IF Cell Buffer = -0, INF, -INF, or NaN
  Return error for unsupported constant in X12 Decimal date type
ENDIF
Convert to uppercase since XML schema language data types allow
    a lower case 'e' to indicate the exponent
IF first Character in Cell Buffer = "+"
  Cell Buffer <- Shift Cell Buffer left one character to remove
      plus sign
  Decrement Buffer Length
ENDIF
Return success

Logic for the DataCellX12R prepareOutput Method
Arguments:
  None

Returns:
  Status or throws exception

NegativeNumber <- false
ExponentialNotation <- false
IF first character in Cell Buffer is "-"
  Cell Buffer <- Shift Cell Buffer left one character to remove
      Minus sign
  Negative Number <- true
  Decrement Buffer Length
ENDIF
Minimum Length <- Call Grammar Element's getAttribute for
    "MinLength", converting to integer
Maximum Length <- Call Grammar Element's getAttribute for
    "MaxLength", converting to integer
IF Cell Buffer contains "E"
  Increment Minimum Length
  Increment Maximum Length
  Exponential Notation <- true
ENDIF
IF Cell Buffer contains a decimal point
  Increment Minimum Length
  Increment Maximum Length
ENDIF
IF (Buffer Length < Minimum Length)
  Call justifyFieldRight, passing Minimum Length and zero
      as Fill Character
ENDIF
IF (Buffer Length > Maximum Length)
  Truncate <- Call Grammar Element's getAttribute for
      "Truncatable"
  IF Truncate = false OR Exponential Notation = true
    Return truncation error
  ENDIF
  Depending on language features, truncate Cell Buffer contents to
      specified Length stopping when Length is achieved or
      decimal point is truncated
  IF (Buffer Length > Maximum Length)
    Return failure
  ENDIF
  Buffer Length <- Maximum Length
ENDIF
IF Negative Number = true
  Cell Buffer <- Shift Cell Buffer right one character to insert
      Minus sign
  Increment Buffer Length
ENDIF
Return success

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

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