edu.rice.cs.drjava.project
Class ProjectProfile

java.lang.Object
  extended by edu.rice.cs.drjava.project.ProjectProfile
All Implemented Interfaces:
ProjectFileIR

public class ProjectProfile
extends Object
implements ProjectFileIR

The internal representation of a project; it is the internal analog of a project file. Includes support for writing corresponding project file.


Field Summary
private  boolean _autoRefreshStatus
           
private  List<DocFile> _auxiliaryFiles
           
private  List<FileRegion> _bookmarks
           
private  List<DebugBreakpointData> _breakpoints
           
private  File _buildDir
           
private  List<AbsRelFile> _classPathFiles
           
private  List<String> _collapsedPaths
           
private  File _createJarFile
           
private  int _createJarFlags
           
private  List<DocFile> _excludedFiles
           
private  String _mainClass
           
private  String _manifest
           
private  File _projectFile
           
private  File _projectRoot
          root of project source tree.
private  List<DocFile> _sourceFiles
           
private  HashMap<OptionParser<?>,String> _storedPreferences
           
private  String _version
           
private  List<DebugWatchData> _watches
           
private  File _workDir
           
private static Log LOG
           
(package private) static DateFormat MOD_DATE_FORMAT
           
(package private) static String MOD_DATE_FORMAT_STRING
           
 
Constructor Summary
ProjectProfile(File f)
          Creates new ProjectProfiles with specifed project file name and project root that is parent folder of the project file.
ProjectProfile(String fileName)
          Constructs a File for fileName and forwards this call to the main constructor.
 
Method Summary
 void addAuxiliaryFile(DocFile df)
           
 void addAuxiliaryFile(DocumentInfoGetter getter)
           
 void addClassPathFile(AbsRelFile cp)
           
 void addCollapsedPath(String cp)
           
 void addExcludedFile(DocFile df)
           
 void addExcludedFile(DocumentInfoGetter getter)
           
 void addExcludedFile(File f)
           
 void addSourceFile(DocFile df)
          Public setters, modifiers
 void addSourceFile(DocumentInfoGetter getter)
           
private  DocFile docFileFromGetter(DocumentInfoGetter g)
           
private  String encodeBookmarkRelative(FileRegion bm, String prefix)
          This encodes a bookmark relative to _projectRoot.
private  String encodeBreakpointRelative(DebugBreakpointData bp, String prefix)
          This encodes a breakpoint relative to _projectRoot.
private  String encodeDocFile(DocFile df, String prefix, boolean relative)
          This encodes a docfile, adding all the special tags that store document-specific information.
private  String encodeDocFileAbsolute(DocFile df, String prefix)
           
private  String encodeDocFileRelative(DocFile df, String prefix)
          Encodes a doc file relative to _projectRoot.
private  String encodeFileAbsolute(File f, String prefix)
          This encodes a normal file with its canonical path.
private  String encodeFileRelative(File f, String prefix, File base)
          This encodes a normal file relative to File base.
private  String encodeWatch(DebugWatchData w, String prefix)
          This encodes a watch.
 boolean getAutoRefreshStatus()
           
 DocFile[] getAuxiliaryFiles()
          These files are the files outside of the project tree that are saved in the project file so that they are opened as well as the project files.
 FileRegion[] getBookmarks()
           
 DebugBreakpointData[] getBreakpoints()
           
 File getBuildDirectory()
           
 Iterable<AbsRelFile> getClassPaths()
           
 String[] getCollapsedPaths()
           
 File getCreateJarFile()
           
 int getCreateJarFlags()
           
 String getCustomManifest()
          Accessor for manifest attribute/
 String getDrJavaVersion()
          The version of dr java that created this project (as determined from its serialization as a .pjt or .drjava or .xml file)
 DocFile[] getExcludedFiles()
          These files are in the project source tree, but have been explicitly excluded from the project.
 String getMainClass()
           
 File getMainClassContainingFile()
           
 Map<OptionParser<?>,String> getPreferencesStoredInProject()
           
 File getProjectFile()
           
 File getProjectRoot()
           
 DocFile[] getSourceFiles()
           
 DebugWatchData[] getWatches()
           
 File getWorkingDirectory()
           
 void setAutoRefreshStatus(boolean status)
           
 void setAuxiliaryFiles(List<DocFile> af)
           
 void setBookmarks(List<? extends FileRegion> bms)
           
 void setBreakpoints(List<? extends DebugBreakpointData> bps)
           
 void setBuildDirectory(File dir)
           
 void setClassPaths(Iterable<? extends AbsRelFile> cpf)
           
 void setCollapsedPaths(List<String> cp)
           
 void setCreateJarFile(File createJarFile)
           
 void setCreateJarFlags(int createJarFlags)
           
 void setCustomManifest(String manifest)
          Mutator for manifest attribute.
 void setDrJavaVersion(String version)
          Sets the version of DrJava that built this project.
 void setExcludedFiles(List<DocFile> ef)
           
 void setMainClass(String main)
           
 void setPreferencesStoredInProject(Map<OptionParser<?>,String> sp)
           
 void setProjectRoot(File root)
          Assumes that root.getParentFile != null
 void setSourceFiles(List<DocFile> sf)
           
 void setWatches(List<? extends DebugWatchData> ws)
           
 void setWorkingDirectory(File dir)
           
 String toString()
           
 void write()
          Write project file in XML format.
 void write(OutputStream os)
           
 void writeOld()
          This method writes what information has been passed to this builder so far to disk in s-expression format.
 void writeOld(Writer fw)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MOD_DATE_FORMAT_STRING

static final String MOD_DATE_FORMAT_STRING
See Also:
Constant Field Values

MOD_DATE_FORMAT

static final DateFormat MOD_DATE_FORMAT

_sourceFiles

private List<DocFile> _sourceFiles

_auxiliaryFiles

private List<DocFile> _auxiliaryFiles

_excludedFiles

private List<DocFile> _excludedFiles

_collapsedPaths

private List<String> _collapsedPaths

_buildDir

private File _buildDir

_workDir

private File _workDir

_classPathFiles

private List<AbsRelFile> _classPathFiles

_mainClass

private String _mainClass

_projectRoot

private File _projectRoot
root of project source tree. Invariant: _projectRoot.exists()


_projectFile

private File _projectFile

_createJarFile

private File _createJarFile

_createJarFlags

private int _createJarFlags

_autoRefreshStatus

private boolean _autoRefreshStatus

_storedPreferences

private HashMap<OptionParser<?>,String> _storedPreferences

_bookmarks

private List<FileRegion> _bookmarks

_breakpoints

private List<DebugBreakpointData> _breakpoints

_watches

private List<DebugWatchData> _watches

_version

private String _version

_manifest

private String _manifest

LOG

private static Log LOG
Constructor Detail

ProjectProfile

public ProjectProfile(String fileName)
               throws IOException
Constructs a File for fileName and forwards this call to the main constructor.

Throws:
IOException

ProjectProfile

public ProjectProfile(File f)
               throws IOException
Creates new ProjectProfiles with specifed project file name and project root that is parent folder of the project file. The project file presumably may not exist yet, but its parent folder is assumed to exist. Assumes that the File f is not a null reference.

Throws:
IOException - parent directory of project file does not exist.
Method Detail

getSourceFiles

public DocFile[] getSourceFiles()
Specified by:
getSourceFiles in interface ProjectFileIR
Returns:
an array of the source files in this project.

getAuxiliaryFiles

public DocFile[] getAuxiliaryFiles()
Description copied from interface: ProjectFileIR
These files are the files outside of the project tree that are saved in the project file so that they are opened as well as the project files.

Specified by:
getAuxiliaryFiles in interface ProjectFileIR
Returns:
an array full of all the aux files (project outside source tree) in this project.

getExcludedFiles

public DocFile[] getExcludedFiles()
Description copied from interface: ProjectFileIR
These files are in the project source tree, but have been explicitly excluded from the project.

Specified by:
getExcludedFiles in interface ProjectFileIR
Returns:
an array chock partially full of most of the excluded files

getProjectFile

public File getProjectFile()
Specified by:
getProjectFile in interface ProjectFileIR
Returns:
project file.

getBuildDirectory

public File getBuildDirectory()
Specified by:
getBuildDirectory in interface ProjectFileIR
Returns:
the build directory stored in this project file

getWorkingDirectory

public File getWorkingDirectory()
Specified by:
getWorkingDirectory in interface ProjectFileIR
Returns:
the working directory stored in this project profile

getCollapsedPaths

public String[] getCollapsedPaths()
Specified by:
getCollapsedPaths in interface ProjectFileIR
Returns:
an array of path strings correspond to which folders in the tree should not be shown. Any paths not in this list will be expanded when the project is opened.

getClassPaths

public Iterable<AbsRelFile> getClassPaths()
Specified by:
getClassPaths in interface ProjectFileIR
Returns:
an array full of all the classpath path elements in the classpath for this project file

getMainClass

public String getMainClass()
Specified by:
getMainClass in interface ProjectFileIR
Returns:
the name of the file that holds the Jar main class associated with this project

getMainClassContainingFile

public File getMainClassContainingFile()
Specified by:
getMainClassContainingFile in interface ProjectFileIR
Returns:
the file containing the project's main class.

getProjectRoot

public File getProjectRoot()
Specified by:
getProjectRoot in interface ProjectFileIR
Returns:
the project root directory which must exist.

getCreateJarFile

public File getCreateJarFile()
Specified by:
getCreateJarFile in interface ProjectFileIR
Returns:
the output file used in the "Create Jar" dialog.

getCreateJarFlags

public int getCreateJarFlags()
Specified by:
getCreateJarFlags in interface ProjectFileIR
Returns:
the output file used in the "Create Jar" dialog.

getBookmarks

public FileRegion[] getBookmarks()
Specified by:
getBookmarks in interface ProjectFileIR
Returns:
an array of the bookmarks in this project.

getBreakpoints

public DebugBreakpointData[] getBreakpoints()
Specified by:
getBreakpoints in interface ProjectFileIR
Returns:
an array of the breakpoints in this project.

getWatches

public DebugWatchData[] getWatches()
Specified by:
getWatches in interface ProjectFileIR
Returns:
an array of the watches in this project.

getAutoRefreshStatus

public boolean getAutoRefreshStatus()
Specified by:
getAutoRefreshStatus in interface ProjectFileIR

getPreferencesStoredInProject

public Map<OptionParser<?>,String> getPreferencesStoredInProject()
Specified by:
getPreferencesStoredInProject in interface ProjectFileIR
Returns:
the stored preferences.

addSourceFile

public void addSourceFile(DocFile df)
Public setters, modifiers


addSourceFile

public void addSourceFile(DocumentInfoGetter getter)

addAuxiliaryFile

public void addAuxiliaryFile(DocFile df)

addAuxiliaryFile

public void addAuxiliaryFile(DocumentInfoGetter getter)

addExcludedFile

public void addExcludedFile(DocFile df)

addExcludedFile

public void addExcludedFile(File f)

addExcludedFile

public void addExcludedFile(DocumentInfoGetter getter)

addClassPathFile

public void addClassPathFile(AbsRelFile cp)

addCollapsedPath

public void addCollapsedPath(String cp)

setBuildDirectory

public void setBuildDirectory(File dir)
Specified by:
setBuildDirectory in interface ProjectFileIR

setWorkingDirectory

public void setWorkingDirectory(File dir)
Specified by:
setWorkingDirectory in interface ProjectFileIR

setMainClass

public void setMainClass(String main)
Specified by:
setMainClass in interface ProjectFileIR

setSourceFiles

public void setSourceFiles(List<DocFile> sf)
Specified by:
setSourceFiles in interface ProjectFileIR

setClassPaths

public void setClassPaths(Iterable<? extends AbsRelFile> cpf)
Specified by:
setClassPaths in interface ProjectFileIR

setCollapsedPaths

public void setCollapsedPaths(List<String> cp)
Specified by:
setCollapsedPaths in interface ProjectFileIR

setAuxiliaryFiles

public void setAuxiliaryFiles(List<DocFile> af)
Specified by:
setAuxiliaryFiles in interface ProjectFileIR

setExcludedFiles

public void setExcludedFiles(List<DocFile> ef)
Specified by:
setExcludedFiles in interface ProjectFileIR

setProjectRoot

public void setProjectRoot(File root)
Assumes that root.getParentFile != null

Specified by:
setProjectRoot in interface ProjectFileIR

setCreateJarFile

public void setCreateJarFile(File createJarFile)
Specified by:
setCreateJarFile in interface ProjectFileIR

setCreateJarFlags

public void setCreateJarFlags(int createJarFlags)
Specified by:
setCreateJarFlags in interface ProjectFileIR

setBookmarks

public void setBookmarks(List<? extends FileRegion> bms)
Specified by:
setBookmarks in interface ProjectFileIR

setBreakpoints

public void setBreakpoints(List<? extends DebugBreakpointData> bps)
Specified by:
setBreakpoints in interface ProjectFileIR

setWatches

public void setWatches(List<? extends DebugWatchData> ws)
Specified by:
setWatches in interface ProjectFileIR

setAutoRefreshStatus

public void setAutoRefreshStatus(boolean status)
Specified by:
setAutoRefreshStatus in interface ProjectFileIR

setPreferencesStoredInProject

public void setPreferencesStoredInProject(Map<OptionParser<?>,String> sp)
Specified by:
setPreferencesStoredInProject in interface ProjectFileIR

write

public void write()
           throws IOException
Write project file in XML format.

Throws:
IOException

write

public void write(OutputStream os)
           throws IOException
Throws:
IOException

writeOld

public void writeOld()
              throws IOException
This method writes what information has been passed to this builder so far to disk in s-expression format.

Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

writeOld

public void writeOld(Writer fw)
              throws IOException
Throws:
IOException

docFileFromGetter

private DocFile docFileFromGetter(DocumentInfoGetter g)
                           throws IOException
Parameters:
g - The getter that can get all the info needed to make the document file
Returns:
the document that contains the information retrieved from the getter
Throws:
IOException

encodeFileRelative

private String encodeFileRelative(File f,
                                  String prefix,
                                  File base)
                           throws IOException
This encodes a normal file relative to File base. None of the special tags are added.

Parameters:
f - the file to encode
prefix - the indent level to place the s-expression at
base - Directory to be made relative to
Returns:
the s-expression syntax to describe the given file.
Throws:
IOException

encodeFileAbsolute

private String encodeFileAbsolute(File f,
                                  String prefix)
                           throws IOException
This encodes a normal file with its canonical path. None of the special tags are added.

Parameters:
f - the file to encode
prefix - the indent level to place the s-expression at
Returns:
the s-expression syntax to describe the given file.
Throws:
IOException

encodeDocFile

private String encodeDocFile(DocFile df,
                             String prefix,
                             boolean relative)
                      throws IOException
This encodes a docfile, adding all the special tags that store document-specific information.

Parameters:
df - the doc file to encode
prefix - the indent level to place the s-expression at
relative - whether this file should be made relative to _projectRoot
Returns:
the s-expression syntax to describe the given docfile.
Throws:
IOException

encodeDocFileRelative

private String encodeDocFileRelative(DocFile df,
                                     String prefix)
                              throws IOException
Encodes a doc file relative to _projectRoot.

Parameters:
df - the DocFile to encode
prefix - the indent level
Throws:
IOException

encodeDocFileAbsolute

private String encodeDocFileAbsolute(DocFile df,
                                     String prefix)
                              throws IOException
Throws:
IOException

encodeBreakpointRelative

private String encodeBreakpointRelative(DebugBreakpointData bp,
                                        String prefix)
                                 throws IOException
This encodes a breakpoint relative to _projectRoot.

Parameters:
bp - the breakpoint to encode
prefix - the indent level to place the s-expression at
Returns:
the s-expression syntax to describe the given breakpoint.
Throws:
IOException

encodeWatch

private String encodeWatch(DebugWatchData w,
                           String prefix)
                    throws IOException
This encodes a watch.

Parameters:
w - the watch to encode
prefix - the indent level to place the s-expression at
Returns:
the s-expression syntax to describe the given watch.
Throws:
IOException

encodeBookmarkRelative

private String encodeBookmarkRelative(FileRegion bm,
                                      String prefix)
                               throws IOException
This encodes a bookmark relative to _projectRoot.

Parameters:
bm - the bookmark to encode
prefix - the indent level to place the s-expression at
Returns:
the s-expression syntax to describe the given breakpoint.
Throws:
IOException

getDrJavaVersion

public String getDrJavaVersion()
Description copied from interface: ProjectFileIR
The version of dr java that created this project (as determined from its serialization as a .pjt or .drjava or .xml file)

Specified by:
getDrJavaVersion in interface ProjectFileIR
Returns:
The version string, if known, or "unknown" otherwise.

setDrJavaVersion

public void setDrJavaVersion(String version)
Description copied from interface: ProjectFileIR
Sets the version of DrJava that built this project.

Specified by:
setDrJavaVersion in interface ProjectFileIR
Parameters:
version - - the version string, should be called with "unknown" if the version could not be determined.

getCustomManifest

public String getCustomManifest()
Accessor for manifest attribute/

Specified by:
getCustomManifest in interface ProjectFileIR
See Also:
ProjectFileIR.getCreateJarFlags()

setCustomManifest

public void setCustomManifest(String manifest)
Mutator for manifest attribute.

Specified by:
setCustomManifest in interface ProjectFileIR