facets.util.app
Class AppFileValues

java.lang.Object
  extended by facets.util.app.AppFileValues

public abstract class AppFileValues
extends java.lang.Object

Manages file history and other file values.

AppFileValues encapsulates file-related operations that read and write values stored in an AppValues.


Field Summary
static java.lang.String NATURE_FILES
          Key for flag specifying file behaviour.
static java.lang.String NATURE_FILES_OPENING
          Key for flag specifying file behaviour.
static java.lang.String NATURE_FILES_OPENING_PREVIOUS
          Key for flag specifying file behaviour.
static java.lang.String NATURE_FILES_RECENT_MAX
          Key for flag specifying file behaviour.
 
Constructor Summary
AppFileValues(AppValues appValues)
          Unique constructor.
 
Method Summary
 java.io.File getOpeningFile(boolean mustGet)
          Tries to get a suitable opening content file.
protected  java.io.File getOpeningOther(FileSpecifier[] specifiers)
          Called from getOpeningFile(boolean).
protected  java.io.File getOpeningRecent(java.lang.String[] recentPaths)
          Called from getOpeningFile(boolean).
 FileSpecifier[] getOpenSpecifiers()
          Get FileSpecifiers specifying application content types.
protected  void gotNoOpening()
          Called from getOpeningFile(boolean).
static AppFileValues newConsole(AppValues values, FileSpecifier s)
          Creates an AppFileValues to read input from the console.
 java.io.File[] recentFiles()
          Returns a validated array of recently opened files.
 java.io.File stateGetPath()
          Gets the current file search path.
 void statePutPath(java.io.File file)
          Stores the path to be returned by stateGetPath().
 ValueNode updateRecentFiles(java.io.File add)
          Maintains the list returned by recentFiles().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NATURE_FILES

public static final java.lang.String NATURE_FILES
Key for flag specifying file behaviour.

See Also:
Constant Field Values

NATURE_FILES_RECENT_MAX

public static final java.lang.String NATURE_FILES_RECENT_MAX
Key for flag specifying file behaviour.

See Also:
Constant Field Values

NATURE_FILES_OPENING

public static final java.lang.String NATURE_FILES_OPENING
Key for flag specifying file behaviour.

See Also:
Constant Field Values

NATURE_FILES_OPENING_PREVIOUS

public static final java.lang.String NATURE_FILES_OPENING_PREVIOUS
Key for flag specifying file behaviour.

See Also:
Constant Field Values
Constructor Detail

AppFileValues

public AppFileValues(AppValues appValues)
Unique constructor.

Parameters:
appValues - stores values.
Method Detail

recentFiles

public final java.io.File[] recentFiles()
Returns a validated array of recently opened files.

Returns:
files updated by updateRecentFiles(File)

updateRecentFiles

public final ValueNode updateRecentFiles(java.io.File add)
Maintains the list returned by recentFiles().

Files are guaranteed to exist, and are returned in reverse order of opening.

Parameters:
add - a file to add, or null to test the values stored
Returns:
the updated ValueNode

getOpeningFile

public final java.io.File getOpeningFile(boolean mustGet)
Tries to get a suitable opening content file.

Parameters:
mustGet - null return not allowed
Returns:
the file or null unless mustGet is true, in which case calls gotNoOpening()

getOpenSpecifiers

public FileSpecifier[] getOpenSpecifiers()
Get FileSpecifiers specifying application content types.

Returns:
by default FileSpecifier.ALL

getOpeningRecent

protected java.io.File getOpeningRecent(java.lang.String[] recentPaths)
Called from getOpeningFile(boolean).


getOpeningOther

protected java.io.File getOpeningOther(FileSpecifier[] specifiers)
Called from getOpeningFile(boolean).


gotNoOpening

protected void gotNoOpening()
Called from getOpeningFile(boolean).


stateGetPath

public final java.io.File stateGetPath()
Gets the current file search path.

Returns:
the last valid file passed to statePutPath(File), or else (for Windows) the user desktop.

statePutPath

public final void statePutPath(java.io.File file)
Stores the path to be returned by stateGetPath().

Parameters:
file - must be non-null and a directory

newConsole

public static AppFileValues newConsole(AppValues values,
                                       FileSpecifier s)
Creates an AppFileValues to read input from the console.

Parameters:
values - for reading and writing
s - filter for file types to input