Class AbstractProperty
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Property>,Property
- Direct Known Subclasses:
ComplexProperty,ListProperty,RemovedProperty,ScalarProperty
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intbooleanfor SimpleDocumentModel usesstatic final intWhether or not this property is deprecated.static final intWhether or not this property is read only.static final intWhether or not this property is secured from edition.protected static final Patternfinal PropertyFields inherited from interface org.nuxeo.ecm.core.api.model.Property
DIRTY_MASK, IS_DIRTY, IS_MODIFIED, IS_MOVED, IS_NEW, IS_PHANTOM, IS_REMOVED, NONE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractProperty(Property parent) protectedAbstractProperty(Property parent, int flags) -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidappendDirtyFlags(int dirtyFlags) final booleanareFlagsSet(long flags) voidNotify the property that its changes was stored so it can safely remove dirty flags.final voidclearFlags(long flags) protected PathcollectPath(Path path) protected PropertycomputeRemovedProperty(String name) Returns theRemovedPropertyif it is a removed property or null otherwise.<T> TconvertTo(Serializable value, Class<T> toType) Converts the given normalized value to the given type.protected SerializableReturns thePropertyfallback to use if the current property is deprecated.protected AbstractPropertyintGet the dirty flags that are set on this property.Gets the property parent.getRoot()Gets the root property.Gets the document schema defining the property tree from which the property belongs.getValue()Gets the property normalized value.<T> TGets the property value as the given type.<T> TGets the value of the property resolved using the given path.Gets the value of the property resolved using the given path.protected SerializableGets the property normalized value for write.getXPath()Gets the xpath of this property.protected voidbooleanWhether or not this property has a default value.voidinit(Serializable value) Initializes the property with the given normalized value.abstract Serializableabstract voidinternalSetValue(Serializable value) Sets the given normalized value.booleanTests whether this property is of a map (complex) type.protected booleanfinal booleanisDirty()Tests whether a property is dirty.booleanonly for SimpleDocumentModelbooleanisList()Tests whether this property is of a list type.booleanTests if a property value was modified.booleanisMoved()Tests if a property value was moved to another index in the parent list if any.booleanisNew()Tests if this property is new (just created but not yet stored).booleanisNormalized(Object value) Checks if the given value is a normalized one.booleanTests if the property is a phantom.booleanWhether the property is read only.booleanTests if a property is flagged as removed.protected booleanisSameValue(Serializable value1, Serializable value2) booleanisScalar()Tests whether this property is of a scalar type.booleanReturnstrueif this property is flagged as secured in system.protected booleanReturns whether or not current user can edit this property.iterator()voidmoveTo(int index) Moves a property position into the parent container list.protected StringBuilderCreates a new and empty instance of a normalized value.Normalizes the given value as dictated by the property type.remove()Removes this property from the tree.voidresolvePath(String path) Same asProperty.resolvePath(Path)but with a string path as argument.resolvePath(Path path) Resolves the given path relative to the current property and return the property if any is found otherwise throws an exception.protected final voidsetDirtyFlags(int dirtyFlags) final voidsetFlags(long flags) voidsetForceDirty(boolean forceDirty) only for SimpleDocumentModelvoidThis method is public because of DataModelImpl which use it.protected voidprotected voidsetIsNew()protected voidvoidsetReadOnly(boolean value) Sets the read only flag.voidSets a child property value given its index.voidSets this property value.voidSets the value of the property resolved using the given path.protected voidsetValueDeprecation(Object value, boolean setFallback) If this property is deprecated and has a fallback, set value to fallback.intsize()Get the count of the children properties.toString()booleanvalidateType(Class<?> type) Validates the given value type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.nuxeo.ecm.core.api.model.Property
accept, addEmpty, addValue, addValue, get, get, getChildren, getDirtyChildren, getField, getName, getType, isContainer, isSameAs, set
-
Field Details
-
NON_CANON_INDEX
-
IS_READONLY
public static final int IS_READONLYWhether or not this property is read only.- See Also:
-
IS_SECURED
public static final int IS_SECUREDWhether or not this property is secured from edition.- Since:
- 11.1
- See Also:
-
IS_DEPRECATED
public static final int IS_DEPRECATEDWhether or not this property is deprecated.- Since:
- 11.1
- See Also:
-
parent
-
forceDirty
public boolean forceDirtyfor SimpleDocumentModel uses -
flags
protected int flags
-
-
Constructor Details
-
AbstractProperty
-
AbstractProperty
-
-
Method Details
-
internalSetValue
Sets the given normalized value.This applies only for nodes that physically store a value (that means non container nodes). Container nodes does nothing.
- Throws:
PropertyException
-
internalGetValue
- Throws:
PropertyException
-
init
Description copied from interface:PropertyInitializes the property with the given normalized value.The 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.
- Specified by:
initin interfaceProperty- Parameters:
value- the normalized value to set- Throws:
PropertyException
-
removePhantomFlag
public void removePhantomFlag() -
setValue
Description copied from interface:PropertySets a child property value given its index. This method is required only for List properties.If this method is not supported, an
UnsupportedOperationExceptionmust 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.
- Specified by:
setValuein interfacePropertyvalue- the new value- Throws:
PropertyNotFoundException- if the child property is not found in the type definitionPropertyException
-
size
public int size()Description copied from interface:PropertyGet the count of the children properties. This includes phantom properties. So the returned size will be equal to the one returned by the propertyComplexType.getFieldsCount(). -
iterator
-
remove
Description copied from interface:PropertyRemoves this property from the tree.This method marks the property as dirty and sets its value to null.
- Specified by:
removein interfaceProperty- Returns:
- the old property value
- Throws:
PropertyException
-
getParent
Description copied from interface:PropertyGets the property parent. -
getXPath
Description copied from interface:PropertyGets the xpath of this property.The xpath is of the form
pref:foo/mylist/123/elem, of note:- there is no initial
/ - the schema prefix is only present if a prefix is configured for the base property's schema
- list elements indexes start at 0
- list elements aren't using the old syntax
foo/bar[123]/bazbut the new syntaxfoo/123/baz
- there is no initial
-
getXPath
-
collectPath
-
getSchema
Description copied from interface:PropertyGets the document schema defining the property tree from which the property belongs. -
isList
public boolean isList()Description copied from interface:PropertyTests whether this property is of a list type. -
isComplex
public boolean isComplex()Description copied from interface:PropertyTests whether this property is of a map (complex) type. -
isScalar
public boolean isScalar()Description copied from interface:PropertyTests whether this property is of a scalar type. -
isNew
public boolean isNew()Description copied from interface:PropertyTests if this property is new (just created but not yet stored).A property is new when added to a collection. This is the typical state for a new property added to a list
-
isRemoved
public boolean isRemoved()Description copied from interface:PropertyTests if a property is flagged as removed. Removed properties are child property that were removed from their container. -
isMoved
public boolean isMoved()Description copied from interface:PropertyTests if a property value was moved to another index in the parent list if any. -
isModified
public boolean isModified()Description copied from interface:PropertyTests if a property value was modified.- Specified by:
isModifiedin interfaceProperty- Returns:
- if the property was removed, false otherwise
-
isPhantom
public boolean isPhantom()Description copied from interface:PropertyTests if the property is a phantom. This means it doesn't exists yet in the storage and it is not a new property. This is a placeholder for a property that is defined by the schema but was not yet set. -
isDirty
public final boolean isDirty()Description copied from interface:PropertyTests whether a property is dirty.This tests whether or not a dirty flag is set on the property.
-
setDirtyFlags
protected final void setDirtyFlags(int dirtyFlags) -
appendDirtyFlags
protected final void appendDirtyFlags(int dirtyFlags) -
isReadOnly
public boolean isReadOnly()Description copied from interface:PropertyWhether the property is read only.- Specified by:
isReadOnlyin interfaceProperty- Returns:
- true if read only false otherwise
-
setReadOnly
public void setReadOnly(boolean value) Description copied from interface:PropertySets the read only flag.- Specified by:
setReadOnlyin interfaceProperty- Parameters:
value- true to set this property read only false otherwise
-
areFlagsSet
public final boolean areFlagsSet(long flags) -
setFlags
public final void setFlags(long flags) -
clearFlags
public final void clearFlags(long flags) -
getDirtyFlags
public int getDirtyFlags()Description copied from interface:PropertyGet the dirty flags that are set on this property.- Specified by:
getDirtyFlagsin interfaceProperty- Returns:
- the dirty flags mask
-
clearDirtyFlags
public void clearDirtyFlags()Description copied from interface:PropertyNotify the property that its changes was stored so it can safely remove dirty flags.Dirty 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.
- Specified by:
clearDirtyFlagsin interfaceProperty
-
hasDefaultValue
public boolean hasDefaultValue()Description copied from interface:PropertyWhether or not this property has a default value. For complex property, this method will lookup in its children.- Specified by:
hasDefaultValuein interfaceProperty- Returns:
- true if property has a default value
-
setIsModified
public void setIsModified()This method is public because of DataModelImpl which use it.TODO after removing DataModelImpl make it protected.
-
setIsNew
protected void setIsNew() -
setIsRemoved
protected void setIsRemoved() -
setIsMoved
protected void setIsMoved() -
isDeprecated
protected boolean isDeprecated() -
getDeprecatedFallback
Returns thePropertyfallback to use if the current property is deprecated.- Returns:
- the fallback as
Propertyif exist
-
isSecuredForContext
protected boolean isSecuredForContext()Returns whether or not current user can edit this property.- Since:
- 11.1
-
isSecured
public boolean isSecured()Returnstrueif this property is flagged as secured in system. -
getValue
Description copied from interface:PropertyGets the property value as the given type.The value is converted using the registered converter to the given type.
If conversion is not supported a runtime exception will be triggered.
- Specified by:
getValuein interfaceProperty- Returns:
- the property value, which may be null
- Throws:
PropertyException
-
setValue
Description copied from interface:PropertySets this property value. The value will be first normalized and then set.For complex or list properties the value will be set recursively (as a map or list value).
- Specified by:
setValuein interfaceProperty- Parameters:
value- the value to set- Throws:
InvalidPropertyValueException- if the given value type is not compatible with the expected value typePropertyException
-
setValueDeprecation
If this property is deprecated and has a fallback, set value to fallback.- Throws:
PropertyException
-
isSameValue
-
setValue
Description copied from interface:PropertySets the value of the property resolved using the given path.This method is a shortcut for:
resolvePath(path).setValue(value).- Specified by:
setValuein interfaceProperty- Parameters:
path- the property pathvalue- the value- Throws:
PropertyException
-
getValue
Description copied from interface:PropertyGets the value of the property resolved using the given path.The 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).- Specified by:
getValuein interfaceProperty- Type Parameters:
T- The type of the value to return- Parameters:
type- the class of the valuepath- the java path of the property value- Returns:
- the value
- Throws:
PropertyException
-
getValue
Description copied from interface:PropertyGets the value of the property resolved using the given path.This method is a shortcut for:
resolvePath(path).getValue().- Specified by:
getValuein interfaceProperty- Parameters:
path- the path to the property- Returns:
- the property value
- Throws:
PropertyException
-
getValue
Description copied from interface:PropertyGets the property normalized value.Normalized values are of the java type that correspond to the field type.
- Specified by:
getValuein interfaceProperty- Returns:
- the property value, which may be null
- Throws:
PropertyException
-
getValueDeprecation
- Returns:
- the fallback value if this property is deprecated and has a fallback, otherwise return null
-
newDeprecatedMessage
-
getDeprecatedParent
- Returns:
- the higher deprecated parent.
-
getValueForWrite
Description copied from interface:PropertyGets the property normalized value for write.Can be different fropm
Property.getValue()in cases where the property adapts the value it is given to store.- Specified by:
getValueForWritein interfaceProperty- Returns:
- the property value to use for write, which may be null
- Throws:
PropertyException
-
getDefaultValue
-
moveTo
public void moveTo(int index) Description copied from interface:PropertyMoves a property position into the parent container list.This method applies only for list item properties. The given index includes removed properties.
-
getRoot
Description copied from interface:PropertyGets the root property. -
resolvePath
Description copied from interface:PropertySame asProperty.resolvePath(Path)but with a string path as argument. This is the same as callingresolvePath(new Path(path)).- Specified by:
resolvePathin interfaceProperty- Parameters:
path- the string path to resolve.- Returns:
- the resolved property
- Throws:
PropertyNotFoundException- if the path cannot be resolved
-
resolvePath
Description copied from interface:PropertyResolves the given path relative to the current property and return the property if any is found otherwise throws an exception.The 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:titleattachments/item[2]/mimeType../dc:title
- Specified by:
resolvePathin interfaceProperty- Parameters:
path- the path to resolve.- Returns:
- the resolved property
- Throws:
PropertyNotFoundException- if the path cannot be resolved
-
computeRemovedProperty
Returns theRemovedPropertyif it is a removed property or null otherwise.- Since:
- 9.2
-
normalize
Description copied from interface:PropertyNormalizes the given value as dictated by the property type.Normalized 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
SerializableIf the given value is already normalized it will be returned back.
- Specified by:
normalizein interfaceProperty- Parameters:
value- the value to normalize according to the property type- Returns:
- the normalized value
- Throws:
PropertyConversionException
-
isNormalized
Description copied from interface:PropertyChecks if the given value is a normalized one. This means the value has a type that is normalized.Null values are considered as normalized.
- Specified by:
isNormalizedin interfaceProperty- Parameters:
value- the value to check- Returns:
- true if the value is normalized false otherwise
-
convertTo
Description copied from interface:PropertyConverts the given normalized value to the given type.If the value has already the given type it will be returned back.
- Specified by:
convertToin interfaceProperty- Parameters:
value- the normalized value to converttoType- the conversion type- Returns:
- the converted value, which may be null
- Throws:
PropertyConversionException- if the conversion cannot be made because of type incompatibilities
-
validateType
Description copied from interface:PropertyValidates the given value type.Tests 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.
- Specified by:
validateTypein interfaceProperty- Parameters:
type- the type to validate- Returns:
- true if the type is valid, false otherwise
-
newInstance
Description copied from interface:PropertyCreates a new and empty instance of a normalized value.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
Stringtype the empty value will be the empty string ""- Specified by:
newInstancein interfaceProperty- Returns:
- the empty instance the empty instance, or null for some implementations
-
toString
-
getObjectResolver
- Specified by:
getObjectResolverin interfaceProperty- Returns:
- A
PropertyObjectResolverto manage this property reference to external entities, null if this property's type has no resolver.
-
isForceDirty
public boolean isForceDirty()Description copied from interface:Propertyonly for SimpleDocumentModel- Specified by:
isForceDirtyin interfaceProperty
-
setForceDirty
public void setForceDirty(boolean forceDirty) Description copied from interface:Propertyonly for SimpleDocumentModel- Specified by:
setForceDirtyin interfaceProperty
-