ptolemy.backtrack.util
Class PathFinder

java.lang.Object
  extended by ptolemy.backtrack.util.PathFinder

public class PathFinder
extends java.lang.Object

A tool to search paths and set up class paths. It provides functions to search paths for certain files, and set up customized class paths from which class can be loaded with ptolemy.backtrack.eclipse.ast.LocalClassLoader.

Since:
Ptolemy II 5.1
Version:
$Id: PathFinder.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Thomas Feng
Accepted Rating:
Red (tfeng)
Proposed Rating:
Red (tfeng)

Nested Class Summary
static class PathFinder.DirectoryFilter
          Filter out all the files in a directory, except for sub-directories.
static class PathFinder.PostfixFilter
          Filter out all the files in a directory, except for those ending with the given postfix.
 
Field Summary
private static java.lang.String _ptolemyPath
          The Ptolemy path.
 
Constructor Summary
PathFinder()
           
 
Method Summary
static java.io.File[] getJavaFiles(java.lang.String path, boolean subdirs)
          Get all the Java source files in a path.
static java.lang.String[] getPtClassPaths()
          Return the class paths containing the root of the Ptolemy tree, and the Jar files in sub-directories lib/, vendors/sun/commapi/ and vendors/sun/jxta.
static java.lang.String getPtolemyPath()
          Get the Ptolemy path.
static void setPtolemyPath(java.lang.String path)
          Set the Ptolemy path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_ptolemyPath

private static java.lang.String _ptolemyPath
The Ptolemy path.

Constructor Detail

PathFinder

public PathFinder()
Method Detail

getJavaFiles

public static java.io.File[] getJavaFiles(java.lang.String path,
                                          boolean subdirs)
Get all the Java source files in a path.

Parameters:
path - The path to be searched.
subdirs - If true, sub-directories of the path are also searched.
Returns:
All the Java files found. If no Java file is found, an array with 0 element is returned.

getPtClassPaths

public static java.lang.String[] getPtClassPaths()
Return the class paths containing the root of the Ptolemy tree, and the Jar files in sub-directories lib/, vendors/sun/commapi/ and vendors/sun/jxta.

Returns:
The class paths.

getPtolemyPath

public static java.lang.String getPtolemyPath()
Get the Ptolemy path. If the Ptolemy path is set with setPtolemyPath(String), that path is returned. If it is not set, ptolemy.ptII.dir system property is used (see StringUtilities.getProperty(String)). If the property does not exist, simply "./" is returned, assuming that the current path contains a working version of Ptolemy (may not be correct).

Returns:
The Ptolemy path.
See Also:
setPtolemyPath(String)

setPtolemyPath

public static void setPtolemyPath(java.lang.String path)
Set the Ptolemy path.

Parameters:
path - The Ptolemy path.
See Also:
getPtolemyPath()