home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
SourceFile.java
< prev
next >
Wrap
Text File
|
1998-10-25
|
8KB
|
225 lines
/*
* Copyright 1998 Symantec Corporation, All Rights Reserved.
*/
package com.symantec.itools.vcafe.openapi;
import java.io.File;
/**
* The API used to represent and access a Visual Cafe source file.
*
* @see VisualProject
* @see ProjectFile
* @see Range
*
* @author Symantec Internet Tools Division
* @version 1.0
* @since VCafe 3.0
*/
public abstract class SourceFile
{
/**
* Gets the <code>ProjectFile</code> associated with this <code>SourceFile</code>. If this file
* is not in a project, returns <code>null</code>.
* @return The <code>ProjectFile</code>, or <code>null</code> if this file is not in a project.
* @see ProjectFile
*/
public abstract ProjectFile getProjectFile();
/**
* Gets the <code>File</code> associated with this <code>SourceFile</code>.
* This method never returns <code>null</code>, but the actual file may not exist on disk
* (i.e. <code>File.exists() == false</code>).
* @return the <code>File</code> associated with this <code>SourceFile</code>.
*/
public abstract File getFile();
/**
* Gets the base name of the <code>File</code> associated with this <code>SourceFile</code>.
* The base name is everything in the pathname after the last occurrence of the
* separator character (i.e. no directory information).
* @return this file's base filename.
*/
public abstract String getName();
/**
* Gets the pathname of the <code>File</code> associated with this <code>SourceFile</code>.
* @return the complete filename of this <code>SourceFile</code>.
*/
public abstract String getFullName();
/**
* Gets the current insertion point, in zero-based bytes.
* @return the current insertion point, in zero-based bytes, or 0 if the <code>SourceFile</code> is not
* currently open.
*/
public abstract int getInsertionPoint();
/**
* Gets the <code>Range</code> of the currently selected text.
* @return the current text selection range, or <code>null</code> if the <code>SourceFile</code> is not
* currently open.
*/
public abstract Range getSelectionRange();
/**
* Sets the range of the currently selected text.
* @param the new text selection range.
*/
public abstract void setSelectionRange(Range newRange);
/**
* Gets this <code>SourceFile</code>'s entire contents.
* @return a <code>StringBuffer</code> containing the entire <code>SourceFile</code> contents.
*/
public abstract StringBuffer getText();
/**
* Gets this <code>SourceFile</code>'s entire contents as a <code>String</code>.
* @return a <code>String</code> containing the entire <code>SourceFile</code> contents.
*/
public abstract String getTextString();
/**
* Replaces the <code>SourceFile</code>'s entire contents.
* @param newText the new contents of this <code>SourceFile</code>.
*/
public abstract void setText(StringBuffer newText);
/**
* Replaces the <code>SourceFile</code>'s entire contents with the contents of a <code>String</code>.
* @param newText the new contents of this <code>SourceFile</code>.
*/
public abstract void setText(String newText);
/**
* Gets the text within the specified <code>Range</code>.
* The current selection range of this <code>SourceFile</code> is not changed by this method.
* @param theRange the <code>Range</code> from which to get the text.
* @return a <code>StringBuffer</code> containing the in-range text.
*/
public abstract StringBuffer getRangeText(Range theRange);
/**
* Gets the text within the specified <code>Range</code> as a <code>String</code>.
* The current selection range of this <code>SourceFile</code> is not changed by this method.
* @param theRange the <code>Range</code> from which to get the text.
* @return a <code>String</code> containing the in-range text.
*/
public abstract String getRangeTextString(Range theRange);
/**
* Replaces the text in the given <code>Range</code> with the new text. The resulting new <code>Range</code> is then
* returned in theRange.
* @param newText the new replacement text.
* @param theRange on input, the range of text to be replaced. On output, the
* newly resulting range.
*/
public abstract void setRangeText(StringBuffer newText, Range theRange);
/**
* Replaces the text in the given <code>Range</code> with the new text <code>String</code>.
* The resulting new <code>Range</code> is then returned in theRange.
* @param newText the new replacement text.
* @param theRange on input, the range of text to be replaced. On output, the
* newly resulting range.
*/
public abstract void setRangeText(String newText, Range theRange);
/**
* Determines if this <code>SourceFile</code> is open in an editor window.
* @return <code>true</code> if the file is open, <code>false</code> otherwise.
*/
public abstract boolean isOpen();
/**
* Activates this <code>SourceFile</code>'s editor window.
* If this <code>SourceFile</code> isn't open yet, it is opened.
*/
public abstract void edit();
/**
* Saves the contents of this <code>SourceFile</code> to disk.
*/
public abstract void save();
/**
* Closes this <code>SourceFile</code>'s editor window, and optionally save its contents.
* @param saveChanges <code>true</code> to save this file's contents, <code>false</code> to discard any changes made to
* this <code>SourceFile</code>.
*/
public abstract void close(boolean saveChanges);
/**
* Refreshes this <code>SourceFile</code>'s editor window with the contents on disk.
*/
public abstract void revertToSaved();
/**
* Determines whether this <code>SourceFile</code> is locked (on disk, or locked in source control).
* @return <code>true</code> if locked either on disk or in source control, <code>false</code> if it is not locked.
*/
public abstract boolean isLocked();
/**
* Determines whether this <code>SourceFile</code> has been modified.
* @return <code>true</code> if it has been modified, <code>false</code> otherwise.
*/
public abstract boolean isModified();
/**
* Set the modified flag of this <code>SourceFile</code>.
*
* Note: Use this method ONLY for marking the <code>SourceFile</code> as modified when
* the changes haven't been set with <code>setRangeText()</code> or <code>setText()</code>.
* Note: Use of this method does <i>not</i> result in listeners being notified of the change.
*
* This can be useful when making a change that hasn't been committed, so
* that if the user closes the <code>SourceFile</code>'s editor window, the user is
* prompted to save the changes. You can then flush or commit your changes.
* You should listen for other changes to the <code>SourceFile</code>, so you don't inadvertantly
* set the <code>SourceFile</code> as unmodified, when it has been modified elsewhere.
*
* @param modified the new modified state of this <code>SourceFile</code>.
* @return the previous modified state of the <code>SourceFile</code>.
* @see SourceFileListener
*/
public abstract boolean setModified(boolean modified);
/**
* Add a listener to this <code>SourceFile</code>.
* All changes to this <code>SourceFile</code> are broadcast to the listeners registered with it.
* @param listener the object that receives notifications of changes to the <code>SourceFile</code>.
*
* @see SourceFileListener
* @see removeSourceFileListener
* @see VisualCafe#addSourceFileListener
*/
public abstract void addSourceFileListener(SourceFileListener listener);
/**
* Remove a listener from this <code>SourceFile</code>.
* The listener stops receiving notifications of changes to this <code>SourceFile</code>.
* @param listener the object that was receiving notifications.
*
* @see SourceFileListener
* @see addSourceFileListener
* @see VisualCafe#removeSourceFileListener
*/
public abstract void removeSourceFileListener(SourceFileListener listener);
/**
* Gets a <code>String</code> that represents this object.
* @return the <code>String</code>.
*/
public String toString() {
return "SourceFile[" + getFile() + "]";
}
/**
* Determine if two <code>SourceFile</code> objects represent the same file.
*/
public abstract boolean equals(SourceFile sourceFile);
}