de.fhg.igd.semoa.starter
Class FileParameter

java.lang.Object
  extended byjava.io.File
      extended byde.fhg.igd.semoa.starter.FileParameter
All Implemented Interfaces:
Comparable, Parameter, Serializable
Direct Known Subclasses:
JavaBinaryFile, JavaSecurityPolicyFile, JceLibraryFile, SemoaBaseDirectory, SemoaLogDirectory, SemoaLoggingConfigFile, SemoaScriptFile, ToolsLibraryFile

public abstract class FileParameter
extends File
implements Parameter

This is the super class of file system based Parameter objects. It provides the feature to shorten the String representation using common abbreviations for the current user directory and the user home directory.

Version:
"$Id: FileParameter.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Matthias Pressfreund
See Also:
Serialized Form

Field Summary
protected  String abbr_
          The abbreviated/short form
static String SHORT_USER_DIR
          The abbreviation of the current user directory
static String SHORT_USER_HOME
          The abbreviation of the user home directory
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
FileParameter(String file)
          Create a FileParameter using file path processing.
FileParameter(String file, boolean process)
          Create a FileParameter.
 
Method Summary
protected  void init()
          If isValid() returned successfully, an abbreviated and a full size representation of this FileParameter will be created.
 boolean isFlawed()
          Indicate whether or not this Parameter is partly invalid but still useable, e.g.
protected abstract  boolean isValid()
          Check if this file is a valid FileParameter instance.
static String normalize(String file)
          Removes useless ".." and "." elements from an absolute file path without resolving symbolic links.
static String toFull(String file)
          Undo transformations done by toShort(java.lang.String).
 String toFullString()
          Get the full String representation instead of the abbreviation.
static String toShort(String file)
          Returns a short file by replacing the users home directory (if present) with a tilde char and the current working directory with a dot char.
 String toShortString()
          Get the abbreviated String representation instead of the full version.
 String toString()
           
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SHORT_USER_HOME

public static final String SHORT_USER_HOME
The abbreviation of the user home directory

See Also:
Constant Field Values

SHORT_USER_DIR

public static final String SHORT_USER_DIR
The abbreviation of the current user directory

See Also:
Constant Field Values

abbr_

protected String abbr_
The abbreviated/short form

Constructor Detail

FileParameter

public FileParameter(String file)
Create a FileParameter using file path processing.

Parameters:
file - The original file path

FileParameter

public FileParameter(String file,
                     boolean process)
Create a FileParameter.

Parameters:
file - The original file
process - if true file path processing will take place
Method Detail

isValid

protected abstract boolean isValid()
Check if this file is a valid FileParameter instance.

Returns:
true if this is a valid FileParameter instance

init

protected void init()
             throws IllegalArgumentException
If isValid() returned successfully, an abbreviated and a full size representation of this FileParameter will be created.

Throws:
IllegalArgumentException - if the original file cannot be used to create a valid instance of this FileParameter subclass

isFlawed

public boolean isFlawed()
Description copied from interface: Parameter
Indicate whether or not this Parameter is partly invalid but still useable, e.g. by processing contained invalid elements anyway.

Specified by:
isFlawed in interface Parameter
Returns:
Whether or not this Parameter contains invalid elements

toShortString

public String toShortString()
Description copied from interface: Parameter
Get the abbreviated String representation instead of the full version.

Specified by:
toShortString in interface Parameter
Returns:
The abbreviated String representation

toFullString

public String toFullString()
Description copied from interface: Parameter
Get the full String representation instead of the abbreviation.

Specified by:
toFullString in interface Parameter
Returns:
The full String representation

normalize

public static String normalize(String file)
Removes useless ".." and "." elements from an absolute file path without resolving symbolic links.

Parameters:
file - The file to normalize
Returns:
The normalized file

toFull

public static String toFull(String file)
Undo transformations done by toShort(java.lang.String).

Parameters:
file - The short file name
Returns:
The full file name

toShort

public static String toShort(String file)
Returns a short file by replacing the users home directory (if present) with a tilde char and the current working directory with a dot char. This transformation can be made undone by toFull(java.lang.String).

Parameters:
file - The full file name
Returns:
The short file name

toString

public String toString()
Returns:
The short form


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.