Class OdfPackages

java.lang.Object
org.openpreservation.odf.pkg.OdfPackages

public final class OdfPackages extends Object
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 Details

    • MIMETYPE

      public static final String MIMETYPE
      The ODF specified name of the mimetype zip entry.
      See Also:
    • NAME_META_INF

      public static final String NAME_META_INF
      The ODF specified name of the package META-INF directory.
      See Also:
    • PATH_MANIFEST

      public static final String PATH_MANIFEST
      The ODF specified path to the package manifest.
      See Also:
    • PATH_THUMBNAIL

      public static final String PATH_THUMBNAIL
      The ODF specified path to a PNG thumbnail file.
      See Also:
  • Method Details

    • getPackageParser

      public static final PackageParser getPackageParser()
      A factory method for PackageParser instances.
      Returns:
      a new PackageParser instance
      Throws:
      ParserConfigurationException - if there's an issue configuring the underlying XML parser
      SAXException - if there's an issue creating the underlying XML parser
    • isZip

      public static final boolean isZip(Path toCheck) throws IOException
      Uses the FormatSniffer 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. See isValidZip(Path) for that.
      Parameters:
      toCheck - a Path 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 resolved Path
    • isValidZip

      public static final boolean isValidZip(Path toCheck) throws IOException
      Check if the supplied Path resolves to a valid zip archive instance. This is a full library parse of the resolved Path.
      Parameters:
      toCheck - a Path to resolve and test
      Returns:
      true if the supplied path resolves to a valid zip file, else false.
      Throws:
      IOException - if there's an issue reading the resolved Path
    • isDsig

      public static final boolean isDsig(String path)
      Check if the given String is an ODF spec compliant Digital Signature path.
      Parameters:
      path - the String path to check
      Returns:
      true if path is a valid dsig path, else false.
    • isOdfXml

      public static final boolean isOdfXml(String entrypath)
      Check if the passed String 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 - a String file path to check
      Returns:
      true if entryPath is an ODF specified XML file name, else false.