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>
Direct Known Subclasses:
BooleanValueImpl, CalendarValueImpl, DoubleValueImpl, LongValueImpl, NodeValueImpl, QNameValue.Impl, QPathValue.Impl, StreamValueImpl, StringValueImpl

public abstract class ValueImpl
extends java.lang.Object
implements 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()
           
 long getSize()
          Returns the approximate size of this object in bytes.
 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
 

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 ValueFormatException,
                          java.lang.IllegalStateException,
                          RepositoryException
Throws:
ValueFormatException
java.lang.IllegalStateException
RepositoryException

getDate

public java.util.Calendar getDate()
                           throws ValueFormatException,
                                  java.lang.IllegalStateException,
                                  RepositoryException
Throws:
ValueFormatException
java.lang.IllegalStateException
RepositoryException

getDouble

public double getDouble()
                 throws ValueFormatException,
                        java.lang.IllegalStateException,
                        RepositoryException
Throws:
ValueFormatException
java.lang.IllegalStateException
RepositoryException

getLong

public long getLong()
             throws ValueFormatException,
                    java.lang.IllegalStateException,
                    RepositoryException
Throws:
ValueFormatException
java.lang.IllegalStateException
RepositoryException

getStream

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

Throws:
java.lang.IllegalStateException
RepositoryException

getString

public java.lang.String getString()
                           throws ValueFormatException,
                                  java.lang.IllegalStateException,
                                  RepositoryException
Throws:
ValueFormatException
java.lang.IllegalStateException
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.

getSize

public long getSize()
Returns the approximate size of this object in bytes. If not determinable, returns -1;

Returns:

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>