org.apache.jackrabbit.core.value
Class InternalValue

java.lang.Object
  extended by org.apache.jackrabbit.spi.commons.value.AbstractQValue
      extended by org.apache.jackrabbit.core.value.InternalValue
All Implemented Interfaces:
Serializable, QValue

public class InternalValue
extends AbstractQValue

InternalValue represents the internal format of a property value.

The following table specifies the internal format for every property type:

 PropertyTypeSTRINGLONGDOUBLEDATEBOOLEANNAMEPATHURIDECIMALBINARYREFERENCE
Internal Format
String
Long
Double
Calendar
Boolean
Name
Path
URI
BigDecimal
BLOBFileValue
NodeId

See Also:
Serialized Form

Field Summary
static InternalValue[] EMPTY_ARRAY
           
 
Fields inherited from class org.apache.jackrabbit.spi.commons.value.AbstractQValue
type, val
 
Method Summary
static InternalValue create(BigDecimal value)
           
static InternalValue create(boolean value)
           
static InternalValue create(byte[] value)
           
static InternalValue create(Calendar value)
           
static InternalValue create(DataStore store, String id)
          Create a binary object with the given identifier.
static InternalValue create(double value)
           
static InternalValue create(FileSystemResource value)
           
static InternalValue create(InputStream value)
           
static InternalValue create(InputStream value, DataStore store)
          Create an internal value that is stored in the data store (if enabled).
static InternalValue create(long value)
           
static InternalValue create(Name value)
           
static InternalValue[] create(Name[] values)
           
static InternalValue create(NodeId value)
           
static InternalValue create(NodeId value, boolean weak)
           
static InternalValue create(Path value)
           
static InternalValue create(QValue value)
           
static InternalValue[] create(QValue[] values)
           
static InternalValue create(String value)
           
static InternalValue create(URI value)
           
static InternalValue create(Value value, NamePathResolver resolver)
          Create a new internal value from the given JCR value.
static InternalValue create(Value value, NamePathResolver resolver, DataStore store)
          Create a new internal value from the given JCR value.
 InternalValue createCopy()
          Create a copy of this object.
static InternalValue createTemporary(InputStream value)
          Create an internal value that is backed by a temporary file.
 void deleteBinaryResource()
          Delete persistent binary objects.
 void discard()
          Frees temporarily allocated resources such as temporary file, buffer, etc.
 boolean equals(Object object)
          Default implementation of the equals method.
 Binary getBinary()
          This implementation creates a binary instance that uses QValue.getStream() and skipping on the given stream as its underlying mechanism to provide random access defined on Binary.
 Calendar getDate()
           
 long getLength()
          Returns the length of the internal value or -1 if the implementation cannot determine the length at this time.
 NodeId getNodeId()
           
 InputStream getStream()
          Returns an InputStream representation of this QValue object.
 void store(DataStore dataStore)
          Store a value in the data store.
static InternalValue valueOf(String s, int type)
          Parses the given string as an InternalValue of the specified type.
 
Methods inherited from class org.apache.jackrabbit.spi.commons.value.AbstractQValue
getBoolean, getCalendar, getDecimal, getDouble, getLong, getName, getPath, getString, getType, getURI, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final InternalValue[] EMPTY_ARRAY
Method Detail

create

public static InternalValue create(Value value,
                                   NamePathResolver resolver)
                            throws ValueFormatException,
                                   RepositoryException
Create a new internal value from the given JCR value. Large binary values are stored in a temporary file.

Parameters:
value - the JCR value
resolver -
Returns:
the created internal value
Throws:
RepositoryException
ValueFormatException

create

public static InternalValue create(Value value,
                                   NamePathResolver resolver,
                                   DataStore store)
                            throws ValueFormatException,
                                   RepositoryException
Create a new internal value from the given JCR value. If the data store is enabled, large binary values are stored in the data store.

Parameters:
value - the JCR value
resolver -
store - the data store
Returns:
the created internal value
Throws:
RepositoryException
ValueFormatException

create

public static InternalValue create(QValue value)
                            throws RepositoryException
Throws:
RepositoryException

create

public static InternalValue[] create(QValue[] values)
                              throws RepositoryException
Throws:
RepositoryException

create

public static InternalValue create(String value)
Parameters:
value -
Returns:
the created value

create

public static InternalValue create(long value)
Parameters:
value -
Returns:
the created value

create

public static InternalValue create(double value)
Parameters:
value -
Returns:
the created value

create

public static InternalValue create(Calendar value)
Parameters:
value -
Returns:
the created value

create

public static InternalValue create(BigDecimal value)
Parameters:
value -
Returns:
the created value

create

public static InternalValue create(URI value)
Parameters:
value -
Returns:
the created value

create

public static InternalValue create(boolean value)
Parameters:
value -
Returns:
the created value

create

public static InternalValue create(byte[] value)
Parameters:
value -
Returns:
the created value

createTemporary

public static InternalValue createTemporary(InputStream value)
                                     throws RepositoryException
Create an internal value that is backed by a temporary file.

Parameters:
value - the stream
Returns:
the internal value
Throws:
RepositoryException

create

public static InternalValue create(InputStream value,
                                   DataStore store)
                            throws RepositoryException
Create an internal value that is stored in the data store (if enabled).

Parameters:
value - the input stream
store -
Returns:
the internal value
Throws:
RepositoryException

create

public static InternalValue create(InputStream value)
                            throws RepositoryException
Parameters:
value -
Returns:
Throws:
IOException
RepositoryException

create

public static InternalValue create(FileSystemResource value)
                            throws IOException
Parameters:
value -
Returns:
Throws:
IOException

create

public static InternalValue create(DataStore store,
                                   String id)
Create a binary object with the given identifier.

Parameters:
store - the data store
id - the identifier
Returns:
the value

create

public static InternalValue create(Name value)
Parameters:
value -
Returns:
the created value

create

public static InternalValue[] create(Name[] values)
Parameters:
values -
Returns:
the created value

create

public static InternalValue create(Path value)
Parameters:
value -
Returns:
the created value

create

public static InternalValue create(NodeId value)
Parameters:
value -
Returns:
the created value

create

public static InternalValue create(NodeId value,
                                   boolean weak)
Parameters:
value -
weak -
Returns:
the created value

getNodeId

public NodeId getNodeId()

getDate

public Calendar getDate()

createCopy

public InternalValue createCopy()
                         throws RepositoryException
Create a copy of this object. Immutable values will return itself, while mutable values will return a copy.

Returns:
itself or a copy
Throws:
RepositoryException

valueOf

public static InternalValue valueOf(String s,
                                    int type)
Parses the given string as an InternalValue of the specified type. The string must be in the format returned by the InternalValue.toString() method.

Parameters:
s - a String containing the InternalValue representation to be parsed.
type -
Returns:
the InternalValue represented by the arguments
Throws:
IllegalArgumentException - if the specified string can not be parsed as an InternalValue of the specified type.
See Also:
AbstractQValue.toString()

store

public void store(DataStore dataStore)
           throws RepositoryException
Store a value in the data store. This will store temporary files or in-memory objects in the data store.

Parameters:
dataStore - the data store
Throws:
RepositoryException

getLength

public long getLength()
               throws RepositoryException
Description copied from interface: QValue
Returns the length of the internal value or -1 if the implementation cannot determine the length at this time.
NOTE: for PropertyType.NAME and PropertyType.PATH the length of the internal value must not be used for indicating the length of a property such as retrieved by calling Property.getLength() and Property.getLengths().

Specified by:
getLength in interface QValue
Overrides:
getLength in class AbstractQValue
Returns:
length of this QValue object.
Throws:
RepositoryException
See Also:
QValue.getLength()

getStream

public InputStream getStream()
                      throws RepositoryException
Description copied from interface: QValue
Returns an InputStream representation of this QValue object. This method always returns a new stream.

Returns:
A stream representation of this value.
Throws:
RepositoryException
See Also:
QValue.getStream()

getBinary

public Binary getBinary()
                 throws RepositoryException
Description copied from class: AbstractQValue
This implementation creates a binary instance that uses QValue.getStream() and skipping on the given stream as its underlying mechanism to provide random access defined on Binary.

Specified by:
getBinary in interface QValue
Overrides:
getBinary in class AbstractQValue
Returns:
A Binary representation of this value.
Throws:
RepositoryException
See Also:
QValue.getBinary()

discard

public void discard()
Description copied from interface: QValue
Frees temporarily allocated resources such as temporary file, buffer, etc.

Specified by:
discard in interface QValue
Overrides:
discard in class AbstractQValue
See Also:
QValue.discard()

deleteBinaryResource

public void deleteBinaryResource()
Delete persistent binary objects. This method does not delete objects in the data store.


equals

public boolean equals(Object object)
Description copied from class: AbstractQValue
Default implementation of the equals method. Subclasses may optimize this e.g. by special handling for DATE properties.

Overrides:
equals in class AbstractQValue
See Also:
Object.equals(Object)


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