|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.odftoolkit.odfdom.pkg.OdfPackage
public class OdfPackage
OdfPackage represents the package view to an OpenDocument document. The OdfPackage will be created from an ODF document and represents a copy of the loaded document, where files can be inserted and deleted. The changes take effect, when the OdfPackage is being made persistend by save().
| Nested Class Summary | |
|---|---|
static class |
OdfPackage.OdfFile
|
| Method Summary | |
|---|---|
void |
close()
Close the OdfPackage after it is no longer needed. |
boolean |
contains(java.lang.String packagePath)
Check existence of a file in the package. |
java.lang.String |
getBaseURI()
Get the URI, where this ODF package is stored. |
byte[] |
getBytes(java.lang.String packagePath)
Get package (sub-) content as byte array |
org.w3c.dom.Document |
getDom(java.lang.String packagePath)
Gets org.w3c.dom.Document for XML file contained in package. |
org.xml.sax.EntityResolver |
getEntityResolver()
Get EntityResolver to be used in XML Parsers which can resolve content inside the OdfPackage |
java.util.Set<java.lang.String> |
getFileEntries()
Get a OdfFileEntries from the manifest file (i.e. |
OdfFileEntry |
getFileEntry(java.lang.String packagePath)
Get an OdfFileEntry for the packagePath NOTE: This method should be better moved to a DOM inherited Manifest class |
java.io.InputStream |
getInputStream()
Gets the InputStream containing whole OdfPackage. |
java.io.InputStream |
getInputStream(java.lang.String packagePath)
Get subcontent as InputStream |
java.lang.String |
getManifestAsString()
Get Manifest as String NOTE: This functionality should better be moved to a DOM based Manifest class |
java.util.HashMap<java.lang.String,OdfFileEntry> |
getManifestEntries()
|
java.lang.String |
getMediaType()
Get the media type of the ODF package (equal to media type of ODF root document) |
javax.xml.transform.URIResolver |
getURIResolver()
Get URIResolver to be used in XSL Transformations which can resolve content inside the OdfPackage |
boolean |
hasDom(java.lang.String packagePath)
returns true if a DOM tree has been requested for given sub-content of OdfPackage |
void |
insert(byte[] fileBytes,
java.lang.String packagePath,
java.lang.String mediaType)
Insert byte array into OdfPackage. |
void |
insert(org.w3c.dom.Document fileDOM,
java.lang.String packagePath,
java.lang.String mediaType)
Insert DOM tree into OdfPackage. |
void |
insert(java.io.InputStream fileStream,
java.lang.String packagePath,
java.lang.String mediaType)
Inserts InputStream into an OdfPackage. |
void |
insert(java.net.URI sourceURI,
java.lang.String packagePath,
java.lang.String mediaType)
Inserts InputStream into an OdfPackage. |
java.io.OutputStream |
insertOutputStream(java.lang.String packagePath)
Insert the OutputStream for into OdfPackage. |
java.io.OutputStream |
insertOutputStream(java.lang.String packagePath,
java.lang.String mediaType)
Insert the OutputStream - to be filled after method - when stream is closed into OdfPackage. |
static boolean |
isExternalReference(java.lang.String fileRef)
Checks if the given reference is a reference, which points outside the ODF package |
static OdfPackage |
loadPackage(java.io.File odfFile)
Loads an OdfPackage from the OpenDocument provided by a File. |
static OdfPackage |
loadPackage(java.io.InputStream odfStream)
Creates an OdfPackage from the OpenDocument provided by a InputStream. |
static OdfPackage |
loadPackage(java.lang.String odfPath)
Loads an OdfPackage from the given filePath. |
void |
remove(java.lang.String packagePath)
|
void |
save(java.io.File odfFile)
Save package to a given File. |
void |
save(java.io.OutputStream odfStream)
|
void |
save(java.lang.String odfPath)
Save the package to given filePath. |
void |
setMediaType(java.lang.String mediaType)
Set the media type of the ODF package (equal to media type of ODF root document) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static OdfPackage loadPackage(java.lang.String odfPath)
throws java.lang.Exception
OdfPackage relies on the file being available for read access over the whole lifecycle of OdfPackage.
odfPath - - the filePath to the ODF package
java.lang.Exception - - if the package could not be loaded
public static OdfPackage loadPackage(java.io.File odfFile)
throws java.lang.Exception
OdfPackage relies on the file being available for read access over the whole lifecycle of OdfPackage.
odfFile - - a File to loadPackage content from
java.lang.Exception - - if the package could not be loaded
public static OdfPackage loadPackage(java.io.InputStream odfStream)
throws java.lang.Exception
Since an InputStream does not provide the arbitrary (non sequentiell) read access needed by OdfPackage, the InputStream is cached. This usually takes more time compared to the other loadPackage methods.
odfStream - - an inputStream representing the ODF package
java.lang.Exception - - if the package could not be loadedpublic java.lang.String getBaseURI()
public java.lang.String getMediaType()
public void setMediaType(java.lang.String mediaType)
mediaType - string of this ODF packagepublic OdfFileEntry getFileEntry(java.lang.String packagePath)
packagePath - The relative package path within the ODF package
public java.util.Set<java.lang.String> getFileEntries()
public boolean contains(java.lang.String packagePath)
packagePath - The relative package filePath within the ODF package
public void save(java.lang.String odfPath)
throws java.lang.Exception
odfPath - - the path to the ODF package destination
java.lang.Exception - - if the package could not be saved
public void save(java.io.File odfFile)
throws java.lang.Exception
odfFile - - the File to save the ODF package to
java.lang.Exception - - if the package could not be saved
public void save(java.io.OutputStream odfStream)
throws java.lang.Exception
java.lang.Exceptionpublic void close()
public void insert(org.w3c.dom.Document fileDOM,
java.lang.String packagePath,
java.lang.String mediaType)
throws java.lang.Exception
fileDOM - - XML DOM tree to be inserted as filepackagePath - - relative filePath where the DOM tree should be inserted as
XML filemediaType - - media type of stream. Set to null if unknown
java.lang.Exception - when the DOM tree could not be insertedpublic boolean hasDom(java.lang.String packagePath)
packagePath - - a path inside the OdfPackage eg to a content.xml stream
public org.w3c.dom.Document getDom(java.lang.String packagePath)
throws org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException,
java.lang.Exception,
java.lang.IllegalArgumentException,
javax.xml.transform.TransformerConfigurationException,
javax.xml.transform.TransformerException
packagePath - - a path inside the OdfPackage eg to a content.xml stream
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.lang.Exception
java.lang.IllegalArgumentException
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException
public void insert(java.net.URI sourceURI,
java.lang.String packagePath,
java.lang.String mediaType)
throws java.lang.Exception
sourceURI - - the source URI to the file to be inserted into the package.mediaType - - media type of stream. Set to null if unknownpackagePath - - relative filePath where the tree should be inserted as XML
file
java.lang.Exception - In case the file could not be saved
public void insert(java.io.InputStream fileStream,
java.lang.String packagePath,
java.lang.String mediaType)
throws java.lang.Exception
fileStream - - the stream of the file to be inserted into the ODF package.mediaType - - media type of stream. Set to null if unknownpackagePath - - relative filePath where the tree should be inserted as XML
file
java.lang.Exception - In case the file could not be saved
public void insert(byte[] fileBytes,
java.lang.String packagePath,
java.lang.String mediaType)
throws java.lang.Exception
fileBytes - - data of the file stream to be stored in packagemediaType - - media type of stream. Set to null if unknownpackagePath - - relative filePath where the DOM tree should be inserted as
XML file
java.lang.Exception - when the DOM tree could not be insertedpublic java.util.HashMap<java.lang.String,OdfFileEntry> getManifestEntries()
public java.lang.String getManifestAsString()
public byte[] getBytes(java.lang.String packagePath)
throws java.lang.Exception
packagePath - relative filePath to the package content
java.lang.Exception
public java.io.InputStream getInputStream(java.lang.String packagePath)
throws java.lang.Exception
packagePath - of the desired stream.
java.lang.Exception
public java.io.InputStream getInputStream()
throws java.lang.Exception
java.lang.Exception - - if the package could not be read
public java.io.OutputStream insertOutputStream(java.lang.String packagePath)
throws java.lang.Exception
packagePath - - relative filePath where the DOM tree should be inserted as
XML file
java.lang.Exception - when the DOM tree could not be inserted
public java.io.OutputStream insertOutputStream(java.lang.String packagePath,
java.lang.String mediaType)
throws java.lang.Exception
packagePath - - relative filePath where the DOM tree should be inserted as
XML filemediaType - - media type of stream
java.lang.Exception - when the DOM tree could not be insertedpublic void remove(java.lang.String packagePath)
public static boolean isExternalReference(java.lang.String fileRef)
fileRef - the file reference to be checked
public org.xml.sax.EntityResolver getEntityResolver()
public javax.xml.transform.URIResolver getURIResolver()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||