javax.jcr.ValueFactory Maven / Gradle / Ivy
Show all versions of aem-sdk-api Show documentation
/*
* Copyright 2009 Day Management AG, Switzerland. All rights reserved.
*/
package javax.jcr;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.Calendar;
/**
* The ValueFactory
object provides methods for the creation Value
* objects that can then be used to set properties.
*/
public interface ValueFactory {
/**
* Returns a Value
object of {@link PropertyType#STRING} with
* the specified value
.
*
* @param value a String
* @return a Value
of {@link PropertyType#STRING}
*/
public Value createValue(String value);
/**
* Returns a Value
object of the {@link PropertyType} specified
* by type
with the specified value
.
*
* @param value a String
* @param type one of the constants defined in {@link PropertyType}.
* @return a Value
of {@link PropertyType} type
.
* @throws ValueFormatException if the specified value
cannot
* be converted to the specified type
.
*/
public Value createValue(String value, int type) throws ValueFormatException;
/**
* Returns a Value
object of {@link PropertyType#LONG} with the
* specified value
.
*
* @param value a long
* @return a Value
of {@link PropertyType#LONG}
*/
public Value createValue(long value);
/**
* Returns a Value
object of {@link PropertyType#DOUBLE} with
* the specified value
.
*
* @param value a double
* @return a Value
of {@link PropertyType#DOUBLE}
*/
public Value createValue(double value);
/**
* Returns a Value
object of {@link PropertyType#DECIMAL} with
* the specified value
.
*
* @param value a double
* @return a Value
of {@link PropertyType#DECIMAL}
* @since JCR 2.0
*/
public Value createValue(BigDecimal value);
/**
* Returns a Value
object of {@link PropertyType#BOOLEAN} with
* the specified value
.
*
* @param value a boolean
* @return a Value
of {@link PropertyType#BOOLEAN}
*/
public Value createValue(boolean value);
/**
* Returns a Value
object of {@link PropertyType#DATE} with the
* specified value
.
*
* @param value a Calendar
* @return a Value
of {@link PropertyType#DATE}
* @throws IllegalArgumentException if the specified value
* cannot be expressed in the ISO 8601-based format defined in the JCR 2.0
* specification and the implementation does not support dates incompatible
* with that format.
*/
public Value createValue(Calendar value);
/**
* Returns a Value
object of PropertyType.BINARY
* with a value consisting of the content of the specified
* InputStream
.
*
* The passed InputStream
is closed before this method returns
* either normally or because of an exception.
*
* @param value an InputStream
* @return a Value
of {@link PropertyType#BINARY}
* @deprecated As of JCR 2.0, {@link #createValue(Binary)} should be used
* instead.
*/
public Value createValue(InputStream value);
/**
* Returns a Value
object of PropertyType.BINARY
* with a value consisting of the content of the specified
* Binary
.
*
* @param value a Binary
* @return a Value
of {@link PropertyType#BINARY}
* @since JCR 2.0
*/
public Value createValue(Binary value);
/**
* Returns a Value
object of {@link PropertyType#REFERENCE}
* that holds the identifier of the specified Node
. This
* Value
object can then be used to set a property that will be
* a reference to that Node
.
*
* @param value a Node
* @return a Value
of {@link PropertyType#REFERENCE}
* @throws RepositoryException if the specified Node
is not
* referenceable, the current Session
is no longer active, or
* another error occurs.
*/
public Value createValue(Node value) throws RepositoryException;
/**
* Returns a Value
object of {@link PropertyType#REFERENCE} (if
* weak
is false
) or {@link
* PropertyType#REFERENCE} (if weak
is true
) that
* holds the identifier of the specified Node
. This
* Value
object can then be used to set a property that will be
* a reference to that Node
.
*
* @param value a Node
* @param weak a boolean
. If true then a {@link
* PropertyType#WEAKREFERENCE} is created, otherwise a {@link
* PropertyType#REFERENCE} is created.
* @return a Value
of {@link PropertyType#REFERENCE} or {@link
* PropertyType#REFERENCE}
* @throws RepositoryException if the specified Node
is not
* referenceable, the current Session
is no longer active, or
* another error occurs.
*/
public Value createValue(Node value, boolean weak) throws RepositoryException;
/**
* Returns a Binary
object with a value consisting of the
* content of the specified InputStream
.
*
* The passed InputStream
is closed before this method returns
* either normally or because of an exception.
*
* @param stream an InputStream
* @return a Binary
* @throws RepositoryException if an error occurs.
* @since JCR 2.0
*/
public Binary createBinary(InputStream stream) throws RepositoryException;
}