IBM Branch Transformation Toolkit Javadoc

com.ibm.dse.base
Class FixedLength

java.lang.Object
  extended bycom.ibm.dse.base.FormatElement
      extended bycom.ibm.dse.base.FormatDecorator
          extended bycom.ibm.dse.base.FixedLength
All Implemented Interfaces:
Cacheable, Externalizable, java.io.Externalizable, java.io.Serializable

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
           
 int length
           
 java.lang.String noEmpty
           
 char padCharacter
           
 
Fields inherited from class com.ibm.dse.base.FormatDecorator
decorated
 
Fields inherited from class com.ibm.dse.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.
 
Methods inherited from class com.ibm.dse.base.FormatDecorator
format, format, getDataElementName, getDecorated, getName, isConstant, isItConstant, reinitialize, rootDecorated, rootDecorator, setDecorated, toString, unformat, unformat
 
Methods inherited from class com.ibm.dse.base.FormatElement
exceptionInfo, externalizer, format, getExternalizer, getTagName, isCacheable, readExternal, readExternal, readObject, removeExternal, 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
 

Field Detail

length

public int length

justify

public int justify

padCharacter

public char padCharacter

noEmpty

public java.lang.String noEmpty
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
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 interface Externalizable
Specified by:
initializeFrom in class FormatElement
Parameters:
aTag - com.ibm.dse.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 interface Externalizable
Specified by:
toStrings in class FormatDecorator
Returns:
com.ibm.dse.base.Vector

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005