Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.api.model.impl
Class ScalarProperty

java.lang.Object
  extended by org.nuxeo.ecm.core.api.model.impl.AbstractProperty
      extended by org.nuxeo.ecm.core.api.model.impl.ScalarProperty
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Property>, Property
Direct Known Subclasses:
ArrayProperty, BinaryProperty, BooleanProperty, DateProperty, DoubleProperty, LongProperty, ScalarMemberProperty, StringProperty

public class ScalarProperty
extends AbstractProperty

A scalar property that is linked to a schema field

Author:
Bogdan Stefanescu
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.nuxeo.ecm.core.api.model.impl.AbstractProperty
IS_READONLY, IS_VALIDATING, KEYED_DATA
 
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
ScalarProperty(Property parent, Field field)
           
ScalarProperty(Property parent, Field field, int flags)
           
 
Method Summary
 void accept(PropertyVisitor visitor, Object arg)
          Method that implement the visitor pattern.
 Property addEmpty()
          Creates an empty child property and adds it as a property to the list container.
 Property addValue(int index, Object value)
          Inserts at the given position a new value to the list.
 Property addValue(Object value)
          Appends a new value to the list.
 Object clone()
           
 Property get(int index)
          Get the child property given it's index.
 Property get(String name)
          Gets the child property having the given name.
 Collection<Property> getChildren()
          Get a collection over the children properties.
 Iterator<Property> getDirtyChildren()
          Gets an iterator over the dirty children properties.
 Field getField()
          Gets the field corresponding to this property.
 String getName()
          Gets the property name.
 Type getType()
          Get the type of the field corresponding to this property.
 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 isSameAs(Property property)
          Compare the two properties by content.
 String toString()
           
 
Methods inherited from class org.nuxeo.ecm.core.api.model.impl.AbstractProperty
areFlagsSet, clearDirtyFlags, clearFlags, convertTo, getData, getData, getDirtyFlags, getParent, getPath, getRoot, getSchema, getValue, getValue, getValue, getValue, getValueForWrite, init, isComplex, isDirty, isList, isModified, isMoved, isNew, isNormalized, isPhantom, isReadOnly, isRemoved, isScalar, isValidating, iterator, moveTo, newInstance, normalize, remove, removePhantomFlag, resolvePath, resolvePath, setData, setData, setFlags, setIsModified, setReadOnly, setValidating, setValue, setValue, setValue, size, validate, validateType
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScalarProperty

public ScalarProperty(Property parent,
                      Field field)

ScalarProperty

public ScalarProperty(Property parent,
                      Field field,
                      int flags)
Method Detail

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.

Specified by:
internalSetValue in class AbstractProperty
Throws:
PropertyException

getName

public String getName()
Description copied from interface: Property
Gets the property name.

Returns:
the property name

getType

public Type getType()
Description copied from interface: Property
Get the type of the field corresponding to this property.

Returns:
the property type

internalGetValue

public Serializable internalGetValue()
                              throws PropertyException
Specified by:
internalGetValue in class AbstractProperty
Throws:
PropertyException

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.

Returns:
true if scalar false otherwise

getChildren

public Collection<Property> getChildren()
Description copied from interface: Property
Get 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.

Returns:
the children properties

get

public Property get(int index)
Description copied from interface: Property
Get the child property given it's index. This operation is mandatory for List properties.

If this method is not supported an UnsupportedOperationException must be thrown

Relative paths are not resolved. THis method is intended to lookup direct chilren. For path lookups, use Property.resolvePath(String) instead.

Returns:
the child property if any null if no child property with that name is found or if the property is a scalar

get

public Property get(String name)
Description copied from interface: Property
Gets 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.

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

addValue

public Property addValue(Object value)
Description copied from interface: Property
Appends 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().

Returns:
the added property

addValue

public Property addValue(int index,
                         Object value)
Description copied from interface: Property
Inserts 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().

Parameters:
index - the position to insert the value
Returns:
the added property

addEmpty

public Property addEmpty()
Description copied from interface: Property
Creates an empty child property and adds it as a property to the list container.

This method is useful to construct lists.

Returns:
the created property

getField

public Field getField()
Description copied from interface: Property
Gets the field corresponding to this property.

The field is the object defining the property. You can see the field as a java class and the property as a class instance

Returns:

clone

public final Object clone()
                   throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

accept

public void accept(PropertyVisitor visitor,
                   Object arg)
            throws PropertyException
Description copied from interface: Property
Method that implement the visitor pattern.

The visitor must return null to stop visiting children otherwise a context object that will be passed as the arg argument to children

Parameters:
visitor - the visitor to accept
arg - an argument passed to the visitor. This should be used by the visitor to carry on the visiting context.
Throws:
PropertyException

isSameAs

public boolean isSameAs(Property property)
                 throws PropertyException
Description copied from interface: Property
Compare the two properties by content.

Returns:
true If the properties have a similar content, otherwise false
Throws:
PropertyException

getDirtyChildren

public Iterator<Property> getDirtyChildren()
Description copied from interface: Property
Gets an iterator over the dirty children properties.

Returns:
the iterator

toString

public String toString()
Overrides:
toString in class AbstractProperty

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.