IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.base
Class PackedFormat

java.lang.Object
  extended by com.ibm.btt.base.FormatElement
      extended by com.ibm.btt.base.FieldFormat
          extended by com.ibm.btt.base.PackedFormat
All Implemented Interfaces:
Cacheable, java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
PackedDateFormat

@ATTR(value={"decPlaces#Integer#IMPLIED","signed#Boolean#IMPLIED"})
public class PackedFormat
extends FieldFormat

This class formats a number as a String that represents the packed value of the number (a digit per 4 bits).

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.ibm.btt.base.FormatElement
dataElementName, externalizer, name
 
Constructor Summary
PackedFormat()
          This is the default constructor used to create a PackedFormat object.
PackedFormat(java.lang.String aName)
          This is the constructor used by the externalizer to create a PackedFormat object.
 
Method Summary
protected  java.lang.String basicFormat(long num)
          Performs the conversion of num into a String.
protected  long basicParse(java.lang.String aString)
          Interprets the String as a packed integer in which a digit is represented by four bits of a character.
 java.lang.String format(double value)
          Formats a Double into a packed integer.
 java.lang.String format(long value)
          Formats a long into a packed integer.
 java.lang.String formatField(DataField aDataField)
          Accesses the value of the aDataField, checks it, and returns it as a packed decimal string representation with an EBCDIC sign such as "+" --> 0xc or "-" --> 0xd.
 int getDecimalPlaces()
          Returns the value of decimalPlaces.
 boolean getSigned()
          Returns the value of the signed attribute.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes a PackedFormat with the aTag attributes.
 boolean isSigned()
          Returns true if the data is to be formatted as signed.
 double parseToDouble(java.lang.String aString)
          Unformats a String by interpreting it as a packed double.
 long parseToLong(java.lang.String aString)
          Unformats a String by interpreting it as a packed integer.
 void setDecimalPlaces(int anInt)
          Sets the value of decimalPlaces.
 void setSigned(boolean aBoolean)
          Sets the value of signed.
 java.lang.String toString()
          Returns a visual representation of this format.
 DataField unformatField(java.lang.String aString, DataField aDataField)
          Updates the value of the DataField by interpreting aString as a packed decimal string representation with an an EBCDIC sign such as "+" --> 0xc or "-" --> 0xd.
 
Methods inherited from class com.ibm.btt.base.FieldFormat
format, format, toStrings, unformat, unformat, unformat
 
Methods inherited from class com.ibm.btt.base.FormatElement
checkIndexes, exceptionInfo, externalizer, extract, getDataElementName, getExternalizer, getName, getTagName, isCacheable, isConstant, isItConstant, isNull, readExternal, readExternal, readObject, reinitialize, removeExternal, rootDecorated, setDataElementName, setExternalizer, setName, setSize, toTags, unformat, writeExternal, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PackedFormat

public PackedFormat()
This is the default constructor used to create a PackedFormat object.


PackedFormat

public PackedFormat(java.lang.String aName)
             throws java.io.IOException
This is the constructor used by the externalizer to create a PackedFormat object.

Parameters:
aName - java.lang.String
Throws:
java.io.IOException
Method Detail

basicFormat

protected java.lang.String basicFormat(long num)
                                throws DSEInvalidArgumentException
Performs the conversion of num into a String. In the String each character represents two digits compressed into four bits each. This format takes the asumption that the second byte of a char is 0 (that is, ASCII code).

Parameters:
num - long
Returns:
java.lang.String
Throws:
DSEInvalidArgumentException

basicParse

protected long basicParse(java.lang.String aString)
                   throws DSEInvalidArgumentException
Interprets the String as a packed integer in which a digit is represented by four bits of a character. As a result, in the String, each character represents two digits. This format takes the asumption that the second byte of a char is 0 (that is, ASCII code).

Parameters:
aString - java.lang.String
Returns:
long
Throws:
DSEInvalidArgumentException

format

public java.lang.String format(double value)
                        throws DSEInvalidArgumentException
Formats a Double into a packed integer.

Parameters:
value - double
Returns:
java.lang.String
Throws:
DSEInvalidArgumentException

format

public java.lang.String format(long value)
                        throws DSEInvalidArgumentException
Formats a long into a packed integer.

Parameters:
value - long
Returns:
java.lang.String
Throws:
DSEInvalidArgumentException

formatField

public java.lang.String formatField(DataField aDataField)
                             throws DSEInvalidClassException,
                                    DSEInvalidArgumentException
Accesses the value of the aDataField, checks it, and returns it as a packed decimal string representation with an EBCDIC sign such as "+" --> 0xc or "-" --> 0xd.

Specified by:
formatField in class FieldFormat
Parameters:
aDataField - DataField
Returns:
String
Throws:
DSEInvalidClassException
DSEInvalidArgumentException

getDecimalPlaces

public int getDecimalPlaces()
Returns the value of decimalPlaces.

Returns:
int

getSigned

public boolean getSigned()
Returns the value of the signed attribute.

Returns:
boolean

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException
Initializes a PackedFormat with the aTag attributes.

Specified by:
initializeFrom in class FormatElement
Parameters:
aTag - com.ibm.btt.base.Tag
Returns:
java.lang.Object
Throws:
java.io.IOException

isSigned

public boolean isSigned()
Returns true if the data is to be formatted as signed.

Returns:
boolean

parseToDouble

public double parseToDouble(java.lang.String aString)
                     throws DSEInvalidArgumentException
Unformats a String by interpreting it as a packed double.

Parameters:
aString - java.lang.String
Returns:
double
Throws:
DSEInvalidArgumentException

parseToLong

public long parseToLong(java.lang.String aString)
                 throws DSEInvalidArgumentException
Unformats a String by interpreting it as a packed integer.

Parameters:
aString - java.lang.String
Returns:
long
Throws:
DSEInvalidArgumentException

setDecimalPlaces

public void setDecimalPlaces(int anInt)
Sets the value of decimalPlaces.

Parameters:
anInt - int

setSigned

public void setSigned(boolean aBoolean)
Sets the value of signed.

Parameters:
aBoolean - boolean

toString

public java.lang.String toString()
Returns a visual representation of this format.

Overrides:
toString in class FormatElement
Returns:
java.lang.String

unformatField

public DataField unformatField(java.lang.String aString,
                               DataField aDataField)
                        throws DSEInvalidArgumentException
Updates the value of the DataField by interpreting aString as a packed decimal string representation with an an EBCDIC sign such as "+" --> 0xc or "-" --> 0xd.

Specified by:
unformatField in class FieldFormat
Parameters:
aString - String
aDataField - DataField
Returns:
DataField
Throws:
DSEInvalidArgumentException

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2011