org.apache.jackrabbit.rmi.value
Class NameValue

java.lang.Object
  extended by org.apache.jackrabbit.rmi.value.NameValue
All Implemented Interfaces:
Serializable, Value

public class NameValue
extends Object

The NameValue class implements the committed value state for Name values as a part of the State design pattern (Gof) used by this package.

Since:
0.16.4.1
See Also:
Serialized Form

Constructor Summary
protected NameValue(String value)
          Creates an instance for the given name value.
 
Method Summary
 boolean equals(Object object)
          Compares values as defined in the JCR specification.
 Binary getBinary()
          Returns the binary representation of this value.
 boolean getBoolean()
          Always throws a ValueFormatException.
 Calendar getDate()
          Always throws a ValueFormatException.
 BigDecimal getDecimal()
          Always throws a ValueFormatException.
 double getDouble()
          Always throws a ValueFormatException.
 long getLong()
          Always throws a ValueFormatException.
 InputStream getStream()
          Returns the stream representation of this value.
 String getString()
          Returns the string representation of the Name value.
 int getType()
          Returns PropertyType.NAME.
protected  ValueFormatException getValueFormatException(String destType)
          Returns a ValueFormatException with a message indicating what kind of type conversion is not supported.
 int hashCode()
          Returns a hash code that's in line with how the equals(Object) method is implemented.
 String toString()
          Returns a string representation of this value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NameValue

protected NameValue(String value)
             throws ValueFormatException
Creates an instance for the given name value.

Throws:
ValueFormatException
Method Detail

getType

public int getType()
Returns PropertyType.NAME.


getString

public String getString()
                 throws RepositoryException
Returns the string representation of the Name value.

Throws:
RepositoryException

getStream

public final InputStream getStream()
                            throws RepositoryException
Returns the stream representation of this value. This method implements the deprecated JCR 1.0 behaviour of always returning the same stream instance. The stream is retrieved from a Binary instance returned by getBinary().

Specified by:
getStream in interface Value
Returns:
stream representation of this value
Throws:
RepositoryException - if the stream can not be created

getBinary

public Binary getBinary()
                 throws RepositoryException
Returns the binary representation of this value. The default implementation uses the UTF-8 serialization of the string returned by Value.getString(). Subclasses

Specified by:
getBinary in interface Value
Throws:
RepositoryException

getBoolean

public boolean getBoolean()
                   throws ValueFormatException
Always throws a ValueFormatException. Implementations should overwrite if conversion to boolean is supported.

Specified by:
getBoolean in interface Value
Returns:
nothing
Throws:
ValueFormatException - If the value cannot be converted to a boolean.

getDate

public Calendar getDate()
                 throws ValueFormatException
Always throws a ValueFormatException. Implementations should overwrite if conversion to Calender is supported.

Specified by:
getDate in interface Value
Returns:
nothing
Throws:
ValueFormatException - If the value cannot be converted to a Calendar instance.

getDecimal

public BigDecimal getDecimal()
                      throws RepositoryException
Always throws a ValueFormatException. Implementations should overwrite if conversion to a BigDecimal is supported.

Specified by:
getDecimal in interface Value
Returns:
nothing
Throws:
ValueFormatException - If the value cannot be converted to a BigDecimal.
RepositoryException

getDouble

public double getDouble()
                 throws ValueFormatException
Always throws a ValueFormatException. Implementations should overwrite if conversion to double is supported.

Specified by:
getDouble in interface Value
Returns:
nothing
Throws:
ValueFormatException - If the value cannot be converted to a double.

getLong

public long getLong()
             throws ValueFormatException
Always throws a ValueFormatException. Implementations should overwrite if conversion to long is supported.

Specified by:
getLong in interface Value
Returns:
nothing
Throws:
ValueFormatException - If the value cannot be converted to a long.

getValueFormatException

protected ValueFormatException getValueFormatException(String destType)
Returns a ValueFormatException with a message indicating what kind of type conversion is not supported.

Parameters:
destType - The name of the value type to which this value cannot be converted.
Returns:
nothing

equals

public boolean equals(Object object)
Compares values as defined in the JCR specification.

Overrides:
equals in class Object
Parameters:
object - value for comparison
Returns:
true if the values are equal, false otherwise
See Also:
JCRRMI-16

hashCode

public int hashCode()
Returns a hash code that's in line with how the equals(Object) method is implemented.

Overrides:
hashCode in class Object
Returns:
hash code of this value

toString

public String toString()
Returns a string representation of this value.

Overrides:
toString in class Object
Returns:
value string


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.