org.fopps.share
Class Util

java.lang.Object
  |
  +--org.fopps.share.Util

public class Util
extends java.lang.Object

Useful things to make live easier. Special thanks to the authors of the ant project


Field Summary
static boolean DEBUG
          Debug enabled
static java.lang.Class[] EMPTY_CLASS_ARRAY
          Empty class array (Class[0])
static java.lang.Object[] EMPTY_OBJECT_ARRAY
          Empty object array (Object[0])
static java.lang.String FILE_SEPARATOR
           
static boolean IS_WINDOWS_OS
          Trze, if windows present
static boolean ISJDK_14
          True, if JDK 1.4 present
static java.lang.String NEWLINE
          Newline character(s)
static java.lang.String PATH_SEPARATOR
           
static java.io.File USERDIR
          Value of property 'user.dir' as File object
static java.lang.String USERDIR_NAME
          Value of property 'user.dir'
 
Constructor Summary
Util()
           
 
Method Summary
static void assertWithMessage(java.lang.Object pMsg)
          Assert form program execution (throws a runtime exception)
static void copyFile(java.io.File sourceFile, java.io.File destFile, boolean overwrite, boolean preserveLastModified)
          Convienence method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains must be used, if source files may overwrite newer destination files and the last modified time of destFile file should be made equal to the last modified time of sourceFile.
static void copyFile(java.lang.String sourceFile, java.lang.String destFile)
          Convienence method to copy a file from a source to a destination.
static void copyFile(java.lang.String sourceFile, java.lang.String destFile, boolean overwrite)
          Convienence method to copy a file from a source to a destination specifying if token filtering must be used and if source files may overwrite newer destination files.
static void debug(java.lang.Throwable t)
          Issues an error with stack trace
static void dumpStack()
          Print out call stack.
static java.lang.String enum2String(java.util.Enumeration v)
          Converts an enumeration to a comma seperated string
static void error(java.lang.Throwable t)
          Issues an error without stack trace
static java.lang.String exception2String(java.lang.Throwable e)
          Converts an exception stack trace into a string
static java.lang.String findRelativeDirectory(java.lang.String pFilepath)
          Transforms an absolute path to a relative path, if possible.
static java.lang.String findRelativeDirectory(java.lang.String pRefPath, java.lang.String pOtherPath)
          Transforms an absolute path to a relative path, if possible.
static int getCurrentDayOfMonth()
          Returns the current day
static int getCurrentMonth()
          Returns the current month
static int getCurrentYear()
          Returns the current year
static void info(java.lang.Object pMsg)
          Logs an info message
static java.io.File[] locateFile(java.lang.String pName, java.lang.String pSearchPath, boolean pMustBeFile)
          Searches the file in the given search path.
static void log(java.lang.Object pMsg)
          Logs a message
static void setFileLastModified(java.io.File file, long time)
          Set last file modified (needs jdk 1.2 or higher!)
static void warn(java.lang.Object pMsg)
          Issues a warning message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USERDIR_NAME

public static final java.lang.String USERDIR_NAME
Value of property 'user.dir'


USERDIR

public static final java.io.File USERDIR
Value of property 'user.dir' as File object


NEWLINE

public static final java.lang.String NEWLINE
Newline character(s)


PATH_SEPARATOR

public static final java.lang.String PATH_SEPARATOR

FILE_SEPARATOR

public static final java.lang.String FILE_SEPARATOR

DEBUG

public static final boolean DEBUG
Debug enabled


EMPTY_OBJECT_ARRAY

public static final java.lang.Object[] EMPTY_OBJECT_ARRAY
Empty object array (Object[0])


EMPTY_CLASS_ARRAY

public static final java.lang.Class[] EMPTY_CLASS_ARRAY
Empty class array (Class[0])


ISJDK_14

public static final boolean ISJDK_14
True, if JDK 1.4 present


IS_WINDOWS_OS

public static final boolean IS_WINDOWS_OS
Trze, if windows present

Constructor Detail

Util

public Util()
Method Detail

info

public static void info(java.lang.Object pMsg)
Logs an info message


log

public static void log(java.lang.Object pMsg)
Logs a message


warn

public static void warn(java.lang.Object pMsg)
Issues a warning message


error

public static void error(java.lang.Throwable t)
Issues an error without stack trace


debug

public static void debug(java.lang.Throwable t)
Issues an error with stack trace


assertWithMessage

public static void assertWithMessage(java.lang.Object pMsg)
Assert form program execution (throws a runtime exception)


dumpStack

public static void dumpStack()
Print out call stack. Only for debug purposes


getCurrentYear

public static int getCurrentYear()
Returns the current year


getCurrentMonth

public static int getCurrentMonth()
Returns the current month


getCurrentDayOfMonth

public static int getCurrentDayOfMonth()
Returns the current day


locateFile

public static java.io.File[] locateFile(java.lang.String pName,
                                        java.lang.String pSearchPath,
                                        boolean pMustBeFile)
Searches the file in the given search path. If parameter pMustBeFile is set, the found file must be a file, otherwise null is returned.

Parameters:
pName - Name of the file to search for
pSearchPath - Search path to search in. The seperation of each entry is platform dependent (see java.io.File.pathSeparator for details)
pMustBeFile - If set, this method ignores matching directories
Returns:
List of matching files. If no matching file was found, this method returns an empty array

enum2String

public static java.lang.String enum2String(java.util.Enumeration v)
Converts an enumeration to a comma seperated string


copyFile

public static void copyFile(java.lang.String sourceFile,
                            java.lang.String destFile)
                     throws java.io.IOException
Convienence method to copy a file from a source to a destination. No filtering is performed.

Throws:
java.io.IOException

copyFile

public static void copyFile(java.lang.String sourceFile,
                            java.lang.String destFile,
                            boolean overwrite)
                     throws java.io.IOException
Convienence method to copy a file from a source to a destination specifying if token filtering must be used and if source files may overwrite newer destination files.

Throws:
java.io.IOException

copyFile

public static void copyFile(java.io.File sourceFile,
                            java.io.File destFile,
                            boolean overwrite,
                            boolean preserveLastModified)
                     throws java.io.IOException
Convienence method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains must be used, if source files may overwrite newer destination files and the last modified time of destFile file should be made equal to the last modified time of sourceFile.

Throws:
java.io.IOException

setFileLastModified

public static void setFileLastModified(java.io.File file,
                                       long time)
                                throws java.io.IOException
Set last file modified (needs jdk 1.2 or higher!)

java.io.IOException

findRelativeDirectory

public static java.lang.String findRelativeDirectory(java.lang.String pFilepath)
Transforms an absolute path to a relative path, if possible.


findRelativeDirectory

public static java.lang.String findRelativeDirectory(java.lang.String pRefPath,
                                                     java.lang.String pOtherPath)
Transforms an absolute path to a relative path, if possible.

Parameters:
pRefPath - Reference path
pOtherPath - Path to search a relative path for

exception2String

public static java.lang.String exception2String(java.lang.Throwable e)
Converts an exception stack trace into a string



Fopps 0.19 - Copyright © 2002 Oliver Wieland. All Rights Reserved.