org.cdmckay.coffeedom.adapters
Class AbstractDOMAdapter

java.lang.Object
  extended by org.cdmckay.coffeedom.adapters.AbstractDOMAdapter
All Implemented Interfaces:
DOMAdapter
Direct Known Subclasses:
CrimsonDOMAdapter, JAXPDOMAdapter, OracleV1DOMAdapter, OracleV2DOMAdapter, XercesDOMAdapter, XML4JDOMAdapter

public abstract class AbstractDOMAdapter
extends Object
implements DOMAdapter

A DOMAdapter utility abstract base class.

Author:
Brett McLaughlin, Jason Hunter

Constructor Summary
AbstractDOMAdapter()
           
 
Method Summary
abstract  Document createDocument()
          This creates an empty Document object based on a specific parser implementation.
 Document createDocument(DocType doctype)
          This creates an empty Document object based on a specific parser implementation with the given DOCTYPE.
 Document getDocument(File filename, boolean validate)
          This creates a new Document from an existing InputStream by letting a DOM parser handle parsing using the supplied stream.
abstract  Document getDocument(InputStream in, boolean validate)
          This creates a new Document from an existing InputStream by letting a DOM parser handle parsing using the supplied stream.
protected  void setInternalSubset(DocumentType dt, String s)
          This attempts to change the DocumentType to have the given internal DTD subset value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDOMAdapter

public AbstractDOMAdapter()
Method Detail

getDocument

public Document getDocument(File filename,
                            boolean validate)
                     throws IOException,
                            CoffeeDOMException
This creates a new Document from an existing InputStream by letting a DOM parser handle parsing using the supplied stream.

Specified by:
getDocument in interface DOMAdapter
Parameters:
filename - file to parse.
validate - boolean to indicate if validation should occur.
Returns:
Document - instance ready for use.
Throws:
IOException - when I/O error occurs.
CoffeeDOMException - when errors occur in parsing.

getDocument

public abstract Document getDocument(InputStream in,
                                     boolean validate)
                              throws IOException,
                                     CoffeeDOMException
This creates a new Document from an existing InputStream by letting a DOM parser handle parsing using the supplied stream.

Specified by:
getDocument in interface DOMAdapter
Parameters:
in - InputStream to parse.
validate - boolean to indicate if validation should occur.
Returns:
Document - instance ready for use.
Throws:
IOException - when I/O error occurs.
CoffeeDOMException - when errors occur in parsing.

createDocument

public abstract Document createDocument()
                                 throws CoffeeDOMException
This creates an empty Document object based on a specific parser implementation.

Specified by:
createDocument in interface DOMAdapter
Returns:
Document - created DOM Document.
Throws:
CoffeeDOMException - when errors occur.

createDocument

public Document createDocument(DocType doctype)
                        throws CoffeeDOMException
This creates an empty Document object based on a specific parser implementation with the given DOCTYPE. If the doctype parameter is null, the behavior is the same as calling createDocument().

Specified by:
createDocument in interface DOMAdapter
Parameters:
doctype - Initial DocType of the document.
Returns:
Document - created DOM Document.
Throws:
CoffeeDOMException - when errors occur.

setInternalSubset

protected void setInternalSubset(DocumentType dt,
                                 String s)
This attempts to change the DocumentType to have the given internal DTD subset value. This is not a standard ability in DOM, so it's only available with some parsers. Subclasses can alter the mechanism by which the attempt is made to set the value.

Parameters:
dt - DocumentType to be altered
s - String to use as the internal DTD subset


Copyright © 2011. All Rights Reserved.