org.exoplatform.services.jcr.rmi.api.value
Class BinaryValue

java.lang.Object
  extended by org.exoplatform.services.jcr.rmi.api.value.BaseNonStreamValue
      extended by org.exoplatform.services.jcr.rmi.api.value.BinaryValue
All Implemented Interfaces:
java.io.Serializable, javax.jcr.Value, ExtendedValue, StatefulValue

public class BinaryValue
extends BaseNonStreamValue

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

Field Summary
 
Fields inherited from class org.exoplatform.services.jcr.rmi.api.value.BaseNonStreamValue
orderNumber
 
Constructor Summary
protected BinaryValue(java.io.InputStream stream)
          Creates an instance on the given InputStream.
protected BinaryValue(java.lang.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.
 java.util.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 getLength()
           
 long getLong()
          Always throws IllegalStateException because only an InputStream is available from this implementation.
 int getOrderNumber()
           
 java.lang.String getReference()
           
 java.io.InputStream getStream()
          Returns the InputStream from which this instance has been created.
 java.lang.String getString()
          Always throws IllegalStateException because only an InputStream is available from this implementation.
 int getType()
          Returns PropertyType.BINARY.
 void setOrderNumber(int arg0)
           
protected static java.io.InputStream toStream(java.lang.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 org.exoplatform.services.jcr.rmi.api.value.BaseNonStreamValue
getValueFormatException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryValue

protected BinaryValue(java.io.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(java.lang.String value)
               throws javax.jcr.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:
javax.jcr.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 java.io.InputStream toStream(java.lang.String value)
                                       throws javax.jcr.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:
javax.jcr.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 java.io.InputStream getStream()
Returns the InputStream from which this instance has been created.

Specified by:
getStream in interface javax.jcr.Value
Overrides:
getStream in class BaseNonStreamValue
Returns:
value stream

getType

public int getType()
Returns PropertyType.BINARY.

Returns:
property type

getString

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

Returns:
nothing
Throws:
java.lang.IllegalStateException - as defined above.

getLong

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

Specified by:
getLong in interface javax.jcr.Value
Overrides:
getLong in class BaseNonStreamValue
Returns:
nothing
Throws:
java.lang.IllegalStateException - as defined above.

getDouble

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

Specified by:
getDouble in interface javax.jcr.Value
Overrides:
getDouble in class BaseNonStreamValue
Returns:
nothing
Throws:
java.lang.IllegalStateException - as defined above.

getDate

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

Specified by:
getDate in interface javax.jcr.Value
Overrides:
getDate in class BaseNonStreamValue
Returns:
nothing
Throws:
java.lang.IllegalStateException - as defined above.

getBoolean

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

Specified by:
getBoolean in interface javax.jcr.Value
Overrides:
getBoolean in class BaseNonStreamValue
Returns:
nothing
Throws:
java.lang.IllegalStateException - as defined above.

getLength

public long getLength()

getOrderNumber

public int getOrderNumber()
Specified by:
getOrderNumber in interface ExtendedValue
Overrides:
getOrderNumber in class BaseNonStreamValue

getReference

public java.lang.String getReference()
                              throws javax.jcr.ValueFormatException,
                                     java.lang.IllegalStateException,
                                     javax.jcr.RepositoryException
Specified by:
getReference in interface ExtendedValue
Overrides:
getReference in class BaseNonStreamValue
Throws:
javax.jcr.ValueFormatException - , IllegalStateException, RepositoryException
java.lang.IllegalStateException
javax.jcr.RepositoryException

setOrderNumber

public void setOrderNumber(int arg0)
Specified by:
setOrderNumber in interface ExtendedValue
Overrides:
setOrderNumber in class BaseNonStreamValue


Copyright © 2011 eXo Platform SAS. All Rights Reserved.