IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.base
Class FixedLength

java.lang.Object
  extended by com.ibm.btt.base.FormatElement
      extended by com.ibm.btt.base.FormatDecorator
          extended by com.ibm.btt.base.FixedLength
All Implemented Interfaces:
Cacheable, java.io.Externalizable, java.io.Serializable

@ATTR(value={"length#Integer#IMPLIED","justify#String#IMPLIED","padChar#String#IMPLIED","noEmpty#Boolean#IMPLIED"})
public class FixedLength
extends FormatDecorator

This class ensures that a String has a specified length. To do this, it may truncate long Strings or add characters to theString until it has the length determined by the length attribute.

See Also:
Serialized Form

Field Summary
 int justify
          The justification to be applied to the string.
 int length
          The length of the string after the decoration is applied.
 java.lang.String noEmpty
          A boolean that indicates whether to return the pad character when the resulting string is empty after applying the decorator.
 char padCharacter
          The character to use to pad the string so that it has the specified length.
 
Fields inherited from class com.ibm.btt.base.FormatDecorator
decorated
 
Fields inherited from class com.ibm.btt.base.FormatElement
dataElementName, externalizer, name
 
Constructor Summary
FixedLength()
          This is the default constructor used to create a FixedLength object.
FixedLength(java.lang.String aName)
          This is the constructor used by the Externalizer to create a FixedLength object.
 
Method Summary
 java.lang.String addDecoration(java.lang.String aString)
          Adjusts the length of the String to the length specified by the length attribute.
 java.lang.String[] extract(java.lang.String aString)
          Extracts (strips) the substring corresponding to the format element from the input String and returns it and the remaining String as the elements of an array.
 int getJustify()
          Returns the value of justify.
 int getLength()
          Returns the value of the length attribute.
 java.lang.String getNoEmpty()
          Returns the value of noEmpty.
 char getPadCharacter()
          Returns the value of padCharacter.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes a FixedLength object using the supplied Tag.
 java.lang.String removeDecoration(java.lang.String aString)
          Removes the padding characters from the input String.
 void setJustify(int anInteger)
          Sets the value of justify.
 void setLength(int anInteger)
          Sets the value of length.
 void setNoEmpty(java.lang.String aString)
          Sets the value of noEmpty.
 void setPadCharacter(char aCharacter)
          Sets the value of padCharacter.
 Vector toStrings()
          Returns a Vector containing a visual representation of the fixed length decorator.
 int unformat(int ndxFrom, int ndxTo, java.lang.String str, Context ctx)
          Unformat strings that between ndxFrom and ndxTo into the Context.
 int unformat(int ndxFrom, int ndxTo, java.lang.String str, DataElement de)
          Unformat strings that between ndxFrom and ndxTo into the DataElement.
 
Methods inherited from class com.ibm.btt.base.FormatDecorator
format, format, getDataElementName, getDecorated, getName, isConstant, isItConstant, reinitialize, rootDecorated, rootDecorator, setDecorated, toString, unformat, unformat
 
Methods inherited from class com.ibm.btt.base.FormatElement
checkIndexes, exceptionInfo, externalizer, getExternalizer, getTagName, isCacheable, isNull, readExternal, readExternal, readObject, removeExternal, setDataElementName, setExternalizer, setName, setSize, toTags, writeExternal, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

length

public int length
The length of the string after the decoration is applied.


justify

public int justify
The justification to be applied to the string.


padCharacter

public char padCharacter
The character to use to pad the string so that it has the specified length.


noEmpty

public java.lang.String noEmpty
A boolean that indicates whether to return the pad character when the resulting string is empty after applying the decorator. The default value is no.

Constructor Detail

FixedLength

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


FixedLength

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

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

addDecoration

public java.lang.String addDecoration(java.lang.String aString)
Adjusts the length of the String to the length specified by the length attribute. If the String is too long, this method truncates it. If the String is too short, this method justifies the String according to the justify attribute and then pads it using the character specified by the padCharacter attribute.

Specified by:
addDecoration in class FormatDecorator
Parameters:
aString - String
Returns:
String

extract

public java.lang.String[] extract(java.lang.String aString)
                           throws DSEInvalidArgumentException
Extracts (strips) the substring corresponding to the format element from the input String and returns it and the remaining String as the elements of an array.

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

getJustify

public int getJustify()
Returns the value of justify.

Returns:
java.lang.Integer

getLength

public int getLength()
Returns the value of the length attribute.

Returns:
java.lang.Integer

getNoEmpty

public java.lang.String getNoEmpty()
Returns the value of noEmpty.

Returns:
java.lang.String

getPadCharacter

public char getPadCharacter()
Returns the value of padCharacter.

Returns:
java.lang.Character

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
Initializes a FixedLength object using the supplied Tag.

Specified by:
initializeFrom in class FormatElement
Parameters:
aTag - com.ibm.btt.base.Tag
Returns:
Object

removeDecoration

public java.lang.String removeDecoration(java.lang.String aString)
                                  throws DSEInvalidArgumentException
Removes the padding characters from the input String.

Specified by:
removeDecoration in class FormatDecorator
Parameters:
aString - String
Returns:
String
Throws:
DSEInvalidArgumentException

setJustify

public void setJustify(int anInteger)
Sets the value of justify.

Parameters:
anInteger - java.lang.Integer

setLength

public void setLength(int anInteger)
Sets the value of length.

Parameters:
anInteger - java.lang.Integer

setNoEmpty

public void setNoEmpty(java.lang.String aString)
Sets the value of noEmpty.

Parameters:
aString - java.lang.String

setPadCharacter

public void setPadCharacter(char aCharacter)
Sets the value of padCharacter. This is the character added to Strings to make them the length determined by the length attribute.

Parameters:
aCharacter - java.lang.Character

toStrings

public Vector toStrings()
Returns a Vector containing a visual representation of the fixed length decorator.

Specified by:
toStrings in class FormatDecorator
Returns:
com.ibm.btt.base.Vector

unformat

public int unformat(int ndxFrom,
                    int ndxTo,
                    java.lang.String str,
                    DataElement de)
             throws DSEInvalidRequestException,
                    DSEInvalidArgumentException
Unformat strings that between ndxFrom and ndxTo into the DataElement.

Overrides:
unformat in class FormatElement
Parameters:
str - java.lang.String
ndxFrom - int
ndxTo - int
de - com.ibm.btt.base.DataElement;
Returns:
int
Throws:
DSEInvalidRequestException
DSEInvalidArgumentException

unformat

public int unformat(int ndxFrom,
                    int ndxTo,
                    java.lang.String str,
                    Context ctx)
             throws DSEInvalidRequestException,
                    DSEInvalidArgumentException
Unformat strings that between ndxFrom and ndxTo into the Context.

Overrides:
unformat in class FormatElement
Parameters:
str - java.lang.String
ndxFrom - int
ndxTo - int
ctx - com.ibm.btt.base.Context;
Returns:
int
Throws:
DSEInvalidRequestException
DSEInvalidArgumentException

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2011