Class CustomizableDisplayText
java.lang.Object
net.okapia.osid.primordium.locale.CustomizableDisplayText
- All Implemented Interfaces:
Serializable, Comparable<DisplayText>, DisplayText, OsidPrimitive, DisplayText, OsidPrimitive
A
DisplayText that wraps another displayText and forwards every
method to it, so it carries exactly the wrapped value and the same
identity: it is equal to the displayText it wraps and to any other
displayText of the same value. The single seam is toString();
every other method is final, so a subclass cannot reach
anything the contract depends on. Customize the string form by
passing a CustomizableDisplayText.Codec to displayText(org.osid.locale.DisplayText, Codec), or by subclassing and overriding toString().
See CustomizableDistance
for the full design rationale (value-based identity, the
toString() seam, and the bundling pattern). Intentionally not
final.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFormats a displayText to a string and parses it back. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCustomizableDisplayText(DisplayText delegate) Constructs a newCustomizableDisplayTextthat renders with the wrapped displayText's own string form.protectedCustomizableDisplayText(DisplayText delegate, CustomizableDisplayText.Codec codec) Constructs a newCustomizableDisplayTextthat renders with the given codec. -
Method Summary
Modifier and TypeMethodDescriptionfinal intcompareTo(DisplayText arg0) static CustomizableDisplayTextdisplayText(DisplayText displayText) Wraps a displayText, rendering with its own string form.static CustomizableDisplayTextdisplayText(DisplayText displayText, CustomizableDisplayText.Codec codec) Wraps a displayText, rendering with the given codec.final booleanprotected DisplayTextGets the wrapped displayText.final Typefinal Typefinal Typefinal StringgetText()final inthashCode()toString()Returns the string form of this displayText.
-
Constructor Details
-
CustomizableDisplayText
Constructs a newCustomizableDisplayTextthat renders with the wrapped displayText's own string form.- Parameters:
delegate- the displayText to wrap- Throws:
NullArgumentException-delegateisnull
-
CustomizableDisplayText
Constructs a newCustomizableDisplayTextthat renders with the given codec.- Parameters:
delegate- the displayText to wrapcodec- the codec used bytoString(), ornullto render with the wrapped displayText's own string form- Throws:
NullArgumentException-delegateisnull
-
-
Method Details
-
displayText
Wraps a displayText, rendering with its own string form.- Parameters:
displayText- the displayText to wrap- Returns:
- the wrapped displayText
- Throws:
NullArgumentException-displayTextisnull
-
displayText
public static CustomizableDisplayText displayText(DisplayText displayText, CustomizableDisplayText.Codec codec) Wraps a displayText, rendering with the given codec.- Parameters:
displayText- the displayText to wrapcodec- the codec used bytoString()- Returns:
- the wrapped displayText
- Throws:
NullArgumentException-displayTextorcodecisnull
-
getDelegate
-
getLanguageType
- Specified by:
getLanguageTypein interfaceDisplayText
-
getScriptType
- Specified by:
getScriptTypein interfaceDisplayText
-
getFormatType
- Specified by:
getFormatTypein interfaceDisplayText
-
getText
- Specified by:
getTextin interfaceDisplayText
-
compareTo
- Specified by:
compareToin interfaceComparable<DisplayText>- Specified by:
compareToin interfaceDisplayText
-
equals
- Specified by:
equalsin interfaceDisplayText- Overrides:
equalsin classObject
-
hashCode
- Specified by:
hashCodein interfaceDisplayText- Overrides:
hashCodein classObject
-
toString
Returns the string form of this displayText. With a codec, this iscodec.format(wrapped); otherwise it is the wrapped displayText's own string form. This is the one method a subclass may override.- Specified by:
toStringin interfaceOsidPrimitive- Overrides:
toStringin classObject- Returns:
- the string form
-