ERXFixedLengthString Class Reference

Inherits er::extensions::components::ERXStatelessComponent.

Collaboration diagram for ERXFixedLengthString:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ERXFixedLengthString (WOContext context)
boolean escapeHTML ()
int length ()
void reset ()
String strippedValue ()
String suffixWhenTrimmed ()
String value ()

Protected Attributes

String _fixedLengthString
boolean valueWasTrimmed = false


Detailed Description

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;]

value string that is passed in to display in a fixed length setting. length fixed length that is compared to the length of the passed in string. shouldPadToLength boolean binding to indicate if the string to be displayed is shorter than the fixed length if it should then be padded with white space. suffixWhenTrimmed only appended to the end of the string if characters are trimmed from the end of the string to be displayed escapeHTML replace the entities > and & with their escape codes (like WOString does). When this is set to true, all HTML text is cleared from the string first to prevent half-open tags


Constructor & Destructor Documentation

ERXFixedLengthString ( WOContext  context  ) 

Public constructor

Parameters:
context to be used


Member Function Documentation

boolean escapeHTML (  ) 

Returns the value for the binding: escapeHTML.

Returns:
optionally returns the boolean value of the binding or TRUE of not given.

int length (  ) 

Fixed length of the string to be displayed.

Returns:
int value of the binding: length

void reset (  ) 

Resets cached instance variables.

Reimplemented from ERXStatelessComponent.

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

Returns:
value stripped from tags.

String suffixWhenTrimmed (  ) 

Returns the value for the binding: suffixWhenTrimmed only if the string was trimmed.

Returns:
optionally returns the suffix to be added to the end of the string to be displayed.

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.

Returns:
fixed length version of the string passed in via the value binding.


Member Data Documentation

Holds the local cache for the calculated fixed length string

boolean valueWasTrimmed = false [protected]

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


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:04 2012 for Project Wonder by  doxygen 1.5.8