IBM Branch Transformation Toolkit Javadoc

com.ibm.btt.base
Class IntegerFormat

java.lang.Object
  extended bycom.ibm.btt.base.FormatElement
      extended bycom.ibm.btt.base.FieldFormat
          extended bycom.ibm.btt.base.IntegerFormat
All Implemented Interfaces:
Cacheable, Externalizable, java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
BinaryIntegerStringFormat

public class IntegerFormat
extends FieldFormat

This class formats an Integer or a Long into its internal byte-representation as a String.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.ibm.btt.base.FormatElement
dataElementName, externalizer, name
 
Constructor Summary
IntegerFormat()
          This is the default constructor used to create an IntegerFormat object.
IntegerFormat(java.lang.String aName)
          This constructor creates an IntegerFormat object with the specified name.
 
Method Summary
 java.lang.String[] extract(java.lang.String aString)
          Extracts the String according its size attribute.
 java.lang.String format(long aValue)
          Returns the integer's binary representation in a chain of bytes provided.
 java.lang.String formatField(DataField aDataField)
          Accesses the value of the DataField and checks that it is a valid integer.
 int getByteOrdering()
          Returns the value of byteOrdering.
 boolean getSign()
          Returns the value of sign.
 int getSize()
          Returns the value of size.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes an IntegerFormat with the aTag attributes.
 long parse(java.lang.String aString)
          Converts aString to a char[] and then converts the char[] to a Java long.
 void setByteOrdering(int anInt)
          Sets the value of byteOrdering.
 void setSign(boolean useSign)
          Sets the sign.
 void setSize(int aSize)
          Sets the value of size.
 java.lang.String toString()
          Converts the IntegerFormat to a String.
 DataField unformatField(java.lang.String aString, DataField aDataField)
          Updates the DataField value by interpreting the input string.
 
Methods inherited from class com.ibm.btt.base.FieldFormat
format, format, toStrings, unformat, unformat
 
Methods inherited from class com.ibm.btt.base.FormatElement
exceptionInfo, externalizer, getDataElementName, getExternalizer, getName, getTagName, isCacheable, isConstant, isItConstant, readExternal, readExternal, readObject, reinitialize, removeExternal, rootDecorated, setDataElementName, setExternalizer, setName, toTags, writeExternal, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntegerFormat

public IntegerFormat()
This is the default constructor used to create an IntegerFormat object.


IntegerFormat

public IntegerFormat(java.lang.String aName)
              throws java.io.IOException
This constructor creates an IntegerFormat object with the specified name.

Parameters:
aName - java.lang.String
Method Detail

extract

public java.lang.String[] extract(java.lang.String aString)
                           throws DSEInvalidArgumentException
Extracts the String according its size attribute.

Overrides:
extract in class FormatElement
Parameters:
aString - String
Returns:
String[]
Throws:
DSEInvalidArgumentException

format

public java.lang.String format(long aValue)
                        throws DSEInvalidArgumentException
Returns the integer's binary representation in a chain of bytes provided. aValue is from one to eight bytes in size.

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

formatField

public java.lang.String formatField(DataField aDataField)
                             throws DSEInvalidArgumentException,
                                    DSEInvalidClassException
Accesses the value of the DataField and checks that it is a valid integer. It then returns the integer's binary representation in a chain of bytes provided. aValue is from one to eight bytes in size.

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

getByteOrdering

public int getByteOrdering()
Returns the value of byteOrdering.

Returns:
int

getSign

public boolean getSign()
Returns the value of sign.

Returns:
boolean

getSize

public int getSize()
Returns the value of size.

Returns:
int

initializeFrom

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

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

parse

public long parse(java.lang.String aString)
           throws DSEInvalidArgumentException
Converts aString to a char[] and then converts the char[] to a Java long.

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

setByteOrdering

public void setByteOrdering(int anInt)
Sets the value of byteOrdering. The values of the parameter are: 0 ==> PC or littleEndian 1 ==> Host or bigEndian.


setSign

public void setSign(boolean useSign)
Sets the sign.

Parameters:
useSign - boolean

setSize

public void setSize(int aSize)
Sets the value of size. The values of the parameter are: 1 byte representation 2 short representation 3 4 integer representation 5 6 7 8 long representation.

Overrides:
setSize in class FormatElement
Parameters:
aSize - int

toString

public java.lang.String toString()
Converts the IntegerFormat to a String. Default values are not concatenated.

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

unformatField

public DataField unformatField(java.lang.String aString,
                               DataField aDataField)
                        throws DSEInvalidArgumentException
Updates the DataField value by interpreting the input string. If the size of the number is: of 1 byte then the DataField value will be updated with a Byte Object. of 2 bytes then the DataField value will be updated with a Short Object. of from 3 to 4 bytes then the DataField value will be updated with an Integer Object. of from 5 to 8 bytes then the DataField value will be updated with a Long Object.

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

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005