org.apache.jackrabbit.rmi.value
Class BaseNonStreamValue

java.lang.Object
  extended by org.apache.jackrabbit.rmi.value.BaseNonStreamValue
All Implemented Interfaces:
Serializable, Value, StatefulValue
Direct Known Subclasses:
BooleanValue, DateValue, DoubleValue, LongValue, NameValue, PathValue, ReferenceValue, StringValue

public abstract class BaseNonStreamValue
extends Object
implements StatefulValue

The BaseNonStreamValue class implements the basic committed value state for non-stream values as a part of the State design pattern (Gof) used by this package.

This class implements all methods of the org.apache.jackrabbit.rmi.value.StatefullValue except getString and getType interface by always throwing an appropriate exception. Extensions of this class should overwrite methods as appropriate except for the getStream() which must throw an IllegalStateException for this line of committed non-stream states.

See Also:
Serialized Form

Constructor Summary
protected BaseNonStreamValue()
          Default constructor with no special tasks.
 
Method Summary
 boolean getBoolean()
          Always throws a ValueFormatException.
 Calendar getDate()
          Always throws a ValueFormatException.
 double getDouble()
          Always throws a ValueFormatException.
 long getLong()
          Always throws a ValueFormatException.
 InputStream getStream()
          Always throws IllegalStateException because only non-stream getters are available from this implementation.
protected  ValueFormatException getValueFormatException(String destType)
          Returns a ValueFormatException with a message indicating what kind of type conversion is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jcr.Value
getString, getType
 

Constructor Detail

BaseNonStreamValue

protected BaseNonStreamValue()
Default constructor with no special tasks.

Method Detail

getStream

public final InputStream getStream()
                            throws IllegalStateException
Always throws IllegalStateException because only non-stream getters are available from this implementation.

This method is declared final to mark that this line of implementations does not provide access to InputStreams.

Specified by:
getStream in interface Value
Returns:
nothing
Throws:
IllegalStateException - as defined above.

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.

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


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