Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

er.extensions
Class ERXFixedLengthString  view ERXFixedLengthString download ERXFixedLengthString.java

java.lang.Object
  extended byWOComponent
      extended byer.extensions.ERXStatelessComponent
          extended byer.extensions.ERXFixedLengthString

public class ERXFixedLengthString
extends ERXStatelessComponent

This stateless component is useful for displaying a string of a fixed length. For example imagine you have the string: 'The brown dog jumped' and for a given table cell you only want to display at most 10 characters of the string, then using this component you could bind the given string to the 'value' binding, 10 to the 'length' binding and the string '...' to the 'suffixWhenTrimmed' binding. When rendering this would display:
The brown ...
This component can also be used to pad whitespace onto the end of strings that are shorter than the given length.
Synopsis:
value=aString;length=aNumber;[shouldPadToLength=aBoolean;][suffixWhenTrimmed=aString;][escapeHTML=aBoolean;]


Field Summary
protected  java.lang.String _fixedLengthString
          Holds the local cache for the calculated fixed length string
protected  boolean valueWasTrimmed
          flag to indicate if characters were trimmed from the end of the passed in string.
 
Constructor Summary
ERXFixedLengthString(WOContext context)
          Public constructor
 
Method Summary
 boolean escapeHTML()
          Returns the value for the binding: escapeHTML.
 int length()
          Fixed length of the string to be displayed.
 void reset()
          Resets cached instance variables.
 java.lang.String strippedValue()
          Returns the value stripped from HTML tags if escapeHTML is false.
 java.lang.String suffixWhenTrimmed()
          Returns the value for the binding: suffixWhenTrimmed only if the string was trimmed.
 java.lang.String value()
          Calculates the fixed length string from the string passed in via the binding: value.
 
Methods inherited from class er.extensions.ERXStatelessComponent
isStateless, synchronizesVariablesWithBindings, valueForBooleanBinding, valueForBooleanBinding, valueForBooleanBinding, valueForIntBinding, valueForObjectBinding, valueForObjectBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

valueWasTrimmed

protected boolean valueWasTrimmed
flag to indicate if characters were trimmed from the end of the passed in string.


_fixedLengthString

protected java.lang.String _fixedLengthString
Holds the local cache for the calculated fixed length string

Constructor Detail

ERXFixedLengthString

public ERXFixedLengthString(WOContext context)
Public constructor

Method Detail

length

public int length()
Fixed length of the string to be displayed.


reset

public void reset()
Resets cached instance variables.


value

public java.lang.String value()
Calculates the fixed length string from the string passed in via the binding: value. If the length of the value string is greater than the int value of the length binding then the string is trimmed to the fixed length. If the string is shorter than the fixed length size and the binding: shouldPadToLength is set to true then whitespace is added to the end of the string buffer.


strippedValue

public java.lang.String strippedValue()
Returns the value stripped from HTML tags if escapeHTML is false. This makes sense because it is not terribly useful to have half-finished tags in your code. Note that the "length" of the resulting string is not very exact. FIXME: we could remove extra whitespace and character entities here MOVEME: should go to ERXStringUtilities


suffixWhenTrimmed

public java.lang.String suffixWhenTrimmed()
Returns the value for the binding: suffixWhenTrimmed only if the string was trimmed.


escapeHTML

public boolean escapeHTML()
Returns the value for the binding: escapeHTML.