|
||||||||||
| 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 | |
|---|---|
boolean |
contains(String packagePath)
Check existence of a file in the package. |
String |
getBaseURI()
Get the URI, where this ODF package is stored. |
byte[] |
getBytes(String packagePath)
Get package (sub-) content as byte array |
Document |
getDom(String packagePath)
Gets org.w3c.dom.Document for XML file contained in package. |
EntityResolver |
getEntityResolver()
get EntityResolver to be used in XML Parsers which can resolve content inside the OdfPackage |
Set<String> |
getFileEntries()
Get a OdfFileEntries from the manifest file (i.e. |
OdfFileEntry |
getFileEntry(String packagePath)
Get an OdfFileEntry for the packagePath NOTE: This method should be better moved to a DOM inherited Manifest class |
InputStream |
getInputStream()
Gets the InputStream containing whole OdfPackage. |
InputStream |
getInputStream(String packagePath)
Get subcontent as InputStream |
String |
getMediaType()
Get the media type of the ODF package (equal to media type of ODF root document) |
URIResolver |
getURIResolver()
get URIResolver to be used in XSL Transformations which can resolve content inside the OdfPackage |
boolean |
hasDom(String packagePath)
returns true if a DOM tree has been requested for given sub-content of OdfPackage |
void |
insert(byte[] fileBytes,
String fileDestPath)
Insert byte array into OdfPackage. |
void |
insert(byte[] fileBytes,
String fileDestPath,
String mediaType)
Insert byte array into OdfPackage. |
void |
insert(Document fileDOM,
String packagePath)
Insert DOM tree into OdfPackage. |
void |
insert(Document fileDOM,
String packagePath,
String mediaType)
Insert DOM tree into OdfPackage. |
void |
insert(InputStream fileStream,
String packagePath)
Inserts InputStream into an OdfPackage. |
void |
insert(InputStream fileStream,
String packagePath,
String mediaType)
Inserts InputStream into an OdfPackage. |
void |
insert(URI sourceURI,
String packagePath)
Inserts InputStream into an OdfPackage. |
void |
insert(URI sourceURI,
String packagePath,
String mediaType)
Inserts InputStream into an OdfPackage. |
OutputStream |
insertOutputStream(String packagePath)
Insert the OutputStream for into OdfPackage. |
OutputStream |
insertOutputStream(String packagePath,
String mediaType)
Insert the OutputStream - to be filled after method - when stream is closed into OdfPackage. |
static boolean |
isExternalReference(String fileRef)
Checks if the given reference is a reference, which points outside the ODF package |
static OdfPackage |
loadPackage(File odfFile)
Loads an OdfPackage from the OpenDocument provided by a File. |
static OdfPackage |
loadPackage(InputStream odfStream)
Creates an OdfPackage from the OpenDocument provided by a InputStream. |
static OdfPackage |
loadPackage(String odfPath)
Loads an OdfPackage from the given filePath. |
void |
remove(String packagePath)
|
void |
save(File odfFile)
Save package to a given File. |
void |
save(OutputStream odfStream,
String baseURI)
Save an ODF document to the OutputStream. |
void |
save(String odfPath)
Save the package to given filePath. |
void |
setMediaType(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(String odfPath)
throws Exception
odfPath - - the filePath to the ODF package
Exception - - if the package could not be loaded
public static OdfPackage loadPackage(File odfFile)
throws Exception
odfFile - - a File to loadPackage content from
Exception - - if the package could not be loaded
public static OdfPackage loadPackage(InputStream odfStream)
throws Exception
odfStream - - an inputStream representing the ODF package
Exception - - if the package could not be loadedpublic String getBaseURI()
public String getMediaType()
public void setMediaType(String mediaType)
mediaType - string of this ODF packagepublic OdfFileEntry getFileEntry(String packagePath)
packagePath - The relative package path within the ODF package
public Set<String> getFileEntries()
public boolean contains(String packagePath)
packagePath - The relative package filePath within the ODF package
public void save(String odfPath)
throws Exception
odfPath - - the path to the ODF package destination
Exception - - if the package could not be saved
public void save(File odfFile)
throws Exception
odfFile - - the File to save the ODF package to
Exception - - if the package could not be saved
public void save(OutputStream odfStream,
String baseURI)
throws Exception
odfStream - - the OutputStream to insert content tobaseURI - - a URI for the package to be stored
Exception - - if the package could not be saved
public void insert(Document fileDOM,
String packagePath)
throws Exception
fileDOM - - XML DOM tree to be inserted as filepackagePath - - relative filePath where the DOM tree should be inserted as XML file
Exception - when the DOM tree could not be inserted
public void insert(Document fileDOM,
String packagePath,
String mediaType)
throws 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
Exception - when the DOM tree could not be insertedpublic boolean hasDom(String packagePath)
packagePath - - a path inside the OdfPackage eg to a content.xml stream
public Document getDom(String packagePath)
throws SAXException,
ParserConfigurationException,
Exception,
IllegalArgumentException,
TransformerConfigurationException,
TransformerException
packagePath - - a path inside the OdfPackage eg to a content.xml stream
SAXException
ParserConfigurationException
Exception
IllegalArgumentException
TransformerConfigurationException
TransformerException
public void insert(URI sourceURI,
String packagePath)
throws Exception
sourceURI - - the source URI to the file to be inserted into the package.packagePath - - relative filePath where the tree should be inserted as XML file
Exception - In case the file could not be saved
public void insert(URI sourceURI,
String packagePath,
String mediaType)
throws 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
Exception - In case the file could not be saved
public void insert(InputStream fileStream,
String packagePath)
throws Exception
fileStream - - the stream of the file to be inserted into the ODF package.packagePath - - relative filePath where the tree should be inserted as XML file
Exception - In case the file could not be saved
public void insert(InputStream fileStream,
String packagePath,
String mediaType)
throws 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
Exception - In case the file could not be saved
public void insert(byte[] fileBytes,
String fileDestPath)
throws Exception
fileBytes - - data of the file stream to be stored in packagefileDestPath - - relative filePath where the DOM tree should be inserted as XML file
Exception - when the DOM tree could not be inserted
public void insert(byte[] fileBytes,
String fileDestPath,
String mediaType)
throws Exception
fileBytes - - data of the file stream to be stored in packagemediaType - - media type of stream. Set to null if unknownfileDestPath - - relative filePath where the DOM tree should be inserted as XML file
Exception - when the DOM tree could not be inserted
public byte[] getBytes(String packagePath)
throws Exception
packagePath - relative filePath to the package content
Exception
public InputStream getInputStream(String packagePath)
throws Exception
packagePath - of the desired stream.
Exception
public InputStream getInputStream()
throws Exception
Exception - - if the package could not be read
public OutputStream insertOutputStream(String packagePath)
throws Exception
packagePath - - relative filePath where the DOM tree should be inserted as XML file
Exception - when the DOM tree could not be inserted
public OutputStream insertOutputStream(String packagePath,
String mediaType)
throws Exception
packagePath - - relative filePath where the DOM tree should be inserted as XML filemediaType - - media type of stream
Exception - when the DOM tree could not be insertedpublic void remove(String packagePath)
public static boolean isExternalReference(String fileRef)
fileRef - the file reference to be checked
public EntityResolver getEntityResolver()
public URIResolver getURIResolver()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||