com.evolveum.midpoint.prism
Class Item<V extends PrismValue>

java.lang.Object
  extended by com.evolveum.midpoint.prism.Item<V>
All Implemented Interfaces:
Itemable, Visitable, DebugDumpable, Dumpable, Serializable
Direct Known Subclasses:
PrismContainer, PrismProperty, PrismReference

public abstract class Item<V extends PrismValue>
extends Object
implements Itemable, Dumpable, DebugDumpable, Visitable, Serializable

Item is a common abstraction of Property and PropertyContainer.

This is supposed to be a superclass for all items. Items are things that can appear in property containers, which generally means only a property and property container itself. Therefore this is in fact superclass for those two definitions.

Author:
Radovan Semancik
See Also:
Serialized Form

Field Summary
protected  ItemDefinition definition
           
protected  QName name
           
protected  PrismValue parent
           
protected  PrismContext prismContext
           
 
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
 
Method Summary
 void accept(Visitor visitor)
           
 boolean add(V newValue)
           
 boolean addAll(Collection<V> newValues)
           
 void applyDefinition(ItemDefinition definition)
           
 void applyDefinition(ItemDefinition definition, boolean force)
           
 List<Element> asDomElements()
           
 void assertDefinitions()
           
 void assertDefinitions(boolean tolarateRawValues, String sourceDescription)
           
 void assertDefinitions(String sourceDescription)
           
 void checkConsistence()
           
 void checkConsistence(boolean requireDefinitions)
           
 void checkConsistence(boolean requireDefinitions, boolean prohibitRaw)
           
 void checkConsistenceInternal(Itemable rootItem, ItemPath path, boolean requireDefinitions, boolean prohibitRaw)
           
protected abstract  void checkDefinition(ItemDefinition def)
           
 void clear()
           
abstract  Item clone()
           
static
<T extends Item>
Collection<T>
cloneCollection(Collection<T> items)
           
 boolean contains(V value)
           
 boolean contains(V value, boolean ignoreMetadata)
           
 boolean containsEquivalentValue(V value)
           
 boolean containsRealValue(V value)
           
protected  void copyValues(Item clone)
           
abstract  ItemDelta<V> createDelta(ItemPath path)
          Creates specific sublcass of ItemDelta appropriate for type of item that this definition represents (e.g.
static
<T extends Item>
T
createNewDefinitionlessItem(QName name, Class<T> type)
           
 String debugDump()
          Provide terse and readable dump of the object suitable for log (at debug level).
 String debugDump(int indent)
           
 Collection<? extends ItemDelta> diff(Item<V> other)
           
 Collection<? extends ItemDelta> diff(Item<V> other, boolean ignoreMetadata, boolean isLiteral)
           
 Collection<? extends ItemDelta> diff(Item<V> other, ItemPath pathPrefix, boolean ignoreMetadata, boolean isLiteral)
           
protected  void diffInternal(Item<V> other, ItemPath pathPrefix, Collection<? extends ItemDelta> deltas, boolean ignoreMetadata, boolean isLiteral)
           
 String dump()
          Show the content of the object intended for diagnostics by developer.
 boolean equals(Object obj)
           
 boolean equalsRealValue(Object obj)
           
 PrismValue findValue(PrismValue value, boolean ignoreMetadata)
          Returns value that is equal or equivalent to the provided value.
protected  ItemDelta fixupDelta(ItemDelta delta, Item<V> other, ItemPath pathPrefix, boolean ignoreMetadata)
           
 Collection<V> getClonedValues()
           
protected  String getDebugDumpClassName()
          Return a human readable name of this class suitable for logs.
 ItemDefinition getDefinition()
          Returns applicable property definition.
 String getDisplayName()
          Returns a display name for the property type.
 String getHelp()
          Returns help message defined for the property type.
 QName getName()
          Returns the name of the property.
 PrismValue getNextValue(PrismValue value)
          Returns values that is following the specified value.
 PrismValue getParent()
           
 ItemPath getPath(ItemPath pathPrefix)
           
 PrismValue getPreviousValue(PrismValue value)
          Returns value that is previous to the specified value.
 PrismContext getPrismContext()
           
 Map<String,Object> getUserData()
           
 Object getUserData(String key)
           
 V getValue(int index)
           
 List<V> getValues()
           
 boolean hasCompleteDefinition()
           
 int hashCode()
           
 boolean hasRaw()
          Returns true is at least one of the values is raw.
 boolean hasRealValue(PrismValue value)
           
 boolean hasValue(PrismValue value)
           
 boolean hasValue(PrismValue value, boolean ignoreMetadata)
           
 boolean isEmpty()
           
 boolean isRaw()
          Returns true is all the values are raw.
 void normalize()
           
 V remove(int index)
           
 boolean remove(V newValue)
           
 boolean removeAll(Collection<V> newValues)
           
 void replace(V newValue)
           
 void replaceAll(Collection<V> newValues)
           
static
<T extends Item>
Collection<T>
resetParentCollection(Collection<T> items)
          Sets all parents to null.
 void revive(PrismContext prismContext)
           
 void setDefinition(ItemDefinition definition)
          Sets applicable property definition.
 void setName(QName name)
          Sets the name of the property.
 void setParent(PrismValue parentValue)
           
 void setPrismContext(PrismContext prismContext)
           
 void setUserData(String key, Object value)
           
 int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected QName name

parent

protected PrismValue parent

definition

protected ItemDefinition definition

prismContext

protected transient PrismContext prismContext
Method Detail

getDefinition

public ItemDefinition getDefinition()
Returns applicable property definition.

May return null if no definition is applicable or the definition is not know.

Specified by:
getDefinition in interface Itemable
Returns:
applicable property definition

hasCompleteDefinition

public boolean hasCompleteDefinition()

getName

public QName getName()
Returns the name of the property.

The name is a QName. It uniquely defines a property.

The name may be null, but such a property will not work.

The name is the QName of XML element in the XML representation.

Specified by:
getName in interface Itemable
Returns:
property name

setName

public void setName(QName name)
Sets the name of the property.

The name is a QName. It uniquely defines a property.

The name may be null, but such a property will not work.

The name is the QName of XML element in the XML representation.

Parameters:
name - the name to set

setDefinition

public void setDefinition(ItemDefinition definition)
Sets applicable property definition.

Parameters:
definition - the definition to set

getDisplayName

public String getDisplayName()
Returns a display name for the property type.

Returns null if the display name cannot be determined.

The display name is fetched from the definition. If no definition (schema) is available, the display name will not be returned.

Returns:
display name for the property type

getHelp

public String getHelp()
Returns help message defined for the property type.

Returns null if the help message cannot be determined.

The help message is fetched from the definition. If no definition (schema) is available, the help message will not be returned.

Returns:
help message for the property type

getPrismContext

public PrismContext getPrismContext()
Specified by:
getPrismContext in interface Itemable

setPrismContext

public void setPrismContext(PrismContext prismContext)

getParent

public PrismValue getParent()

setParent

public void setParent(PrismValue parentValue)

getPath

public ItemPath getPath(ItemPath pathPrefix)
Specified by:
getPath in interface Itemable

getUserData

public Map<String,Object> getUserData()

getUserData

public Object getUserData(String key)

setUserData

public void setUserData(String key,
                        Object value)

getValues

public List<V> getValues()

getValue

public V getValue(int index)

hasValue

public boolean hasValue(PrismValue value,
                        boolean ignoreMetadata)

hasValue

public boolean hasValue(PrismValue value)

hasRealValue

public boolean hasRealValue(PrismValue value)

findValue

public PrismValue findValue(PrismValue value,
                            boolean ignoreMetadata)
Returns value that is equal or equivalent to the provided value. The returned value is an instance stored in this item, while the provided value argument may not be.


getPreviousValue

public PrismValue getPreviousValue(PrismValue value)
Returns value that is previous to the specified value. Note that the order is semantically insignificant and this is used only for presentation consistency in order-sensitive formats such as XML or JSON.


getNextValue

public PrismValue getNextValue(PrismValue value)
Returns values that is following the specified value. Note that the order is semantically insignificant and this is used only for presentation consistency in order-sensitive formats such as XML or JSON.


getClonedValues

public Collection<V> getClonedValues()

contains

public boolean contains(V value)

containsEquivalentValue

public boolean containsEquivalentValue(V value)

contains

public boolean contains(V value,
                        boolean ignoreMetadata)

containsRealValue

public boolean containsRealValue(V value)

size

public int size()

addAll

public boolean addAll(Collection<V> newValues)
               throws SchemaException
Throws:
SchemaException

add

public boolean add(V newValue)
            throws SchemaException
Throws:
SchemaException

removeAll

public boolean removeAll(Collection<V> newValues)

remove

public boolean remove(V newValue)

remove

public V remove(int index)

replaceAll

public void replaceAll(Collection<V> newValues)
                throws SchemaException
Throws:
SchemaException

replace

public void replace(V newValue)

clear

public void clear()

normalize

public void normalize()

asDomElements

public List<Element> asDomElements()

diff

public Collection<? extends ItemDelta> diff(Item<V> other)

diff

public Collection<? extends ItemDelta> diff(Item<V> other,
                                            boolean ignoreMetadata,
                                            boolean isLiteral)

diff

public Collection<? extends ItemDelta> diff(Item<V> other,
                                            ItemPath pathPrefix,
                                            boolean ignoreMetadata,
                                            boolean isLiteral)

diffInternal

protected void diffInternal(Item<V> other,
                            ItemPath pathPrefix,
                            Collection<? extends ItemDelta> deltas,
                            boolean ignoreMetadata,
                            boolean isLiteral)

fixupDelta

protected ItemDelta fixupDelta(ItemDelta delta,
                               Item<V> other,
                               ItemPath pathPrefix,
                               boolean ignoreMetadata)

createDelta

public abstract ItemDelta<V> createDelta(ItemPath path)
Creates specific sublcass of ItemDelta appropriate for type of item that this definition represents (e.g. PropertyDelta, ContainerDelta, ...)


accept

public void accept(Visitor visitor)
Specified by:
accept in interface Visitable

applyDefinition

public void applyDefinition(ItemDefinition definition)
                     throws SchemaException
Throws:
SchemaException

applyDefinition

public void applyDefinition(ItemDefinition definition,
                            boolean force)
                     throws SchemaException
Throws:
SchemaException

revive

public void revive(PrismContext prismContext)

clone

public abstract Item clone()
Overrides:
clone in class Object

copyValues

protected void copyValues(Item clone)

cloneCollection

public static <T extends Item> Collection<T> cloneCollection(Collection<T> items)

resetParentCollection

public static <T extends Item> Collection<T> resetParentCollection(Collection<T> items)
Sets all parents to null. This is good if the items are to be "transplanted" into a different Containerable.


createNewDefinitionlessItem

public static <T extends Item> T createNewDefinitionlessItem(QName name,
                                                             Class<T> type)

checkConsistence

public void checkConsistence(boolean requireDefinitions)

checkConsistence

public void checkConsistence(boolean requireDefinitions,
                             boolean prohibitRaw)

checkConsistence

public void checkConsistence()

checkConsistenceInternal

public void checkConsistenceInternal(Itemable rootItem,
                                     ItemPath path,
                                     boolean requireDefinitions,
                                     boolean prohibitRaw)

checkDefinition

protected abstract void checkDefinition(ItemDefinition def)

assertDefinitions

public void assertDefinitions()
                       throws SchemaException
Throws:
SchemaException

assertDefinitions

public void assertDefinitions(String sourceDescription)
                       throws SchemaException
Throws:
SchemaException

assertDefinitions

public void assertDefinitions(boolean tolarateRawValues,
                              String sourceDescription)
                       throws SchemaException
Throws:
SchemaException

isRaw

public boolean isRaw()
Returns true is all the values are raw.


hasRaw

public boolean hasRaw()
Returns true is at least one of the values is raw.


isEmpty

public boolean isEmpty()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equalsRealValue

public boolean equalsRealValue(Object obj)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

dump

public String dump()
Description copied from interface: Dumpable
Show the content of the object intended for diagnostics by developer. The content may be multi-line, in case of hierarchical objects it may be intended. The use of this method may not be efficient. It is not supposed to be used in normal operation. However, it is very useful in tests or in case of dumping objects in severe error situations.

Specified by:
dump in interface Dumpable
Returns:
content of the object intended for diagnostics.

debugDump

public String debugDump()
Provide terse and readable dump of the object suitable for log (at debug level).

Specified by:
debugDump in interface DebugDumpable
Returns:
content of the object intended for diagnostics by system administrator.

debugDump

public String debugDump(int indent)
Specified by:
debugDump in interface DebugDumpable

getDebugDumpClassName

protected String getDebugDumpClassName()
Return a human readable name of this class suitable for logs.



Copyright © 2013 evolveum. All Rights Reserved.