org.galagosearch.tupleflow
Class Utility

java.lang.Object
  extended by org.galagosearch.tupleflow.Utility

public class Utility
extends java.lang.Object

Lots of static methods here that have broad use.

Author:
trevor

Constructor Summary
Utility()
           
 
Method Summary
static void calculateMessageDigest(java.io.File file, java.security.MessageDigest instance)
           
static java.lang.String caps(java.lang.String input)
           
static int compare(byte[] one, byte[] two)
           
static int compare(double one, double two)
           
static int compare(float one, float two)
           
static int compare(int one, int two)
           
static int compare(long one, long two)
           
static int compare(java.lang.String one, java.lang.String two)
           
static void copyFileToStream(java.io.File file, java.io.OutputStream stream)
          Copies the data from file into the stream.
static void copyStreamToFile(java.io.InputStream stream, java.io.File file)
          Copies the data from the InputStream to a file, then closes both when finished.
static java.io.File createTemporary()
           
static java.io.File createTemporary(long requiredSpace)
           
static void deleteDirectory(java.io.File directory)
           
static java.lang.String escape(java.lang.String raw)
           
static int getFreePort()
          Finds a free port to listen on.
static long getFreeSpace(java.lang.String pathname)
           
static Step getSorter(Order sortOrder)
          Builds a simple Sorter step that can be added to a TupleFlow stage.
static long getUnixFreeSpace(java.lang.String pathname)
           
static int hash(byte b)
           
static int hash(byte[] b)
           
static int hash(double d)
           
static int hash(float f)
           
static int hash(int i)
           
static int hash(long l)
           
static int hash(java.lang.String s)
           
static boolean isInteger(java.lang.String s)
           
static java.lang.String join(java.lang.String[] args)
           
static java.lang.String join(java.lang.String[] args, java.lang.String delimiter)
          Returns a string containing all the elements of args, space delimited.
static byte[] makeBytes(java.lang.String word)
           
static java.lang.String makeString(byte[] word)
           
static java.lang.String plural(java.lang.String input)
           
static java.util.HashSet<java.lang.String> readFileToStringSet(java.io.File file)
           
static java.lang.String strip(java.lang.String source, java.lang.String suffix)
           
static java.lang.String[] subarray(java.lang.String[] master, int index)
          For an array master, returns an array containing the last master.length-index elements.
static java.lang.String wrap(java.lang.String t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utility

public Utility()
Method Detail

getSorter

public static Step getSorter(Order sortOrder)
Builds a simple Sorter step that can be added to a TupleFlow stage.

Parameters:
sortOrder - An order object representing how and what to sort.
Returns:
a Step object that can be added to a TupleFlow Stage.

getFreePort

public static int getFreePort()
                       throws java.io.IOException
Finds a free port to listen on. Useful for starting up internal web servers. (copied from chaoticjava.com)

Throws:
java.io.IOException

isInteger

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

wrap

public static java.lang.String wrap(java.lang.String t)

escape

public static java.lang.String escape(java.lang.String raw)

strip

public static java.lang.String strip(java.lang.String source,
                                     java.lang.String suffix)

makeString

public static java.lang.String makeString(byte[] word)

makeBytes

public static byte[] makeBytes(java.lang.String word)

subarray

public static java.lang.String[] subarray(java.lang.String[] master,
                                          int index)
For an array master, returns an array containing the last master.length-index elements.


join

public static java.lang.String join(java.lang.String[] args,
                                    java.lang.String delimiter)
Returns a string containing all the elements of args, space delimited.


join

public static java.lang.String join(java.lang.String[] args)

caps

public static java.lang.String caps(java.lang.String input)

plural

public static java.lang.String plural(java.lang.String input)

compare

public static int compare(int one,
                          int two)

compare

public static int compare(long one,
                          long two)

compare

public static int compare(double one,
                          double two)

compare

public static int compare(float one,
                          float two)

compare

public static int compare(java.lang.String one,
                          java.lang.String two)

compare

public static int compare(byte[] one,
                          byte[] two)

hash

public static int hash(byte b)

hash

public static int hash(int i)

hash

public static int hash(long l)

hash

public static int hash(double d)

hash

public static int hash(float f)

hash

public static int hash(java.lang.String s)

hash

public static int hash(byte[] b)

deleteDirectory

public static void deleteDirectory(java.io.File directory)
                            throws java.io.IOException
Throws:
java.io.IOException

createTemporary

public static java.io.File createTemporary()
                                    throws java.io.IOException
Throws:
java.io.IOException

getUnixFreeSpace

public static long getUnixFreeSpace(java.lang.String pathname)
                             throws java.io.IOException
Throws:
java.io.IOException

getFreeSpace

public static long getFreeSpace(java.lang.String pathname)
                         throws java.io.IOException
Throws:
java.io.IOException

createTemporary

public static java.io.File createTemporary(long requiredSpace)
                                    throws java.io.IOException
Throws:
java.io.IOException

copyFileToStream

public static void copyFileToStream(java.io.File file,
                                    java.io.OutputStream stream)
                             throws java.io.IOException
Copies the data from file into the stream. Note that this method does not close the stream (in case you want to put more in it).

Parameters:
file -
stream -
Throws:
java.io.IOException

copyStreamToFile

public static void copyStreamToFile(java.io.InputStream stream,
                                    java.io.File file)
                             throws java.io.IOException
Copies the data from the InputStream to a file, then closes both when finished.

Parameters:
stream -
file -
Throws:
java.io.IOException

calculateMessageDigest

public static void calculateMessageDigest(java.io.File file,
                                          java.security.MessageDigest instance)
                                   throws java.io.IOException
Throws:
java.io.IOException

readFileToStringSet

public static java.util.HashSet<java.lang.String> readFileToStringSet(java.io.File file)
                                                               throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2009. All Rights Reserved.