org.apache.jackrabbit.rmi.value
Class BinaryValue

java.lang.Object
  extended byorg.apache.jackrabbit.rmi.value.BinaryValue
All Implemented Interfaces:
Serializable, StatefulValue, Value

public class BinaryValue
extends Object
implements Serializable, StatefulValue

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

NOTE: This class forwards the InputStream from which it was created through the getStream() method but does not close the stream. It is the sole responsibility of the user of this value to close the stream if not needed anymore to prevent memory loss.

This class implements #readObject(ObjectInputStream) and #writeObject(ObjectOutputStream) methods to (de-)serialize the data.

Since:
0.16.4.1
See Also:
SerialValue, Serialized Form

Constructor Summary
protected BinaryValue(InputStream stream)
          Creates an instance on the given InputStream.
protected BinaryValue(String value)
          Creates an instance providing the UTF-8 representation of the given string value.
 
Method Summary
 boolean getBoolean()
          Always throws IllegalStateException because only an InputStream is available from this implementation.
 Calendar getDate()
          Always throws IllegalStateException because only an InputStream is available from this implementation.
 double getDouble()
          Always throws IllegalStateException because only an InputStream is available from this implementation.
 long getLong()
          Always throws IllegalStateException because only an InputStream is available from this implementation.
 InputStream getStream()
          Returns the InputStream from which this instance has been created.
 String getString()
          Always throws IllegalStateException because only an InputStream is available from this implementation.
 int getType()
          Returns PropertyType.BINARY.
protected static InputStream toStream(String value)
          Helper method to convert a string value into an InputStream from which the UTF-8 representation can be read.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryValue

protected BinaryValue(InputStream stream)
Creates an instance on the given InputStream. This exact stream will be provided by the getStream(), thus care must be taken to not inadvertendly read or close the stream.

Parameters:
stream - The InputStream providing the value.

BinaryValue

protected BinaryValue(String value)
               throws ValueFormatException
Creates an instance providing the UTF-8 representation of the given string value.

Parameters:
value - The string whose UTF-8 representation is provided as the value of this instance.
Throws:
ValueFormatException - If the platform does not support UTF-8 encoding (which is unlikely as UTF-8 is required to be available on all platforms).
Method Detail

toStream

protected static InputStream toStream(String value)
                               throws ValueFormatException
Helper method to convert a string value into an InputStream from which the UTF-8 representation can be read.

Parameters:
value - The string value to be made available through a stream.
Returns:
The InputStream from which the UTF-8 representation of the value may be read.
Throws:
ValueFormatException - If the platform does not support UTF-8 encoding (which is unlikely as UTF-8 is required to be available on all platforms).

getStream

public InputStream getStream()
Returns the InputStream from which this instance has been created.

Specified by:
getStream in interface Value
Returns:
value stream

getType

public int getType()
Returns PropertyType.BINARY.

Specified by:
getType in interface Value
Returns:
property type

getString

public String getString()
                 throws IllegalStateException
Always throws IllegalStateException because only an InputStream is available from this implementation.

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

getLong

public long getLong()
             throws IllegalStateException
Always throws IllegalStateException because only an InputStream is available from this implementation.

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

getDouble

public double getDouble()
                 throws IllegalStateException
Always throws IllegalStateException because only an InputStream is available from this implementation.

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

getDate

public Calendar getDate()
                 throws IllegalStateException
Always throws IllegalStateException because only an InputStream is available from this implementation.

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

getBoolean

public boolean getBoolean()
                   throws IllegalStateException
Always throws IllegalStateException because only an InputStream is available from this implementation.

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


Copyright © 2004-2006 . All Rights Reserved.