home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
ProjectFile.java
< prev
next >
Wrap
Text File
|
1998-11-11
|
9KB
|
227 lines
/*
* Copyright 1998 Symantec Corporation, All Rights Reserved.
*/
package com.symantec.itools.vcafe.openapi;
import java.io.File;
import com.symantec.itools.vcafe.openapi.dtreflect.DTClass;
import com.symantec.itools.vcafe.openapi.dtreflect.DTMember;
/**
* The API used to represent and access a Project File in a <code>VisualProject</code>.
* Each <code>ProjectFile</code> corresponds to an entry in the "Files" tab of Visual Cafe's
* project window.
* A plug-in can use the methods in this class to update file attributes.
*
* The implementation of all of <code>ProjectFile</code>'s abstract methods first calls
* checkValidity(). Any method could therefore throw an <code>InvalidProjectFileException</code>.
* This exception extends <code>RuntimeException</code>, so doesn't have to be explicity declared or
* caught. A <code>ProjectFile</code> can become invalid if it is removed from its project, or its
* project is closed, and the corresponding <code>ProjectListener</code> message is ignored, for example.
*
* @see VisualProject#getProjectFiles
* @see VisualProject#getProjectFiles(int)
* @see VisualProject#getProjectFile(String)
* @see VisualProject#getProjectFile(int)
* @see InvalidProjectFileException
*
* @author Symantec Internet Tools Division
* @version 1.0
* @since VCafe 3.0
*/
public abstract class ProjectFile
{
/**
* Indicates this file was added by the user.
*/
public static final int USER_ADDED = 1;
/**
* Indicates this file was added by the compiler.
*/
public static final int COMPILER_ADDED = 2;
/**
* Indicates this file was added by the parser.
*/
public static final int PARSER_ADDED = 4;
/**
* Indicates this file was added by an unknown source.
*/
public static final int UNKNOWN_ADDED = 8;
/**
* Indicates this file was added by the database.
*/
public static final int SHARED_DATABASE_ADDED = 16;
/**
* Indicates this file was added by one of the ERAD wizards.
*/
public static final int ERAD_WIZARD_ADDED = 32;
/**
* Specifies a file added by any source.
*/
public static final int ALL_FILE_ADDED = 0x7fff;
/**
* Gets the complete filename (including path) of the <code>File</code> associated with
* this <code>ProjectFile</code>.
* @return the complete filename of this <code>ProjectFile</code>.
*/
public abstract String getFullName();
/**
* Get the <code>File</code> that corresponds to this <code>ProjectFile</code>.
* This method never returns <code>null</code>, but the actual file may not exist on disk
* (i.e. <code> File.exists() == false</code>).
*/
public abstract File getFile();
/**
* Get a <code>SourceFile</code> associated with this <code>ProjectFile</code>.
* This method never returns <code>null</code>, but the actual file may not exist on disk
* (i.e. <code> SourceFile.getFile().exists() == false</code>).
*/
public abstract SourceFile getSourceFile();
/**
* Gets the <code>VisualProject</code> that owns this <code>ProjectFile</code>.
* @return the owning <code>VisualProject</code>.
*/
public abstract VisualProject getProject();
/**
* Gets a number that uniquely identifies this file within its project.
* @return a unique numeric ID within the project.
*/
public abstract int getFileId();
/**
* Determines who added this file to the project.
* @return the source that added this file to the project, is a mask containing any of:<ul type=circle>
* <li>USER_ADDED - the file was added by the user.
* <li>COMPILER_ADDED - the file was added by the compiler.
* <li>PARSER_ADDED - the file was added by the parser.
* <li>UNKNOWN_ADDED - the file was added by an unknown source.
* <li>SHARED_DATABASE_ADDED - the file was added by the database.
* <li>ERAD_WIZARD_ADDED - the file was added by one of the ERAD wizards.
* </ul>
*/
public abstract int getFileAddedBy();
/**
* Gets the Rapid Application Development (RAD) state of this <code>ProjectFile</code>. This determines whether this
* <code>ProjectFile</code> is parsed for Rapid Application Development or not. It is shown by the 'Start RAD'/'Stop RAD'
* menu item in the project window.
* @return <code>true</code>if RAD is enabled, <code>false</code> otherwise.
*/
public abstract boolean isRADEnabled();
/**
* Remove this <code>ProjectFile</code> from its <code>VisualProject</code>.
*/
public abstract void remove();
/**
* Renames this <code>ProjectFile</code>. The new file name must be fully qualified.
* This method optionally overwrites any existing file with the same new name.
* The old file with the original name is deleted.
* NOTE: This function assumes the file contents/type will remain the same.
* If it is a <code>.java</code> source file it will still be marked as a source file
* even if the extension changes. If you want to make sure that the file type
* in the build system is correct, remove the old file and add a new file instead.
*
* @param newName the new fully qualified name for this file.
* @param replace <code>true</code> to overwrite any file that might already have the new name.
*/
public abstract void rename(String newName, boolean replace);
/**
* Determines the package name for classes in this <code>ProjectFile</code>.
* @return the package name.
*/
public abstract String getPackageName();
/**
* Determines the list of imports in this <code>ProjectFile</code>.
* @return the list of imports.
*/
public abstract String[] getImports();
/**
* Gets an array of <code>DTClass</code> objects reflecting all the top-level classes and
* interfaces declared in this <code>ProjectFile</code>. This includes public, protected, default
* (package) access, and private classes and interfaces declared in the <code>ProjectFile</code>.
* To also get nested classes, use the <code>getClasses()</code> method.
* @return an array of <code>DTClass</code> objects for top-level classes.
* @see getClasses
*/
public abstract DTClass[] getDeclaredClasses();
/**
* Gets an array of <code>DTClass</code> objects reflecting all the classes and interfaces
* declared in this <code>ProjectFile</code>. This includes public, protected, default
* (package) access, and private classes and interfaces declared in the <code>ProjectFile</code>.
* This includes nested classes.
* To only get top-level classes (and not nested ones), use the <code>getDeclaredClasses</code> method.
* @return an array of <code>DTClass</code> objects for all <code>ProjectFile</code> classes.
* @see getDeclaredClasses
*/
public abstract DTClass[] getClasses();
/**
* Gets the closest class to the given <code>ProjectFile</code> location. The closest class is the
* innermost class with a source range or Javadoc range that surrounds the given location.
* @param location the location offset, in zero-based bytes.
* @return the <code>DTClass</code> object of the closest class.
*/
public abstract DTClass getClosestClass(int location);
/**
* Gets the closest member to the given <code>ProjectFile</code> location.. The closest member is the
* member of the innermost class with a source range or Javadoc range that surrounds the given location.
* @param location the location offset, in zero-based bytes.
* @return the <code>DTMember</code> object of the closest member.
* @see DTClass#getClosestMember
*/
public abstract DTMember getClosestMember(int location);
/**
* Gets a <code>String</code> representation of this <code>ProjectFile</code>.
* @return the <code>String</code>, formatted as "ProjectFile[full path name]".
*/
public String toString() {
return "ProjectFile[" + getFullName() + "]";
}
/**
* Determine if two <code>ProjectFile</code> objects represent the same file in a <code>VisualProject</code>.
* @param projectFile the <code>ProjectFile</code> to test against.
* @return <code>true</code> if the two <code>ProjectFile</code> objects represent the same file.
*/
public abstract boolean equals(ProjectFile projectFile);
/**
* Determine if this <code>ProjectFile</code> corresponds to a valid file in its <code>VisualProject</code>.
* A <code>ProjectFile</code> can become invalid if it has been removed from its project, or its
* project has been closed, for example.
* @return <code>true</code> if the <code>ProjectFile</code> is still valid.
*/
public abstract boolean isValid();
/**
* Checks that this object is valid, and throws a <code>RuntimeException</code> if not.
* Note that the implementation of all of <code>ProjectFile</code>'s abstract methods first call
* checkValidity(). Any method could therefore throw an <code>InvalidProjectFileException</code>.
* @exception com.symantec.itools.vcafe.openapi.InvalidProjectFileException
*/
public void checkValidity() throws InvalidProjectFileException {
if (!isValid()) throw new InvalidProjectFileException();
}
}