public abstract class AbstractFileInfo extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractFileInfo.Options
Options for an asString method
|
| Modifier and Type | Field and Description |
|---|---|
protected AbstractFileInfo.Options |
asStringOpt
Option for the return value of asString method.
|
protected IsErrorSetFT |
errors
Local list of errors collected during process, cleared for every new validation call.
|
protected File |
file
The underlying file object for the file name.
|
protected URL |
url
The underlying URL object for the file name.
|
| Constructor and Description |
|---|
AbstractFileInfo(File file)
Creates a new file info object from an existing File object.
|
AbstractFileInfo(File file,
boolean doValidate)
Creates a new file info object from an existing File object with optional validation.
|
AbstractFileInfo(File file,
String setRoot)
Creates a new file info object from an existing File object with a set-as-root directory.
|
AbstractFileInfo(String fileName)
Creates a new file info object from a file name.
|
AbstractFileInfo(String fileName,
InfoLocationOptions option)
Creates a new file info object from a file name with options.
|
AbstractFileInfo(String directory,
String fileName)
Creates a new file info object from a path and a file name.
|
AbstractFileInfo(String directory,
String fileName,
InfoLocationOptions option)
Creates a new file info object from a path and a file name with options.
|
| Modifier and Type | Method and Description |
|---|---|
File |
asFile()
Returns the file info object name as File object
|
URL |
asURL()
Returns the file info object name as URL object.
|
String |
getAbsoluteName()
Returns the absolute name of the file with all path information and the file (with extension).
|
String |
getAbsolutePath()
Returns the absolute path of the file, without the file name
|
String |
getBaseFileName()
Returns the base name of the file name of the object.
|
String |
getFileExtension()
Returns the file extension of the file name, without the leading dot.
|
String |
getFullFileName()
Returns the full file name (base name plus dot plus extension).
|
String |
getRootPath()
Returns the root path which is either the absolute path or (if any directory is set and
getSetRootPath() returns not null) the path to the set-as-root path |
String |
getSetRootName()
Returns the path and file elements for the set-as-root path of the file if a directory was explicitly given to one of the constructors.
|
String |
getSetRootPath()
Returns a path set-as-root to the file if a directory was explicitly given to one of the constructors.
|
protected void |
init(File file,
String directory,
String fileName,
InfoLocationOptions option)
Initialize the file info object with any parameters presented by the constructors.
|
boolean |
isValid()
Flag reporting on the validation.
|
protected void |
reset()
Resets all local members to null, except for the error.
|
void |
setAsStringOption(AbstractFileInfo.Options option)
Sets the option for an asString method
|
protected boolean |
testFile(File file)
Test a file for several conditions (does exist, is not hidden etc).
|
String |
toString() |
protected boolean |
tryFS(String directory,
String fileName)
Try to locate a file in the file system.
|
protected boolean |
tryResource(String directory,
String fileName)
Try to locate a file as resource.
|
protected abstract ValidationOptions |
valOption()
Returns the validation option which makes this abstract implementation a info object or target or both.
|
protected File file
protected URL url
protected final IsErrorSetFT errors
protected AbstractFileInfo.Options asStringOpt
public AbstractFileInfo(File file, boolean doValidate)
file - existing file objectdoValidate - true if internal validation is required, false otherwise (for instance if the file object comes from another loader).
If validation is set to false and the input argument for file is not valid, the behavior of this object and anyone using it is unpredictable.
If validation is set to false a null validation and a validation of the getURI method of the file is still run by the constructor.public AbstractFileInfo(File file, String setRoot)
file - existing file objectsetRoot - set-as-root directorypublic AbstractFileInfo(File file)
file - existing file objectpublic AbstractFileInfo(String fileName)
fileName - name of the file.
The file name must include a path that is accessible.
The file name must include path information if it is not in the root path.
Path information can be relative to any path in the class path.public AbstractFileInfo(String fileName, InfoLocationOptions option)
fileName - name of the file.
The file name must include a path that is accessible.
The file name must include path information if it is not in the root path.
Path information can be relative to any path in the class path.option - an option on how to locate the filepublic AbstractFileInfo(String directory, String fileName)
directory - a directory in which the file can be found. The directory can be absolute or relative to any directory in the class path.fileName - the file name to locatepublic AbstractFileInfo(String directory, String fileName, InfoLocationOptions option)
directory - directory a directory in which the file can be found. The directory can be absolute or relative to any directory in the class path.fileName - the file name to locateoption - an option on how to locate the fileprotected void reset()
protected void init(File file, String directory, String fileName, InfoLocationOptions option)
file - a file with all informationdirectory - a directory to locate a file infileName - a file name with or without path informationoption - an option on how to locate the file (not used if parameter file is set)protected final boolean tryFS(String directory, String fileName)
directory - a directory to locate the file infileName - a file name with optional path informationprotected final boolean tryResource(String directory, String fileName)
directory - a directory to locate the file infileName - a file name with optional path informationprotected final boolean testFile(File file)
file - file object to testpublic File asFile()
public URL asURL()
public String getFileExtension()
public String getBaseFileName()
public String getFullFileName()
public String getAbsolutePath()
public String getAbsoluteName()
public String getSetRootPath()
public String getSetRootName()
public String getRootPath()
getSetRootPath() returns not null) the path to the set-as-root pathpublic boolean isValid()
protected abstract ValidationOptions valOption()
public void setAsStringOption(AbstractFileInfo.Options option)
option - new option, only set if not nullCopyright © 2010–2017. All rights reserved.