FileDocCategorySizeDatePackage
SourcePath.javaAPI DocExample3129Wed Apr 19 11:17:18 BST 2000com.sun.tools.doclets

SourcePath

public class SourcePath extends Object
This class is used to represent a source path which can contain only directories no zip files. If a zip file is specified in the command line it will not get reflected in the SourcePath.
author
Atul M Dambalkar

Fields Summary
private final char
dirSeparator
private final String
fileSeparator
private String
pathstr
The original class path string
private File[]
sourcePath
List of source path entries. Each entry is a directory.
Constructors Summary
public SourcePath(String pathstr)
Build a source path from the specified path string on the command line.



                      
       
	init(pathstr);
    
public SourcePath()
Build a default source path from the path strings specified by the properties env.class.path.

        init(System.getProperty("env.class.path"));
    
Methods Summary
public java.io.FilegetDirectory(java.lang.String name)
Find the specified directory in the source path.

param
name Name of the directory to be searched for in the source path.
return
File Return the directory if found else return null.

        for (int i = 0; i < sourcePath.length; i++) {
            File directoryNeeded = new File(sourcePath[i], name);
            if (directoryNeeded.isDirectory()) {
                return directoryNeeded;
            }
        }         
	return null;
    
private voidinit(java.lang.String pathstr)
Initialize the SourcePath File array, which will contain only the directory names from the given path string.

param
pathstr Path String.

        if (pathstr == null ||  pathstr.length() == 0) {
            pathstr = ".";
        }

	int noOfFileSep = 0;
        int index = 0;
	this.pathstr = pathstr; // Save original class path string

	// Count the number of path separators
	while ((index = pathstr.indexOf(dirSeparator, index)) != -1) {
	    noOfFileSep++;
            index++;
	}
	// Build the source path
	File[] tempPath = new File[noOfFileSep + 1];
        int tempPathIndex = 0;
	int len = pathstr.length();
        int sepPos;
	for (index = 0; index < len; index = sepPos + 1) {
	    sepPos = pathstr.indexOf(dirSeparator, index);
            if (sepPos < 0) {
                sepPos = len;
	    }
            File file = new File(pathstr.substring(index, sepPos));
	    if (file.isDirectory()) {
   	        tempPath[tempPathIndex++] = file;
            } // if it is really a file, ignore it.
	}
	sourcePath = new File[tempPathIndex];
	System.arraycopy((Object)tempPath, 0, (Object)sourcePath, 
                         0, tempPathIndex);
    
public java.lang.StringtoString()
Return original source path string.

	return pathstr;