org.apache.uima.pear.tools

## Class PackageBrowser

- java.lang.Object
- - org.apache.uima.pear.tools.PackageBrowser

-     public class PackageBrowser
      extends Object

  The `PackageBrowser` class allows browsing both archived and unarchived PEAR packages, finding package files and directories, loading installation descriptor files and returning run-time environment settings required for installed components.
  See Also:
    `InstallationDescriptor`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `BINARY_DIR`
    `static String` | `CONFIGURATION_DIR`
    `static String` | `DATA_DIR`
    `static String` | `DESCRIPTORS_DIR`
    `static String` | `DOCUMENTATION_DIR`
    `static String` | `INSTALLATION_DESCRIPTOR_FILE`
    `static String` | `LIBRARY_DIR`
    `static String` | `METADATA_DIR`
    `static String` | `PEAR_PROPERTIES_FILE`
    `static String` | `RESOURCES_DIR`
    `static String` | `SETENV_TXT_FILE`
    `static String` | `SOURCES_DIR`
    `static String` | `SUBMISSION_PROPERTIES_FILE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PackageBrowser(File pearPackageDir)` Constructor that allows browsing a given unacrhived PEAR package before or after its installation.
    `PackageBrowser(JarFile pearPackage)` Constructor that allows browsing a given PEAR package without unarchiving it.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `buildComponentClassPath()` Creates a string that should be added to the CLASSPATH to run the given installed component, based on its installation descriptor specifications, as well as the contents of its `lib` directory.
    `String` | `buildComponentClassPath(boolean relativePath, boolean addLibDir)` Creates a string that should be added to the CLASSPATH to run the given installed component, based on its installation descriptor specifications, as well as the contents of its `lib` directory.
    `String` | `buildComponentPath()` Creates a string that should be added to the PATH to run the given installed component, based on the PEAR package defaults and its installation descriptor specifications.
    `String` | `buildComponentPath(boolean relativePath)` Creates a string that should be added to the PATH to run the given installed component, based on the PEAR package defaults and its installation descriptor specifications.
    `String` | `buildComponentRuntimeClassPath()` Like `buildComponentClassPath()`, but without all jars from the lib dir.
    `File[]` | `findDirectory(String dirNamePattern)` Looks for package directories matching a given directory name pattern in the PEAR package.
    `File[]` | `findFile(String fileNamePattern)` Looks for package files matching a given file name pattern in the PEAR package.
    `File` | `findStandardDirectory(String stdDirName)` Looks for a given standard package directory.
    `File` | `findStandardFile(String stdFileName)` Looks for a given standard package file.
    `File[]` | `getAllDirectories()`
    `File[]` | `getAllFiles()`
    `String` | `getComponentDataPath()` Returns the UIMA datapath setting for the component.
    `Properties` | `getComponentEnvVars()` Returns the environment variable settings for the component.
    `String` | `getComponentPearDescPath()` returns the pear component pearSpecifier file path.
    `InstallationDescriptor` | `getInstallationDescriptor()` Loads the `INSTALLATION_DESCRIPTOR_FILE` file, and creates the `InstallationDescriptor` (InsD) object.
    `File` | `getRootDirectory()`
    `boolean` | `isArchived()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BINARY_DIR

          public static final String BINARY_DIR

    - #### CONFIGURATION_DIR

          public static final String CONFIGURATION_DIR

    - #### DATA_DIR

          public static final String DATA_DIR

    - #### DESCRIPTORS_DIR

          public static final String DESCRIPTORS_DIR

    - #### DOCUMENTATION_DIR

          public static final String DOCUMENTATION_DIR

    - #### LIBRARY_DIR

          public static final String LIBRARY_DIR

    - #### METADATA_DIR

          public static final String METADATA_DIR

    - #### RESOURCES_DIR

          public static final String RESOURCES_DIR

    - #### SOURCES_DIR

          public static final String SOURCES_DIR

    - #### INSTALLATION_DESCRIPTOR_FILE

          public static final String INSTALLATION_DESCRIPTOR_FILE

    - #### PEAR_PROPERTIES_FILE

          public static final String PEAR_PROPERTIES_FILE

    - #### SUBMISSION_PROPERTIES_FILE

          public static final String SUBMISSION_PROPERTIES_FILE

    - #### SETENV_TXT_FILE

          public static final String SETENV_TXT_FILE

  - ### Constructor Detail

    - #### PackageBrowser

          public PackageBrowser(JarFile pearPackage)
                         throws IOException

      Constructor that allows browsing a given PEAR package without unarchiving it.
      Parameters:
        `pearPackage` - The given archived PEAR package to browse.
      Throws:
        `IOException` - if a problem with IO

    - #### PackageBrowser

          public PackageBrowser(File pearPackageDir)
                         throws IOException

      Constructor that allows browsing a given unacrhived PEAR package before or after its installation.
      Parameters:
        `pearPackageDir` - The root directory where the PEAR package was unarchived.
      Throws:
        `IOException` - if a problem with IO

  - ### Method Detail

    - #### buildComponentClassPath

          public String buildComponentClassPath()
                                         throws IOException

      Creates a string that should be added to the CLASSPATH to run the given installed component, based on its installation descriptor specifications, as well as the contents of its `lib` directory. The output string includes absolute path expressions for all relevant objects containing in the component PEAR package. If the component package is archived, returns `null`.
      Returns:
        The string that needs to be added to the CLASSPATH to run the given installed component.
      Throws:
        `IOException` - If any I/O exception occurred.

    - #### buildComponentRuntimeClassPath

          public String buildComponentRuntimeClassPath()
                                                throws IOException

      Like `buildComponentClassPath()`, but without all jars from the lib dir.
      Returns:
        The runtime classpath for the component.
      Throws:
        `IOException` - if there was an IO problem

    - #### buildComponentClassPath

          public String buildComponentClassPath(boolean relativePath,
                                                boolean addLibDir)
                                         throws IOException

      Creates a string that should be added to the CLASSPATH to run the given installed component, based on its installation descriptor specifications, as well as the contents of its `lib` directory. The output string includes absolute or relative path expressions for all relevant objects containing in the component PEAR package, depending on the value of a given `boolean` argument. If the component package is archived, returns `null`.
      Parameters:
        `relativePath` - If `true`, the output string will include relative path expressions for all relevant objects containing in the component PEAR package, otherwise it will contain absolute path expressions for these objects.
        `addLibDir` - Whether to add jars from the lib dir to the classpath (true at packaging time, false at runtime).
      Returns:
        The string that should be added to the CLASSPATH to run the given installed component.
      Throws:
        `IOException` - If any I/O exception occurred.

    - #### buildComponentPath

          public String buildComponentPath()
                                    throws IOException

      Creates a string that should be added to the PATH to run the given installed component, based on the PEAR package defaults and its installation descriptor specifications. The output string includes absolute path expressions for all relevant objects containing in the component PEAR package. If the component package is archived, returns `null`.
      Returns:
        The string that needs to be added to the PATH to run the given installed component.
      Throws:
        `IOException` - If any I/O exception occurred.

    - #### buildComponentPath

          public String buildComponentPath(boolean relativePath)
                                    throws IOException

      Creates a string that should be added to the PATH to run the given installed component, based on the PEAR package defaults and its installation descriptor specifications. The output string includes absolute or relative path expressions for all relevant objects containing in the component PEAR package, depending on the value of a given `boolean` argument. If the component package is archived, returns `null`.
      Parameters:
        `relativePath` - If `true`, the output string will include relative path expressions for all relevant objects containing in the component PEAR package, otherwise it will contain absolute path expressions for these objects.
      Returns:
        The string that needs to be added to the PATH to run the given installed component.
      Throws:
        `IOException` - If any I/O exception occurred.

    - #### findDirectory

          public File[] findDirectory(String dirNamePattern)

      Looks for package directories matching a given directory name pattern in the PEAR package. If the given directory name pattern starts with '/' or '\', the method looks for directory names that start with the given name pattern, otherwise it looks for directory names that contain the given name pattern as a substring. The method does not support wild cards.
      Parameters:
        `dirNamePattern` - The given directory name pattern to look for.
      Returns:
        The array of matching package directories.

    - #### findFile

          public File[] findFile(String fileNamePattern)

      Looks for package files matching a given file name pattern in the PEAR package. If the given file name pattern starts with '/' or '\', the method looks for file names that start from the given name pattern, otherwise it looks for file names that contain the given name pattern as a substring. The method does not support wild cards.
      Parameters:
        `fileNamePattern` - The given file name pattern to look for.
      Returns:
        The array of matching package files.

    - #### findStandardDirectory

          public File findStandardDirectory(String stdDirName)

      Looks for a given standard package directory. This method assumes that the given standard directory name is the full name of the directory in the package root directory.
      Parameters:
        `stdDirName` - The given full standard package directory name.
      Returns:
        The specified standard package directory, if this directory exists in the package, `null` otherwise.

    - #### findStandardFile

          public File findStandardFile(String stdFileName)

      Looks for a given standard package file. This method assumes that the given standard file name is the full name of the file in the package root directory.
      Parameters:
        `stdFileName` - The given full standard package file name.
      Returns:
        The specified standard package file, if this file exists in the package, `null` otherwise.

    - #### getAllDirectories

          public File[] getAllDirectories()

      Returns:
        Array of `File` objects representing all directories existing in the package.

    - #### getAllFiles

          public File[] getAllFiles()

      Returns:
        Array of `File` objects representing all files existing in the package.

    - #### getInstallationDescriptor

          public InstallationDescriptor getInstallationDescriptor()
                                                           throws IOException

      Loads the `INSTALLATION_DESCRIPTOR_FILE` file, and creates the `InstallationDescriptor` (InsD) object. Note: if the component package has been installed, the InsD object contains real specifications of package directories, otherwise it may contain macros like `$main_root`.
      Returns:
        The InsD object corresponding the installation descriptor file.
      Throws:
        `IOException` - If any I/O exception occurred.

    - #### getRootDirectory

          public File getRootDirectory()

      Returns:
        The package root directory, where the package was unarchived, or the directory corresponding to the package file path without its extension, if the archived package was specified.

    - #### isArchived

          public boolean isArchived()

      Returns:
        `true`, if the archived package was specified, `false` otherwise.

    - #### getComponentPearDescPath

          public String getComponentPearDescPath()
                                          throws IOException

      returns the pear component pearSpecifier file path.
      Returns:
        returns the pear component pearSpecifier file path or null if an archived package was used.
      Throws:
        `IOException` - if there was an IO problem

    - #### getComponentDataPath

          public String getComponentDataPath()
                                      throws IOException

      Returns the UIMA datapath setting for the component. The datapath of the component must be specified as environment variable with the key `uima.datapath`.
      Returns:
        the datapath setting for the component or null if the datapath is not specified.
      Throws:
        `IOException` - If any I/O exception occurred while reading the component meta data.

    - #### getComponentEnvVars

          public Properties getComponentEnvVars()
                                         throws IOException

      Returns the environment variable settings for the component. The variable settings does not contain the `classpath` and `uima.datapath` settings for the component.
      Returns:
        returns the environment variable settings for the component
      Throws:
        `IOException` - If any I/O exception occurred while reading the component meta data.

Copyright © 2006–2018 The Apache Software Foundation. All rights reserved.