Package writer2latex.base

# Class DOMDocument

java.lang.Object
writer2latex.base.DOMDocument

All Implemented Interfaces:
  `OutputFile`

Direct Known Subclasses:
  `ContainerWriter`, `NavigationWriter`, `NCXWriter`, `OPFWriter`, `XhtmlDocument`

public class DOMDocument extends Object implements OutputFile
This class represents XML-based documents. It is loosely based on a class from the former xmerge project from OOo.

## Constructor Summary

Constructors
Constructor
Description
`DOMDocument(String name, String ext)`
Default constructor.
`DOMDocument(String name, String ext, boolean namespaceAware, boolean validating)`
Constructor with arguments to set `namespaceAware` and `validating` flags.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`containsMath()`
Test whether this document contains mathematical formulas
`Document`
`getContentDOM()`
Return a DOM `Document` object of the document content file.
`protected String`
`getFileExtension()`
Returns the file extension of the `Document` represented.
`String`
`getFileName()`
Return the file name of the `Document`, possibly with the standard extension.
`String`
`getMIMEType()`
Get the MIME type of the `OutputFile`.
`String`
`getName()`
Return the name of the `Document`.
`final void`
`initContentDOM()`
Initializes a new DOM `Document` with the content containing minimum XML tags.
`boolean`
`isMasterDocument()`
Test whether this document is part of the main document flow (master documents) or an auxiliary document
`void`
`read(InputStream is)`
Read the Office `Document` from the specified `InputStream`.
`void`
`setContentDOM(Node newDom)`
Sets the Content of the `Document` to the contents of the supplied `Node` list.
`void`
`write(OutputStream os)`
Write out content to the supplied `OutputStream`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DOMDocument

public DOMDocument(String name, String ext)
Default constructor.

Parameters:
  `name` - `Document` name.
  `ext` - `Document` extension.

### DOMDocument

public DOMDocument(String name, String ext, boolean namespaceAware, boolean validating)
Constructor with arguments to set `namespaceAware` and `validating` flags.

Parameters:
  `name` - `Document` name (may or may not contain extension).
  `ext` - `Document` extension.
  `namespaceAware` - Value for `namespaceAware` flag.
  `validating` - Value for `validating` flag.

## Method Details

### getFileExtension

protected String getFileExtension()
Returns the file extension of the `Document` represented.

Returns:
  file extension of the `Document`.

### getContentDOM

public Document getContentDOM()
Return a DOM `Document` object of the document content file. Note that a content DOM is not created when the constructor is called. So, either the `read` method or the `initContentDOM` method will need to be called ahead on this object before calling this method.

Returns:
  DOM `Document` object.

### setContentDOM

public void setContentDOM(Node newDom)
Sets the Content of the `Document` to the contents of the supplied `Node` list.

Parameters:
  `newDom` - DOM `Document` object.

### getName

public String getName()
Return the name of the `Document`.

Returns:
  The name of `Document`.

### getFileName

public String getFileName()
Return the file name of the `Document`, possibly with the standard extension.

Specified by:
  `getFileName` in interface `OutputFile`
Returns:
  The file name of `Document`.

### read

public void read(InputStream is) throws IOException
Read the Office `Document` from the specified `InputStream`.

Parameters:
  `is` - Office document `InputStream`.
Throws:
  `IOException` - If any I/O error occurs.

### write

public void write(OutputStream os) throws IOException
Write out content to the supplied `OutputStream`. (with pretty printing)

Specified by:
  `write` in interface `OutputFile`
Parameters:
  `os` - XML `OutputStream`.
Throws:
  `IOException` - If any I/O error occurs.

### initContentDOM

public final void initContentDOM() throws IOException
Initializes a new DOM `Document` with the content containing minimum XML tags.

Throws:
  `IOException` - If any I/O error occurs.

### getMIMEType

public String getMIMEType()
Description copied from interface: `OutputFile`
Get the MIME type of the `OutputFile`.

Specified by:
  `getMIMEType` in interface `OutputFile`
Returns:
  string representation of the MIME type

### isMasterDocument

public boolean isMasterDocument()
Description copied from interface: `OutputFile`
Test whether this document is part of the main document flow (master documents) or an auxiliary document

Specified by:
  `isMasterDocument` in interface `OutputFile`
Returns:
  true if this document is a master document

### containsMath

public boolean containsMath()
Description copied from interface: `OutputFile`
Test whether this document contains mathematical formulas

Specified by:
  `containsMath` in interface `OutputFile`
Returns:
  true if the document contains formulas