xjavadoc.filesystem

Class FileSourceSet

public final class FileSourceSet extends Object implements SourceSet

This class represents a set of Java source files. It designs a directory and an optional array of files. The size() and getQualifiedName( int ) methods depend on what files were passed in the constructor. The getSourceFile( String ) will work regardless of wether the class was instantiated with files or not (provided the file exists).

Author: Aslak Hellesxy

UNKNOWN: 14. mars 2002

Nested Class Summary
classFileSourceSet.DirectoryFilter
FileFilter that only accepts directories
classFileSourceSet.JavaSourceFilter
FileFilter that only accepts java sources
Field Summary
inthash
overridden hash code
File_dir
root directory
ArrayList_files
source files
Constructor Summary
FileSourceSet(File dir, String[] files)
Constructs a new FileSourceSet.
FileSourceSet(File fileOrDir)
Creates a SoureSet from a directory or a file.
Method Summary
booleancontainsAbsolute(String filename)
whether source set contains given absolute file name
booleancontainsRelative(String filename)
whether source set contains relative file name
booleanequals(Object o)
Compares with another object.
FilegetDir()
Gets the root directory of the source files.
AbstractFile[]getFiles()
Gets the files contained in the source set.
StringgetQualifiedName(int i)
Gets the fully qualified class name of the i'th file in the instance.
StringgetQualifiedName(String relativeFileName)
Gets the fully qualified class name for a relative file
StringgetRelativeFileName(String qualifiedName)
Gets the relative file name (relative to dir) for a fully qualified class name
intgetSize()
Returns the number of files in the instance
AbstractFilegetSourceFile(String qualifiedName)
Gets the File containing the source of the class.
inthashCode()

Field Detail

hash

private int hash
overridden hash code

_dir

private File _dir
root directory

_files

private ArrayList _files
source files

Constructor Detail

FileSourceSet

public FileSourceSet(File dir, String[] files)
Constructs a new FileSourceSet. If the files parameter is null, the FileSourceSet will report that it does not know about any java source files, even if they exist. See the general class comment.

Parameters: dir The root directory of the java sources files The desired files under the root directory

FileSourceSet

public FileSourceSet(File fileOrDir)
Creates a SoureSet from a directory or a file. If fileOrDir is a directory, all java files under that directory (and all subdirectories) will be added to this FileSourceSet.

Parameters: fileOrDir

Method Detail

containsAbsolute

public boolean containsAbsolute(String filename)
whether source set contains given absolute file name

Parameters: filename absolute filename to check

Returns:

containsRelative

public boolean containsRelative(String filename)
whether source set contains relative file name

Parameters: filename relative filename to check

Returns:

equals

public boolean equals(Object o)
Compares with another object. They are equal if o is a FileSourceSet and have the same dir and the same files.

Parameters: o object to compare

Returns: true if they are equal

getDir

private File getDir()
Gets the root directory of the source files.

Returns: the root directory of the source files.

getFiles

public AbstractFile[] getFiles()
Gets the files contained in the source set.

Returns:

getQualifiedName

public String getQualifiedName(int i)
Gets the fully qualified class name of the i'th file in the instance.

Parameters: i the index of the class

Returns: fully qualified class name

getQualifiedName

private String getQualifiedName(String relativeFileName)
Gets the fully qualified class name for a relative file

Parameters: relativeFileName filename relative to the dir

Returns: fully qualified class name

getRelativeFileName

private String getRelativeFileName(String qualifiedName)
Gets the relative file name (relative to dir) for a fully qualified class name

Parameters: qualifiedName fully qualified class name

Returns: the relative file name

getSize

public int getSize()
Returns the number of files in the instance

Returns: the number of files in the instance

getSourceFile

public AbstractFile getSourceFile(String qualifiedName)
Gets the File containing the source of the class.
IMPORTANT: This method will find a file regardless of whether it was part of the files passed in the constructor.

Parameters: qualifiedName fully qualified class name of the source file to find.

Returns: the File containing the source of the class

hashCode

public int hashCode()