|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jopendocument.dom.ODPackage
public class ODPackage
An OpenDocument package, ie a zip containing XML documents and their associated files.
Nested Class Summary | |
---|---|
static class |
ODPackage.RootElement
Root element of an OpenDocument document. |
Constructor Summary | |
---|---|
ODPackage()
|
|
ODPackage(File f)
|
|
ODPackage(InputStream ins)
Read from the input stream into memory and close it. |
|
ODPackage(ODPackage o)
|
Method Summary | |
---|---|
Set<String> |
addBasicLibraries(Collection<? extends Library> libraries)
Add the passed libraries to this package. |
Set<String> |
addBasicLibraries(ODPackage pkg)
|
String |
checkStyles()
Verify that styles referenced by this document are indeed defined. |
void |
clear()
|
static ODPackage |
createFromDocuments(ContentTypeVersioned type,
org.jdom.Document content,
org.jdom.Document style,
org.jdom.Document meta,
org.jdom.Document settings)
|
static ODPackage |
createFromDocuments(org.jdom.Document content,
org.jdom.Document style)
Create a package from a collection of sub-documents. |
static ODPackage |
createFromFile(File f)
|
static ODPackage |
createFromStream(InputStream ins,
String name)
Read from the input stream into memory and close it. |
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.Element |
getDefaultStyle(StyleStyleDesc<?> desc,
boolean create)
|
org.jdom.Document |
getDocument(String xmlEntry)
Return an XML document. |
Set<String> |
getEntries()
|
ODPackageEntry |
getEntry(String entry)
|
File |
getFile()
|
XMLFormatVersion |
getFormatVersion()
|
ODMeta |
getMeta()
|
ODMeta |
getMeta(boolean create)
|
String |
getMimeType()
|
ODDocument |
getODDocument()
|
static String |
getPageCount()
|
SpreadSheet |
getSpreadSheet()
|
org.jdom.Element |
getStyle(org.jdom.Document referent,
StyleDesc<?> desc,
String name)
Find the passed automatic or common style. |
org.jdom.Element |
getStyle(StyleDesc<?> desc,
String name)
Find the passed automatic or common style referenced from the content. |
ODXMLDocument |
getStyles()
The XML document where are located the common styles. |
TextDocument |
getTextDocument()
|
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 |
hasODDocument()
|
boolean |
isSingle()
|
static boolean |
isStandardFile(String name)
Whether the passed entry is specific to a package. |
boolean |
isTemplate()
|
void |
putCopy(ODPackageEntry entry)
|
void |
putCopy(ODPackageEntry entry,
String entryName)
|
void |
putFile(String entry,
Object data)
|
void |
putFile(String entry,
Object data,
String mediaType)
|
void |
putFile(String entry,
Object data,
String mediaType,
boolean compress)
|
Map<String,Library> |
readBasicLibraries()
Parse BASIC libraries in this package. |
Map<String,EventListener> |
readEventListeners()
Parse events for the whole document. |
Set<String> |
removeBasicLibraries(Collection<String> libraries)
Remove the passed libraries. |
void |
rmFile(String entry)
|
void |
rmFiles(Collection<String> entries)
|
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 |
setContentType(ContentTypeVersioned newType)
|
void |
setFile(File f)
|
static void |
setPageCount(int count)
Allow to specify a fixed number of pages for all text documents. |
void |
setTemplate(boolean b)
|
boolean |
split()
Split the ODPackage.RootElement.SINGLE_CONTENT . |
ODSingleXMLDocument |
toSingle()
Transform this to use a ODSingleXMLDocument . |
Map<String,String> |
validateSubDocuments()
Call Validator.isValid() on each XML subdocuments. |
Map<String,String> |
validateSubDocuments(boolean allowChangeToValidate)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ODPackage()
public ODPackage(InputStream ins) throws IOException
ins
- the package.
IOException
- if ins
couldn't be read.public ODPackage(File f) throws IOException
IOException
public ODPackage(ODPackage o)
Method Detail |
---|
public static final void setPageCount(int count)
count
- page count, negative means remove.public static final String getPageCount()
public static final boolean isStandardFile(String name)
name
- a entry name, eg "mimetype"
true
if name
is a standard file, eg true
.public static ODPackage createFromDocuments(org.jdom.Document content, org.jdom.Document style)
content
- the content.style
- the styles, can be null
.
public static ODPackage createFromDocuments(ContentTypeVersioned type, org.jdom.Document content, org.jdom.Document style, org.jdom.Document meta, org.jdom.Document settings)
public static ODPackage createFromStream(InputStream ins, String name) throws IOException
ins
- the package or flat XML.name
- the name, can be null
.
IOException
- if an error occurs.public static ODPackage createFromFile(File f) throws IOException
IOException
public final File getFile()
public final void setFile(File f)
public final XMLVersion getVersion()
null
if it cannot be found (eg this package is
empty, or contains no xml).
null
.public final XMLFormatVersion getFormatVersion()
public final ContentTypeVersioned getContentType()
null
if it cannot be found (eg this package is empty).
null
.public final void setContentType(ContentTypeVersioned newType)
public final String getMimeType()
public final boolean isTemplate()
public final void setTemplate(boolean b)
public final Map<String,String> validateSubDocuments()
Validator.isValid()
on each XML subdocuments.
null
if validation couldn't occur.public final Map<String,String> validateSubDocuments(boolean allowChangeToValidate)
public final ODDocument getODDocument()
public final boolean hasODDocument()
public final SpreadSheet getSpreadSheet()
public final TextDocument getTextDocument()
public final Set<String> getEntries()
public final ODPackageEntry getEntry(String entry)
protected final Object getData(String entry)
public final byte[] getBinaryFile(String entry)
public final ODXMLDocument getXMLFile(String xmlEntry)
public final ODXMLDocument getXMLFile(org.jdom.Document doc)
public final ODXMLDocument getStyles()
public final ODXMLDocument getContent()
public final ODMeta getMeta()
public final ODMeta getMeta(boolean create)
public final Map<String,Library> readBasicLibraries()
public final Set<String> addBasicLibraries(Collection<? extends Library> libraries)
libraries
- what to add.
IllegalArgumentException
- if libraries
contains duplicates or if it
cannot be merged into this.Library.canBeMerged(Library)
public final Set<String> addBasicLibraries(ODPackage pkg)
public final Set<String> removeBasicLibraries(Collection<String> libraries)
libraries
- which libraries to remove.
public final Map<String,EventListener> readEventListeners()
public org.jdom.Document getDocument(String xmlEntry)
xmlEntry
- the filename, eg "styles.xml".
null
if there's none.
org.jdom.JDOMException
- if error about the XML.
IOException
- if an error occurs while reading the file.public final org.jdom.Element getStyle(StyleDesc<?> desc, String name)
desc
- the family, eg StyleStyleDesc<ParagraphStyle>
.name
- the name, eg "P1".
public final org.jdom.Element getStyle(org.jdom.Document referent, StyleDesc<?> desc, String name)
referent
is needed because
there can exist automatic styles with the same name in both "content.xml" and "styles.xml".
referent
- the document referencing the style.desc
- the family, eg StyleStyleDesc<ParagraphStyle>
.name
- the name, eg "P1".
ODXMLDocument.getStyle(StyleDesc, String, Document)
public final org.jdom.Element getDefaultStyle(StyleStyleDesc<?> desc, boolean create)
public final String checkStyles()
null
if no problem has been found, else a String describing it.public void putFile(String entry, Object data)
public void putFile(String entry, Object data, String mediaType)
public void putFile(String entry, Object data, String mediaType, boolean compress)
public final void putCopy(ODPackageEntry entry)
public final void putCopy(ODPackageEntry entry, String entryName)
public void rmFile(String entry)
public final void rmFiles(Collection<String> entries)
public void clear()
public ODSingleXMLDocument toSingle()
ODSingleXMLDocument
. Ie after this method, only "content.xml"
remains and it's an instance of ODSingleXMLDocument.
public final boolean isSingle()
public final boolean split()
ODPackage.RootElement.SINGLE_CONTENT
. If this was single
the
former content
won't be useable anymore, you can check it with
ODSingleXMLDocument.isDead()
.
true
if this was modified.public final void save(OutputStream out) throws IOException
IOException
public File save() throws IOException
IOException
- if an error occurs while saving.public File saveAs(File fNoExt) throws IOException
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |