org.mozilla.util
Class Utilities

java.lang.Object
  extended by org.mozilla.util.Utilities

public class Utilities
extends java.lang.Object


Constructor Summary
Utilities()
           
 
Method Summary
static boolean arrayContainsElement(java.lang.Object[] anArray, java.lang.Object anElement)
          Returns "true" if the passed in array contains the passed in element.
static java.lang.String currentTimeString(boolean useTwentyFourHourTime, boolean showAMPMIndicator)
          Can return a string of the form "5:35:09pm", as opposed to "17:35:09" If "useTwentyFourHourTime" is "true", returns time in the form "17:35:09" If "showAMPMIndicator" is "true" it will include the "am" or "pm" text, otherwise it won't.
static boolean endsWithIgnoringCase(java.lang.String aString, java.lang.String possibleEnding)
          Case insensitive String.endsWith()
static java.lang.Object getImplFromServices(java.lang.String interfaceClassName)
          This method tries to load the resource META-INF/services/<interfaceClassName>, where <interfaceClassName> is the argument to this method.
static java.lang.String getPackageName(java.lang.Class aClass)
           
static java.util.ResourceBundle getResourceBundle(java.lang.String baseName)
          This method is a simpler alternative to ResourceLoader.loadResourceBundle.
static java.awt.Component getTopLevelParent(java.awt.Component aComponent)
          Uses "getParent()" to find this Component's top-level ancestor.
static java.lang.String removeAllWhitespace(java.lang.String aString)
          Removes leading, trailing, and internal whitespace from the passed-in string.
static java.lang.String stringFromVector(java.util.Vector aVector, java.lang.String delimiter)
          Creates a String by combining the elements of aVector.
static java.util.Vector vectorFromArray(java.lang.Object[] anArray)
          Convert an Array into a Vector.
static java.util.Vector vectorFromString(java.lang.String input, java.lang.String delimiter)
          Take the given string and chop it up into a series of strings on "delimiter" boundries.
static boolean vectorsAreEqual(java.util.Vector vectorOne, java.util.Vector vectorTwo)
          Amazing that "Vector" does not override Object's "equals()" method to do this itself!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utilities

public Utilities()
Method Detail

vectorFromString

public static java.util.Vector vectorFromString(java.lang.String input,
                                                java.lang.String delimiter)
Take the given string and chop it up into a series of strings on "delimiter" boundries. This is useful for trying to get an array of strings out of the resource file.


stringFromVector

public static java.lang.String stringFromVector(java.util.Vector aVector,
                                                java.lang.String delimiter)
Creates a String by combining the elements of aVector. after each element it will insert the String "delimiter". If no "delimiter" is desired, the "delimiter" parameter should be ""


vectorFromArray

public static java.util.Vector vectorFromArray(java.lang.Object[] anArray)
Convert an Array into a Vector. Can you *believe* that there is no Vector constructor which takes an Array!!! &()*&$#(*&$


vectorsAreEqual

public static boolean vectorsAreEqual(java.util.Vector vectorOne,
                                      java.util.Vector vectorTwo)
Amazing that "Vector" does not override Object's "equals()" method to do this itself!


arrayContainsElement

public static boolean arrayContainsElement(java.lang.Object[] anArray,
                                           java.lang.Object anElement)
Returns "true" if the passed in array contains the passed in element. Checks for equality using ".equals()". Returns "false" if "anArray" is null.


removeAllWhitespace

public static java.lang.String removeAllWhitespace(java.lang.String aString)
Removes leading, trailing, and internal whitespace from the passed-in string. Returns a new string without any whitespace.


currentTimeString

public static java.lang.String currentTimeString(boolean useTwentyFourHourTime,
                                                 boolean showAMPMIndicator)
Can return a string of the form "5:35:09pm", as opposed to "17:35:09" If "useTwentyFourHourTime" is "true", returns time in the form "17:35:09" If "showAMPMIndicator" is "true" it will include the "am" or "pm" text, otherwise it won't. Note that the "showAMPMIndicator" field is ignored if "useTwentyFourHourTime" is "true" since it provides redundant information in that case.


getTopLevelParent

public static java.awt.Component getTopLevelParent(java.awt.Component aComponent)
Uses "getParent()" to find this Component's top-level ancestor. If this Component has no ancestors, this method will return the Component itself.


getPackageName

public static java.lang.String getPackageName(java.lang.Class aClass)
Parameters:
aClass - the class whose package name should be returned
Returns:
the fully qualified package name of the given class, null if not found

getResourceBundle

public static java.util.ResourceBundle getResourceBundle(java.lang.String baseName)
This method is a simpler alternative to ResourceLoader.loadResourceBundle. Instead of returning an PropertyResourceBundle, as ResourceLoader.loadResourceBundle does, it must returns a java.util.ResourceBundle

Parameters:
baseName - the fully qualified name of the resource bundle, sans ".properties" suffix. For example, a valid value for baseName would be com.sun.jag.apps.spex.util.SUResources when the properties file SUResources.properties is in the classpath under the directory com/sun/jag/apps/spex/util.
Returns:
the actual ResourceBundle instance, or null if not found.

endsWithIgnoringCase

public static boolean endsWithIgnoringCase(java.lang.String aString,
                                           java.lang.String possibleEnding)
Case insensitive String.endsWith()


getImplFromServices

public static java.lang.Object getImplFromServices(java.lang.String interfaceClassName)

This method tries to load the resource META-INF/services/<interfaceClassName>, where <interfaceClassName> is the argument to this method. If the resource is found, interpret it as a Properties file and read out its first line. Interpret the first line as the fully qualified class name of a class that implements interfaceClassName. The named class must have a public no-arg constructor.



Copyright © 2002-2005 Mozilla.org All Rights Reserved.