org.jopendocument.dom
Class ODSingleXMLDocument

java.lang.Object
  extended by org.jopendocument.dom.ODXMLDocument
      extended by org.jopendocument.dom.ODSingleXMLDocument
All Implemented Interfaces:
Cloneable, ODDocument

public class ODSingleXMLDocument
extends ODXMLDocument
implements Cloneable, ODDocument

An XML document containing all of an office document, see section 2.1 of OpenDocument 1.1.

Author:
Sylvain CUAZ 24 nov. 2004

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jopendocument.dom.ODXMLDocument
ODXMLDocument.ElementTransformer
 
Field Summary
 
Fields inherited from class org.jopendocument.dom.ODXMLDocument
NOP_ElementTransformer
 
Constructor Summary
ODSingleXMLDocument(org.jdom.Document content)
           
 
Method Summary
 void add(org.jdom.Element where, int index, ODSingleXMLDocument doc)
           
 void add(ODSingleXMLDocument doc)
          Append a document.
 void add(ODSingleXMLDocument doc, boolean pageBreak)
          Append a document.
 void add(TextNode p)
          Append a paragraph or a heading.
 void add(TextNode p, org.jdom.Element where, int index)
           
 String checkStyles()
          Verify that styles referenced by this document are indeed defined.
 ODSingleXMLDocument clone()
           
static ODSingleXMLDocument createFromDocument(org.jdom.Document content, org.jdom.Document style)
          Create a document from a collection of subdocuments.
static ODSingleXMLDocument createFromDocument(org.jdom.Document content, org.jdom.Document style, org.jdom.Document settings)
           
static ODSingleXMLDocument createFromFile(File f)
          Create a document from a file.
protected  void detachDuplicate(org.jdom.Element elem)
          Detach the children of elem whose names already exist in the body.
 org.jdom.Element getBody()
           
 int getNumero()
          The number of files concatenated with add(ODSingleXMLDocument).
 ODPackage getPackage()
           
 void replace(org.jdom.Element elem, ODSingleXMLDocument doc)
           
 File saveAs(File f)
          Saves this OO document to a file.
 
Methods inherited from class org.jopendocument.dom.ODXMLDocument
add, add, addAutoStyle, addIfNotPresent, addIfNotPresent, asString, findUnusedName, getChild, getChild, getDescendant, getDescendant, getDescendantByName, getDescendantByName, getDocument, getNamedElements, getStyle, getVersion, getXPath, isValid, mergeAll, mergeAll, setChild
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jopendocument.dom.ODDocument
getVersion
 

Constructor Detail

ODSingleXMLDocument

public ODSingleXMLDocument(org.jdom.Document content)
Method Detail

createFromDocument

public static ODSingleXMLDocument createFromDocument(org.jdom.Document content,
                                                     org.jdom.Document style)
Create a document from a collection of subdocuments.

Parameters:
content - the content.
style - the styles, can be null.
Returns:
the merged document.

createFromDocument

public static ODSingleXMLDocument createFromDocument(org.jdom.Document content,
                                                     org.jdom.Document style,
                                                     org.jdom.Document settings)

createFromFile

public static ODSingleXMLDocument createFromFile(File f)
                                          throws org.jdom.JDOMException,
                                                 IOException
Create a document from a file.

Parameters:
f - an OpenDocument package file.
Returns:
the merged file.
Throws:
org.jdom.JDOMException - if the file is not a valid OpenDocument file.
IOException - if the file can't be read.
See Also:
createFromDocument(Document, Document)

clone

public ODSingleXMLDocument clone()
Overrides:
clone in class Object

getNumero

public final int getNumero()
The number of files concatenated with add(ODSingleXMLDocument).

Returns:
number of files concatenated.

getPackage

public ODPackage getPackage()
Specified by:
getPackage in interface ODDocument

add

public void add(TextNode p)
Append a paragraph or a heading.

Parameters:
p - paragraph to add.

add

public void add(TextNode p,
                org.jdom.Element where,
                int index)

add

public void add(ODSingleXMLDocument doc)
Append a document.

Parameters:
doc - the document to add.

add

public void add(ODSingleXMLDocument doc,
                boolean pageBreak)
Append a document.

Parameters:
doc - the document to add, null means no-op.
pageBreak - whether a page break should be inserted before doc.

replace

public void replace(org.jdom.Element elem,
                    ODSingleXMLDocument doc)

add

public void add(org.jdom.Element where,
                int index,
                ODSingleXMLDocument doc)

detachDuplicate

protected final void detachDuplicate(org.jdom.Element elem)
                              throws org.jdom.JDOMException
Detach the children of elem whose names already exist in the body.

Parameters:
elem - the elem to be trimmed.
Throws:
org.jdom.JDOMException - if an error occurs.

getBody

public final org.jdom.Element getBody()

checkStyles

public final String checkStyles()
Verify that styles referenced by this document are indeed defined. NOTE this method is not perfect : not all problems are detected.

Returns:
null if no problem has been found, else a String describing it.

saveAs

public File saveAs(File f)
            throws IOException
Saves this OO document to a file.

Parameters:
f - the file where this document will be saved, without extension, eg "dir/myfile".
Returns:
the actual file where it has been saved (with extension), eg "dir/myfile.odt".
Throws:
IOException - if an error occurs.


Copyright © 2010 jOpenDocument All Rights Reserved.