You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.




org.mozilla.util
Class Utilities

java.lang.Object
  |
  +--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.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 delimeter)
          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 delimeter)
          Take the given string and chop it up into a series of strings on "delimeter" 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 delimeter)
Take the given string and chop it up into a series of strings on "delimeter" 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 delimeter)
Creates a String by combining the elements of aVector. after each element it will insert the String "delimeter". If no "delimeter" is desired, the "delimeter" 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()