org.oreodata.util
Class Util

java.lang.Object
  |
  +--org.oreodata.util.Util

public class Util
extends java.lang.Object

Dumping ground for utility functions that are more or less general-purpose.


Field Summary
static java.util.Enumeration EMPTY_ENUM
          An empty java.util.Enumeration, comes in handy for API's that require an Enumeration to be passed in or out.
static java.util.Iterator EMPTY_ITERATOR
          An empty java.util.Iterator, comes in handy for API's that require an Iterator to be passed in or out.
static java.lang.Integer ZERO
          A zero integer wrapper, defined statically here to avoid replications
 
Constructor Summary
Util()
           
 
Method Summary
static java.util.Enumeration arrayAsEnumeration(java.lang.Object[] arr)
          wraps an array of objects as an instance of java.util.Enumeration useful for API's that require an Enumeration to be passed in or out.
static java.lang.String convertHTMLEntities(java.lang.String s)
          Converts the literal characters in a string to HTML entities as need be.
 org.xml.sax.InputSource createEmptyInputSource(java.lang.String systemId)
           
static java.lang.Class findClass(java.lang.String className, java.lang.ClassLoader loader)
           
static java.lang.String fromByteEncodedString(java.lang.String s)
           
static java.io.InputStream getInputStream(java.lang.String location)
          Gets the specified input stream, assuming that it may be a fully specified filename, OR relative to the system classpath.
static java.io.InputStream getInputStream(java.lang.String location, java.lang.ClassLoader cl)
           
static java.lang.Throwable getNested(java.lang.Throwable t)
           
static void gunzipFile(java.io.File file)
           
static void gzipFile(java.io.File file)
           
static boolean hasContent(java.lang.String s)
           
static boolean hasNonAscii(java.lang.String s)
          A routine that says whether the given string has unicode characters in it -- by that I mean, characters above 0x7F, for which a naive byte encoding will not work.
static boolean isAffirmative(java.lang.String s)
           
static boolean isNegative(java.lang.String s)
           
static java.lang.String noNull(java.lang.String s)
           
static java.util.Iterator objectAsIterator(java.lang.Object o)
          take a single object and wrap it up as an instance of java.util.Iterator useful for API's that require an Iterator to be passed in or out.
static void printFullStackTrace(java.lang.Throwable t, java.io.PrintStream stream)
           
static java.lang.String randomAlphaNumString(int length)
          generate a random alphanum string of the given length.
static java.lang.String toByteEncodedString(java.lang.String s)
           
static java.lang.String toDoubleQuoteLiteral(java.lang.String s)
          A convenience routine that switches a string with possibly embedded \' to '' for escaping the single quote character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ENUM

public static final java.util.Enumeration EMPTY_ENUM
An empty java.util.Enumeration, comes in handy for API's that require an Enumeration to be passed in or out.


EMPTY_ITERATOR

public static final java.util.Iterator EMPTY_ITERATOR
An empty java.util.Iterator, comes in handy for API's that require an Iterator to be passed in or out.


ZERO

public static final java.lang.Integer ZERO
A zero integer wrapper, defined statically here to avoid replications

Constructor Detail

Util

public Util()
Method Detail

noNull

public static java.lang.String noNull(java.lang.String s)
Returns:
the zero-length string if s is null, otherwise just echoes

hasContent

public static boolean hasContent(java.lang.String s)
Returns:
true if the string is null or zero-length

getInputStream

public static java.io.InputStream getInputStream(java.lang.String location)
Gets the specified input stream, assuming that it may be a fully specified filename, OR relative to the system classpath.


getInputStream

public static java.io.InputStream getInputStream(java.lang.String location,
                                                 java.lang.ClassLoader cl)

findClass

public static java.lang.Class findClass(java.lang.String className,
                                        java.lang.ClassLoader loader)
                                 throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException

arrayAsEnumeration

public static java.util.Enumeration arrayAsEnumeration(java.lang.Object[] arr)
wraps an array of objects as an instance of java.util.Enumeration useful for API's that require an Enumeration to be passed in or out.


objectAsIterator

public static java.util.Iterator objectAsIterator(java.lang.Object o)
take a single object and wrap it up as an instance of java.util.Iterator useful for API's that require an Iterator to be passed in or out.


printFullStackTrace

public static void printFullStackTrace(java.lang.Throwable t,
                                       java.io.PrintStream stream)

getNested

public static java.lang.Throwable getNested(java.lang.Throwable t)

convertHTMLEntities

public static java.lang.String convertHTMLEntities(java.lang.String s)
Converts the literal characters in a string to HTML entities as need be.

Returns:
converted string or simply echoes if no conversion was necessary.

hasNonAscii

public static boolean hasNonAscii(java.lang.String s)
A routine that says whether the given string has unicode characters in it -- by that I mean, characters above 0x7F, for which a naive byte encoding will not work.


toByteEncodedString

public static java.lang.String toByteEncodedString(java.lang.String s)
Returns:
a String containing the UTF-8 encoding of the given string.

fromByteEncodedString

public static java.lang.String fromByteEncodedString(java.lang.String s)
Returns:
a String containing the straight unicode chars from previous byte encoding.

randomAlphaNumString

public static java.lang.String randomAlphaNumString(int length)
generate a random alphanum string of the given length.


toDoubleQuoteLiteral

public static java.lang.String toDoubleQuoteLiteral(java.lang.String s)
A convenience routine that switches a string with possibly embedded \' to '' for escaping the single quote character.


gzipFile

public static void gzipFile(java.io.File file)
                     throws java.io.IOException
java.io.IOException

gunzipFile

public static void gunzipFile(java.io.File file)
                       throws java.io.IOException
java.io.IOException

createEmptyInputSource

public org.xml.sax.InputSource createEmptyInputSource(java.lang.String systemId)

isNegative

public static boolean isNegative(java.lang.String s)

isAffirmative

public static boolean isAffirmative(java.lang.String s)