xArch/xADL 2.0 Data Binding Library

edu.uci.isr.xarch
Class DOMBasedXArchImplementation

java.lang.Object
  extended byedu.uci.isr.xarch.DOMBasedXArchImplementation
All Implemented Interfaces:
IXArchImplementation

public class DOMBasedXArchImplementation
extends Object
implements IXArchImplementation

This is the IXArchImplementation class that corresponds to the DOM-based data binding library. Documents created and manipulated by this implementation object will use an in-memory DOM model as their data store.

Author:
Eric M. Dashofy edashofy@ics.uci.edu

Constructor Summary
DOMBasedXArchImplementation()
           
 
Method Summary
 IXArch cloneXArch(IXArch xArch)
          Clone a DOM-based xArch document.
 IXArch cloneXArch(IXArch xArch, Object params)
          Clone a DOM-based xArch document.
 IXArchContext createContext(IXArch xArch, String contextType)
          Creates a new DOM-based context object for a given document and context type.
 IXArch createXArch()
          Creates a DOM-based XArch document.
 IXArch createXArch(Object params)
          Creates a DOM-based XArch document.
static DOMImplementation getDOMImplementation()
          Gets the DOMImplementation for the preferred parser.
 boolean isContainedIn(IXArch xArch, IXArchElement elt)
          Determines if a given IXArchElement is contained (a child of) a given IXArch.
 IXArch parse(Object documentSource)
          Parse a document into data bindings.
 String serialize(IXArch xArch, Object params)
          Serializes a DOM-based xArch document into XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMBasedXArchImplementation

public DOMBasedXArchImplementation()
Method Detail

getDOMImplementation

public static DOMImplementation getDOMImplementation()
Gets the DOMImplementation for the preferred parser.

Returns:
DOMImplementation object for the preferred parser.

createXArch

public IXArch createXArch()
Creates a DOM-based XArch document.

Specified by:
createXArch in interface IXArchImplementation
Returns:
Top-level element for new document.

createXArch

public IXArch createXArch(Object params)
Creates a DOM-based XArch document. Currently, the parameters passed are unused.

Specified by:
createXArch in interface IXArchImplementation
Parameters:
params - (unused).
Returns:
Top-level element for new document.

createContext

public IXArchContext createContext(IXArch xArch,
                                   String contextType)
Creates a new DOM-based context object for a given document and context type.

Specified by:
createContext in interface IXArchImplementation
Parameters:
xArch - Document for which to create the context object.
contextType - The type of context to create. For example, if the schema is called "types.xsd" then this should be "types".
Returns:
a context object.
Throws:
IllegalArgumentException - if the context type is invalid.

cloneXArch

public IXArch cloneXArch(IXArch xArch)
Clone a DOM-based xArch document.

Specified by:
cloneXArch in interface IXArchImplementation
Parameters:
xArch - Top-level element of the document to clone.
Returns:
Top-level element of cloned document.
Throws:
IllegalArgumentException - if the xArch document is not DOM-based.

cloneXArch

public IXArch cloneXArch(IXArch xArch,
                         Object params)
Clone a DOM-based xArch document. Currently, the parameters passed are unused.

Specified by:
cloneXArch in interface IXArchImplementation
Parameters:
xArch - Top-level element of the document to clone.
params - (unused).
Returns:
Top-level element of cloned document.
Throws:
IllegalArgumentException - if the xArch document is not DOM-based.

parse

public IXArch parse(Object documentSource)
             throws XArchParseException
Parse a document into data bindings. Valid sources for this implementation include a stream (java.io.Reader) or a DOM Document.

Specified by:
parse in interface IXArchImplementation
Parameters:
documentSource - The data source from which to parse.
Returns:
Top-level element of document.
Throws:
XArchParseException - if parsing failed for some reason. In the case of a Reader the chained exception will either be a SAXException or IOException.
IllegalArgumentException - if the document source was not supported.

isContainedIn

public boolean isContainedIn(IXArch xArch,
                             IXArchElement elt)
Determines if a given IXArchElement is contained (a child of) a given IXArch.

Specified by:
isContainedIn in interface IXArchImplementation
Parameters:
xArch - IXArch to check for the element.
elt - Element to check for parentage.
Returns:
true if the element is attached, false otherwise.

serialize

public String serialize(IXArch xArch,
                        Object params)
                 throws XArchSerializeException
Serializes a DOM-based xArch document into XML. Params are ignored in this implementation but may be supported in future versions.

Specified by:
serialize in interface IXArchImplementation
Parameters:
xArch - Top-level element of document to serialize.
params - (ignored)
Returns:
String representation of the given document in XML format.
Throws:
XArchSerializeException - if the serialization failed. In this implementation, the chained exception is generally a DOMException.

xArch/xADL 2.0 Data Binding Library