org.apache.jackrabbit.rmi.value
Class SerialValueFactory

java.lang.Object
  extended by org.apache.jackrabbit.rmi.value.SerialValueFactory
All Implemented Interfaces:
ValueFactory

public class SerialValueFactory
extends Object
implements ValueFactory

The SerialValueFactory class is used in the RMI infrastructure to create serializable Value instances on the client side.

This class works in conjunction with the implementations of the javax.jcr.Value interface found in this package.

This class may be extended to overwrite any of the createXXXValue methods to create instances of the respective type of org.apache.jackrabbit.rmi.value.StatefullValueimplementation. The methods of the ValueFactory interface are declared final to guard against breaking the rules.


Constructor Summary
protected SerialValueFactory()
          Default constructor only visible to extensions of this class.
 
Method Summary
protected  BinaryValue createBinaryValue(InputStream value)
          Creates an instance of the BinaryValue class or an extension thereof.
protected  BinaryValue createBinaryValue(String value)
          Creates an instance of the BinaryValue class or an extension thereof from the string whose UTF-8 representation is used as the binary data.
protected  BooleanValue createBooleanValue(boolean value)
          Creates an instance of the BooleanValue class or an extension thereof.
protected  BooleanValue createBooleanValue(String value)
          Creates an instance of the BooleanValue class or an extension thereof from the string representation of the boolean.
protected  DateValue createDateValue(Calendar value)
          Creates an instance of the DateValue class or an extension thereof.
protected  DateValue createDateValue(String value)
          Creates an instance of the DateValue class or an extension thereof from the string representation of Calendar instance formatted as specified in the JCR specification.
protected  DoubleValue createDoubleValue(double value)
          Creates an instance of the DoubleValue class or an extension thereof.
protected  DoubleValue createDoubleValue(String value)
          Creates an instance of the DoubleValue class or an extension thereof from the string representation of the double number.
protected  LongValue createLongValue(long value)
          Creates an instance of the LongValue class or an extension thereof.
protected  LongValue createLongValue(String value)
          Creates an instance of the LongValue class or an extension thereof from the string representation of the long number.
protected  NameValue createNameValue(String value)
          Creates an instance of the NameValue class or an extension thereof.
protected  PathValue createPathValue(String value)
          Creates an instance of the PathValue class or an extension thereof.
protected  ReferenceValue createReferenceValue(String value)
          Creates an instance of the ReferenceValue class or an extension thereof.
protected  StringValue createStringValue(String value)
          Creates an instance of the StringValue class or an extension thereof.
 Value createValue(boolean value)
          
 Value createValue(Calendar value)
          
 Value createValue(double value)
          
 Value createValue(InputStream value)
          
 Value createValue(long value)
          
 Value createValue(Node value)
          
 Value createValue(String value)
          
 Value createValue(String value, int type)
          
static SerialValueFactory getInstance()
          Returns the ValueFactory instance, which currently is a singleton instance of this class.
static Value makeSerialValue(Value value)
          Utility method for decorating a value.
static Value[] makeSerialValueArray(Value[] values)
          Utility method for decorating an array of values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialValueFactory

protected SerialValueFactory()
Default constructor only visible to extensions of this class. See class comments for details.

Method Detail

getInstance

public static final SerialValueFactory getInstance()
Returns the ValueFactory instance, which currently is a singleton instance of this class.

Future revisions will support some kind of configuration to specify which concrete class should be used.


makeSerialValueArray

public static Value[] makeSerialValueArray(Value[] values)
Utility method for decorating an array of values. The returned array will contain serializable value decorators for all the given values. Note that the contents of the original values will only be copied when the decorators are serialized.

If the given array is null, then an empty array is returned.

Parameters:
values - the values to be decorated
Returns:
array of decorated values

makeSerialValue

public static Value makeSerialValue(Value value)
Utility method for decorating a value. Note that the contents of the original values will only be copied when the decorators are serialized. Null referenced and already serializable values are passed as-is.

Parameters:
value - the value to be decorated, or null
Returns:
the decorated value, or null

createValue

public final Value createValue(String value)

Specified by:
createValue in interface ValueFactory

createValue

public final Value createValue(String value,
                               int type)
                        throws ValueFormatException

Specified by:
createValue in interface ValueFactory
Throws:
ValueFormatException

createValue

public final Value createValue(long value)

Specified by:
createValue in interface ValueFactory

createValue

public final Value createValue(double value)

Specified by:
createValue in interface ValueFactory

createValue

public final Value createValue(boolean value)

Specified by:
createValue in interface ValueFactory

createValue

public final Value createValue(Calendar value)

Specified by:
createValue in interface ValueFactory

createValue

public final Value createValue(InputStream value)

Specified by:
createValue in interface ValueFactory

createValue

public final Value createValue(Node value)
                        throws RepositoryException

Specified by:
createValue in interface ValueFactory
Throws:
RepositoryException

createStringValue

protected StringValue createStringValue(String value)
Creates an instance of the StringValue class or an extension thereof.

This implementation just calls StringValue.StringValue(String) with the string value.

Parameters:
value - The string making up the value itself.

createNameValue

protected NameValue createNameValue(String value)
                             throws ValueFormatException
Creates an instance of the NameValue class or an extension thereof.

This implementation just calls NameValue.NameValue(String) with the string value.

Parameters:
value - The string making up the value itself.
Throws:
ValueFormatException - if the string is not a synthactically correct JCR name.

createPathValue

protected PathValue createPathValue(String value)
                             throws ValueFormatException
Creates an instance of the PathValue class or an extension thereof.

This implementation just calls PathValue.PathValue(String) with the string value.

Parameters:
value - The string making up the value itself.
Throws:
ValueFormatException - if the string is not a synthactically correct JCR path.

createReferenceValue

protected ReferenceValue createReferenceValue(String value)
                                       throws ValueFormatException
Creates an instance of the ReferenceValue class or an extension thereof.

This implementation just calls ReferenceValue.ReferenceValue(String) with the string value.

Parameters:
value - The string making up the value itself.
Throws:
ValueFormatException - if the string is not a synthactically correct JCR reference.

createLongValue

protected LongValue createLongValue(long value)
Creates an instance of the LongValue class or an extension thereof.

This implementation just calls LongValue.LongValue(long) with the long value.

Parameters:
value - The long making up the value itself.

createLongValue

protected LongValue createLongValue(String value)
                             throws ValueFormatException
Creates an instance of the LongValue class or an extension thereof from the string representation of the long number.

This implementation just calls LongValue.LongValue(String) with the string value.

Parameters:
value - The string representation of the long number making up the value itself.
Throws:
ValueFormatException - if the string cannot be converted to a long number.

createDoubleValue

protected DoubleValue createDoubleValue(double value)
Creates an instance of the DoubleValue class or an extension thereof.

This implementation just calls DoubleValue.DoubleValue(double) with the double value.

Parameters:
value - The double making up the value itself.

createDoubleValue

protected DoubleValue createDoubleValue(String value)
                                 throws ValueFormatException
Creates an instance of the DoubleValue class or an extension thereof from the string representation of the double number.

This implementation just calls DoubleValue.DoubleValue(String) with the string value.

Parameters:
value - The string representation of the long number making up the value itself.
Throws:
ValueFormatException - if the string cannot be converted to a double number.

createDateValue

protected DateValue createDateValue(Calendar value)
Creates an instance of the DateValue class or an extension thereof.

This implementation just calls DateValue.DateValue(Calendar) with the Calendar value.

Parameters:
value - The Calendar making up the value itself.

createDateValue

protected DateValue createDateValue(String value)
                             throws ValueFormatException
Creates an instance of the DateValue class or an extension thereof from the string representation of Calendar instance formatted as specified in the JCR specification.

This implementation just calls DateValue.DateValue(String) with the string value.

Parameters:
value - The string representation of the Calendar instance making up the value itself.
Throws:
ValueFormatException - if the string cannot be converted to a Calendar instance.

createBooleanValue

protected BooleanValue createBooleanValue(boolean value)
Creates an instance of the BooleanValue class or an extension thereof.

This implementation just calls BooleanValue.BooleanValue(boolean) with the boolean value.

Parameters:
value - The boolean making up the value itself.

createBooleanValue

protected BooleanValue createBooleanValue(String value)
Creates an instance of the BooleanValue class or an extension thereof from the string representation of the boolean.

This implementation just calls BooleanValue.BooleanValue(String) with the string value.

Parameters:
value - The string representation of the boolean making up the value itself.
Throws:
ValueFormatException - if the string cannot be converted to a long number.

createBinaryValue

protected BinaryValue createBinaryValue(InputStream value)
Creates an instance of the BinaryValue class or an extension thereof.

This implementation just calls BinaryValue.BinaryValue(InputStream) with the InputStream value.

Parameters:
value - The InputStream making up the value itself.

createBinaryValue

protected BinaryValue createBinaryValue(String value)
                                 throws ValueFormatException
Creates an instance of the BinaryValue class or an extension thereof from the string whose UTF-8 representation is used as the binary data.

This implementation just calls BinaryValue.BinaryValue(String) with the string value.

Parameters:
value - The string whose UTF-8 representation is making up the value itself.
Throws:
ValueFormatException - if the UTF-8 representation of the string cannot be created.


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