com.evolveum.midpoint.prism.schema
Class PrismSchema

java.lang.Object
  extended by com.evolveum.midpoint.prism.schema.PrismSchema
All Implemented Interfaces:
DebugDumpable, Dumpable
Direct Known Subclasses:
RefinedResourceSchema, ResourceSchema

public class PrismSchema
extends java.lang.Object
implements Dumpable, DebugDumpable

Schema as a collection of definitions. This is a midPoint-specific view of schema definition. It is just a collection of definitions grouped under a specific namespace. The schema and all the public classes in this package define a schema meta-model. It is supposed to be used for run-time schema interpretation. It will not be a convenient tool to work with static data model objects such as user or role. But it is needed for interpreting dynamic schemas for resource objects, extensions and so on.

Author:
Radovan Semancik

Field Summary
protected  java.util.Collection<Definition> definitions
           
protected  java.lang.String namespace
           
protected  PrismContext prismContext
           
 
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
 
Constructor Summary
protected PrismSchema(PrismContext prismContext)
           
  PrismSchema(java.lang.String namespace, PrismContext prismContext)
           
 
Method Summary
 void add(Definition def)
           
 ComplexTypeDefinition createComplexTypeDefinition(javax.xml.namespace.QName typeName)
           
 PrismContainerDefinition createPropertyContainerDefinition(java.lang.String localTypeName)
          Creates a new property container definition and adds it to the schema.
 PrismContainerDefinition createPropertyContainerDefinition(java.lang.String localElementName, java.lang.String localTypeName)
           
 PrismPropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name, javax.xml.namespace.QName typeName)
          Creates a top-level property definition and adds it to the schema.
 PrismPropertyDefinition createPropertyDefinition(java.lang.String localName, javax.xml.namespace.QName typeName)
          Creates a top-level property definition and adds it to the schema.
 PrismPropertyDefinition createPropertyDefinition(java.lang.String localName, java.lang.String localTypeName)
          Creates a top-level property definition and adds it to the schema.
 java.lang.String debugDump()
          Show the content of the object intended for diagnostics by system administrator.
 java.lang.String debugDump(int indent)
           
 java.lang.String dump()
          Show the content of the object intended for diagnostics by developer.
 ComplexTypeDefinition findComplexTypeDefinition(javax.xml.namespace.QName typeName)
          Finds complex type definition by type name.
 PrismContainerDefinition findContainerDefinitionByElementName(javax.xml.namespace.QName elementName)
           
 PrismContainerDefinition findContainerDefinitionByType(javax.xml.namespace.QName typeName)
          Finds a PropertyContainerDefinition by the type name.
<T extends ItemDefinition>
T
findItemDefinition(javax.xml.namespace.QName definitionName, java.lang.Class<T> definitionType)
          Finds item definition by name.
<T extends ItemDefinition>
T
findItemDefinition(java.lang.String localName, java.lang.Class<T> definitionType)
          Finds item definition by local name
<T extends ItemDefinition>
T
findItemDefinitionByType(javax.xml.namespace.QName typeName, java.lang.Class<T> definitionType)
          Finds item definition by type.
<T extends Objectable>
PrismObjectDefinition<T>
findObjectDefinitionByCompileTimeClass(java.lang.Class<T> type)
           
<X extends Objectable>
PrismObjectDefinition<X>
findObjectDefinitionByElementName(javax.xml.namespace.QName elementName)
           
<X extends Objectable>
PrismObjectDefinition<X>
findObjectDefinitionByType(javax.xml.namespace.QName typeName)
           
<T extends Objectable>
PrismObjectDefinition<T>
findObjectDefinitionByType(javax.xml.namespace.QName typeName, java.lang.Class<T> type)
           
 PrismPropertyDefinition findPropertyDefinitionByElementName(javax.xml.namespace.QName elementName)
           
 java.util.Collection<Definition> getDefinitions()
          Returns set of definitions.
<T extends Definition>
java.util.Collection<T>
getDefinitions(java.lang.Class<T> type)
           
 java.lang.String getNamespace()
          Returns schema namespace.
protected  PrismContext getPrismContext()
           
 boolean isEmpty()
           
protected static PrismSchema parse(org.w3c.dom.Element element, org.xml.sax.EntityResolver resolver, PrismSchema schema, java.lang.String shortDescription, PrismContext prismContext)
           
static PrismSchema parse(org.w3c.dom.Element element, org.xml.sax.EntityResolver resolver, java.lang.String shortDescription, PrismContext prismContext)
           
protected static PrismSchema parse(org.w3c.dom.Element element, PrismSchema schema, java.lang.String shortDescription, PrismContext prismContext)
           
static PrismSchema parse(org.w3c.dom.Element element, java.lang.String shortDescription, PrismContext prismContext)
           
 org.w3c.dom.Document serializeToXsd()
           
 void setNamespace(java.lang.String namespace)
           
protected  java.lang.String toElementName(java.lang.String localTypeName)
          Internal method to create a "nice" element name from the type name.
protected  javax.xml.namespace.QName toElementQName(javax.xml.namespace.QName qname)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

namespace

protected java.lang.String namespace

definitions

protected java.util.Collection<Definition> definitions

prismContext

protected PrismContext prismContext
Constructor Detail

PrismSchema

protected PrismSchema(PrismContext prismContext)

PrismSchema

public PrismSchema(java.lang.String namespace,
                   PrismContext prismContext)
Method Detail

getNamespace

public java.lang.String getNamespace()
Returns schema namespace. All schema definitions are placed in the returned namespace.

Returns:
schema namespace

setNamespace

public void setNamespace(java.lang.String namespace)

getDefinitions

public java.util.Collection<Definition> getDefinitions()
Returns set of definitions. The set contains all definitions of all types that were parsed. Order of definitions is insignificant.

Returns:
set of definitions

getDefinitions

public <T extends Definition> java.util.Collection<T> getDefinitions(java.lang.Class<T> type)

add

public void add(Definition def)

getPrismContext

protected PrismContext getPrismContext()

parse

public static PrismSchema parse(org.w3c.dom.Element element,
                                java.lang.String shortDescription,
                                PrismContext prismContext)
                         throws SchemaException
Throws:
SchemaException

parse

public static PrismSchema parse(org.w3c.dom.Element element,
                                org.xml.sax.EntityResolver resolver,
                                java.lang.String shortDescription,
                                PrismContext prismContext)
                         throws SchemaException
Throws:
SchemaException

parse

protected static PrismSchema parse(org.w3c.dom.Element element,
                                   PrismSchema schema,
                                   java.lang.String shortDescription,
                                   PrismContext prismContext)
                            throws SchemaException
Throws:
SchemaException

parse

protected static PrismSchema parse(org.w3c.dom.Element element,
                                   org.xml.sax.EntityResolver resolver,
                                   PrismSchema schema,
                                   java.lang.String shortDescription,
                                   PrismContext prismContext)
                            throws SchemaException
Throws:
SchemaException

serializeToXsd

public org.w3c.dom.Document serializeToXsd()
                                    throws SchemaException
Throws:
SchemaException

findContainerDefinitionByType

public PrismContainerDefinition findContainerDefinitionByType(javax.xml.namespace.QName typeName)
Finds a PropertyContainerDefinition by the type name.

Parameters:
typeName - property container type name
Returns:
found property container definition
Throws:
java.lang.IllegalStateException - if more than one definition is found

findObjectDefinitionByType

public <X extends Objectable> PrismObjectDefinition<X> findObjectDefinitionByType(javax.xml.namespace.QName typeName)

findObjectDefinitionByElementName

public <X extends Objectable> PrismObjectDefinition<X> findObjectDefinitionByElementName(javax.xml.namespace.QName elementName)

findObjectDefinitionByType

public <T extends Objectable> PrismObjectDefinition<T> findObjectDefinitionByType(javax.xml.namespace.QName typeName,
                                                                                  java.lang.Class<T> type)

findObjectDefinitionByCompileTimeClass

public <T extends Objectable> PrismObjectDefinition<T> findObjectDefinitionByCompileTimeClass(java.lang.Class<T> type)

findContainerDefinitionByElementName

public PrismContainerDefinition findContainerDefinitionByElementName(javax.xml.namespace.QName elementName)

findPropertyDefinitionByElementName

public PrismPropertyDefinition findPropertyDefinitionByElementName(javax.xml.namespace.QName elementName)

findComplexTypeDefinition

public ComplexTypeDefinition findComplexTypeDefinition(javax.xml.namespace.QName typeName)
Finds complex type definition by type name.


findItemDefinition

public <T extends ItemDefinition> T findItemDefinition(javax.xml.namespace.QName definitionName,
                                                       java.lang.Class<T> definitionType)
Finds item definition by name.


findItemDefinition

public <T extends ItemDefinition> T findItemDefinition(java.lang.String localName,
                                                       java.lang.Class<T> definitionType)
Finds item definition by local name


findItemDefinitionByType

public <T extends ItemDefinition> T findItemDefinitionByType(javax.xml.namespace.QName typeName,
                                                             java.lang.Class<T> definitionType)
Finds item definition by type.


isEmpty

public boolean isEmpty()

createPropertyContainerDefinition

public PrismContainerDefinition createPropertyContainerDefinition(java.lang.String localTypeName)
Creates a new property container definition and adds it to the schema. This is a preferred way how to create definition in the schema.

Parameters:
localTypeName - type name "relative" to schema namespace
Returns:
new property container definition

createPropertyContainerDefinition

public PrismContainerDefinition createPropertyContainerDefinition(java.lang.String localElementName,
                                                                  java.lang.String localTypeName)

createComplexTypeDefinition

public ComplexTypeDefinition createComplexTypeDefinition(javax.xml.namespace.QName typeName)

createPropertyDefinition

public PrismPropertyDefinition createPropertyDefinition(java.lang.String localName,
                                                        javax.xml.namespace.QName typeName)
Creates a top-level property definition and adds it to the schema. This is a preferred way how to create definition in the schema.

Parameters:
localName - element name "relative" to schema namespace
typeName - XSD type name of the element
Returns:
new property definition

createPropertyDefinition

public PrismPropertyDefinition createPropertyDefinition(java.lang.String localName,
                                                        java.lang.String localTypeName)
Creates a top-level property definition and adds it to the schema. This is a preferred way how to create definition in the schema.

Parameters:
localName - element name "relative" to schema namespace
localTypeName - XSD type name "relative" to schema namespace
Returns:
new property definition

createPropertyDefinition

public PrismPropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name,
                                                        javax.xml.namespace.QName typeName)
Creates a top-level property definition and adds it to the schema. This is a preferred way how to create definition in the schema.

Parameters:
localName - element name
typeName - XSD type name of the element
Returns:
new property definition

toElementName

protected java.lang.String toElementName(java.lang.String localTypeName)
Internal method to create a "nice" element name from the type name.


toElementQName

protected javax.xml.namespace.QName toElementQName(javax.xml.namespace.QName qname)

debugDump

public java.lang.String debugDump()
Description copied from interface: DebugDumpable
Show the content of the object intended for diagnostics by system administrator. The out put should be suitable to use in system logs at "debug" level. It may be multi-line, but in that case it should be well indented and quite terse. As it is intended to be used by system administrator, it should not use any developer terms such as class names, exceptions or stack traces.

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

debugDump

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

dump

public java.lang.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.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2012 evolveum. All Rights Reserved.