Joda System API

org.joda.property.impl.type
Class DefaultLocaleProperty

java.lang.Object
  |
  +--org.joda.property.impl.AbstractModelElement
        |
        +--org.joda.property.impl.AbstractProperty
              |
              +--org.joda.property.impl.type.DefaultLocaleProperty
All Implemented Interfaces:
DataProperty, InitializableProperty, LocaleProperty, ModelElement, Property, Property.Internal, java.io.Serializable

public class DefaultLocaleProperty
extends AbstractProperty
implements LocaleProperty

Default implementation of a Locale property.

Data is stored in the associated PropertyData object as a Locale object. This is immutable so can be directly returned.

Author:
Stephen Colebourne
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.joda.property.Property
Property.Internal
 
Constructor Summary
DefaultLocaleProperty()
          Constructor
 
Method Summary
protected  java.util.Locale convertObjectToLocale(java.lang.Object object)
          Convert an Object to a Locale, throwing an exception if unable to convert.
 java.util.Locale get()
          Get the property's value as a Locale.
protected  java.util.Locale getInternal()
          Get the property as a Locale
 java.lang.Class getPropertyType()
          Get the type of the property.
 void set(java.lang.Object propertyValue)
          Set the property's value as an object.
 void set(java.lang.String language, java.lang.String country)
          Set the property's value to a specific language and country.
protected  void setInternal(java.util.Locale newValue)
          Set the property value as a Locale
 java.util.Locale toLocale()
          Get the property's value as a Locale.
 java.lang.Object toObject()
          Get the property's value as an object.
 
Methods inherited from class org.joda.property.impl.AbstractProperty
addPropertyChangeListener, bean, checkArgumentNotNull, checkModifiable, checkValueNotNull, checkValueNotNull, cloneDeep, convertObject, createClonedProperty, data, equals, equalsValue, firePropertyChange, firePropertyChange, getContentName, getContentType, getPropertyName, getThis, hashCode, initBeanCreated, initPropertyCreated, isModifiable, isNull, isReadOnly, populateClonedProperty, removePropertyChangeListener, setModifiable, setReadOnly, toDataString, toString
 
Methods inherited from class org.joda.property.impl.AbstractModelElement
getAttribute, getAttributeCount, getAttributeMap, setAttribute
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.joda.property.type.DataProperty
toDataString
 
Methods inherited from interface org.joda.property.Property
addPropertyChangeListener, bean, equals, equalsValue, firePropertyChange, getContentName, getContentType, getPropertyName, hashCode, isModifiable, isNull, isReadOnly, removePropertyChangeListener, setModifiable, setReadOnly, toString
 
Methods inherited from interface org.joda.property.ModelElement
getAttribute, getAttributeCount, getAttributeMap, setAttribute
 

Constructor Detail

DefaultLocaleProperty

public DefaultLocaleProperty()
Constructor

Method Detail

getPropertyType

public java.lang.Class getPropertyType()
Get the type of the property. A method String getFoo() has a property type of String.class.

Specified by:
getPropertyType in interface Property
Returns:
the property type

getInternal

protected java.util.Locale getInternal()
Get the property as a Locale

Returns:
the stored value

setInternal

protected void setInternal(java.util.Locale newValue)
Set the property value as a Locale

Parameters:
newValue - the value to store

toObject

public java.lang.Object toObject()
Description copied from interface: Property
Get the property's value as an object. The object type will be appropriate for the type of property. The object will either be immutable or a clone of the real object.

This method has strong semantics such that where a and b are properties of the same type, it must be true that:
b.set( a.toObject() ); a.equals(b);
In other words, the object contains all the data necessary to recreate the property's value.

Specified by:
toObject in interface Property
Specified by:
toObject in class AbstractProperty
Returns:
an Object representing the property's value
See Also:
Property#toObject()

toLocale

public java.util.Locale toLocale()
Description copied from interface: LocaleProperty
Get the property's value as a Locale.

Specified by:
toLocale in interface LocaleProperty
Returns:
the property value as a Locale
See Also:
LocaleProperty.toLocale()

get

public java.util.Locale get()
Description copied from interface: LocaleProperty
Get the property's value as a Locale.

Specified by:
get in interface LocaleProperty
Returns:
the property value as a Locale
See Also:
LocaleProperty.get()

convertObjectToLocale

protected java.util.Locale convertObjectToLocale(java.lang.Object object)
Convert an Object to a Locale, throwing an exception if unable to convert.

Parameters:
object - the value to convert
Returns:
the converted boolean

set

public void set(java.lang.Object propertyValue)
Description copied from interface: Property
Set the property's value as an object. The object type should be appropriate for the type of property. If necessary, the object will be cloned before it is stored internally. Implementations will recognise as many types of object passed in as possible. Null should always be accepted, primitive types will be reset back to zero/false.

If a String is passed in, it can be parsed in various ways. If the results of toDataString() are passed in, it must reconstitute the original value.

Specified by:
set in interface Property
Specified by:
set in class AbstractProperty
Parameters:
propertyValue - an Object to set the property's value to
See Also:
Property#set(Object)

set

public void set(java.lang.String language,
                java.lang.String country)
Description copied from interface: LocaleProperty
Set the property's value to a specific language and country.

Specified by:
set in interface LocaleProperty
Parameters:
language - the language to set the locale to
country - the country to set the locale to
See Also:
LocaleProperty.set(String, String)

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.