public class FileServer extends Object
Modifier and Type | Method and Description |
---|---|
void |
closeFile(String name) |
void |
closeFiles() |
String |
getBaseDir() |
File |
getBaseDirRelative()
Calculates the relative path from
DEFAULT_BASE to the current base,
which must be the same as or a child of the default. |
static String |
getDefaultBase() |
static FileServer |
getFileServer() |
String[] |
getParsedLine(String alias,
boolean recycle,
boolean firstLineIsNames,
char delim) |
File |
getRandomFile(String basedir,
String[] extensions)
Method will get a random file in a base directory
TODO hey, not sure this method belongs here.
|
String |
getScriptName() |
String |
readLine(String filename)
Get the next line of the named file, recycle by default.
|
String |
readLine(String filename,
boolean recycle)
Get the next line of the named file, first line is name to false
|
String |
readLine(String filename,
boolean recycle,
boolean firstLineIsNames)
Get the next line of the named file.
|
void |
reserveFile(String filename)
Creates an association between a filename and a File inputOutputObject,
and stores it for later use - unless it is already stored.
|
void |
reserveFile(String filename,
String charsetName)
Creates an association between a filename and a File inputOutputObject,
and stores it for later use - unless it is already stored.
|
void |
reserveFile(String filename,
String charsetName,
String alias)
Creates an association between a filename and a File inputOutputObject,
and stores it for later use - unless it is already stored.
|
String |
reserveFile(String filename,
String charsetName,
String alias,
boolean hasHeader)
Creates an association between a filename and a File inputOutputObject,
and stores it for later use - unless it is already stored.
|
void |
resetBase()
Resets the current base to
DEFAULT_BASE . |
static String |
resolveBaseRelativeName(String relativeName)
Resolve a file name that may be relative to the base directory.
|
void |
setBase(File jmxBase)
Sets the current base directory for relative file names.
|
void |
setBasedir(String basedir)
Sets the current base directory for relative file names from the provided path.
|
void |
setBaseForScript(File scriptPath)
Sets the current base directory for relative file names from the provided script file.
|
void |
setScriptName(String scriptName) |
void |
write(String filename,
String value) |
public static FileServer getFileServer()
public void resetBase()
DEFAULT_BASE
.public void setBasedir(String basedir)
basedir
- the path to set, or null
if the GUI is being clearedIllegalStateException
- if files are still openpublic void setBaseForScript(File scriptPath)
scriptPath
- the path of the script file; must be not be null
IllegalStateException
- if files are still openIllegalArgumentException
- if scriptPath parameter is nullpublic void setBase(File jmxBase)
jmxBase
- the path of the script file base directory, cannot be nullIllegalStateException
- if files are still openIllegalArgumentException
- if basepath
is nullpublic String getBaseDir()
public static String getDefaultBase()
public File getBaseDirRelative()
DEFAULT_BASE
to the current base,
which must be the same as or a child of the default."."
if the path cannot be determinedpublic void reserveFile(String filename)
filename
- - relative (to base) or absolute file name (must not be null)public void reserveFile(String filename, String charsetName)
filename
- - relative (to base) or absolute file name (must not be null)charsetName
- - the character set encoding to use for the file (may be null)public void reserveFile(String filename, String charsetName, String alias)
filename
- - relative (to base) or absolute file name (must not be null)charsetName
- - the character set encoding to use for the file (may be null)alias
- - the name to be used to access the object (must not be null)public String reserveFile(String filename, String charsetName, String alias, boolean hasHeader)
filename
- - relative (to base) or absolute file name (must not be null)charsetName
- - the character set encoding to use for the file (may be null)alias
- - the name to be used to access the object (must not be null)hasHeader
- true if the file has a header line describing the contentspublic String readLine(String filename) throws IOException
filename
- the filename or alias that was used to reserve the fileIOException
public String readLine(String filename, boolean recycle) throws IOException
filename
- the filename or alias that was used to reserve the filerecycle
- - should file be restarted at EOF?IOException
public String readLine(String filename, boolean recycle, boolean firstLineIsNames) throws IOException
filename
- the filename or alias that was used to reserve the filerecycle
- - should file be restarted at EOF?firstLineIsNames
- - 1st line is fields namesIOException
public String[] getParsedLine(String alias, boolean recycle, boolean firstLineIsNames, char delim) throws IOException
alias
- the file name or aliasrecycle
- whether the file should be re-started on EOFfirstLineIsNames
- whether the file contains a file headerdelim
- the delimiter to use for parsingIOException
public void write(String filename, String value) throws IOException
IOException
public void closeFiles() throws IOException
IOException
public void closeFile(String name) throws IOException
name
- IOException
public File getRandomFile(String basedir, String[] extensions)
basedir
- public static String resolveBaseRelativeName(String relativeName)
relativeName
- public String getScriptName()
public void setScriptName(String scriptName)
scriptName
- Script nameCopyright © 1998-2013 Apache Software Foundation. All Rights Reserved.