Project Wonder 2.0

er.extensions
Class ERXFixedLengthString

java.lang.Object
  extended bycom.webobjects.appserver.WOElement
      extended bycom.webobjects.appserver.WOComponent
          extended byer.extensions.ERXNonSynchronizingComponent
              extended byer.extensions.ERXStatelessComponent
                  extended byer.extensions.ERXFixedLengthString
All Implemented Interfaces:
Cloneable, NSKeyValueCoding, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions, NSValidation, Serializable, WOActionResults

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

See Also:
Serialized Form
Bindings
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
           

Nested Class Summary
 
Nested classes inherited from class com.webobjects.appserver.WOComponent
WOComponent._EventLoggingEnabler, WOComponent.Event
 
Nested classes inherited from class com.webobjects.foundation.NSKeyValueCoding
NSKeyValueCoding._BooleanFieldBinding, NSKeyValueCoding._BooleanMethodBinding, NSKeyValueCoding._FieldBinding, NSKeyValueCoding._ForwardingBinding, NSKeyValueCoding._KeyBinding, NSKeyValueCoding._KeyBindingCreation, NSKeyValueCoding._MethodBinding, NSKeyValueCoding._NumberFieldBinding, NSKeyValueCoding._NumberMethodBinding, NSKeyValueCoding._ReflectionKeyBindingCreation, NSKeyValueCoding.DefaultImplementation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.Utility, NSKeyValueCoding.ValueAccessor
 
Nested classes inherited from class com.webobjects.foundation.NSKeyValueCodingAdditions
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility
 
Nested classes inherited from class com.webobjects.foundation.NSValidation
NSValidation._MethodBinding, NSValidation._ValidationBinding, NSValidation.DefaultImplementation, NSValidation.Utility, NSValidation.ValidationException
 
Field Summary
protected  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.
 
Fields inherited from class er.extensions.ERXNonSynchronizingComponent
_dynamicBindings
 
Fields inherited from class com.webobjects.appserver.WOComponent
_Extension, _IsEventLoggingEnabled, _keyAssociations
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
_CLASS, NullValue
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSValidation
_CLASS
 
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.
 String strippedValue()
          Returns the value stripped from HTML tags if escapeHTML is false.
 String suffixWhenTrimmed()
          Returns the value for the binding: suffixWhenTrimmed only if the string was trimmed.
 String value()
          Calculates the fixed length string from the string passed in via the binding: value.
 
Methods inherited from class er.extensions.ERXStatelessComponent
isStateless, valueForBooleanBinding, valueForBooleanBinding, valueForBooleanBinding, valueForIntBinding, valueForObjectBinding, valueForObjectBinding
 
Methods inherited from class er.extensions.ERXNonSynchronizingComponent
booleanValueForBinding, booleanValueForBinding, booleanValueForBinding, dynamicBindings, intValueForBinding, localizer, objectValueForBinding, objectValueForBinding, stringValueForBinding, stringValueForBinding, synchronizesVariablesWithBindings
 
Methods inherited from class com.webobjects.appserver.WOComponent
_associationWithName, _awakeInContext, _childTemplate, _componentDefinition, _componentUnroll, _isPage, _setContext, _setIsPage, _setParent, _setSubcomponent, _sleepInContext, _subcomponentForElementWithID, _templateNameForClass, _unroll, appendToResponse, application, awake, baseURL, bindingKeys, canAccessFieldsDirectly, canGetValueForBinding, canSetValueForBinding, clone, context, debugString, descriptionForResponse, ensureAwakeInContext, frameworkName, generateResponse, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hasBinding, hasSession, invokeAction, isCachingEnabled, isEventLoggingEnabled, logString, name, pageWithName, parent, path, pathURL, performParentAction, pullValuesFromParent, pushValuesToParent, session, set_componentUnroll, set_unroll, setCachingEnabled, setValueForBinding, sleep, takeValueForKey, takeValueForKeyPath, takeValuesFromRequest, template, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForKey, valueForKeyPath
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, 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 String _fixedLengthString
Holds the local cache for the calculated fixed length string

Constructor Detail

ERXFixedLengthString

public ERXFixedLengthString(WOContext context)
Public constructor

Parameters:
context - to be used
Method Detail

length

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

Returns:
int value of the binding: length

reset

public void reset()
Resets cached instance variables.

Overrides:
reset in class ERXStatelessComponent

value

public 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.

strippedValue

public 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.

suffixWhenTrimmed

public 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.

escapeHTML

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

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

Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.