org.apache.wookie.w3c.impl
Class AbstractLocalizedEntity

java.lang.Object
  extended by org.apache.wookie.w3c.impl.AbstractLocalizedEntity
All Implemented Interfaces:
IDirectional, ILocalized, IElement
Direct Known Subclasses:
AuthorEntity, ContentEntity, DescriptionEntity, IconEntity, LicenseEntity, NameEntity, WidgetManifestModel

public abstract class AbstractLocalizedEntity
extends java.lang.Object
implements ILocalized, IDirectional, IElement

Abstract base class for entities containing i18n or l10n content, including utility methods for extracting and processing text that uses language tags and text direction (e.g. RTL)


Field Summary
protected  java.lang.String dir
          Text direction conforming to http://www.w3.org/TR/2007/REC-its-20070403/
protected  java.lang.String lang
          a Language string conforming to BCP47
static java.lang.String LEFT_TO_RIGHT
           
static java.lang.String LEFT_TO_RIGHT_OVERRIDE
           
static java.lang.String RIGHT_TO_LEFT
           
static java.lang.String RIGHT_TO_LEFT_OVERRIDE
           
 
Constructor Summary
AbstractLocalizedEntity()
           
 
Method Summary
 void fromXML(org.jdom.Element element)
          Unmarshall the given XML Element to this Object
 java.lang.String getDir()
          Get the direction of text, which can be one of "ltr", "rtl", "lro", or "rlo".
 java.lang.String getLang()
          Get the language tag for the element.
static java.lang.String getLocalizedTextContent(org.jdom.Element element)
          Returns the text content of an element, recursively adding any text nodes found in its child nodes AND any elements that include localization information
static java.lang.String getTextDirection(org.jdom.Element element)
          Returns the direction (rtl, ltr, lro, rlo) of the child text of an element
 boolean isValid()
          Checks whether the language tag for the entity is OK.
 void setDir(java.lang.String dir)
          Set the direction of text, which can be one of "ltr", "rtl", "lro", or "rlo".
 void setLang(java.lang.String lang)
          Set the language tag for the object
protected  org.jdom.Element setLocalisationAttributes(org.jdom.Element element)
          Set the dir and lang attributes of an element representing the entity - used when marshalling an entity to XML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.wookie.w3c.xml.IElement
toXml
 

Field Detail

lang

protected java.lang.String lang
a Language string conforming to BCP47


dir

protected java.lang.String dir
Text direction conforming to http://www.w3.org/TR/2007/REC-its-20070403/


LEFT_TO_RIGHT

public static final java.lang.String LEFT_TO_RIGHT
See Also:
Constant Field Values

RIGHT_TO_LEFT

public static final java.lang.String RIGHT_TO_LEFT
See Also:
Constant Field Values

LEFT_TO_RIGHT_OVERRIDE

public static final java.lang.String LEFT_TO_RIGHT_OVERRIDE
See Also:
Constant Field Values

RIGHT_TO_LEFT_OVERRIDE

public static final java.lang.String RIGHT_TO_LEFT_OVERRIDE
See Also:
Constant Field Values
Constructor Detail

AbstractLocalizedEntity

public AbstractLocalizedEntity()
Method Detail

getLang

public java.lang.String getLang()
Description copied from interface: ILocalized
Get the language tag for the element. This should conform to BCP47.

Specified by:
getLang in interface ILocalized
Returns:
the language tag, or null if no language tag has been set for the element

setLang

public void setLang(java.lang.String lang)
Set the language tag for the object

Specified by:
setLang in interface ILocalized
Parameters:
lang - the language tag to set; this should be a valid BCP-47 language tag

getDir

public java.lang.String getDir()
Description copied from interface: IDirectional
Get the direction of text, which can be one of "ltr", "rtl", "lro", or "rlo". The default value is "ltr".

Specified by:
getDir in interface IDirectional
Returns:
the direction of the text

setDir

public void setDir(java.lang.String dir)
Description copied from interface: IDirectional
Set the direction of text, which can be one of "ltr", "rtl", "lro", or "rlo". The default value is "ltr".

Specified by:
setDir in interface IDirectional
Parameters:
dir - the direction to set

isValid

public boolean isValid()
Checks whether the language tag for the entity is OK. A null value is OK, as is a BCP47 tag

Specified by:
isValid in interface IDirectional
Returns:
true if the locale for this object is aeither valid language tag or null, otherwise false.

fromXML

public void fromXML(org.jdom.Element element)
Description copied from interface: IElement
Unmarshall the given XML Element to this Object

Specified by:
fromXML in interface IElement
Parameters:
element - The Element to unmarshall

getLocalizedTextContent

public static java.lang.String getLocalizedTextContent(org.jdom.Element element)
Returns the text content of an element, recursively adding any text nodes found in its child nodes AND any elements that include localization information

Parameters:
element -
Returns:
a string containing the element text

getTextDirection

public static java.lang.String getTextDirection(org.jdom.Element element)
Returns the direction (rtl, ltr, lro, rlo) of the child text of an element

Parameters:
element - the element to parse
Returns:
the string "ltr", "rtl", "lro" or "rlo"

setLocalisationAttributes

protected org.jdom.Element setLocalisationAttributes(org.jdom.Element element)
Set the dir and lang attributes of an element representing the entity - used when marshalling an entity to XML

Parameters:
element - the element to add attributes to
Returns:
the element with dir and lang attributes added if appropriate


2012 Apache Software Foundation.