JavaView® v2.00.008

jv.object
Class PsUtil

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

public class PsUtil
extends java.lang.Object

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

Version:
21.11.98, 1.0 revised (kp)
21.11.98, 1.0 created (kp)
Author:
Konrad Polthier

Constructor Summary
PsUtil()
           
 
Method Summary
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 base file name including extension from full path file name.
static boolean hasAllBits(int flag, int bit)
           
static boolean hasBits(int flag, int bit)
           
static boolean hasSomeBits(int flag, int bit)
           
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.BufferedReader open(java.lang.String fileName)
          Open a file either on the local file system or in the internet 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.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
clone, equals, finalize, 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:
String - 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 in the internet for reading within an application. This version works both within an application and in applets.
Parameters:
aFileName - 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-sfb288.math.tu-berlin.de/vgp/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 = "c:/JavaView/src/models/primitive/Octahedron.byu";
Returns:
a BufferedReader if open was successfull, other wise null.
See Also:
openURL(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.
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.

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)

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.

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.

getFilePath

public static java.lang.String getFilePath(java.lang.String fullFileName)
Extract base file name including extension from full path file name. Anything before and equal the last occurrence of '/' or '\' is considered as path information.

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)

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.