Package org.apache.jackrabbit.oak.api
Interface PropertyState
-
- All Known Implementing Classes:
AbstractPropertyState
,BinaryPropertyState
,BooleanPropertyState
,DecimalPropertyState
,DoublePropertyState
,EmptyPropertyState
,GenericPropertyState
,LongPropertyState
,MultiBinaryPropertyState
,MultiBooleanPropertyState
,MultiDecimalPropertyState
,MultiDoublePropertyState
,MultiGenericPropertyState
,MultiLongPropertyState
,MultiStringPropertyState
,StringPropertyState
public interface PropertyState
Immutable property state. A property consists of a name and a value. A value is either an atom or an array of atoms.Equality and hash codes
Two property states are considered equal if and only if their names and values match. The
Object.equals(Object)
method needs to be implemented so that it complies with this definition. And while property states are not meant for use as hash keys, theObject.hashCode()
method should still be implemented according to this equality contract.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
count()
The number of values of this property.@NotNull String
getName()
Type<?>
getType()
Determine the type of this property<T> T
getValue(Type<T> type)
Value of this property.<T> T
getValue(Type<T> type, int index)
Value at the givenindex
.boolean
isArray()
Determine whether the value is an array of atomslong
size()
The size of the value of this property.long
size(int index)
The size of the value at the givenindex
.
-
-
-
Method Detail
-
getName
@NotNull @NotNull String getName()
- Returns:
- the name of this property state
-
isArray
boolean isArray()
Determine whether the value is an array of atoms- Returns:
true
if and only if the value is an array of atoms.
-
getType
Type<?> getType()
Determine the type of this property- Returns:
- the type of this property
-
getValue
@NotNull <T> T getValue(Type<T> type)
Value of this property. The type of the return value is determined by the targettype
argument. Iftype.isArray()
is true, this method returns anIterable
of thebase type
oftype
containing all values of this property. If the target type is not the same as the type of this property an attempt is made to convert the value to the target type. If the conversion fails an exception is thrown. The actual conversions which take place are those defined in theorg.apache.jackrabbit.oak.plugins.value.Conversions
class.- Type Parameters:
T
-- Parameters:
type
- target type- Returns:
- the value of this property
- Throws:
IllegalStateException
- iftype.isArray() == false
andthis.isArray() == true
. In other words, when trying to convert from an array to an atom.IllegalArgumentException
- iftype
refers to an unknown type.NumberFormatException
- if conversion to a number failed.UnsupportedOperationException
- if conversion to boolean failed.
-
getValue
@NotNull <T> T getValue(Type<T> type, int index)
Value at the givenindex
. The type of the return value is determined by the targettype
argument. If the target type is not the same as the type of this property an attempt is made to convert the value to the target type. If the conversion fails an exception is thrown. The actual conversions which take place are those defined in theorg.apache.jackrabbit.oak.plugins.value.Conversions
class.- Type Parameters:
T
-- Parameters:
type
- target typeindex
-- Returns:
- the value of this property at the given
index
- Throws:
IndexOutOfBoundsException
- ifindex
is less than0
or greater or equalscount()
.IllegalArgumentException
- iftype
refers to an unknown type or iftype.isArray()
is true.
-
size
long size()
The size of the value of this property.- Returns:
- size of the value of this property
- Throws:
IllegalStateException
- if the value is an array
-
size
long size(int index)
The size of the value at the givenindex
.- Parameters:
index
-- Returns:
- size of the value at the given
index
. - Throws:
IndexOutOfBoundsException
- ifindex
is less than0
or greater or equalscount()
.
-
count
int count()
The number of values of this property.1
for atoms.- Returns:
- number of values
-
-