org.norvelle.textcite.model
Class Utils

java.lang.Object
  extended by org.norvelle.textcite.model.Utils

public class Utils
extends java.lang.Object

Utils

Author:
eriknorvelle

Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String getExtension(java.io.File f)
          Get the extension of a file.
static java.lang.Object getObjectAtIteratorPos(java.util.Iterator i, int pos)
          Given a numeric position, cycle through the given Iterator until the position is reached, and return the Object found there.
static int getPosInEnumeration(java.util.Enumeration e, java.lang.Object o)
          Find the location of a given object in an Enumeration.
static int getPosInIterator(java.util.Iterator i, java.lang.Object o)
          Find the location of a given object in an Iterator.
static java.lang.String loadTextFile(java.lang.String filename)
          Load a text file into a string, from within the Jar itself
static java.lang.String noNullString(java.lang.String s)
          Useful for situations where one needs to use a string, while being sure that it isn't null.
 
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

getPosInIterator

public static int getPosInIterator(java.util.Iterator i,
                                   java.lang.Object o)
Find the location of a given object in an Iterator. Useful for finding the numeric position of an object in a sorted Map.

Parameters:
i - The Iterator that contains the objects to be compared against
o - The Object that is to be located
Returns:
The position of the Object o in the Iterator, or -1 if not found.

getPosInEnumeration

public static int getPosInEnumeration(java.util.Enumeration e,
                                      java.lang.Object o)
Find the location of a given object in an Enumeration. Useful for finding the numeric position of an object in a set of node children

Parameters:
i - The Enumeration that contains the objects to be compared against
o - The Object that is to be located
Returns:
The position of the Object o in the Iterator, or -1 if not found.

getObjectAtIteratorPos

public static java.lang.Object getObjectAtIteratorPos(java.util.Iterator i,
                                                      int pos)
                                               throws java.lang.ArrayIndexOutOfBoundsException
Given a numeric position, cycle through the given Iterator until the position is reached, and return the Object found there.

Parameters:
i - The Iterator to be cycled through.
pos - The numeric position of the Object to be returned
Returns:
The Object at the indicated position
Throws:
java.lang.ArrayIndexOutOfBoundsException

getExtension

public static java.lang.String getExtension(java.io.File f)
Get the extension of a file.

Parameters:
f - The File object to extract the extension from
Returns:
The extension (minus the period) in lower case.

loadTextFile

public static java.lang.String loadTextFile(java.lang.String filename)
                                     throws java.io.IOException
Load a text file into a string, from within the Jar itself

Parameters:
filename - The path + name of the file to load, relative to the Application class
Returns:
The contents of the file as a String
Throws:
java.io.IOException

noNullString

public static java.lang.String noNullString(java.lang.String s)
Useful for situations where one needs to use a string, while being sure that it isn't null.