xjavadoc.filesystem

Class FileSourceSet

Implemented Interfaces:
Serializable, SourceSet

public final class FileSourceSet
extends java.lang.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 Helles?y

Nested Class Summary

(package private) class
FileSourceSet.DirectoryFilter
FileFilter that only accepts directories
(package private) class
FileSourceSet.JavaSourceFilter
FileFilter that only accepts java sources

Field Summary

private File
_dir
root directory
private ArrayList
_files
source files
private int
hash
overridden hash code

Constructor Summary

FileSourceSet(File fileOrDir)
Creates a SoureSet from a directory or a file.
FileSourceSet(File dir, String[] files)
Constructs a new FileSourceSet.

Method Summary

boolean
containsAbsolute(String filename)
whether source set contains given absolute file name
boolean
containsRelative(String filename)
whether source set contains relative file name
boolean
equals(Object o)
Compares with another object.
private File
getDir()
Gets the root directory of the source files.
AbstractFile[]
getFiles()
Gets the files contained in the source set.
private String
getQualifiedName(String relativeFileName)
Gets the fully qualified class name for a relative file
String
getQualifiedName(int i)
Gets the fully qualified class name of the i'th file in the instance.
private String
getRelativeFileName(String qualifiedName)
Gets the relative file name (relative to dir) for a fully qualified class name
int
getSize()
Returns the number of files in the instance
AbstractFile
getSourceFile(String qualifiedName)
Gets the File containing the source of the class.
int
hashCode()

Field Details

_dir

private File _dir
root directory

_files

private ArrayList _files
source files

hash

private int hash
overridden hash code

Constructor Details

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 -

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

Method Details

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.
Specified by:
getFiles in interface SourceSet
Returns:

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

getQualifiedName

public String getQualifiedName(int i)
Gets the fully qualified class name of the i'th file in the instance.
Specified by:
getQualifiedName in interface SourceSet
Parameters:
i - the index of the class
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
Specified by:
getSize in interface SourceSet
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.
Specified by:
getSourceFile in interface SourceSet
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()