Class ListProperty

java.lang.Object
org.nuxeo.ecm.core.api.model.impl.AbstractProperty
org.nuxeo.ecm.core.api.model.impl.ListProperty
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Property>, Collection<Property>, List<Property>, Property

public class ListProperty extends AbstractProperty implements List<Property>
See Also:
  • Field Details

    • field

      protected final Field field
      The corresponding field.
    • children

      protected final List<Property> children
  • Constructor Details

    • ListProperty

      public ListProperty(Property parent, Field field)
    • ListProperty

      public ListProperty(Property parent, Field field, int flags)
  • Method Details

    • 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
    • isContainer

      public boolean isContainer()
      TODO FIXME XXX uncommented return true; see NXP-1653.
      Specified by:
      isContainer in interface Property
      Returns:
      true if scalar false otherwise
      See Also:
    • addValue

      public Property addValue(int index, Object value) throws PropertyException
      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().

      Specified by:
      addValue in interface Property
      Parameters:
      index - the position to insert the value
      Returns:
      the added property
      Throws:
      PropertyException
    • addValue

      public Property addValue(Object value) throws PropertyException
      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().

      Specified by:
      addValue in interface Property
      Returns:
      the added property
      Throws:
      PropertyException
    • 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.

      Specified by:
      addEmpty in interface Property
      Returns:
      the created property
    • 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.

      Specified by:
      getChildren in interface Property
      Returns:
      the children properties
    • getName

      public String getName()
      Description copied from interface: Property
      Gets the property name.
      Specified by:
      getName in interface Property
      Returns:
      the property name
    • getType

      public ListType getType()
      Description copied from interface: Property
      Get the type of the field corresponding to this property.
      Specified by:
      getType in interface Property
      Returns:
      the property type
    • 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.

      Specified by:
      get in interface Property
      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
    • 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.

      Specified by:
      get in interface List<Property>
      Specified by:
      get in interface Property
      Returns:
      the child property if any null if no child property with that name is found or if the property is a scalar
    • set

      public void set(String name, Property property) throws PropertyException
      Description copied from interface: Property
      Sets 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:
      set in interface Property
      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
      PropertyException
    • getDefaultValue

      protected Serializable getDefaultValue()
      Overrides:
      getDefaultValue in class AbstractProperty
    • internalGetValue

      public Serializable internalGetValue() throws PropertyException
      Specified by:
      internalGetValue in class AbstractProperty
      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 interface Property
      Overrides:
      getValueForWrite in class AbstractProperty
      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: 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 interface Property
      Overrides:
      init in class AbstractProperty
      Parameters:
      value - the normalized value to set
      Throws:
      PropertyException
    • 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 interface Property
      Overrides:
      setValue in class AbstractProperty
      Parameters:
      value - the value to set
      Throws:
      InvalidPropertyValueException - if the given value type is not compatible with the expected value type
      PropertyException
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<Property>
      Specified by:
      clear in interface List<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

      Specified by:
      getField in interface Property
    • remove

      public boolean remove(Property property)
    • remove

      public Property remove(int index)
      Specified by:
      remove in interface List<Property>
    • clone

      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

      Specified by:
      accept in interface Property
      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
    • 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 interface Property
      Overrides:
      isNormalized in class AbstractProperty
      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 interface Property
      Overrides:
      normalize in class AbstractProperty
      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 interface Property
      Overrides:
      convertTo in class AbstractProperty
      Parameters:
      value - the normalized value to convert
      toType - the conversion type
      Returns:
      the converted value, which may be null
      Throws:
      PropertyConversionException - if the conversion cannot be made because of type incompatibilities
    • arrayToList

      public static ArrayList<?> arrayToList(Object obj)
    • applyListDiff

      public void applyListDiff(ListDiff ld) throws PropertyException
      Supports ListDiff for compatibility.
      Throws:
      PropertyException
    • isSameAs

      public boolean isSameAs(Property property) throws PropertyException
      Description copied from interface: Property
      Compare the two properties by content.
      Specified by:
      isSameAs in interface Property
      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.
      Specified by:
      getDirtyChildren in interface Property
      Returns:
      the iterator
    • indexOf

      public int indexOf(Property property)
    • add

      public void add(int index, Property element)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      add in interface List<Property>
    • add

      public boolean add(Property o)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      add in interface Collection<Property>
      Specified by:
      add in interface List<Property>
    • addAll

      public boolean addAll(Collection<? extends Property> c)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      addAll in interface Collection<Property>
      Specified by:
      addAll in interface List<Property>
    • addAll

      public boolean addAll(int index, Collection<? extends Property> c)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      addAll in interface List<Property>
    • contains

      public boolean contains(Object o)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      contains in interface Collection<Property>
      Specified by:
      contains in interface List<Property>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      containsAll in interface Collection<Property>
      Specified by:
      containsAll in interface List<Property>
    • indexOf

      public int indexOf(Object o)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      indexOf in interface List<Property>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<Property>
      Specified by:
      isEmpty in interface List<Property>
    • lastIndexOf

      public int lastIndexOf(Object o)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      lastIndexOf in interface List<Property>
    • listIterator

      public ListIterator<Property> listIterator()
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      listIterator in interface List<Property>
    • listIterator

      public ListIterator<Property> listIterator(int index)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      listIterator in interface List<Property>
    • remove

      public boolean remove(Object o)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      remove in interface Collection<Property>
      Specified by:
      remove in interface List<Property>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      removeAll in interface Collection<Property>
      Specified by:
      removeAll in interface List<Property>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      retainAll in interface Collection<Property>
      Specified by:
      retainAll in interface List<Property>
    • set

      public Property set(int index, Property element)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      set in interface List<Property>
    • subList

      public List<Property> subList(int fromIndex, int toIndex)
      Throws UnsupportedOperationException, added to implement List<Property> interface.
      Specified by:
      subList in interface List<Property>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<Property>
      Specified by:
      toArray in interface List<Property>
    • toArray

      public <T> T[] toArray(T[] a)
      Specified by:
      toArray in interface Collection<Property>
      Specified by:
      toArray in interface List<Property>
    • clearDirtyFlags

      public void clearDirtyFlags()
      Description copied from interface: Property
      Notify 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:
      clearDirtyFlags in interface Property
      Overrides:
      clearDirtyFlags in class AbstractProperty