org.jopendocument.dom
Class ODPackage

java.lang.Object
  extended by org.jopendocument.dom.ODPackage

public class ODPackage
extends Object

An OpenDocument package, ie a zip containing XML documents and their associated files.

Author:
ILM Informatique 2 août 2004

Constructor Summary
ODPackage()
           
ODPackage(File f)
           
ODPackage(InputStream ins)
           
ODPackage(ODPackage o)
           
 
Method Summary
 byte[] getBinaryFile(String entry)
           
 ODXMLDocument getContent()
           
 ContentTypeVersioned getContentType()
          The type of this package, null if it cannot be found (eg this package is empty).
protected  Object getData(String entry)
           
 org.jdom.Document getDocument(String xmlEntry)
          Return an XML document.
 Set<String> getEntries()
           
 ODPackageEntry getEntry(String entry)
           
 File getFile()
           
 ODMeta getMeta()
           
 String getMimeType()
           
 org.jdom.Element getStyle(org.jdom.Document referent, String family, String name)
          Find the passed automatic or common style.
 org.jdom.Element getStyle(String family, String name)
          Find the passed automatic or common style referenced from the content.
 XMLVersion getVersion()
          The version of this package, null if it cannot be found (eg this package is empty, or contains no xml).
 ODXMLDocument getXMLFile(org.jdom.Document doc)
           
 ODXMLDocument getXMLFile(String xmlEntry)
           
 boolean isSingle()
           
static boolean isStandardFile(String name)
          Whether the passed entry is specific to a package.
 void putFile(String entry, Object data)
           
 void putFile(String entry, Object data, String mediaType)
           
 void putFile(String entry, Object data, String mediaType, boolean compress)
           
 void rmFile(String entry)
           
 File save()
          Save the content of this package to our file, overwriting it if it exists.
 void save(OutputStream out)
           
 File saveAs(File fNoExt)
           
 void setFile(File f)
           
 ODSingleXMLDocument toSingle()
          Transform this to use a ODSingleXMLDocument.
 Map<String,String> validateSubDocuments()
          Call OOXML.isValid(Document) on each XML subdocuments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ODPackage

public ODPackage()

ODPackage

public ODPackage(InputStream ins)
          throws IOException
Throws:
IOException

ODPackage

public ODPackage(File f)
          throws IOException
Throws:
IOException

ODPackage

public ODPackage(ODPackage o)
Method Detail

isStandardFile

public static final boolean isStandardFile(String name)
Whether the passed entry is specific to a package.

Parameters:
name - a entry name, eg "mimetype"
Returns:
true if name is a standard file, eg true.

getFile

public final File getFile()

setFile

public final void setFile(File f)

getVersion

public final XMLVersion getVersion()
The version of this package, null if it cannot be found (eg this package is empty, or contains no xml).

Returns:
the version of this package, can be null.

getContentType

public final ContentTypeVersioned getContentType()
The type of this package, null if it cannot be found (eg this package is empty).

Returns:
the type of this package, can be null.

getMimeType

public final String getMimeType()

validateSubDocuments

public final Map<String,String> validateSubDocuments()
Call OOXML.isValid(Document) on each XML subdocuments.

Returns:
all problems indexed by subdocuments names, ie empty if all ok.

getEntries

public final Set<String> getEntries()

getEntry

public final ODPackageEntry getEntry(String entry)

getData

protected final Object getData(String entry)

getBinaryFile

public final byte[] getBinaryFile(String entry)

getXMLFile

public final ODXMLDocument getXMLFile(String xmlEntry)

getXMLFile

public final ODXMLDocument getXMLFile(org.jdom.Document doc)

getContent

public final ODXMLDocument getContent()

getMeta

public final ODMeta getMeta()

getDocument

public org.jdom.Document getDocument(String xmlEntry)
Return an XML document.

Parameters:
xmlEntry - the filename, eg "styles.xml".
Returns:
the matching document, or null if there's none.
Throws:
org.jdom.JDOMException - if error about the XML.
IOException - if an error occurs while reading the file.

getStyle

public final org.jdom.Element getStyle(String family,
                                       String name)
Find the passed automatic or common style referenced from the content.

Parameters:
family - the family, eg "paragraph".
name - the name, eg "P1".
Returns:
the corresponding XML element.

getStyle

public final org.jdom.Element getStyle(org.jdom.Document referent,
                                       String family,
                                       String name)
Find the passed automatic or common style. NOTE : referent is needed because there can exist automatic styles with the same name in both "content.xml" and "styles.xml".

Parameters:
referent - the document referencing the style.
family - the family, eg "paragraph".
name - the name, eg "P1".
Returns:
the corresponding XML element.
See Also:
ODXMLDocument.getStyle(String, String)

putFile

public void putFile(String entry,
                    Object data)

putFile

public void putFile(String entry,
                    Object data,
                    String mediaType)

putFile

public void putFile(String entry,
                    Object data,
                    String mediaType,
                    boolean compress)

rmFile

public void rmFile(String entry)

toSingle

public ODSingleXMLDocument toSingle()
Transform this to use a ODSingleXMLDocument. Ie after this method, only "content.xml" remains and it's an instance of ODSingleXMLDocument.

Returns:
the created ODSingleXMLDocument.

isSingle

public final boolean isSingle()

save

public final void save(OutputStream out)
                throws IOException
Throws:
IOException

save

public File save()
          throws IOException
Save the content of this package to our file, overwriting it if it exists.

Returns:
the saved file.
Throws:
IOException - if an error occurs while saving.

saveAs

public File saveAs(File fNoExt)
            throws IOException
Throws:
IOException


Copyright © 2010 jOpenDocument All Rights Reserved.