com.ibm.commons.xsdutil.xsd.schema
Class XSDSchemaSet

java.lang.Object
  extended by com.ibm.commons.xsdutil.xsd.schema.XSDSchemaSet

public class XSDSchemaSet
extends java.lang.Object

A schema aggregator that is used to compile schema information. This information is later used by the Domino Designer data tooling to calculate how to bind XPage controls to their data sources.


Field Summary
static java.lang.String XML_STANDARD_HEADER
           
 
Constructor Summary
XSDSchemaSet()
          Creates a new instance of this class.
XSDSchemaSet(java.util.Map<java.lang.String,java.lang.String> nsPrefixToUriMap)
          Creates a new instance of this class with the a map of namespaces that will populate the schema set.
 
Method Summary
 void addRootSchema(org.eclipse.xsd.XSDSchema xsdSchema)
          Users will typically call this method to initialize the XSDSchemaSet.
 void addSchema(org.eclipse.xsd.XSDSchema xsdSchema)
          Add a schema to the set.
 XSDSchemaSet cloneWithoutRoot()
          Create a clone of this XSDSchemaSet without the root node.
 org.w3c.dom.Document createInitialDocument(int rootIndex)
          Create an initial document from the current schema.
 java.lang.String createInitialDocumentAsString(int rootIndex)
          Not intended for external use - Not public api
 java.util.HashMap<java.lang.String,com.ibm.commons.xsdutil.xsd.schema.Namespace> getNamespaceByPrefixMap()
          Returns a map of namespaces used across all schemas in the SchemaSet
protected  java.util.HashMap<java.lang.String,com.ibm.commons.xsdutil.xsd.schema.Namespace> getNamespaceByUriMap()
           
 java.lang.String getOrCreateNamespacePrefix(java.lang.String uri)
          Retrieve the prefix for the requested namespace URI.
 java.util.List getReachableItems(XSDConcreteComponentWrapper component)
          Iterates through the schema to calculate which items can be 'reached' from the given node.
 org.eclipse.xsd.XSDElementDeclaration[] getRootElements()
          Returns all "root" elements of the designated root schema.
 org.eclipse.xsd.XSDSchema getRootSchema()
          Returns the root schema for the schema set.
 org.eclipse.xsd.XSDSchema getSchemaByUri(java.lang.String uri)
          Return the schema associated with the uri provided, as maintained by this XSDSchemaSet object.
protected  java.util.HashMap<java.lang.String,org.eclipse.xsd.XSDSchema> getSchemaMap()
           
 java.util.List getTypes()
          Returns all types defined in all schemas in the schema set
 XSDConcreteComponentWrapper[] getWrappedRoots()
          Returns an array of wrapped components.
 boolean hasCyclicalDependency(XSDConcreteComponentWrapper component)
          The XSD might contain circular dependencies.
 void print(java.io.PrintStream os)
          Dumps the schema set to the given print stream.
protected  void setNamespaceByPrefixMap(java.util.HashMap<java.lang.String,com.ibm.commons.xsdutil.xsd.schema.Namespace> map)
           
protected  void setNamespaceByUriMap(java.util.HashMap<java.lang.String,com.ibm.commons.xsdutil.xsd.schema.Namespace> map)
           
protected  void setSchemaMap(java.util.HashMap<java.lang.String,org.eclipse.xsd.XSDSchema> map)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_STANDARD_HEADER

public static final java.lang.String XML_STANDARD_HEADER
See Also:
Constant Field Values
Constructor Detail

XSDSchemaSet

public XSDSchemaSet()
Creates a new instance of this class.


XSDSchemaSet

public XSDSchemaSet(java.util.Map<java.lang.String,java.lang.String> nsPrefixToUriMap)
Creates a new instance of this class with the a map of namespaces that will populate the schema set.

Parameters:
nsPrefixToUriMap - a map of prefix-uri pairs
Method Detail

getRootSchema

public org.eclipse.xsd.XSDSchema getRootSchema()
Returns the root schema for the schema set.

Returns:
an XSDSchema object

getNamespaceByUriMap

protected java.util.HashMap<java.lang.String,com.ibm.commons.xsdutil.xsd.schema.Namespace> getNamespaceByUriMap()

setNamespaceByUriMap

protected void setNamespaceByUriMap(java.util.HashMap<java.lang.String,com.ibm.commons.xsdutil.xsd.schema.Namespace> map)

getNamespaceByPrefixMap

public java.util.HashMap<java.lang.String,com.ibm.commons.xsdutil.xsd.schema.Namespace> getNamespaceByPrefixMap()
Returns a map of namespaces used across all schemas in the SchemaSet

Returns:
a map of namespaces

setNamespaceByPrefixMap

protected void setNamespaceByPrefixMap(java.util.HashMap<java.lang.String,com.ibm.commons.xsdutil.xsd.schema.Namespace> map)

getSchemaMap

protected java.util.HashMap<java.lang.String,org.eclipse.xsd.XSDSchema> getSchemaMap()

setSchemaMap

protected void setSchemaMap(java.util.HashMap<java.lang.String,org.eclipse.xsd.XSDSchema> map)

getOrCreateNamespacePrefix

public java.lang.String getOrCreateNamespacePrefix(java.lang.String uri)
Retrieve the prefix for the requested namespace URI. If the uri does not exist, add it and create a corresponding prefix

Parameters:
uri - a fully qualified namespace URI
Returns:
a prefix for the given namespace uri

getSchemaByUri

public org.eclipse.xsd.XSDSchema getSchemaByUri(java.lang.String uri)
Return the schema associated with the uri provided, as maintained by this XSDSchemaSet object.

Parameters:
uri - a fully qualified namespace uri
Returns:
an XSDSchema if found, may be null

cloneWithoutRoot

public XSDSchemaSet cloneWithoutRoot()
Create a clone of this XSDSchemaSet without the root node. The clone is shallow in the sense that references to the contained XSDSchemas are copied in to the new object, and hence shared across copies. As these documents are read only.


addSchema

public void addSchema(org.eclipse.xsd.XSDSchema xsdSchema)
Add a schema to the set. This schema is not added as a root, convenience method for calling #addSchema(XSDSchema, false).

Parameters:
xsdSchema - the schema to be added to the schema set

addRootSchema

public void addRootSchema(org.eclipse.xsd.XSDSchema xsdSchema)
Users will typically call this method to initialize the XSDSchemaSet. The schema passed in here is the one that will be queried for type and element declarations.

Parameters:
xsdSchema -

getRootElements

public org.eclipse.xsd.XSDElementDeclaration[] getRootElements()
Returns all "root" elements of the designated root schema. That is, all first level children of the "" element. If no root schema has been established, an empty list is returned.

Returns:
list of root Elements

getWrappedRoots

public XSDConcreteComponentWrapper[] getWrappedRoots()
Returns an array of wrapped components. The wrappers allow the caller to retrieve information in a more user readable format.

Returns:
an array of XSDConcreteComponentWrapper objects

getReachableItems

public java.util.List getReachableItems(XSDConcreteComponentWrapper component)
Iterates through the schema to calculate which items can be 'reached' from the given node. This allows UI controls to build a tree of information from any given element in the schema.

Parameters:
component - a component whose reachable items are required
Returns:
a list of items that can be reached from the given element

createInitialDocumentAsString

public java.lang.String createInitialDocumentAsString(int rootIndex)
                                               throws XMLException
Not intended for external use - Not public api

Throws:
XMLException

createInitialDocument

public org.w3c.dom.Document createInitialDocument(int rootIndex)
                                           throws XMLException
Create an initial document from the current schema.

Returns:
an skeleton document based on the schema
Throws:
XMLException

print

public void print(java.io.PrintStream os)
Dumps the schema set to the given print stream. Utility method for debugging purposes.

Parameters:
stream - a stream where the contents of the schema set will be printed

hasCyclicalDependency

public boolean hasCyclicalDependency(XSDConcreteComponentWrapper component)
The XSD might contain circular dependencies. This helper method determines whether a component appears in its ancestry.

Parameters:
component - a schema element that is to be tested
Returns:
true if the given component appears in its own ancestry

getTypes

public java.util.List getTypes()
Returns all types defined in all schemas in the schema set

Returns:
a list of schema types