public abstract class AbstractProperty extends Object implements Property
| Modifier and Type | Field and Description |
|---|---|
static int |
IS_READONLY
Whether or not this property is read only.
|
static int |
IS_VALIDATING
Whether or not this property is validating values when they are set.
|
static int |
KEYED_DATA
Whether or not the data field contains keyed data.
|
DIRTY_MASK, IS_DIRTY, IS_MODIFIED, IS_MOVED, IS_NEW, IS_PHANTOM, IS_REMOVED, NONE| Modifier and Type | Method and Description |
|---|---|
boolean |
areFlagsSet(long flags) |
void |
clearDirtyFlags()
Notify the property that its changes was stored so it can safely remove
dirty flags.
|
void |
clearFlags(long flags) |
<T> T |
convertTo(Serializable value,
Class<T> toType)
Converts the given normalized value to the given type.
|
Object |
getData()
application data impl.
|
Object |
getData(String key)
Returns the application defined data associated with the receiver under
the given key, or null if it has not been set.
|
int |
getDirtyFlags()
Get the dirty flags that are set on this property.
|
Property |
getParent()
Gets the property parent.
|
String |
getPath()
Gets the path of this property relative to the owner document.
|
DocumentPart |
getRoot()
Gets the root property.
|
Schema |
getSchema()
Gets the document schema defining the property tree from which the
property belongs.
|
Serializable |
getValue()
Gets the property normalized value.
|
<T> T |
getValue(Class<T> type)
Gets the property value as the given type.
|
<T> T |
getValue(Class<T> type,
String path)
Gets the value of the property resolved using the given path.
|
Serializable |
getValue(String path)
Gets the value of the property resolved using the given path.
|
Serializable |
getValueForWrite()
Gets the property normalized value for write.
|
void |
init(Serializable value)
Initializes the property with the given normalized value.
|
abstract Serializable |
internalGetValue() |
abstract void |
internalSetValue(Serializable value)
Sets the given normalized value.
|
boolean |
isComplex()
Tests whether this property is of a map (complex) type.
|
boolean |
isDirty()
Tests whether a property is dirty.
|
boolean |
isList()
Tests whether this property is of a list type.
|
boolean |
isModified()
Tests if a property value was modified.
|
boolean |
isMoved()
Tests if a property value was moved to another index in the parent list
if any.
|
boolean |
isNew()
Tests if this property is new (just created but not yet stored).
|
boolean |
isNormalized(Object value)
Checks if the given value is a normalized one.
|
boolean |
isPhantom()
Tests if the property is a phantom.
|
boolean |
isReadOnly()
Whether the property is read only.
|
boolean |
isRemoved()
Tests if a property is flagged as removed.
|
boolean |
isScalar()
Tests whether this property is of a scalar type.
|
boolean |
isValidating()
Checks whether this property is validating values when set.
|
Iterator<Property> |
iterator() |
void |
moveTo(int index)
Moves a property position into the parent container list.
|
Object |
newInstance()
Creates a new and empty instance of a normalized value.
|
Serializable |
normalize(Object value)
Normalizes the given value as dictated by the property type.
|
Serializable |
remove()
Removes this property from the tree.
|
void |
removePhantomFlag() |
Property |
resolvePath(Path path)
Resolves the given path relative to the current property and return the
property if any is found otherwise throws an exception.
|
Property |
resolvePath(String path)
Same as
Property.resolvePath(Path) but with a string path as
argument. |
void |
setData(Object value)
Sets the application-defined data to associated it with the receiver
property.
|
void |
setData(String key,
Object value)
Sets the application defined data associated with the receiver under the
given key.
|
void |
setFlags(long flags) |
void |
setIsModified()
This method is public because of DataModelImpl which use it.
|
void |
setReadOnly(boolean value)
Sets the read only flag.
|
void |
setValidating(boolean value)
Sets the validating flag.
|
void |
setValue(int index,
Object value)
Sets a child property value given its index.
|
void |
setValue(Object value)
Sets this property value.
|
void |
setValue(String path,
Object value)
Sets the value of the property resolved using the given path.
|
int |
size()
Get the count of the children properties.
|
String |
toString() |
boolean |
validate(Serializable value)
Validates the given normalized value.
|
boolean |
validateType(Class<?> type)
Validates the given value type.
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitaccept, addEmpty, addValue, addValue, get, get, getChildren, getDirtyChildren, getField, getName, getType, isContainer, isSameAspublic static final int IS_READONLY
public static final int IS_VALIDATING
public static final int KEYED_DATA
public abstract void internalSetValue(Serializable value) throws PropertyException
This applies only for nodes that physically store a value (that means non container nodes). Container nodes does nothing.
value - PropertyExceptionpublic abstract Serializable internalGetValue() throws PropertyException
PropertyExceptionpublic void init(Serializable value) throws PropertyException
PropertyThe given value must be normalized - note that no check is done on that.
The phantom flag is unset by this operation.
This method should be used to initialize properties.
init in interface Propertyvalue - the normalized value to setPropertyExceptionpublic void removePhantomFlag()
public void setValue(int index,
Object value)
throws PropertyException
Property
If this method is not supported, an UnsupportedOperationException
must be thrown.
This method will mark the child value as dirty for existing values and in the case of map properties it will mark phantom properties as new properties.
setValue in interface Propertyvalue - the new valuePropertyExceptionpublic int size()
PropertyComplexType.getFieldsCount().public Serializable remove() throws PropertyException
PropertyThis method marks the property as dirty and sets its value to null.
remove in interface PropertyPropertyExceptionpublic Property getParent()
Propertypublic String getPath()
PropertyThe path for top level properties is the same to the property name.
public Schema getSchema()
Propertypublic boolean isList()
Propertypublic boolean isComplex()
Propertypublic boolean isScalar()
Propertypublic boolean isNew()
PropertyA property is new when added to a collection. This is the typical state for a new property added to a list
public boolean isRemoved()
Propertypublic boolean isMoved()
Propertypublic boolean isModified()
PropertyisModified in interface Propertypublic boolean isPhantom()
Propertypublic final boolean isDirty()
PropertyThis tests whether or not a dirty flag is set on the property.
public boolean isValidating()
PropertyisValidating in interface Propertypublic boolean isReadOnly()
PropertyisReadOnly in interface Propertypublic void setReadOnly(boolean value)
PropertysetReadOnly in interface Propertyvalue - true to set this property read only false otherwisepublic void setValidating(boolean value)
PropertysetValidating in interface Propertyvalue - true to put validating on false otherwisepublic final boolean areFlagsSet(long flags)
public final void setFlags(long flags)
public final void clearFlags(long flags)
public int getDirtyFlags()
PropertygetDirtyFlags in interface Propertypublic void clearDirtyFlags()
PropertyDirty flags are removed according to the type of the modifications. This way if the property was REMOVED it becomes a PHANTOM otherwise all dirty flags are cleared.
This method should be used by storage implementors to notify the property it should reset its dirty flags. Note that clearing dirty flags is not propagated to the parent property or to children. You need to clear dirty flags explicitly for each property.
clearDirtyFlags in interface Propertypublic void setIsModified()
TODO after removing DataModelImpl make it protected.
public <T> T getValue(Class<T> type) throws PropertyException
PropertyThe value is converted using the registered converter to the given type.
If conversion is not supported a runtime exception will be triggered.
getValue in interface PropertyPropertyExceptionpublic void setValue(Object value) throws PropertyException
PropertyFor complex or list properties the value will be set recursively (as a map or list value).
setValue in interface Propertyvalue - the value to setPropertyExceptionpublic void setValue(String path, Object value) throws PropertyException
Property
This method is a shortcut for:
resolvePath(path).setValue(value).
setValue in interface Propertypath - the property pathvalue - the valuePropertyExceptionpublic <T> T getValue(Class<T> type, String path) throws PropertyException
PropertyThe value will be converted to the given type if possible, otherwise an exception will be thrown.
This method is a shortcut for:
resolvePath(path).getValue(type).
getValue in interface PropertyT - The type of the value to returntype - the class of the valuepath - the java path of the property valuePropertyExceptionpublic Serializable getValue(String path) throws PropertyException
Property
This method is a shortcut for: resolvePath(path).getValue().
getValue in interface Propertypath - the path to the propertyPropertyExceptionpublic Serializable getValue() throws PropertyException
PropertyNormalized values are of the java type that correspond to the field type.
getValue in interface PropertyPropertyExceptionpublic Serializable getValueForWrite() throws PropertyException
Property
Can be different fropm Property.getValue() in cases where the property
adapts the value it is given to store.
getValueForWrite in interface PropertyPropertyExceptionpublic void moveTo(int index)
PropertyThis method applies only for list item properties. The given index includes removed properties.
public DocumentPart getRoot()
Propertypublic Property resolvePath(String path) throws PropertyNotFoundException
PropertyProperty.resolvePath(Path) but with a string path as
argument. This is the same as calling resolvePath(new Path(path)).resolvePath in interface Propertypath - the string path to resolve.PropertyNotFoundException - if the path cannot be resolvedpublic Property resolvePath(Path path) throws PropertyNotFoundException
PropertyThe path format is a subset of XPath. Thus, / is used as path element separator, [n] for list element indexes. Attribute separator '@' are not supported since all properties are assumed to be elements. Also you .. and . can be used as element names.
Example of paths:
dc:title
attachments/item[2]/mimeType
../dc:title
resolvePath in interface Propertypath - the path to resolve.PropertyNotFoundException - if the path cannot be resolvedpublic Serializable normalize(Object value) throws PropertyConversionException
PropertyNormalized values are the ones that are used for transportation over the net and that are given to the storage implementation to be stored in the repository
Normalized values must be Serializable
If the given value is already normalized it will be returned back.
normalize in interface Propertyvalue - the value to normalize according to the property typePropertyConversionExceptionpublic boolean isNormalized(Object value)
PropertyNull values are considered as normalized.
isNormalized in interface Propertyvalue - the value to checkpublic <T> T convertTo(Serializable value, Class<T> toType) throws PropertyConversionException
PropertyIf the value has already the given type it will be returned back.
convertTo in interface Propertyvalue - the normalized value to converttoType - the conversion typePropertyConversionException - if the conversion cannot be made
because of type incompatibilitiespublic boolean validateType(Class<?> type)
PropertyTests if the given value type can be converted to a normalized type and thus a value of this type can be set to that property.
validateType in interface Propertytype - the type to validatepublic boolean validate(Serializable value)
PropertyOnly normalized values can be validated.
If the value is not validated, returns false.
validate in interface Propertyvalue - the value to validateProperty.validateType(Class)public Object newInstance()
Property
Empty is used in the sense of a value that has not been initialized or
can be considered as an empty value. For example for the String
type the empty value will be the empty string ""
newInstance in interface Propertypublic Object getData()
public Object getData(String key)
Property
You are free to set any data you want on properties but be aware to use
Serializable objects if you want to serialize them along with the
property.
public void setData(Object value)
Property
The property data is reserved for the implementation and you must not
directly set it. Data attached with properties must be
Serializable objects if you want to serialize them along with the
property
public void setData(String key, Object value)
Property
The property data is reserved for the implementation and you must not
directly set it. Data attached with properties must be
Serializable objects if you want to serialize them along with the
property.
Copyright © 2011 Nuxeo SA. All Rights Reserved.