Package mars.venus
Class FileStatus
java.lang.Object
mars.venus.FileStatus
Used to store and return information on the status of the current ASM file
that is being edited in the program.
- Author:
- Team JSpim
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
open/saved edit window with unsaved editsstatic int
New edit window with unsaved editsstatic int
New edit window with no editsstatic int
initial state or after closestatic int
open/saved edit window with no editsstatic int
file is being opened.static int
successful assemblystatic int
execution is under waystatic int
execution terminated -
Constructor Summary
ConstructorsConstructorDescriptionCreate a FileStatus object with FileStatus.NO_FILE for status and null for file getters.FileStatus(int status, String pathname)
Create a FileStatus object with given status and file pathname. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
get()
Get file statusstatic File
getFile()
Returns the ASM file.Get file name with no path information.int
Get editing status of this file.static String
getName()
Returns the name of the file.Get file parent pathname.Get full file pathname.boolean
Determine if file has been modified since last save or, if not yet saved, since being created using New or Open.static boolean
Tells whether the file has been assembled.static boolean
isEdited()
Tells whether the file has been edited since it has been saved.boolean
isNew()
Determine if file is "new", which means created using New but not yet saved.static boolean
isSaved()
Tells whether the file has been saved.static void
reset()
Resets all the values in FileStatusstatic void
set(int newStatus)
Set file status and menu state accordingly.static void
setAssembled(boolean b)
Sets whether the file has been assembled or not.static void
setEdited(boolean b)
Changes the value of edited to the parameter given.static void
Sets the file to the ASM file passed.void
setFileStatus(int newStatus)
Set editing status of this file.static void
Changes the value of name to the parameter given.void
setPathname(String newPath)
Set full file pathname.void
setPathname(String parent, String name)
Set full file pathname.static void
setSaved(boolean b)
Changes the value of saved to the parameter given.void
Update static FileStatus fields with values from this FileStatus object to support legacy code that depends on the static.
-
Field Details
-
NO_FILE
public static final int NO_FILEinitial state or after close- See Also:
- Constant Field Values
-
NEW_NOT_EDITED
public static final int NEW_NOT_EDITEDNew edit window with no edits- See Also:
- Constant Field Values
-
NEW_EDITED
public static final int NEW_EDITEDNew edit window with unsaved edits- See Also:
- Constant Field Values
-
NOT_EDITED
public static final int NOT_EDITEDopen/saved edit window with no edits- See Also:
- Constant Field Values
-
EDITED
public static final int EDITEDopen/saved edit window with unsaved edits- See Also:
- Constant Field Values
-
RUNNABLE
public static final int RUNNABLEsuccessful assembly- See Also:
- Constant Field Values
-
RUNNING
public static final int RUNNINGexecution is under way- See Also:
- Constant Field Values
-
TERMINATED
public static final int TERMINATEDexecution terminated- See Also:
- Constant Field Values
-
OPENING
public static final int OPENINGfile is being opened. DPS 9-Aug-2011- See Also:
- Constant Field Values
-
-
Constructor Details
-
FileStatus
public FileStatus()Create a FileStatus object with FileStatus.NO_FILE for status and null for file getters. -
FileStatus
Create a FileStatus object with given status and file pathname.- Parameters:
status
- Initial file status. See FileStatus static constants.pathname
- Full file pathname. SeesetPathname(String)
-
-
Method Details
-
set
public static void set(int newStatus)Set file status and menu state accordingly.- Parameters:
newStatus
- New status: EDITED, RUNNABLE, etc, see list above.
-
get
public static int get()Get file status- Returns:
- file status EDITED, RUNNABLE, etc, see list above
-
setAssembled
public static void setAssembled(boolean b)Sets whether the file has been assembled or not.- Parameters:
b
-
-
setSaved
public static void setSaved(boolean b)Changes the value of saved to the parameter given.- Parameters:
b
- boolean variable that tells what to set saved to .
-
setEdited
public static void setEdited(boolean b)Changes the value of edited to the parameter given.- Parameters:
b
- boolean variable that tells what to set edited to.
-
setName
Changes the value of name to the parameter given.- Parameters:
s
- string variable tells what to set the name of the file to .
-
setFile
Sets the file to the ASM file passed.- Parameters:
f
- file object variable that stores the ASM file.
-
getFile
Returns the ASM file.- Returns:
- The ASM file.
-
getName
Returns the name of the file.- Returns:
- The name of the ASM file.
-
isAssembled
public static boolean isAssembled()Tells whether the file has been assembled.- Returns:
- Boolean value that is true if the ASM file has been assembled.
-
isSaved
public static boolean isSaved()Tells whether the file has been saved.- Returns:
- Boolean variable that is true if the ASM file has been saved
-
isEdited
public static boolean isEdited()Tells whether the file has been edited since it has been saved.- Returns:
- Boolean value that returns true if the ASM file has been edited.
-
reset
public static void reset()Resets all the values in FileStatus -
setFileStatus
public void setFileStatus(int newStatus)Set editing status of this file. See FileStatus static constants.- Parameters:
newStatus
- the new status
-
getFileStatus
public int getFileStatus()Get editing status of this file.- Returns:
- current editing status. See FileStatus static constants.
-
isNew
public boolean isNew()Determine if file is "new", which means created using New but not yet saved. If created using Open, it is not new.- Returns:
- true if file was created using New and has not yet been saved, false otherwise.
-
hasUnsavedEdits
public boolean hasUnsavedEdits()Determine if file has been modified since last save or, if not yet saved, since being created using New or Open.- Returns:
- true if file has been modified since save or creation, false otherwise.
-
setPathname
Set full file pathname. SeeFile(String)
for parameter specs.- Parameters:
newPath
- the new pathname. If no directory path, getParent() will return null.
-
setPathname
Set full file pathname. SeeFile(String parent, String child)
for parameter specs.- Parameters:
parent
- the parent directory of the file. If null, getParent() will return null.name
- the name of the file (no directory path)
-
getPathname
Get full file pathname. SeeFile.getPath()
- Returns:
- full pathname as a String.
Null if
setPathname(String, String)
was given null as parent argument
-
getFilename
Get file name with no path information. SeeFile.getName()
- Returns:
- filename as a String
-
getParent
Get file parent pathname. SeeFile.getParent()
- Returns:
- parent full pathname as a String
-
updateStaticFileStatus
public void updateStaticFileStatus()Update static FileStatus fields with values from this FileStatus object to support legacy code that depends on the static.
-