|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ca.bc.webarts.widgets.Util
A set of useful utility methods/functions for reuse.
Field Summary | |
private static java.lang.String |
CLASSNAME
A holder This classes name (used when logging). |
private static java.lang.String |
CLASSPATH
The VM classpath (used in some methods).. |
private static boolean |
initUtil
Class flag signifying if the initUtil method has been called |
private static Log |
log_
Gets a Log instance in case any calling classes are using it. |
static short |
OPEN_DIALOG
A constant to specify which dialog to open with the chooseFileDialog. |
static short |
SAVE_DIALOG
A constant to specify which dialog to open with the chooseFileDialog. |
static java.lang.String |
SYSTEM_FILE_SEPERATOR
A holder for this clients System File Separator. |
Constructor Summary | |
Util()
|
Method Summary | |
static java.lang.String |
chooseAFilename(java.awt.Component parent,
java.lang.String startPath)
Encapsulates the showing of the FileChooser dialog and returns a String representing the absolute path. |
static java.lang.String |
chooseAFilename(java.awt.Component parent,
java.lang.String startPath,
ExampleFileFilter[] filters,
boolean filesAndDirs)
Encapsulates the showing of the FileChooser dialog and returns a String representing the absolute path. |
static java.lang.String |
chooseAFilename(java.awt.Component parent,
java.lang.String startPath,
ExampleFileFilter[] filters,
boolean filesAndDirs,
short openOrClose)
Encapsulates the showing of the FileChooser dialog and returns a String representing the absolute path. |
static java.lang.String |
createCurrentTimeStamp()
Creates a timestamp for the current time in the form of 'hour + "-" + min + "-" + sec + "-" + millis'. |
static void |
ensureFolderExists(java.io.File folder)
Ensures that a folder exists. |
static java.net.URL |
getFileBaseURL(java.lang.String fileString)
Creates a URL for the specified filename string. |
static java.lang.String |
getFilePathFromClasspath(java.lang.String filename)
Searches the classpath for the specified filename and then returns the full path that is used for it. |
static java.lang.String |
getFilePathFromClasspath(java.lang.String filename,
java.lang.String fallBack)
Searches the classpath for the specified filename and then returns the full path that is used for it. |
static java.io.File |
initDirFile(java.lang.String s)
Initisalizes File only if it is directory.It is represented by the passed in String. |
private static void |
initUtil()
|
static java.awt.Image |
loadImage(java.lang.String imageFilename)
Loads the requested Image filename from the classpath. |
static java.awt.Image |
loadImage(java.lang.String imageFilename,
java.lang.String jarFilename)
Loads the requested Image filename from the specified jarfile. |
static void |
removeDir(java.lang.String fileName)
Recursively deletes all the files in the spec'd directory and subdirectories, and then removes the dir. |
static boolean |
sleep(long waitTime)
A method to simply abstract the Try/Catch required to put the current thread to sleep for the specified time in ms. |
static java.lang.String |
toHEXString(byte b)
A simple byte to Hex String converter. |
static java.lang.String |
tokenReplace(java.lang.String sentence,
java.lang.String token,
java.lang.String replacement)
A simple String token replacement routine. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final java.lang.String SYSTEM_FILE_SEPERATOR
public static final short OPEN_DIALOG
public static final short SAVE_DIALOG
private static java.lang.String CLASSNAME
private static java.lang.String CLASSPATH
private static Log log_
private static boolean initUtil
Constructor Detail |
public Util()
Method Detail |
private static void initUtil()
public static void ensureFolderExists(java.io.File folder)
Ensures that a folder exists | |
Description: use it like this: ensureFolderExists(new File(fileName).getParentFile()); |
folder
- The File object to check.public static java.lang.String toHEXString(byte b)
b
- The byte to convertpublic static java.lang.String createCurrentTimeStamp()
public static java.lang.String tokenReplace(java.lang.String sentence, java.lang.String token, java.lang.String replacement)
sentence
- The String to perform the token replacement ontoken
- the token String to seartch for and replacereplacement
- the tokens replacement valuepublic static void removeDir(java.lang.String fileName)
fileName
- The filename of the directory to delete.public static java.io.File initDirFile(java.lang.String s)
s
- the directory name to init as a Filepublic static java.lang.String getFilePathFromClasspath(java.lang.String filename, java.lang.String fallBack)
filename
- to look for in the classpathfallBack
- if the file is not found in classpathpublic static java.lang.String getFilePathFromClasspath(java.lang.String filename)
public static java.awt.Image loadImage(java.lang.String imageFilename, java.lang.String jarFilename)
imageFilename
- the filename in the jarfile to use as the basis for
the Image to retrieve.jarFilename
- the jar file to look through for the image.public static java.awt.Image loadImage(java.lang.String imageFilename)
imageFilename
- the filename in the jarfile to use as the basis for
the Image to retrieve.public static boolean sleep(long waitTime)
waitTime
- the sleep time in milli seconds (ms).public static java.lang.String chooseAFilename(java.awt.Component parent, java.lang.String startPath)
NO file filters will be used and NO directory selection is allowed.
parent
- the owner of this dialog (generally just send this)startPath
- the dir to start the file chooser dialog frompublic static java.lang.String chooseAFilename(java.awt.Component parent, java.lang.String startPath, ExampleFileFilter[] filters, boolean filesAndDirs)
This method requires all the config parms specified by the ExampleFileFilter.
parent
- the owner of this dialog (generally just send this)startPath
- the dir to start the file chooser dialog fromfilters
- an array holding the Filters to use in the dialogfilesAndDirs
- specs if the user will be allowed to choose both files
or dirs.public static java.lang.String chooseAFilename(java.awt.Component parent, java.lang.String startPath, ExampleFileFilter[] filters, boolean filesAndDirs, short openOrClose)
This method requires all the config parms specified by the ExampleFileFilter.
parent
- the owner of this dialog (generally just send this)startPath
- the dir to start the file chooser dialog fromfilters
- an array holding the Filters to use in the dialogfilesAndDirs
- specs if the user will be allowed to choose both files
or dirs.public static java.net.URL getFileBaseURL(java.lang.String fileString)
fileString
- is the filename to turn into a file://URL
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |