Class BlobProperty
- java.lang.Object
-
- org.nuxeo.ecm.core.api.model.impl.AbstractProperty
-
- org.nuxeo.ecm.core.api.model.impl.ComplexProperty
-
- org.nuxeo.ecm.core.api.model.impl.MapProperty
-
- org.nuxeo.ecm.core.api.model.impl.primitives.BlobProperty
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<Property>
,Map<String,Property>
,Property
public class BlobProperty extends MapProperty
Blob property, reading and writing from aBlob
object.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Serializable
value
-
Fields inherited from class org.nuxeo.ecm.core.api.model.impl.MapProperty
field
-
Fields inherited from class org.nuxeo.ecm.core.api.model.impl.ComplexProperty
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 Constructor Description BlobProperty(Property parent, Field field, int flags)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
convertTo(Serializable value, Class<T> toType)
Converts the given normalized value to the given type.Serializable
getDefaultValue()
protected Object
getMemberValue(Object object, String name)
Serializable
getValueForWrite()
Gets the property normalized value for write.void
init(Serializable value)
Initializes the property with the given normalized value.protected Property
internalGetChild(Field field)
Gets the property given its name.Serializable
internalGetValue()
void
internalSetValue(Serializable value)
Sets the given normalized value.boolean
isContainer()
Whether this property is a container - this means the property value is a map or a list.boolean
isNormalized(Object value)
Checks if the given value is a normalized one.protected boolean
isNullOrSameValue(Serializable value1, Serializable value2)
boolean
isSameAs(Property property)
Should be used by container properties.protected boolean
isSameValue(Serializable value1, Serializable value2)
protected boolean
isSameValue(ManagedBlob value1, ManagedBlob value2)
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.protected void
setMap(Object object, Map<String,Object> value)
protected void
setMemberValue(Object object, String name, Object value)
protected void
setMemberValue(Blob blob, String name, Object value)
void
setValue(Object value)
Sets this property value.-
Methods inherited from class org.nuxeo.ecm.core.api.model.impl.MapProperty
accept, clone, getField, getName, getType
-
Methods inherited from class org.nuxeo.ecm.core.api.model.impl.ComplexProperty
addEmpty, addValue, addValue, clear, clearDirtyFlags, containsKey, containsValue, entrySet, get, get, get, getChild, getChildren, getDirtyChildren, getNonPhantomChild, getNonPhantomChildren, isEmpty, keySet, put, putAll, remove, set, values, visitChildren
-
Methods inherited from class org.nuxeo.ecm.core.api.model.impl.AbstractProperty
appendDirtyFlags, areFlagsSet, clearFlags, collectPath, computeRemovedProperty, getDeprecatedFallback, getDeprecatedParent, getDirtyFlags, getObjectResolver, getParent, getPath, getRoot, getSchema, getValue, getValue, getValue, getValue, getValueDeprecation, getXPath, getXPath, hasDefaultValue, isComplex, isDeprecated, isDirty, isForceDirty, isList, isModified, isMoved, isNew, isPhantom, isReadOnly, isRemoved, isScalar, isSecured, isSecuredForContext, iterator, moveTo, newDeprecatedMessage, 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
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
-
-
-
-
Field Detail
-
value
protected Serializable value
-
-
Constructor Detail
-
BlobProperty
public BlobProperty(Property parent, Field field, int flags)
-
-
Method Detail
-
getDefaultValue
public Serializable getDefaultValue()
- Overrides:
getDefaultValue
in classComplexProperty
-
internalGetValue
public Serializable internalGetValue() throws PropertyException
- Overrides:
internalGetValue
in classComplexProperty
- Throws:
PropertyException
-
internalSetValue
public void internalSetValue(Serializable value) throws PropertyException
Description copied from class:AbstractProperty
Sets the given normalized value.This applies only for nodes that physically store a value (that means non container nodes). Container nodes does nothing.
- Overrides:
internalSetValue
in classMapProperty
- Throws:
PropertyException
-
isNormalized
public boolean isNormalized(Object value)
Description copied from interface:Property
Checks 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:
isNormalized
in interfaceProperty
- Overrides:
isNormalized
in classComplexProperty
- 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:Property
Normalizes 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
Serializable
If the given value is already normalized it will be returned back.
- Specified by:
normalize
in interfaceProperty
- Overrides:
normalize
in classComplexProperty
- Parameters:
value
- the value to normalize according to the property type- Returns:
- the normalized value
- Throws:
PropertyConversionException
-
convertTo
public <T> T convertTo(Serializable value, Class<T> toType) throws PropertyConversionException
Description copied from interface:Property
Converts the given normalized value to the given type.If the value has already the given type it will be returned back.
- Specified by:
convertTo
in interfaceProperty
- Overrides:
convertTo
in classAbstractProperty
- 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
-
newInstance
public Object newInstance()
Description copied from interface:Property
Creates 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
String
type the empty value will be the empty string ""- Specified by:
newInstance
in interfaceProperty
- Overrides:
newInstance
in classAbstractProperty
- Returns:
- the empty instance the empty instance, or null for some implementations
-
isContainer
public boolean isContainer()
Description copied from interface:Property
Whether this property is a container - this means the property value is a map or a list.Container properties don't have a scalar values. Container values are computed each time they are requested - by calling on of the
getValue
methods - by collecting the values of the child properties.- Specified by:
isContainer
in interfaceProperty
- Overrides:
isContainer
in classMapProperty
- Returns:
- true if scalar false otherwise
-
setValue
public void setValue(Object value) throws PropertyException
Description copied from interface:Property
Sets 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:
setValue
in interfaceProperty
- Overrides:
setValue
in classComplexProperty
- Parameters:
value
- the value to set- Throws:
InvalidPropertyValueException
- if the given value type is not compatible with the expected value typePropertyException
-
isSameValue
protected boolean isSameValue(Serializable value1, Serializable value2)
- Overrides:
isSameValue
in classAbstractProperty
-
isSameValue
protected boolean isSameValue(ManagedBlob value1, ManagedBlob value2)
-
isNullOrSameValue
protected boolean isNullOrSameValue(Serializable value1, Serializable value2)
-
init
public void init(Serializable value) throws PropertyException
Description copied from interface:Property
Initializes 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:
init
in interfaceProperty
- Overrides:
init
in classComplexProperty
- Parameters:
value
- the normalized value to set- Throws:
PropertyException
-
getValueForWrite
public Serializable getValueForWrite() throws PropertyException
Description copied from interface:Property
Gets 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:
getValueForWrite
in interfaceProperty
- Overrides:
getValueForWrite
in classComplexProperty
- Returns:
- the property value to use for write, which may be null
- Throws:
PropertyException
-
internalGetChild
protected Property internalGetChild(Field field)
Description copied from class:ComplexProperty
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.
- Overrides:
internalGetChild
in classComplexProperty
- Returns:
- the child. Cannot return null
-
setMap
protected void setMap(Object object, Map<String,Object> value) throws PropertyException
- Throws:
PropertyException
-
setMemberValue
protected void setMemberValue(Blob blob, String name, Object value) throws PropertyNotFoundException
- Throws:
PropertyNotFoundException
-
getMemberValue
protected Object getMemberValue(Object object, String name) throws PropertyException
- Throws:
PropertyException
-
setMemberValue
protected void setMemberValue(Object object, String name, Object value) throws PropertyException
- Throws:
PropertyException
-
isSameAs
public boolean isSameAs(Property property) throws PropertyException
Description copied from class:ComplexProperty
Should be used by container properties. Non container props must overwrite this.- Specified by:
isSameAs
in interfaceProperty
- Overrides:
isSameAs
in classComplexProperty
- Returns:
- true If the properties have a similar content, otherwise false
- Throws:
PropertyException
-
-