Package org.openpreservation.odf.pkg
Interface OdfPackage
public interface OdfPackage
An interface defining the behaviour of ODF packages.
Most of the methods in this interface concern themselves
with the properties of the package needed for validation.
-
Method Summary
Modifier and TypeMethodDescriptionGet the detectedFormats
of the package.Get the detectedVersion
of the package.Get theOdfPackageDocument
for the package, this is the root document of the ODF PackagegetEntryStream
(FileEntry entry) Get theInputStream
for any item from the document'sManifest
getEntryXmlParseResult
(String path) Get the XMLParseResult
of and identified ODF XML documents in the packagegetEntryXmlStream
(String path) Get theInputStream
to any of an identified ODF XML document in the packageGet theManifest
object for the package, this is parsed as long as theMETA-INF/manifest.xml
file exists and is a well formed XML document.Retrieve theMap
ofString
path keys andParseResult
values for anyZipEntry
below theMETA-INF
directory.Get the declaredmimetype
of the package.getName()
Get the name or identifier of the package, often the path to the file parsed.getSubDocument
(String path) Get anOdfPackageDocument
for a sub-document identified by the passedString
path.Get theSet
ofFileEntry
to all of the identified ODF XML documents in the package.Get aList
paths of the package's identified ODF XML documents.Returns the details of the underlyingZipArchive
for the package.boolean
Does the META-INF directory or sub-directories contain aZipeEntry
with the term "signatures" in its name.boolean
Does the package have a manifest, that is aZipEntry
with the pathMETA-INF/manifest.xml
?boolean
Does the package have amimetype
ZipEntry
?boolean
Does the package have aZipEntry
with the pathThumbnails/thumbnail.png
?boolean
Discover if the package had any encrypted entries.boolean
Discover if the file uses any namespaces outside of the ODF specification.boolean
Is themimetype
ZipEntry
the firstZipEntry
in the package?boolean
Is the item parsed a well formedZipArchive
.
-
Method Details
-
getName
String getName()Get the name or identifier of the package, often the path to the file parsed.- Returns:
- the
String
name of the package
-
getDetectedFormat
Formats getDetectedFormat()Get the detectedFormats
of the package. This is the format detected by format sniffing and may not be the actual ODF type depending on anymimetype
zip entry in the package.- Returns:
- the detected
Formats
of the package
-
getDetectedVersion
Version getDetectedVersion()Get the detectedVersion
of the package. -
isWellFormedZip
boolean isWellFormedZip()Is the item parsed a well formedZipArchive
.- Returns:
true
if the package is well formed, otherwisefalse
-
getMimeType
String getMimeType()Get the declaredmimetype
of the package. This is the mimetype declared in themimetype
ZipEntry
and/or themanifest
's root("/")FileEntry
. This may differ from the detected format.- Returns:
- the declared mimetype of the package
-
hasMimeEntry
boolean hasMimeEntry()Does the package have amimetype
ZipEntry
?- Returns:
true
if the package has amimetype
ZipEntry
, otherwisefalse
-
isMimeFirst
boolean isMimeFirst()Is themimetype
ZipEntry
the firstZipEntry
in the package?- Returns:
true
if themimetype
ZipEntry
is the first entry in the package'sZipArchive
, otherwisefalse
-
hasManifest
boolean hasManifest()Does the package have a manifest, that is aZipEntry
with the pathMETA-INF/manifest.xml
?- Returns:
true
if the package has a manifest, otherwisefalse
-
hasThumbnail
boolean hasThumbnail()Does the package have aZipEntry
with the pathThumbnails/thumbnail.png
?- Returns:
true
if the package has a thumbnail previewZipEntry
, otherwisefalse
-
getZipArchive
ZipArchive getZipArchive()Returns the details of the underlyingZipArchive
for the package.- Returns:
- the package
ZipAchive
-
getManifest
Manifest getManifest()Get theManifest
object for the package, this is parsed as long as theMETA-INF/manifest.xml
file exists and is a well formed XML document.- Returns:
- the package
Manifest
-
getEntryXmlStream
Get theInputStream
to any of an identified ODF XML document in the package- Parameters:
path
- the internalString
path to the XML document- Returns:
- the
InputStream
to the XML document - Throws:
IOException
- when there's a problem reading the entry with the suppliedpath
-
getEntryXmlParseResult
Get the XMLParseResult
of and identified ODF XML documents in the package- Parameters:
path
- the internalString
package path to the XML document- Returns:
- the
ParseResult
returned from parsing the XML document with the suppliedpath
. - Throws:
IOException
- when there's a problem reading the entry with the suppliedpath
.
-
getXmlEntryPaths
Get aList
paths of the package's identified ODF XML documents. These will be all paths to files with the following names:- content.xml
- styles.xml
- meta.xml
- settings.xml
- manifest.rdf
- Returns:
- a
List
of all of the String internal paths to the packge ODF XML documents
-
getXmlEntries
Get theSet
ofFileEntry
to all of the identified ODF XML documents in the package. SeegetXmlEntryPaths()
for the list of XML documents.- Returns:
- a
Set
of all of the identified ODF XML documents in the package.
-
getEntryStream
Get theInputStream
for any item from the document'sManifest
- Parameters:
entry
- theManifest
FileEntry
to get theInputStream
for- Returns:
- the
InputStream
for the FileEntry supplied - Throws:
IOException
- when there's a problem reading theFileEntry
.
-
getDocument
OdfPackageDocument getDocument()Get theOdfPackageDocument
for the package, this is the root document of the ODF Package- Returns:
- the package's root
OdfPackageDocument
-
getDocumentMap
Map<String,OdfPackageDocument> getDocumentMap()- Returns:
- the
Map
ofOdfPackageDocument
Sub-Documents for the package.
-
getSubDocument
Get anOdfPackageDocument
for a sub-document identified by the passedString
path.- Parameters:
path
- the internalString
path to the sub-document- Returns:
- the
OdfPackageDocument
for the sub-document
-
getMetaInfMap
Map<String,ParseResult> getMetaInfMap()Retrieve theMap
ofString
path keys andParseResult
values for anyZipEntry
below theMETA-INF
directory.- Returns:
- the
Map
of META-INFString
paths and XMLParseResults
.
-
hasDsigEntries
boolean hasDsigEntries()Does the META-INF directory or sub-directories contain aZipeEntry
with the term "signatures" in its name.- Returns:
true
if the package has Digital Signature entries, otherwisefalse
.
-
isExtended
boolean isExtended()Discover if the file uses any namespaces outside of the ODF specification.- Returns:
- true if the file uses any namespaces outside of the ODF
-
isEncrypted
boolean isEncrypted()Discover if the package had any encrypted entries.- Returns:
- true if the package has encrypted entries
-