Joda System API

org.joda.property.impl.type
Class DefaultStringProperty

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

public class DefaultStringProperty
extends AbstractProperty
implements StringProperty

Default implementation of a String property.

Data is stored in the associated PropertyData object as a String 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
 
Field Summary
 
Fields inherited from interface org.joda.property.type.StringProperty
DEFAULT_TYPE
 
Constructor Summary
DefaultStringProperty()
          Constructor
 
Method Summary
 void append(java.lang.Object appendValue)
          Append another string to this property's value.
 char charAt(int index)
          Returns the character at a particular index.
 int compareTo(java.lang.Object object)
           
 boolean contains(java.lang.String searchString)
          Check for the presence of a particular string.
protected  java.lang.String convertObjectToString(java.lang.Object object)
          Convert an Object to a String, throwing an exception if unable to convert.
 void delete(int startIndex, int endIndex)
          Delete part of the string.
 void deleteCharAt(int index)
          Delete a character at a particular index.
 boolean endsWith(java.lang.String searchString)
          Check whether the property starts with particular string.
 boolean equalsValueIgnoreCase(java.lang.Object object)
          Check whether this string equals the one passed in ignoring case.
 java.lang.String get()
          Get the property's value.
protected  java.lang.String getInternal()
          Get the property as a string
 java.lang.Class getPropertyType()
          Get the type of the property.
 int indexOf(java.lang.String searchString)
          Get the index of a particular string, or -1 if not found
 int indexOf(java.lang.String searchString, int fromIndex)
          Get the index of a particular string, or -1 if not found
 void insert(int insertIndex, java.lang.Object insertValue)
          Insert another string into this property's value.
 boolean isEmpty()
          Is the string currently null or zero length
 int lastIndexOf(java.lang.String searchString)
          Get the last index of a particular string, or -1 if not found
 java.lang.String left(int length)
          Returns a string that is the leftmost characters of this string.
 int length()
          Get the length of the string.
 java.lang.String mid(int beginIndex, int length)
          Returns a string that is a substring of this string.
 java.lang.Class propertyType()
          Get the type of the property
 void replace(java.lang.String searchString, java.lang.String replaceString)
          Replace one string with another in the property's value.
 java.lang.String right(int length)
          Returns a string that is the rightmost characters of this string.
 void set(java.lang.Object propertyValue)
          Set the property's value as an object.
 void setCharAt(int index, char character)
          Set a character at a particular index.
protected  void setInternal(char[] chars)
          Set the value of the string
protected  void setInternal(java.lang.String newValue)
          Set the property value as a String
 void setToLowerCase()
          Set the property's value to lower case.
 void setToLowerCase(java.util.Locale locale)
          Set the property's value to lower case using the locale's rules.
 void setToUpperCase()
          Set the property's value to upper case.
 void setToUpperCase(java.util.Locale locale)
          Set the property's value to upper case using the locale's rules.
 boolean startsWith(java.lang.String searchString)
          Check whether the property ends with particular string.
 java.lang.String substring(int beginIndex)
          Returns a string that is a substring of this string.
 java.lang.String substring(int beginIndex, int endIndex)
          Returns a string that is a substring of this string.
 java.lang.String toDataString()
          Override for efficiency
 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, 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.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

DefaultStringProperty

public DefaultStringProperty()
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.lang.String getInternal()
Get the property as a string

Returns:
the stored value

setInternal

protected void setInternal(java.lang.String newValue)
Set the property value as a String

Parameters:
newValue - the value to store

setInternal

protected void setInternal(char[] chars)
Set the value of the string


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()

get

public java.lang.String get()
Description copied from interface: StringProperty
Get the property's value.

Specified by:
get in interface StringProperty
Returns:
the string's value
See Also:
StringProperty.get()

toDataString

public java.lang.String toDataString()
Override for efficiency

Specified by:
toDataString in interface DataProperty
Overrides:
toDataString in class AbstractProperty
Returns:
a String representing the property's value
See Also:
DataProperty#toDataString()

equalsValueIgnoreCase

public boolean equalsValueIgnoreCase(java.lang.Object object)
Description copied from interface: StringProperty
Check whether this string equals the one passed in ignoring case. String, StringBuffer and PropertyTools can be passed in.

Specified by:
equalsValueIgnoreCase in interface StringProperty
Returns:
true if the string starts with searchString
See Also:
StringProperty.equalsValueIgnoreCase(Object)

compareTo

public int compareTo(java.lang.Object object)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(Object)

isEmpty

public boolean isEmpty()
Description copied from interface: StringProperty
Is the string currently null or zero length

Specified by:
isEmpty in interface StringProperty
Returns:
true if null or zero length
See Also:
StringProperty.isEmpty()

length

public int length()
Description copied from interface: StringProperty
Get the length of the string.

Specified by:
length in interface StringProperty
Returns:
the string's length
See Also:
StringProperty.length()

contains

public boolean contains(java.lang.String searchString)
Description copied from interface: StringProperty
Check for the presence of a particular string.

Specified by:
contains in interface StringProperty
Parameters:
searchString - the string to search for
Returns:
true if the string is found
See Also:
StringProperty.contains(String)

endsWith

public boolean endsWith(java.lang.String searchString)
Description copied from interface: StringProperty
Check whether the property starts with particular string.

Specified by:
endsWith in interface StringProperty
Parameters:
searchString - the string to search for
Returns:
true if the string starts with searchString
See Also:
StringProperty.endsWith(String)

startsWith

public boolean startsWith(java.lang.String searchString)
Description copied from interface: StringProperty
Check whether the property ends with particular string.

Specified by:
startsWith in interface StringProperty
Parameters:
searchString - the string to search for
Returns:
true if the string ends with searchString
See Also:
StringProperty.startsWith(String)

indexOf

public int indexOf(java.lang.String searchString)
Description copied from interface: StringProperty
Get the index of a particular string, or -1 if not found

Specified by:
indexOf in interface StringProperty
Parameters:
searchString - the string to search for
Returns:
the index of the string, or -1 if not found
See Also:
StringProperty.indexOf(String)

indexOf

public int indexOf(java.lang.String searchString,
                   int fromIndex)
Description copied from interface: StringProperty
Get the index of a particular string, or -1 if not found

Specified by:
indexOf in interface StringProperty
Parameters:
searchString - the string to search for
fromIndex - the index to start the search at
Returns:
the index of the string, or -1 if not found
See Also:
StringProperty.indexOf(String, int)

lastIndexOf

public int lastIndexOf(java.lang.String searchString)
Description copied from interface: StringProperty
Get the last index of a particular string, or -1 if not found

Specified by:
lastIndexOf in interface StringProperty
Parameters:
searchString - the string to search for
Returns:
the index of the string, or -1 if not found
See Also:
StringProperty.lastIndexOf(String)

charAt

public char charAt(int index)
Description copied from interface: StringProperty
Returns the character at a particular index.

Specified by:
charAt in interface StringProperty
Parameters:
index - the index to obtain
Returns:
the specified character
See Also:
StringProperty.charAt(int)

substring

public java.lang.String substring(int beginIndex)
Description copied from interface: StringProperty
Returns a string that is a substring of this string. The substring begins at the specified index and extends to the end of this string.

Specified by:
substring in interface StringProperty
Parameters:
beginIndex - the beginning index, inclusive
Returns:
the specified substring
See Also:
StringProperty.substring(int)

substring

public java.lang.String substring(int beginIndex,
                                  int endIndex)
Description copied from interface: StringProperty
Returns a string that is a substring of this string. The substring begins at the specified index and extends to the end of this string.

Specified by:
substring in interface StringProperty
Parameters:
beginIndex - the beginning index, inclusive
endIndex - the ending index, exclusive
Returns:
the specified substring
See Also:
StringProperty.substring(int, int)

left

public java.lang.String left(int length)
Description copied from interface: StringProperty
Returns a string that is the leftmost characters of this string. No exception is thrown if the specified number of characters is unavailable.

Specified by:
left in interface StringProperty
Parameters:
length - the length of string to obtain
Returns:
the specified substring
See Also:
StringProperty.left(int)

mid

public java.lang.String mid(int beginIndex,
                            int length)
Description copied from interface: StringProperty
Returns a string that is a substring of this string. The substring begins at the specified index and extends to the end of this string. No exception is thrown if the specified number of characters is unavailable.

Specified by:
mid in interface StringProperty
Parameters:
beginIndex - the beginning index, inclusive
length - the length of string to obtain
Returns:
the specified substring
See Also:
StringProperty.mid(int, int)

right

public java.lang.String right(int length)
Description copied from interface: StringProperty
Returns a string that is the rightmost characters of this string. No exception is thrown if the specified number of characters is unavailable.

Specified by:
right in interface StringProperty
Parameters:
length - the length of string to obtain
Returns:
the specified substring
See Also:
StringProperty.right(int)

convertObjectToString

protected java.lang.String convertObjectToString(java.lang.Object object)
Convert an Object to a String, throwing an exception if unable to convert.

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

propertyType

public java.lang.Class propertyType()
Get the type of the property

Returns:
the Class representing the property's type

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)

setCharAt

public void setCharAt(int index,
                      char character)
Description copied from interface: StringProperty
Set a character at a particular index.

Specified by:
setCharAt in interface StringProperty
Parameters:
index - the index to set the value at
character - the character to set to
See Also:
StringProperty.setCharAt(int, char)

deleteCharAt

public void deleteCharAt(int index)
Description copied from interface: StringProperty
Delete a character at a particular index.

Specified by:
deleteCharAt in interface StringProperty
Parameters:
index - the index to set the value at
See Also:
StringProperty.deleteCharAt(int)

append

public void append(java.lang.Object appendValue)
Description copied from interface: StringProperty
Append another string to this property's value. The string is obtained by calling toString() on the object passed in. Appending null has no effect.

Specified by:
append in interface StringProperty
Parameters:
appendValue - a value to append to the property
See Also:
StringProperty.append(Object)

insert

public void insert(int insertIndex,
                   java.lang.Object insertValue)
Description copied from interface: StringProperty
Insert another string into this property's value. The string is obtained by calling toString() on the object passed in. Inserting null has no effect.

Specified by:
insert in interface StringProperty
Parameters:
insertIndex - the index at which to insert
See Also:
StringProperty.insert(int, Object)

delete

public void delete(int startIndex,
                   int endIndex)
Description copied from interface: StringProperty
Delete part of the string.

Specified by:
delete in interface StringProperty
Parameters:
startIndex - the index at which to start, inclusive
endIndex - the index at which to end deleting, exclusive
See Also:
StringProperty.delete(int, int)

replace

public void replace(java.lang.String searchString,
                    java.lang.String replaceString)
Description copied from interface: StringProperty
Replace one string with another in the property's value.

Specified by:
replace in interface StringProperty
Parameters:
searchString - the string to search for
replaceString - the string to replace it with
See Also:
StringProperty.replace(String, String)

setToLowerCase

public void setToLowerCase()
Description copied from interface: StringProperty
Set the property's value to lower case.

Specified by:
setToLowerCase in interface StringProperty
See Also:
StringProperty.setToLowerCase()

setToLowerCase

public void setToLowerCase(java.util.Locale locale)
Description copied from interface: StringProperty
Set the property's value to lower case using the locale's rules.

Specified by:
setToLowerCase in interface StringProperty
Parameters:
locale - the locale to use for conversion
See Also:
StringProperty.setToLowerCase(Locale)

setToUpperCase

public void setToUpperCase()
Description copied from interface: StringProperty
Set the property's value to upper case.

Specified by:
setToUpperCase in interface StringProperty
See Also:
StringProperty.setToUpperCase()

setToUpperCase

public void setToUpperCase(java.util.Locale locale)
Description copied from interface: StringProperty
Set the property's value to upper case using the locale's rules.

Specified by:
setToUpperCase in interface StringProperty
Parameters:
locale - the locale to use for conversion
See Also:
StringProperty.setToUpperCase(Locale)

Joda System API

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