com.evolveum.midpoint.schema.processor
Class PropertyContainerDefinition

java.lang.Object
  extended by com.evolveum.midpoint.schema.processor.Definition
      extended by com.evolveum.midpoint.schema.processor.ItemDefinition
          extended by com.evolveum.midpoint.schema.processor.PropertyContainerDefinition
All Implemented Interfaces:
Dumpable, java.io.Serializable
Direct Known Subclasses:
ObjectDefinition, ResourceObjectDefinition

public class PropertyContainerDefinition
extends ItemDefinition

Definition of a property container. Property container groups properties into logical blocks. The reason for grouping may be as simple as better understandability of data structure. But the group usually means different meaning, source or structure of the data. For example, the property container is frequently used to hold properties that are dynamic, not fixed by a static schema. Such grouping also naturally translates to XML and helps to "quarantine" such properties to avoid Unique Particle Attribute problems. Property Container contains a set of (potentially multi-valued) properties. The order of properties is not significant, regardless of the fact that it may be fixed in the XML representation. In the XML representation, each element inside Property Container must be either Property or a Property Container. This class represents schema definition for property container. See Definition for more details.

Author:
Radovan Semancik
See Also:
Serialized Form

Field Summary
protected  ComplexTypeDefinition complexTypeDefinition
           
protected  Schema schema
           
 
Fields inherited from class com.evolveum.midpoint.schema.processor.ItemDefinition
name
 
Fields inherited from class com.evolveum.midpoint.schema.processor.Definition
defaultName, displayName, help, ignored, typeName
 
Method Summary
 PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name)
           
 PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name, javax.xml.namespace.QName typeName)
          Creates new instance of property definition and adds it to the container.
 PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name, javax.xml.namespace.QName typeName, int minOccurs, int maxOccurs)
          Creates new instance of property definition and adds it to the container.
 PropertyDefinition createPropertyDefinition(java.lang.String localName, javax.xml.namespace.QName typeName)
          Creates new instance of property definition and adds it to the container.
 PropertyDefinition createPropertyDefinition(java.lang.String localName, java.lang.String localTypeName)
          Creates new instance of property definition and adds it to the container.
 PropertyDefinition createPropertyDefinition(java.lang.String localName, java.lang.String localTypeName, int minOccurs, int maxOccurs)
          Creates new instance of property definition and adds it to the container.
 java.lang.String dump(int indent)
           
 ItemDefinition findItemDefinition(javax.xml.namespace.QName name)
           
protected
<T extends ItemDefinition>
T
findItemDefinition(javax.xml.namespace.QName name, java.lang.Class<T> clazz)
           
 PropertyContainerDefinition findPropertyContainerDefinition(javax.xml.namespace.QName name)
          Finds an inner PropertyContainerDefinition by looking at the property container name.
 PropertyDefinition findPropertyDefinition(javax.xml.namespace.QName name)
          Finds a PropertyDefinition by looking at the property name.
 java.util.Set<ItemDefinition> getDefinitions()
          Returns set of property definitions.
 java.util.Set<PropertyDefinition> getPropertyDefinitions()
          Returns set of property definitions.
protected  java.lang.String getSchemaNamespace()
           
 PropertyContainer instantiate()
          Create property container instance with a default name.
 PropertyContainer instantiate(javax.xml.namespace.QName name)
          Create property container instance with a specified name.
 PropertyContainer instantiate(javax.xml.namespace.QName name, java.lang.Object element)
          Create property container instance with a specified name and element.
 boolean isEmpty()
           
 PropertyContainer parseAsContent(javax.xml.namespace.QName name, java.util.List<java.lang.Object> contentElements)
           
protected
<T extends PropertyContainer>
T
parseAsContent(javax.xml.namespace.QName name, java.util.List<java.lang.Object> contentElements, java.lang.Class<T> type)
           
 PropertyContainer parseItem(java.util.List<java.lang.Object> elements)
          Creates new property container from DOM or JAXB representation (multiple elements).
 PropertyContainer parseItem(java.lang.Object element)
          Creates new property container from DOM or JAXB representation (single element).
protected
<T extends PropertyContainer>
T
parseItem(java.lang.Object element, java.lang.Class<T> type)
          Creates new property container from DOM or JAXB representation (multiple elements).
 java.util.Set<Item> parseItems(java.util.List<java.lang.Object> elements)
          Parses items from a list of elements.
protected  java.util.Set<Item> parseItems(java.util.List<java.lang.Object> elements, java.util.Set<? extends ItemDefinition> selection)
          Parses items from a list of elements.
 
Methods inherited from class com.evolveum.midpoint.schema.processor.ItemDefinition
getName, getNameOrDefaultName, toString
 
Methods inherited from class com.evolveum.midpoint.schema.processor.Definition
dump, getDefaultName, getDisplayName, getHelp, getTypeName, isIgnored, setDisplayName, setHelp, setIgnored
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

complexTypeDefinition

protected ComplexTypeDefinition complexTypeDefinition

schema

protected Schema schema
Method Detail

getSchemaNamespace

protected java.lang.String getSchemaNamespace()

findItemDefinition

protected <T extends ItemDefinition> T findItemDefinition(javax.xml.namespace.QName name,
                                                          java.lang.Class<T> clazz)

findItemDefinition

public ItemDefinition findItemDefinition(javax.xml.namespace.QName name)

findPropertyDefinition

public PropertyDefinition findPropertyDefinition(javax.xml.namespace.QName name)
Finds a PropertyDefinition by looking at the property name. Returns null if nothing is found.

Parameters:
name - property definition name
Returns:
found property definition or null

findPropertyContainerDefinition

public PropertyContainerDefinition findPropertyContainerDefinition(javax.xml.namespace.QName name)
Finds an inner PropertyContainerDefinition by looking at the property container name. Returns null if nothing is found.

Parameters:
name - property container definition name
Returns:
found property container definition or null

getDefinitions

public java.util.Set<ItemDefinition> getDefinitions()
Returns set of property definitions. WARNING: This may return definitions from the associated complex type. Therefore changing the returned set may influence also the complex type definition. The set contains all property definitions of all types that were parsed. Order of definitions is insignificant.

Returns:
set of definitions

getPropertyDefinitions

public java.util.Set<PropertyDefinition> getPropertyDefinitions()
Returns set of property definitions. The set contains all property definitions of all types that were parsed. Order of definitions is insignificant. The returned set is immutable! All changes may be lost.

Returns:
set of definitions

instantiate

public PropertyContainer instantiate()
Create property container instance with a default name. This is a preferred way how to create property container.

Specified by:
instantiate in class ItemDefinition
Returns:
created item instance

instantiate

public PropertyContainer instantiate(javax.xml.namespace.QName name)
Create property container instance with a specified name. This is a preferred way how to create property container.

Specified by:
instantiate in class ItemDefinition
Returns:
created item instance

instantiate

public PropertyContainer instantiate(javax.xml.namespace.QName name,
                                     java.lang.Object element)
Create property container instance with a specified name and element. This is a preferred way how to create property container.

Specified by:
instantiate in class ItemDefinition
Returns:
created item instance

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name,
                                                   javax.xml.namespace.QName typeName)
Creates new instance of property definition and adds it to the container. This is the preferred method of creating a new definition.

Parameters:
name - name of the property (element name)
typeName - XSD type of the property
Returns:
created property definition

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name,
                                                   javax.xml.namespace.QName typeName,
                                                   int minOccurs,
                                                   int maxOccurs)
Creates new instance of property definition and adds it to the container. This is the preferred method of creating a new definition.

Parameters:
name - name of the property (element name)
typeName - XSD type of the property
minOccurs - minimal number of occurrences
maxOccurs - maximal number of occurrences (-1 means unbounded)
Returns:
created property definition

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name)

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(java.lang.String localName,
                                                   javax.xml.namespace.QName typeName)
Creates new instance of property definition and adds it to the container. This is the preferred method of creating a new definition.

Parameters:
localName - name of the property (element name) relative to the schema namespace
typeName - XSD type of the property
Returns:
created property definition

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(java.lang.String localName,
                                                   java.lang.String localTypeName)
Creates new instance of property definition and adds it to the container. This is the preferred method of creating a new definition.

Parameters:
localName - name of the property (element name) relative to the schema namespace
localTypeName - XSD type of the property
Returns:
created property definition

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(java.lang.String localName,
                                                   java.lang.String localTypeName,
                                                   int minOccurs,
                                                   int maxOccurs)
Creates new instance of property definition and adds it to the container. This is the preferred method of creating a new definition.

Parameters:
localName - name of the property (element name) relative to the schema namespace
localTypeName - XSD type of the property
minOccurs - minimal number of occurrences
maxOccurs - maximal number of occurrences (-1 means unbounded)
Returns:
created property definition

parseItem

public PropertyContainer parseItem(java.lang.Object element)
                            throws SchemaException
Creates new property container from DOM or JAXB representation (single element).

Parameters:
element - DOM representation of property container
Returns:
created property container parsed from the element
Throws:
SchemaException - error parsing the element

parseItem

public PropertyContainer parseItem(java.util.List<java.lang.Object> elements)
                            throws SchemaException
Creates new property container from DOM or JAXB representation (multiple elements).

Specified by:
parseItem in class ItemDefinition
Parameters:
elements - DOM or JAXB representation of property container
Returns:
created property container parsed from the elements
Throws:
SchemaException - error parsing the elements

parseItem

protected <T extends PropertyContainer> T parseItem(java.lang.Object element,
                                                    java.lang.Class<T> type)
                                         throws SchemaException
Creates new property container from DOM or JAXB representation (multiple elements). Internal parametric method.

Type Parameters:
T - subclass of property container to return
Parameters:
element - JAXB or DOM element representing the container
type - subclass of property container to return
Returns:
created new property container (or subclass)
Throws:
SchemaException - error parsing the elements

parseAsContent

public PropertyContainer parseAsContent(javax.xml.namespace.QName name,
                                        java.util.List<java.lang.Object> contentElements)
                                 throws SchemaException
Throws:
SchemaException

parseAsContent

protected <T extends PropertyContainer> T parseAsContent(javax.xml.namespace.QName name,
                                                         java.util.List<java.lang.Object> contentElements,
                                                         java.lang.Class<T> type)
                                              throws SchemaException
Throws:
SchemaException

parseItems

public java.util.Set<Item> parseItems(java.util.List<java.lang.Object> elements)
                               throws SchemaException
Parses items from a list of elements. The elements must describe properties or property container as defined by this PropertyContainerDefinition. Serializes all the elements from the provided list.

Parameters:
elements - list of elements with serialized properties
Returns:
set of deserialized items
Throws:
SchemaProcessorException - error parsing the elements
SchemaException

parseItems

protected java.util.Set<Item> parseItems(java.util.List<java.lang.Object> elements,
                                         java.util.Set<? extends ItemDefinition> selection)
                                  throws SchemaException
Parses items from a list of elements. The elements must describe properties or property container as defined by this PropertyContainerDefinition. Serializes all the elements from the provided list. Internal parametric method. This does the real work. min/max constraints are not checked now TODO: maybe we need to check them

Throws:
SchemaException

dump

public java.lang.String dump(int indent)
Overrides:
dump in class Definition

isEmpty

public boolean isEmpty()
Returns:


Copyright © 2011 evolveum. All Rights Reserved.