org.priha.core.values
Class ValueImpl

java.lang.Object
  extended by org.priha.core.values.ValueImpl
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<ValueImpl>, javax.jcr.Value
Direct Known Subclasses:
BooleanValueImpl, CalendarValueImpl, DoubleValueImpl, LongValueImpl, NodeValueImpl, QNameValue.Impl, QPathValue.Impl, StreamValueImpl, StringValueImpl

public abstract class ValueImpl
extends java.lang.Object
implements javax.jcr.Value, java.lang.Cloneable, java.lang.Comparable<ValueImpl>

Implements the Value interface and provides a number of default accessors for easy development. All accessors by default throw a ValueFormatException, so you will want to implement those which you can convert to.


Field Summary
protected  org.priha.core.values.ValueImpl.VALUE_STATE m_state
           
 
Constructor Summary
protected ValueImpl()
           
 
Method Summary
protected  void checkStream()
          This method makes sure that the Value value is a stream, not a value.
protected  void checkValue()
          This method makes sure that the Value value is a value, not a stream.
 int compareTo(ValueImpl value)
          By default, does String comparison, which means it may fail.
 boolean equals(java.lang.Object o)
           
 boolean getBoolean()
           
 java.util.Calendar getDate()
           
 double getDouble()
           
 long getLong()
           
 java.io.InputStream getStream()
          By default, returns the inputstream of the String representation.
 java.lang.String getString()
           
 java.lang.String toString()
           
 java.lang.String valueAsString()
          Allows getting the Value as a String without regard to the current Stream/Value format setting.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jcr.Value
getType
 

Field Detail

m_state

protected org.priha.core.values.ValueImpl.VALUE_STATE m_state
Constructor Detail

ValueImpl

protected ValueImpl()
Method Detail

checkStream

protected final void checkStream()
                          throws java.lang.IllegalStateException
This method makes sure that the Value value is a stream, not a value.

Throws:
java.lang.IllegalStateException - If this is a value Value.

checkValue

protected final void checkValue()
                         throws java.lang.IllegalStateException
This method makes sure that the Value value is a value, not a stream.

Throws:
java.lang.IllegalStateException - If this is a stream value.

getBoolean

public boolean getBoolean()
                   throws javax.jcr.ValueFormatException,
                          java.lang.IllegalStateException,
                          javax.jcr.RepositoryException
Specified by:
getBoolean in interface javax.jcr.Value
Throws:
javax.jcr.ValueFormatException
java.lang.IllegalStateException
javax.jcr.RepositoryException

getDate

public java.util.Calendar getDate()
                           throws javax.jcr.ValueFormatException,
                                  java.lang.IllegalStateException,
                                  javax.jcr.RepositoryException
Specified by:
getDate in interface javax.jcr.Value
Throws:
javax.jcr.ValueFormatException
java.lang.IllegalStateException
javax.jcr.RepositoryException

getDouble

public double getDouble()
                 throws javax.jcr.ValueFormatException,
                        java.lang.IllegalStateException,
                        javax.jcr.RepositoryException
Specified by:
getDouble in interface javax.jcr.Value
Throws:
javax.jcr.ValueFormatException
java.lang.IllegalStateException
javax.jcr.RepositoryException

getLong

public long getLong()
             throws javax.jcr.ValueFormatException,
                    java.lang.IllegalStateException,
                    javax.jcr.RepositoryException
Specified by:
getLong in interface javax.jcr.Value
Throws:
javax.jcr.ValueFormatException
java.lang.IllegalStateException
javax.jcr.RepositoryException

getStream

public java.io.InputStream getStream()
                              throws java.lang.IllegalStateException,
                                     javax.jcr.RepositoryException
By default, returns the inputstream of the String representation.

Specified by:
getStream in interface javax.jcr.Value
Throws:
java.lang.IllegalStateException
javax.jcr.RepositoryException

getString

public java.lang.String getString()
                           throws javax.jcr.ValueFormatException,
                                  java.lang.IllegalStateException,
                                  javax.jcr.RepositoryException
Specified by:
getString in interface javax.jcr.Value
Throws:
javax.jcr.ValueFormatException
java.lang.IllegalStateException
javax.jcr.RepositoryException

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

valueAsString

public java.lang.String valueAsString()
Allows getting the Value as a String without regard to the current Stream/Value format setting. This means that this method can be called at any time.

Returns:
The value as a String. However, may return null in case the conversion cannot be made. Default implementation returns null and subclasses are expected to override this.

compareTo

public int compareTo(ValueImpl value)
By default, does String comparison, which means it may fail. Subclasses are expected to override.

Specified by:
compareTo in interface java.lang.Comparable<ValueImpl>