voji.utils
Class U

java.lang.Object
  |
  +--voji.utils.U

public final class U
extends java.lang.Object

This class contains many methods which are useful for java.lang.String, java.util.Vector, java.sql.ResultSet and java.sql.PreparedStatement. These methods should be a part of the API of those classes, but they aren't. So this is a work-around, but no solution.

Message to Sun: Please complete your API! The functions here are simple, but are often indispensible and would be great additions.


Method Summary
static java.util.Vector add(java.util.Vector vector, java.util.Enumeration enum)
          Adds all elements of an Enumeration to a Vector.
static java.util.Vector add(java.util.Vector vector, java.util.Iterator iterator)
          Adds all elements of an Iterator to a Vector.
static java.util.Vector add(java.util.Vector vector, java.lang.Object[] objects)
          Adds the content of an Object Array to a Vector.
static java.lang.String format(java.text.Format format, java.lang.Object object)
          Formats an Object using a Format without throwing an exception
static java.lang.String format(java.text.Format format, java.lang.Object object, java.lang.String def)
          Formats an Object using a Format without throwing an exception
static java.util.Vector getColumnNames(java.sql.ResultSet resultSet)
          Puts a ResultSet's column names into a Vector
static java.util.Vector getColumnNames(java.sql.ResultSetMetaData metaData)
          Puts a ResultSetMetaData's column names into a Vector
static java.lang.Object parseObject(java.text.Format format, java.lang.String string)
          Parses a String using a Format without throwing an exception
static java.util.Vector removeAll(java.util.Vector vector, java.lang.Object object)
          Removes all occurences of an Object from a Vector.
static java.lang.StringBuffer replace(java.lang.StringBuffer text, java.lang.String from, java.lang.String to)
          Replaces all occurences of a sub String in a StringBuffer.
static java.lang.String replace(java.lang.String text, java.lang.String from, java.lang.String to)
          Replaces all occurences of a sub String in a String
static java.util.Vector splitString(java.lang.String text, java.lang.String start, java.lang.String between, java.lang.String end)
          Splits a String
static java.util.Vector splitStringNE(java.lang.String text, java.lang.String start, java.lang.String between, java.lang.String end)
          Splits a String into non-empty parts
static void synchronizeDirectory(javax.swing.JFileChooser fileChooser)
          Synchronizes the current directory between file choosers.
static java.lang.Object[] toArray(java.util.Vector vector)
          Converts a Vector into an Array.
static java.lang.Object[][] toArrayOfArrays(java.util.Vector vector)
          Converts a Vector of Vectors to an Array of Object Arrays
static java.lang.String toString(java.util.Vector parts, java.lang.String start, java.lang.String between, java.lang.String end)
          Concatenates some Strings
static java.lang.String[] toStringArray(java.util.Vector vector)
          Converts a Vector into a String Array.
static java.util.Vector toVector(java.util.Enumeration enum)
          Converts an Enumeration to a Vector.
static java.util.Vector toVector(java.util.Iterator iterator)
          Converts an Iterator to a Vector.
static java.util.Vector toVector(java.lang.Object[] objects)
          Converts an Object Array to a Vector.
static java.util.Vector toVector(java.sql.ResultSet resultSet)
          Puts the current row's data of a ResultSet into a Vector
static java.util.Vector toVectorOfVectors(java.lang.Object[][] objects)
          Converts an Array of Object Arrays to a Vector of Vectors
static java.util.Vector toVectorOfVectors(java.sql.ResultSet resultSet)
          Converts a ResultSet into a Vector of Vectors.
static java.util.Vector toVectorOfVectors(java.sql.ResultSet resultSet, int maxRows)
          Converts a ResultSet into a Vector of Vectors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

removeAll

public static java.util.Vector removeAll(java.util.Vector vector,
                                         java.lang.Object object)
Removes all occurences of an Object from a Vector.

Parameters:
vector - the Vector where to remove from
object - the Object whose equal occourences have to be removed
Returns:
the given Vector

add

public static java.util.Vector add(java.util.Vector vector,
                                   java.util.Enumeration enum)
Adds all elements of an Enumeration to a Vector. After this procedure the Enumeration will be useless, because it won't have any more elements.

Parameters:
vector - the Vector where to insert the elements
enum - the Enumeration where to take the elements from
Returns:
the given Vector

toVector

public static java.util.Vector toVector(java.util.Enumeration enum)
Converts an Enumeration to a Vector. After this operation the Enumeration will be useless, because it won't have any more elements.

Parameters:
enum - the Enumeration where to take the elements from
Returns:
a newly created Vector containing all elements of the given Enumeration

add

public static java.util.Vector add(java.util.Vector vector,
                                   java.util.Iterator iterator)
Adds all elements of an Iterator to a Vector.

Parameters:
vector - the Vector where to insert the elements
iterator - the Iterator where to take the elements from
Returns:
the given Vector

toVector

public static java.util.Vector toVector(java.util.Iterator iterator)
Converts an Iterator to a Vector.

Parameters:
iterator - the Iterator where to take the elements from
Returns:
a newly created Vector containing all elements of the given Iterator

add

public static java.util.Vector add(java.util.Vector vector,
                                   java.lang.Object[] objects)
Adds the content of an Object Array to a Vector.

Parameters:
vector - the Vector where to insert the elements
objects - the Array where to take the elements from
Returns:
the given Vector

toVector

public static java.util.Vector toVector(java.lang.Object[] objects)
Converts an Object Array to a Vector.

Parameters:
objects - the Object Array where to take the elements from
Returns:
a newly created Vector containing all elements of the given Array

toVectorOfVectors

public static java.util.Vector toVectorOfVectors(java.lang.Object[][] objects)
Converts an Array of Object Arrays to a Vector of Vectors

Parameters:
objects - the Array of Object Arrays where to take the elements from
Returns:
a newly created Vector of Vectors containing all elements of the given Array of Object Arrays

toArrayOfArrays

public static java.lang.Object[][] toArrayOfArrays(java.util.Vector vector)
Converts a Vector of Vectors to an Array of Object Arrays

Parameters:
vector - the Vector of Vectors where to take the elements from
Returns:
a newly created Array of Object Arrays containing all elements of the given Vector of Vectors

getColumnNames

public static java.util.Vector getColumnNames(java.sql.ResultSetMetaData metaData)
                                       throws java.sql.SQLException
Puts a ResultSetMetaData's column names into a Vector

Parameters:
metaData - the ResultSetMetaData where to take the column names from
Returns:
a newly created Vector containing the column names of metaData
Throws:
java.sql.SQLException - if there is an SQLException while working with the ResultSetMetaData

getColumnNames

public static java.util.Vector getColumnNames(java.sql.ResultSet resultSet)
                                       throws java.sql.SQLException
Puts a ResultSet's column names into a Vector

Parameters:
resultSet - the ResultSet where to take the column names from
Returns:
a newly created Vector containing the column names of resultSet
Throws:
java.sql.SQLException - if there is an SQLException while working with the ResultSet

toVector

public static java.util.Vector toVector(java.sql.ResultSet resultSet)
                                 throws java.sql.SQLException
Puts the current row's data of a ResultSet into a Vector

Parameters:
resultSet - the ResultSet where to get the data from
Returns:
a newly created Vector containing the data of the resultSet's current row
Throws:
java.sql.SQLException - if there is an SQLException while working with the ResultSet

toVectorOfVectors

public static java.util.Vector toVectorOfVectors(java.sql.ResultSet resultSet)
                                          throws java.sql.SQLException
Converts a ResultSet into a Vector of Vectors. It goes through the whole ResultSet and copies all data into a newly created Vector of Vectors.

Parameters:
resultSet - the ResultSet where to take the data from
Returns:
a newly created Vector containing one Vector for each result row
Throws:
java.sql.SQLException - if there is an SQLException while working with the ResultSet

toVectorOfVectors

public static java.util.Vector toVectorOfVectors(java.sql.ResultSet resultSet,
                                                 int maxRows)
                                          throws java.sql.SQLException
Converts a ResultSet into a Vector of Vectors. It goes through the whole ResultSet and copies all data into a newly created Vector of Vectors.

Parameters:
resultSet - the ResultSet where to take the data from
maxRows - the maximum number of rows or -1 for no maximum
Returns:
a newly created Vector containing one Vector for each result row
Throws:
java.sql.SQLException - if there is an SQLException while working with the ResultSet

toArray

public static java.lang.Object[] toArray(java.util.Vector vector)
Converts a Vector into an Array.

Parameters:
vector - the Vector where to take the Objects from
Returns:
an Object Array containing the the elements of the Vector

toStringArray

public static java.lang.String[] toStringArray(java.util.Vector vector)
Converts a Vector into a String Array. It uses the toString() method of each elements of the Vector.

Parameters:
vector - the Vector where to take the Strings from
Returns:
a String Array containing the string representations of the elements of the Vector

splitString

public static java.util.Vector splitString(java.lang.String text,
                                           java.lang.String start,
                                           java.lang.String between,
                                           java.lang.String end)
Splits a String

Parameters:
text - the String to split
start - the begin of the String which has to be ignored
between - the separator between all the parts of text
end - the end of the String which has to be ignored
Returns:
a Vector containing the parts of text

splitStringNE

public static java.util.Vector splitStringNE(java.lang.String text,
                                             java.lang.String start,
                                             java.lang.String between,
                                             java.lang.String end)
Splits a String into non-empty parts

Parameters:
text - the String to split
start - the begin of the String which has to be ignored
between - the separator between all the parts of text
end - the end of the String which has to be ignored
Returns:
a Vector containing the parts of text without the empty ones.

toString

public static java.lang.String toString(java.util.Vector parts,
                                        java.lang.String start,
                                        java.lang.String between,
                                        java.lang.String end)
Concatenates some Strings

Parameters:
parts - a Vector containing the parts
start - the begin of the full String
between - the String which is situated between the parts
end - the end of the full String
Returns:
the resulting String of the concatenation

replace

public static java.lang.StringBuffer replace(java.lang.StringBuffer text,
                                             java.lang.String from,
                                             java.lang.String to)
Replaces all occurences of a sub String in a StringBuffer. It manipulates the given StringBuffer directly!

Parameters:
text - the input StringBuffer where to replace
from - the sub String which has to replaced by to
to - the sub String which has to be used instead of from
Returns:
the given StringBuffer

replace

public static java.lang.String replace(java.lang.String text,
                                       java.lang.String from,
                                       java.lang.String to)
Replaces all occurences of a sub String in a String

Parameters:
text - the input String where to replace
from - the sub String which has to replaced by to
to - the sub String which has to be used instead of from
Returns:
a new String which is the result of the replacements

parseObject

public static java.lang.Object parseObject(java.text.Format format,
                                           java.lang.String string)
Parses a String using a Format without throwing an exception

Parameters:
format - the Format object that has to parse
string - the String that has to be parsed
Returns:
the result of the parsing, string when format is null or null when there was an exception during the parsing

format

public static java.lang.String format(java.text.Format format,
                                      java.lang.Object object,
                                      java.lang.String def)
Formats an Object using a Format without throwing an exception

Parameters:
format - the Format object that has to format
object - the Object that has to be formatted
def - the default String to return on problems
Returns:
the result of the formatting or object.toString() when format is null or def when there was an exception during the formatting
See Also:
format(Format,Object)

format

public static java.lang.String format(java.text.Format format,
                                      java.lang.Object object)
Formats an Object using a Format without throwing an exception

Parameters:
format - the Format object that has to format
object - the Object that has to be formatted
Returns:
the result of the formatting or object.toString() when format is null or "" when there was an exception during the formatting
See Also:
format(Format,Object,String)

synchronizeDirectory

public static void synchronizeDirectory(javax.swing.JFileChooser fileChooser)
Synchronizes the current directory between file choosers. This is useful if you really need more than one file chooser for your application.

Parameters:
fileChooser - the FileChooser whose current directory needs to be set.