jv.object

## Class PsUtil

- java.lang.Object
- - jv.object.PsUtil

-     public final class PsUtil
      extends java.lang.Object

  Utility to locate and query classes and superclasses, open files, bit manipulations.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PsUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `assureFileSeparator(java.lang.String dir, boolean bDir)` Assure that path name contains and, in case of directories, ends with current file separator.
    `static int` | `clearBits(int flag, int bit)`
    `static java.lang.String` | `getFileBaseName(java.lang.String fullFileName)` Extract file name without extension and without path information.
    `static java.lang.String` | `getFileExtension(java.lang.String fullFileName)` Extract base file name and search for characters behind the last '.'.
    `static java.lang.String` | `getFileName(java.lang.String fullFileName)` Extract file name including extension without path information.
    `static java.lang.String` | `getFilePath(java.lang.String fullFileName)` Extract full path excluding anything behind the last file separator.
    `static java.lang.String` | `getFilePathAndBaseName(java.lang.String fullFileName)` Extract full path and file base name excluding file extensions.
    `static boolean` | `hasAllBits(int flag, int bit)`
    `static boolean` | `hasBits(int flag, int bit)`
    `static boolean` | `hasSomeBits(int flag, int bit)`
    `static boolean` | `isAbsolutePath(java.lang.String dir)` Check if directory is a relative or absolute path.
    `static java.lang.Object` | `newInstance(java.lang.Class baseClass, java.lang.String nameSuffix)` Find a class and create an instance.
    `static java.lang.Object` | `newInstance(java.lang.String className)` Find a class given by name and create an instance.
    `static java.io.DataInputStream` | `open_as_DataInputStream(java.lang.String fileName)` Open a file either on the local file system or as URL for reading.
    `static java.io.BufferedReader` | `open(java.lang.String fileName)` Open a file either on the local file system or as URL for reading.
    `static java.io.DataInputStream` | `openFile_as_DataInputStream(java.lang.String aFileName)` Open a file on the local file system for reading within an application.
    `static java.io.BufferedReader` | `openFile(java.lang.String aFileName)` Open a file on the local file system for reading within an application.
    `static java.io.DataInputStream` | `openURL_as_DataInputStream(java.lang.String aURL)` Opens a URL for reading within an applet.
    `static java.io.BufferedReader` | `openURL(java.lang.String aURL)` Opens a URL for reading within an applet.
    `static int` | `setBits(int flag, int bit)`
    `static java.io.PrintWriter` | `writeFile(java.lang.String aFileName)` Open a file on the local file system for writing from an application.

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

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

- - ### Constructor Detail

    - #### PsUtil

          public PsUtil()

  - ### Method Detail

    - #### newInstance

          public static java.lang.Object newInstance(java.lang.Class baseClass,
                                     java.lang.String nameSuffix)

      Find a class and create an instance. Name of searched class starts with name of baseClass, or one of its super classes, and finishes with string given by nameSuffix.
      Parameters:
        `baseClass` - base class
        `nameSuffix` - post fix of class
      Returns:
        an instance if class is found, else null.

    - #### newInstance

          public static java.lang.Object newInstance(java.lang.String className)

      Find a class given by name and create an instance.
      Parameters:
        `className` - Name of class
      Returns:
        an instance if class is found, else null

    - #### open

          public static java.io.BufferedReader open(java.lang.String fileName)

      Open a file either on the local file system or as URL for reading. This version works both within an application and in applets.
      Parameters:
        `fileName` - If application, string of full file name of a geometry file in BYU file format, e.g. aFileName = "c:/JavaView/src/models/primitive/Octahedron.byu"; or, if applet, a full qualified URL such as aFileName = "file:/c:/JavaView/src/models/primitive/Octahedron.byu"; aFileName = "http://www.javaview.de/models/primitive/Octahedron.byu";
      Returns:
        an InputStream if open was successfull, other wise `null`.
      See Also:
        `openFile(java.lang.String)`, `openURL(java.lang.String)`

    - #### openFile

          public static java.io.BufferedReader openFile(java.lang.String aFileName)

      Open a file on the local file system for reading within an application. This version only works within an application and does not work in applets. In applets, use `PsUtil.openURL(String)`.

      File may be compressed using gz. It should also work with zip but mysteriously does not currently.

      Parameters:
        `aFileName` - String of full file name including directory path, e.g. aFileName = PsConfig.getCodeBase()+"c:/JavaView/src/models/primitive/Octahedron.byu";
      Returns:
        a BufferedReader if open was successfull, other wise `null`.
      See Also:
        `openURL(java.lang.String)`

    - #### openURL

          public static java.io.BufferedReader openURL(java.lang.String aURL)

      Opens a URL for reading within an applet. The URL can be generated within an applet `getCodeBase()` and the local position of the file, e.g.

                          String obj = getCodeBase().toExternalForm();
                          String fileName = new StringBuffer().append(obj).append("models/byu/brezelMid.byu").toString();

      If applet runs in a browser the file must be below the code base, otherwise a SecurityException be thrown.

      File may be compressed using gz. It should also work with zip but mysteriously does not currently.

      Parameters:
        `aURL` - String of full URL of a geometry file in BYU file format, e.g. aFileName = "file:/c:/JavaView/src/models/primitive/Octahedron.byu"; aFileName = "http://www-sfb288.math.tu-berlin.de/vgp/models/primitive/Octahedron.byu";
      Returns:
        a BufferedReader if open was successfull, other wise `null`.
      See Also:
        `openFile(java.lang.String)`

    - #### open_as_DataInputStream

          public static java.io.DataInputStream open_as_DataInputStream(java.lang.String fileName)

      Open a file either on the local file system or as URL for reading. This version works both within an application and in applets.
      Parameters:
        `fileName` - If application, string of full file name of a geometry file in BYU file format, e.g. aFileName = "c:/JavaView/src/models/primitive/Octahedron.byu"; or, if applet, a full qualified URL such as aFileName = "file:/c:/JavaView/src/models/primitive/Octahedron.byu"; aFileName = "http://www.javaview.de/models/primitive/Octahedron.byu";
      Returns:
        an InputStream if open was successfull, other wise `null`.
      See Also:
        `openFile(java.lang.String)`, `openURL(java.lang.String)`

    - #### openFile_as_DataInputStream

          public static java.io.DataInputStream openFile_as_DataInputStream(java.lang.String aFileName)

      Open a file on the local file system for reading within an application. This version only works within an application and does not work in applets. In applets, use `PsUtil.openURL(String)`.

      File may be compressed using gz. It should also work with zip but mysteriously does not currently.

      Parameters:
        `aFileName` - String of full file name including directory path, e.g. aFileName = PsConfig.getCodeBase()+"c:/JavaView/src/models/primitive/Octahedron.byu";
      Returns:
        a BufferedReader if open was successfull, other wise `null`.
      See Also:
        `openURL(java.lang.String)`

    - #### openURL_as_DataInputStream

          public static java.io.DataInputStream openURL_as_DataInputStream(java.lang.String aURL)

      Opens a URL for reading within an applet. The URL can be generated within an applet `getCodeBase()` and the local position of the file, e.g.

                          String obj = getCodeBase().toExternalForm();
                          String fileName = new StringBuffer().append(obj).append("models/byu/brezelMid.byu").toString();

      If applet runs in a browser the file must be below the code base, otherwise a SecurityException be thrown.

      File may be compressed using gz. It should also work with zip but mysteriously does not currently.

      Parameters:
        `aURL` - String of full URL of a geometry file in BYU file format, e.g. aFileName = "file:/c:/JavaView/src/models/primitive/Octahedron.byu"; aFileName = "http://www-sfb288.math.tu-berlin.de/vgp/models/primitive/Octahedron.byu";
      Returns:
        a BufferedReader if open was successfull, other wise `null`.
      See Also:
        `openFile(java.lang.String)`

    - #### writeFile

          public static java.io.PrintWriter writeFile(java.lang.String aFileName)

      Open a file on the local file system for writing from an application. This version only works within an application and does not work in applets.

      If filename ends with ".zip" then writer into ZipOutputStream is opened. The zip file contains a single file whose name is the same as the parameter aFileName without the suffix ".zip".

      Filename suffix ".gz" will returned a writer based on a GZIPOutputStream.

      Parameters:
        `aFileName` - String of full file name including directory path, e.g. aFileName = "c:/JavaView/src/models/primitive/Octahedron.byu";
      Returns:
        PrintWriter if open was successfull, other wise `null`.

    - #### getFileName

          public static java.lang.String getFileName(java.lang.String fullFileName)

      Extract file name including extension without path information. Anything behind the last occurrence of '/' or '\' is considered the file name.

    - #### getFileBaseName

          public static java.lang.String getFileBaseName(java.lang.String fullFileName)

      Extract file name without extension and without path information. Anything behind the last occurrence of '/' or '\' is considered the file name from which anything including the last '.' is removed as extension.

      Note, a trailing number section such as *.0017 is considered as part of the file basename, and therefore not removed from the file basename.

    - #### getFileExtension

          public static java.lang.String getFileExtension(java.lang.String fullFileName)

      Extract base file name and search for characters behind the last '.'. Anything behind the last occurrence of '/' or '\' is considered the base name.

      Note, a trailing number section such as *.0017 is considered as part of the file basename and not returned as filename extension.

    - #### getFilePath

          public static java.lang.String getFilePath(java.lang.String fullFileName)

      Extract full path excluding anything behind the last file separator. Anything before and including the last occurrence of '/' or '\' is considered as path information.

      If string contains no separator then string is consist of a fileName only, and an empty string is returned as path.

    - #### getFilePathAndBaseName

          public static java.lang.String getFilePathAndBaseName(java.lang.String fullFileName)

      Extract full path and file base name excluding file extensions.

      Note, a trailing number section such as *.0017 is considered as part of the file basename, and therefore not removed from the path+basename.

    - #### assureFileSeparator

          public static java.lang.String assureFileSeparator(java.lang.String dir,
                                             boolean bDir)

      Assure that path name contains and, in case of directories, ends with current file separator. Parameter bDir determines if the path name is a directory which must end with a file separator.
      Parameters:
        `dir` - directory or file name with path information
        `bDir` - indicate if string is a directory or file
      Returns:
        modified directory name
      Since:
        JavaView 3.09.003

    - #### isAbsolutePath

          public static boolean isAbsolutePath(java.lang.String dir)

      Check if directory is a relative or absolute path.
      Returns:
        `true` if directory is an absolute path or url.
      Since:
        JavaView 3.09.003

    - #### hasAllBits

          public static boolean hasAllBits(int flag,
                           int bit)

    - #### hasSomeBits

          public static boolean hasSomeBits(int flag,
                            int bit)

    - #### hasBits

          public static boolean hasBits(int flag,
                        int bit)

    - #### setBits

          public static int setBits(int flag,
                    int bit)

    - #### clearBits

          public static int clearBits(int flag,
                      int bit)

"

The software JavaView? is copyright protected. All Rights Reserved.
"