autohit.common
Class Utils

java.lang.Object
  extended byautohit.common.Utils

public class Utils
extends java.lang.Object

A bunch of utils

Version:
1.0 Version History EPG - Rewrite - 9Apr03
Author:
Erich P. Gatejen

Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String copy(java.lang.String source, java.lang.String dest)
          Copy files.
static java.lang.String copyDir(java.lang.String source, java.lang.String dest, boolean wipe)
          Copy entire directories.
static java.lang.String dot2path(java.lang.String header, java.lang.String dot)
          Converts dot namespace to a path
static java.lang.String loadFile2String(java.io.File f)
          Read a file into a String.
static java.io.File makeFile(java.lang.String name)
          Make a file reference.
static java.lang.String merge(java.lang.String source, java.lang.String dest, org.apache.commons.collections.ExtendedProperties props)
          Merge a file with properties.
static java.lang.String norfIt(int value)
           
static int packInteger(byte[] buf)
          Get a packed, big-endian integer.
static java.lang.Object testGetProperty(java.lang.String key, org.apache.commons.collections.ExtendedProperties props)
          Test and get property.
static boolean testGetPropertyTruth(java.lang.String key, org.apache.commons.collections.ExtendedProperties props)
          Test and get property for truth.
static void unpackInteger(byte[] buf, int offset, int value)
          Unpack an integer into an array--big-endian.
static java.lang.String wipeDir(java.lang.String dest)
          Wipe a directory and everything in it
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

dot2path

public static java.lang.String dot2path(java.lang.String header,
                                        java.lang.String dot)
Converts dot namespace to a path

Parameters:
header - prefix for the path
dot - path in dot notation
Returns:
a converted path

makeFile

public static java.io.File makeFile(java.lang.String name)
                             throws java.lang.Exception
Make a file reference. If the file already exists, kill it. If the path doesn't exist, make it. It'll throw an exception if it fails.

Parameters:
name - path name
Returns:
file object
Throws:
java.lang.Exception

testGetProperty

public static java.lang.Object testGetProperty(java.lang.String key,
                                               org.apache.commons.collections.ExtendedProperties props)
Test and get property. Return null if not found or something went wrong. Traps all exceptions

Parameters:
key - key for the property
props - the property set
Returns:
the property object

testGetPropertyTruth

public static boolean testGetPropertyTruth(java.lang.String key,
                                           org.apache.commons.collections.ExtendedProperties props)
Test and get property for truth. If will return true if the property containts 'true', otherwise it will return false; Traps all exceptions

Parameters:
key - key for the property
props - the property set
Returns:
true if the proprerty is 'true', otherwise false.

copy

public static java.lang.String copy(java.lang.String source,
                                    java.lang.String dest)
Copy files. I can't believe I have to write this. It will always overwrite an existing file.

Parameters:
source - source file path
dest - destination file path
Returns:
string containing errors or messages

merge

public static java.lang.String merge(java.lang.String source,
                                     java.lang.String dest,
                                     org.apache.commons.collections.ExtendedProperties props)
Merge a file with properties. It will overwrite an existing file. This is not exactly FAST.

Parameters:
source - source file
dest - destination file
props - properties that are candidates for substitution
Returns:
string containing errors or messages

copyDir

public static java.lang.String copyDir(java.lang.String source,
                                       java.lang.String dest,
                                       boolean wipe)
Copy entire directories. I can't believe I have to write this.

Parameters:
source - source is the source directory, without a training slash
dest - destination is the destination directory, without a training slash
wipe - destructive copy. If true, it will destroy destination directories before copying the files. The files themselves are always overwritten.
Returns:
string containing errors or messages

wipeDir

public static java.lang.String wipeDir(java.lang.String dest)
Wipe a directory and everything in it

Parameters:
dest - path to the directory
Returns:
string containing errors or messages

loadFile2String

public static java.lang.String loadFile2String(java.io.File f)
Read a file into a String.

Parameters:
f - File to read
Returns:
string if successful or otherwise null

packInteger

public static int packInteger(byte[] buf)
Get a packed, big-endian integer. The array better have 4 bytes or you'll get an exception

Parameters:
buf - arracy of bytes
Returns:
the integer

unpackInteger

public static void unpackInteger(byte[] buf,
                                 int offset,
                                 int value)
Unpack an integer into an array--big-endian. The array better have 4 bytes or you'll get an exception

Parameters:
buf - array of bytes. better be at least 4 bytes
offset - offset into the array to start the unpack
value - the integer to unpack

norfIt

public static java.lang.String norfIt(int value)


Test.