Package org.openpreservation.odf.pkg
Class OdfPackages
java.lang.Object
org.openpreservation.odf.pkg.OdfPackages
A static utility class for general ODF package parsing.
The class doubles as a lightweight factory as well as
providing useful constants and utility methods.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The ODF specified name of the mimetype zip entry.static final String
The ODF specified name of the package META-INF directory.static final String
The ODF specified path to the package manifest.static final String
The ODF specified path to a PNG thumbnail file. -
Method Summary
Modifier and TypeMethodDescriptionstatic final PackageParser
A factory method forPackageParser
instances.static final boolean
Check if the givenString
is an ODF spec compliant Digital Signature path.static final boolean
Check if the passedString
path is an ODF specified XML file name.static final boolean
isValidZip
(Path toCheck) Check if the suppliedPath
resolves to a valid zip archive instance.static final boolean
Uses theFormatSniffer
to see if the supplied path resolves to a ZIP instance.
-
Field Details
-
MIMETYPE
The ODF specified name of the mimetype zip entry.- See Also:
-
NAME_META_INF
The ODF specified name of the package META-INF directory.- See Also:
-
PATH_MANIFEST
The ODF specified path to the package manifest.- See Also:
-
PATH_THUMBNAIL
The ODF specified path to a PNG thumbnail file.- See Also:
-
-
Method Details
-
getPackageParser
A factory method forPackageParser
instances.- Returns:
- a new
PackageParser
instance - Throws:
ParserConfigurationException
- if there's an issue configuring the underlying XML parserSAXException
- if there's an issue creating the underlying XML parser
-
isZip
Uses theFormatSniffer
to see if the supplied path resolves to a ZIP instance. This check only tests the file header bytes and doesn't parse the resolved path to ensure the zip is valid. SeeisValidZip(Path)
for that.- Parameters:
toCheck
- aPath
to sniff as a zip file
- Returns:
true
if the supplied path has a zip signature,false
otherwise.- Throws:
IOException
- if there's an issue reading the resolvedPath
-
isValidZip
Check if the suppliedPath
resolves to a valid zip archive instance. This is a full library parse of the resolvedPath
.
- Parameters:
toCheck
- aPath
to resolve and test- Returns:
true
if the supplied path resolves to a valid zip file, elsefalse
.- Throws:
IOException
- if there's an issue reading the resolvedPath
-
isDsig
Check if the givenString
is an ODF spec compliant Digital Signature path.- Parameters:
path
- theString
path to check- Returns:
true
ifpath
is a valid dsig path, elsefalse
.
-
isOdfXml
Check if the passedString
path is an ODF specified XML file name. This is the list of ODF specified XML files:- content.xml
- styles.xml
- meta.xml
- settings.xml
- manifest.rdf
- Parameters:
entrypath
- aString
file path to check- Returns:
true
ifentryPath
is an ODF specified XML file name, elsefalse
.
-