org.dsmltools
Class DSMLDocumentImpl

java.lang.Object
  |
  +--org.apache.xerces.dom.NodeImpl
        |
        +--org.apache.xerces.dom.ChildNode
              |
              +--org.apache.xerces.dom.ParentNode
                    |
                    +--org.apache.xerces.dom.CoreDocumentImpl
                          |
                          +--org.apache.xerces.dom.DocumentImpl
                                |
                                +--org.dsmltools.DSMLDocumentImpl
All Implemented Interfaces:
java.lang.Cloneable, org.w3c.dom.Document, org.w3c.dom.events.DocumentEvent, org.w3c.dom.ls.DocumentLS, org.w3c.dom.ranges.DocumentRange, org.w3c.dom.traversal.DocumentTraversal, org.w3c.dom.events.EventTarget, org.w3c.dom.Node, org.w3c.dom.NodeList, java.io.Serializable

public final class DSMLDocumentImpl
extends org.apache.xerces.dom.DocumentImpl

This class extends DocumentImpl, an implementation of the Document interface, to add DSML-specific functionality, such as directory-style validation.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.apache.xerces.dom.DocumentImpl
 
Nested classes inherited from class org.apache.xerces.dom.CoreDocumentImpl
 
Field Summary
static int TAB_SIZE
          The amount each line is indented from the previous one when a DSMLDocumentImpl is serialized.
 
Fields inherited from class org.apache.xerces.dom.DocumentImpl
eventListeners, iterators, mutationEvents, ranges
 
Fields inherited from class org.apache.xerces.dom.CoreDocumentImpl
actualEncoding, allowGrammarAccess, CDATA, changes, COMMENTS, DEFAULTS, docElement, docType, domNormalizer, DTNORMALIZATION, encoding, ENTITIES, errorChecking, fConfiguration, fDocumentURI, features, fEntityResolver, fErrorHandlerWrapper, fGrammar, fSymbolTable, identifiers, kidOK, NSPROCESSING, SPLITCDATA, standalone, userData, VALIDATION, version
 
Fields inherited from class org.apache.xerces.dom.ParentNode
firstChild, fNodeListCache, ownerDocument
 
Fields inherited from class org.apache.xerces.dom.ChildNode
nextSibling, previousSibling
 
Fields inherited from class org.apache.xerces.dom.NodeImpl
ELEMENT_DEFINITION_NODE, FIRSTCHILD, flags, HASSTRING, IDATTRIBUTE, IGNORABLEWS, OWNED, ownerNode, READONLY, SPECIFIED, SYNCCHILDREN, SYNCDATA, TREE_POSITION_ANCESTOR, TREE_POSITION_DESCENDANT, TREE_POSITION_DISCONNECTED, TREE_POSITION_EQUIVALENT, TREE_POSITION_FOLLOWING, TREE_POSITION_PRECEDING, TREE_POSITION_SAME_NODE, UNNORMALIZED
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
DSMLDocumentImpl()
          When we create new DSML documents, this constructor ensures that they will automatically have the <dsml> node.
 
Method Summary
static void serialize(org.w3c.dom.Document xiDoc, java.io.OutputStream xiOut)
          This method takes a Document and writes its contents as a stream of DSML to the given OutputStream.
 void serialize(java.io.OutputStream xiOut)
          This method serializes this Document to the given OutputStream.
 void validate()
          This function calls validate(this, null) on this Document.
static void validate(org.w3c.dom.Document xiDoc)
          This function calls validate(xiDoc, null) on this Document - in other words, validation using the Document's schema.
static void validate(org.w3c.dom.Document xiDoc, netscape.ldap.LDAPSchema xiSchema)
          This function checks the directory data in the passed in Document for consistency at a directory (rather than XML) level.
 
Methods inherited from class org.apache.xerces.dom.DocumentImpl
addEventListener, cloneNode, copyEventListeners, createEvent, createNodeIterator, createNodeIterator, createRange, createTreeWalker, createTreeWalker, dispatchAggregateEvents, dispatchAggregateEvents, dispatchEvent, dispatchEventToSubtree, getEventListeners, getImplementation, removeEventListener, saveEnclosingAttr, setEventListeners
 
Methods inherited from class org.apache.xerces.dom.CoreDocumentImpl
abort, adoptNode, canSetNormalizationFeature, changed, changes, clone, cloneNode, copyConfigurationProperties, createAttribute, createAttributeNS, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createDocumentType, createElement, createElementDefinition, createElementNS, createElementNS, createEntity, createEntityReference, createNotation, createProcessingInstruction, createTextNode, finalize, getActualEncoding, getAsync, getBaseURI, getDoctype, getDocumentElement, getDocumentURI, getElementById, getElementsByTagName, getElementsByTagNameNS, getEncoding, getErrorChecking, getErrorHandler, getIdentifier, getIdentifiers, getNodeName, getNodeType, getNormalizationFeature, getOwnerDocument, getStandalone, getStrictErrorChecking, getTextContent, getUserData, getUserData, getVersion, importNode, insertBefore, isKidOK, isNormalizeDocRequired, isXMLName, load, loadXML, normalizeDocument, putIdentifier, removeChild, removeIdentifier, renameNode, replaceChild, saveXML, setActualEncoding, setAsync, setDocumentURI, setEncoding, setErrorChecking, setErrorHandler, setNamespaceProcessing, setNormalizationFeature, setStandalone, setStrictErrorChecking, setTextContent, setUserData, setUserData, setVersion
 
Methods inherited from class org.apache.xerces.dom.ParentNode
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, normalize, setReadOnly, synchronizeChildren
 
Methods inherited from class org.apache.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSibling
 
Methods inherited from class org.apache.xerces.dom.NodeImpl
addEventListener, appendChild, compareTreePosition, dispatchEvent, getAttributes, getInterface, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, getUserData, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespacePrefix, lookupNamespaceURI, needsSyncChildren, removeEventListener, setNodeValue, setPrefix, setUserData, setUserData, synchronizeData, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, isSupported, normalize, setNodeValue, setPrefix
 

Field Detail

TAB_SIZE

public static final int TAB_SIZE
The amount each line is indented from the previous one when a DSMLDocumentImpl is serialized.

See Also:
Constant Field Values
Constructor Detail

DSMLDocumentImpl

public DSMLDocumentImpl()
When we create new DSML documents, this constructor ensures that they will automatically have the <dsml> node.

Method Detail

validate

public void validate()
              throws DSMLRefException
This function calls validate(this, null) on this Document.

DSMLRefException

validate

public static void validate(org.w3c.dom.Document xiDoc)
                     throws DSMLRefException
This function calls validate(xiDoc, null) on this Document - in other words, validation using the Document's schema.

Parameters:
xiDoc - The Document to validate
DSMLRefException

validate

public static void validate(org.w3c.dom.Document xiDoc,
                            netscape.ldap.LDAPSchema xiSchema)
                     throws DSMLRefException
This function checks the directory data in the passed in Document for consistency at a directory (rather than XML) level. Specifically, it checks that the following are true: The structure of a DSML document is best ascertained from the DSML spec, but in summary: The schema is denoted by two sorts of XML tag - <class>, representing an objectclass, and <attribute-type>, representing the definition of an attribute. The data is enclosed in <entry> tags.

It takes the following actions on finding invalid bits of DSML: In some situations (DSML2LDAP) the schema information we are validating against is in LDAP structure form, and in others it's in XML form, as part of the same document as the data. This function copes with both, taking a LPDASchema object as a parameter. If this is null, it uses the schema information in the Document instead. Doing things this way prevents converting a massive schema into Document form, passing it into validate() and then converting half of it back to work with.

We assume any schema we are given in LDAPSchema form has been retrieved from a directory, and so don't validate it. (It's in the wrong form to do so, anyway.)

Parameters:
xiDoc - The Document to validate
xiSchema - An LDAPSchema object representing the schema to validate against, or null to use the Document's schema.
Throws:
DSMLRefException - Thrown if, in the course of validation, we encounter a reference to an external schema. This makes continuing with validation impossible, as we might remove valid data.

serialize

public void serialize(java.io.OutputStream xiOut)
This method serializes this Document to the given OutputStream.


serialize

public static void serialize(org.w3c.dom.Document xiDoc,
                             java.io.OutputStream xiOut)
This method takes a Document and writes its contents as a stream of DSML to the given OutputStream.

Parameters:
xiDoc - Document to serialize
xiOut - OutputStream to serialize the document to