Class ComplexProperty
- java.lang.Object
-
- org.nuxeo.ecm.core.api.model.impl.AbstractProperty
-
- org.nuxeo.ecm.core.api.model.impl.ComplexProperty
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Property>,Map<String,Property>,Property
- Direct Known Subclasses:
DocumentPartImpl,MapProperty
public abstract class ComplexProperty extends AbstractProperty implements Map<String,Property>
A scalar property that is linked to a schema field- Author:
- Bogdan Stefanescu
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Property>children-
Fields inherited from class org.nuxeo.ecm.core.api.model.impl.AbstractProperty
flags, forceDirty, IS_DEPRECATED, IS_READONLY, IS_SECURED, NON_CANON_INDEX, parent
-
Fields 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
Constructors Modifier Constructor Description protectedComplexProperty(Property parent)protectedComplexProperty(Property parent, int flags)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PropertyaddEmpty()Creates an empty child property and adds it as a property to the list container.PropertyaddValue(int index, Object value)Inserts at the given position a new value to the list.PropertyaddValue(Object value)Appends a new value to the list.voidclear()Throws UnsupportedOperationException, added to implement Map<String, Property> interface.voidclearDirtyFlags()Notify the property that its changes was stored so it can safely remove dirty flags.booleancontainsKey(Object key)Throws UnsupportedOperationException, added to implement Map<String, Property> interface.booleancontainsValue(Object value)Throws UnsupportedOperationException, added to implement Map<String, Property> interface.Set<Map.Entry<String,Property>>entrySet()Propertyget(int index)Get the child property given it's index.Propertyget(Object key)Propertyget(String name)Gets the child property having the given name.PropertygetChild(Field field)Collection<Property>getChildren()Get a collection over the children properties.protected SerializablegetDefaultValue()Iterator<Property>getDirtyChildren()Gets an iterator over the dirty children properties.PropertygetNonPhantomChild(Field field)Collection<Property>getNonPhantomChildren()abstract ComplexTypegetType()Get the type of the field corresponding to this property.SerializablegetValueForWrite()Gets the property normalized value for write.voidinit(Serializable value)Initializes the property with the given normalized value.protected PropertyinternalGetChild(Field field)Gets the property given its name.SerializableinternalGetValue()booleanisEmpty()booleanisNormalized(Object value)Checks if the given value is a normalized one.booleanisSameAs(Property property)Should be used by container properties.Set<String>keySet()Serializablenormalize(Object value)Normalizes the given value as dictated by the property type.Propertyput(String key, Property value)Throws UnsupportedOperationException, added to implement Map<String, Property> interface.voidputAll(Map<? extends String,? extends Property> t)Throws UnsupportedOperationException, added to implement Map<String, Property> interface.Propertyremove(Object key)Throws UnsupportedOperationException, added to implement Map<String, Property> interface.voidset(String name, Property property)Sets the child property having the given name.voidsetValue(Object value)Sets this property value.Collection<Property>values()voidvisitChildren(PropertyVisitor visitor, Object arg)-
Methods inherited from class org.nuxeo.ecm.core.api.model.impl.AbstractProperty
appendDirtyFlags, areFlagsSet, clearFlags, collectPath, computeRemovedProperty, convertTo, getDeprecatedFallback, getDeprecatedParent, getDirtyFlags, getObjectResolver, getParent, getPath, getRoot, getSchema, getValue, getValue, getValue, getValue, getValueDeprecation, getXPath, getXPath, hasDefaultValue, internalSetValue, isComplex, isDeprecated, isDirty, isForceDirty, isList, isModified, isMoved, isNew, isPhantom, isReadOnly, isRemoved, isSameValue, isScalar, isSecured, isSecuredForContext, iterator, moveTo, newDeprecatedMessage, newInstance, remove, removePhantomFlag, resolvePath, resolvePath, setDirtyFlags, setFlags, setForceDirty, setIsModified, setIsMoved, setIsNew, setIsRemoved, setReadOnly, setValue, setValue, setValueDeprecation, size, toString, validateType
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll, size
-
Methods inherited from interface org.nuxeo.ecm.core.api.model.Property
accept, getField, getName, isContainer
-
-
-
-
Method Detail
-
internalGetChild
protected Property internalGetChild(Field field)
Gets the property given its name. If the property was not set, returns null.This method will always be called using a valid property name (a property specified by the schema). The returned property will be cached by its parent so the next time it is needed, it will be reused from the cache. That means this method servers as a initializer for properties - usually you create a new property and return it - you don't need to cache created properties.
If you want to change the way a property is fetched / stored, you must override this method.
- Returns:
- the child. Cannot return null
-
getType
public abstract ComplexType getType()
Description copied from interface:PropertyGet the type of the field corresponding to this property.
-
isNormalized
public boolean isNormalized(Object value)
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- Overrides:
isNormalizedin classAbstractProperty- Parameters:
value- the value to check- Returns:
- true if the value is normalized false otherwise
-
normalize
public Serializable normalize(Object value) throws PropertyConversionException
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- Overrides:
normalizein classAbstractProperty- Parameters:
value- the value to normalize according to the property type- Returns:
- the normalized value
- Throws:
PropertyConversionException
-
get
public Property get(int index)
Description copied from interface:PropertyGet the child property given it's index. This operation is mandatory for List properties.If this method is not supported an
UnsupportedOperationExceptionmust be thrownRelative paths are not resolved. THis method is intended to lookup direct chilren. For path lookups, use
Property.resolvePath(String)instead.
-
getNonPhantomChildren
public final Collection<Property> getNonPhantomChildren()
-
getChildren
public Collection<Property> getChildren()
Description copied from interface:PropertyGet a collection over the children properties. This includes all children including phantom ones (those who are not yet set by the user).The returned collection is ordered for list properties, and unordered for complex properties
Be aware that this method is creating phantom child properties for all schema fields that are not yet set.
- Specified by:
getChildrenin interfaceProperty- Returns:
- the children properties
-
get
public Property get(String name) throws PropertyNotFoundException
Description copied from interface:PropertyGets the child property having the given name.If the property is a scalar, this will return always null.
The given name should be the full name (i.e. prefixed name if any prefix exists).
If a non prefixed name is given, the first child property having the given local name will be returned.
Relative paths are not resolved. THis method is intended to lookup direct children. For path lookups use
Property.resolvePath(String)instead.- Specified by:
getin interfaceProperty- Parameters:
name- the child property name (the full name including the prefix if any)- Returns:
- the child property if any null if no child property with that name is found or if the property is a scalar
- Throws:
PropertyNotFoundException- if the child property is not found in the type definition
-
set
public void set(String name, Property property) throws PropertyNotFoundException
Description copied from interface:PropertySets the child property having the given name.The given name should be the full name (i.e. prefixed name if any prefix exists).
If a non prefixed name is given, the first child property having the given local name will be returned.
Relative paths are not resolved. This method is intended to lookup direct children. For path lookups use
Property.resolvePath(String)instead.- Specified by:
setin interfaceProperty- Parameters:
name- the child property name (the full name including the prefix if any)property- the child property to set- Throws:
PropertyNotFoundException- if the child property is not found in the type definition
-
internalGetValue
public Serializable internalGetValue() throws PropertyException
- Specified by:
internalGetValuein classAbstractProperty- Throws:
PropertyException
-
getValueForWrite
public Serializable getValueForWrite() throws PropertyException
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- Overrides:
getValueForWritein classAbstractProperty- Returns:
- the property value to use for write, which may be null
- Throws:
PropertyException
-
init
public void init(Serializable value) throws PropertyException
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- Overrides:
initin classAbstractProperty- Parameters:
value- the normalized value to set- Throws:
PropertyException
-
getDefaultValue
protected Serializable getDefaultValue()
- Overrides:
getDefaultValuein classAbstractProperty
-
setValue
public void setValue(Object value) throws PropertyException
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- Overrides:
setValuein classAbstractProperty- Parameters:
value- the value to set- Throws:
InvalidPropertyValueException- if the given value type is not compatible with the expected value typePropertyException
-
addValue
public Property addValue(Object value)
Description copied from interface:PropertyAppends a new value to the list. A new property will be created to store the given value and appended to the children list.The created property will be marked as
Property.isNew().
-
addValue
public Property addValue(int index, Object value)
Description copied from interface:PropertyInserts at the given position a new value to the list. A new property will be created to store the given value and appended to the children list.The created property will be marked as
Property.isNew().
-
addEmpty
public Property addEmpty()
Description copied from interface:PropertyCreates an empty child property and adds it as a property to the list container.This method is useful to construct lists.
-
visitChildren
public void visitChildren(PropertyVisitor visitor, Object arg) throws PropertyException
- Throws:
PropertyException
-
isSameAs
public boolean isSameAs(Property property) throws PropertyException
Should be used by container properties. Non container props must overwrite this.- Specified by:
isSameAsin interfaceProperty- Returns:
- true If the properties have a similar content, otherwise false
- Throws:
PropertyException
-
getDirtyChildren
public Iterator<Property> getDirtyChildren()
Description copied from interface:PropertyGets an iterator over the dirty children properties.- Specified by:
getDirtyChildrenin interfaceProperty- Returns:
- the iterator
-
clear
public void clear()
Throws UnsupportedOperationException, added to implement Map<String, Property> interface.
-
containsKey
public boolean containsKey(Object key)
Throws UnsupportedOperationException, added to implement Map<String, Property> interface.- Specified by:
containsKeyin interfaceMap<String,Property>
-
containsValue
public boolean containsValue(Object value)
Throws UnsupportedOperationException, added to implement Map<String, Property> interface.- Specified by:
containsValuein interfaceMap<String,Property>
-
put
public Property put(String key, Property value)
Throws UnsupportedOperationException, added to implement Map<String, Property> interface.
-
putAll
public void putAll(Map<? extends String,? extends Property> t)
Throws UnsupportedOperationException, added to implement Map<String, Property> interface.
-
remove
public Property remove(Object key)
Throws UnsupportedOperationException, added to implement Map<String, Property> interface.
-
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- Overrides:
clearDirtyFlagsin classAbstractProperty
-
-