Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## things.common
Class ThingsUtilityBelt

    java.lang.Object
      things.common.ThingsUtilityBelt

    public class ThingsUtilityBelt

extends java.lang.Object

A grab bag of static utilities.

Version:
  1.0

  Version History

       EPG - Initial - 16 JUN 01
       EPG - add snap strings 20 AUG 04
       EPG - added load file to array - 9 JUL 07
       EPG - make everything GMT - 10 AUG 08

Author:
  Erich P. Gatejen

Field Summary
`static char[]` | `HEX_VALUES`

Constructor Summary
`ThingsUtilityBelt()`

Method Summary
`static java.lang.String` | `binaryNameToFileName(java.lang.String name)` Convert the binary name to the file name.
`static void` | `copy(java.io.InputStream is, java.io.OutputStream out, int bufferSize)` A copier.
`static void` | `destroyFile(java.io.File theFile)` Make sure a file is deleted for sure.
`static java.lang.String` | `hexFormatter16bit(int value)` Format a integer as a 4 digit hex.
`static java.lang.String` | `hexFormatter8bit(byte[] value)` Format a byte array as 2 digit hex.
`static byte[]` | `loadFileToArray(java.io.File file)` Load a file into an array.
`static byte[]` | `loadFileToArray(java.lang.String path)` Load a file into an array.
`static int` | `nextInteger()` Next integer starting with 1.
`static long` | `parseTimestampYYYYDDDHHMMSSmmmm(java.lang.String stamp)` A timestamp for matter for year,day,hour,minutes,seconds.
`static java.lang.String[]` | `snapStrings(java.lang.String target, int firstRun, int followingRuns)` Snap a string into sized pieces.
`static java.lang.String` | `timestampFormatterDDDHHMMSS(long time)` A timestamp for matter for day:hour,minutes,seconds.
`static java.lang.String` | `timestampFormatterHHMMSS()` A timestamp for matter for hour,minutes,seconds.
`static java.lang.String` | `timestampFormatterHHMMSS(long time)` A timestamp for matter for hour,minutes,seconds.
`static java.lang.String` | `timestampFormatterYYYYDDDHHMMSSmmmm()` A timestamp for matter for year,day,hour,minutes,seconds.
`static java.lang.String` | `timestampFormatterYYYYDDDHHMMSSmmmm(long time)` A timestamp for matter for year,day,hour,minutes,seconds.
`static long` | `timestampYYYYMMDD(java.lang.String text)` Parse a YYYYMMDD string into a timestamp (millis from epoch).
`static long` | `timestampYYYYMMDDHHMMSS(java.lang.String text)` Parse a YYYYMMDDHHMMSS string into a timestamp (millis from epoch).

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### HEX_VALUES

    public static final char[] HEX_VALUES

Constructor Detail

### ThingsUtilityBelt

    public ThingsUtilityBelt()

Method Detail

### timestampFormatterHHMMSS

    public static java.lang.String timestampFormatterHHMMSS()

  A timestamp for matter for hour,minutes,seconds. This is an expensive implementation. No extra characters--HHMMSS It uses the current time.

  Returns:
    A string representation of the timestamp.

### timestampYYYYMMDD

    public static long timestampYYYYMMDD(java.lang.String text)
                                  throws java.lang.Throwable

  Parse a YYYYMMDD string into a timestamp (millis from epoch).

  Parameters:
    `text` -
  Returns:
    the time
  Throws:
    `java.lang.Throwable` - if the format is null or bad.

### timestampYYYYMMDDHHMMSS

    public static long timestampYYYYMMDDHHMMSS(java.lang.String text)
                                        throws java.lang.Throwable

  Parse a YYYYMMDDHHMMSS string into a timestamp (millis from epoch).

  Parameters:
    `text` -
  Returns:
    the time
  Throws:
    `java.lang.Throwable` - if the format is null or bad.

### timestampFormatterHHMMSS

    public static java.lang.String timestampFormatterHHMMSS(long time)

  A timestamp for matter for hour,minutes,seconds. This is an expensive implementation. No extra characters--HHMMSS

  Parameters:
    `time` - timestamp in milliseconds
  Returns:
    A string representation of the timestamp

### timestampFormatterDDDHHMMSS

    public static java.lang.String timestampFormatterDDDHHMMSS(long time)

  A timestamp for matter for day:hour,minutes,seconds. This is an expensive implementation. No extra characters--DDDHHMMSS

  Parameters:
    `time` - timestamp in milliseconds
  Returns:
    A string representation of the timestamp

### timestampFormatterYYYYDDDHHMMSSmmmm

    public static java.lang.String timestampFormatterYYYYDDDHHMMSSmmmm()

  A timestamp for matter for year,day,hour,minutes,seconds. This is an expensive implementation. No extra characters--YYYYDDDHHMMSSmmmm. It uses the current time.

  Returns:
    A string representation of the timestamp.

### timestampFormatterYYYYDDDHHMMSSmmmm

    public static java.lang.String timestampFormatterYYYYDDDHHMMSSmmmm(long time)

  A timestamp for matter for year,day,hour,minutes,seconds. This is an expensive implementation. No extra characters--YYYYDDDHHMMSSmmmm.

  Parameters:
    `time` - timestamp in milliseconds.
  Returns:
    A string representation of the timestamp.

### parseTimestampYYYYDDDHHMMSSmmmm

    public static long parseTimestampYYYYDDDHHMMSSmmmm(java.lang.String stamp)
                                                throws java.lang.Throwable

  A timestamp for matter for year,day,hour,minutes,seconds. This is an expensive 01234567890123456 012345678901234567 implementation. YYYYDDDHHMMSSmmmm (17 characters) or YYYYDDD:HHMMSSmmmm (18 characters).

  Parameters:
    `stamp` - timestamp in milliseconds.
  Returns:
    A string representation of the timestamp.
  Throws:
    `java.lang.Throwable`

### hexFormatter16bit

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

  Format a integer as a 4 digit hex. It will not gracefully handle values over 64k.

  Parameters:
    `value` - the value to render as hex.
  Returns:
    A a 4 digit hex value.

### hexFormatter8bit

    public static java.lang.String hexFormatter8bit(byte[] value)

  Format a byte array as 2 digit hex.

  Parameters:
    `value` - bytes to format.
  Returns:
    A string of hex values.

### loadFileToArray

    public static byte[] loadFileToArray(java.lang.String path)
                                  throws java.io.IOException

  Load a file into an array. There is a practical limit to this, so limit yourself to 1meg. Even then, you might get Out of Memory, so don't use willy-nilly.

  Parameters:
    `path` - the String path to the file.
  Returns:
    the array
  Throws:
    `java.io.IOException`

### loadFileToArray

    public static byte[] loadFileToArray(java.io.File file)
                                  throws java.io.IOException

  Load a file into an array. There is a practical limit to this, so limit yourself to 1meg. Even then, you might get Out of Memory, so don't use willy-nilly.

  Parameters:
    `file` -
  Returns:
    the array
  Throws:
    `java.io.IOException`

### binaryNameToFileName

    public static java.lang.String binaryNameToFileName(java.lang.String name)
                                                 throws java.lang.Exception

  Convert the binary name to the file name.

  Parameters:
    `name` - The binary name.
  Throws:
    `an` - Exception if it encounters disallowed character--slashes, CR, LF, Space, or TAB.
    `java.lang.Exception`

### nextInteger

    public static int nextInteger()
                           throws java.lang.ArithmeticException

  Next integer starting with 1. As long as this class is loaded, it'll give the next integer. If it wraps, it'll throw an exception, but then troop along This is not universally safe, so use it for light-lifting stuff.

  Returns:
    the next integer
  Throws:
    `java.lang.ArithmeticException` - if it overflows.

### destroyFile

    public static void destroyFile(java.io.File theFile)
                            throws ThingsException

  Make sure a file is deleted for sure.

  Parameters:
    `theFile` - The file to smack!
  Throws:
    `ThingsException` - if it wouldn't deleted after several attempts.

### snapStrings

    public static java.lang.String[] snapStrings(java.lang.String target,
                                                 int firstRun,
                                                 int followingRuns)

  Snap a string into sized pieces.

  Parameters:
    `target` - the string to snap.
    `firstRun` - the size in characters of the first run.
    `followingRuns` - the size of all following runs.
  Returns:
    an ordered collection of snapped strings. It may be empty, if the target is null or empty or either run size is less than 1.

### copy

    public static void copy(java.io.InputStream is,
                            java.io.OutputStream out,
                            int bufferSize)
                     throws java.lang.Exception

  A copier.

  Parameters:
    `is` - input stream.
    `out` - output stream.
    `bufferSize` - The buffer size.
  Throws:
    `java.lang.Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Things.