Holger's
Java API

com.antelmann.util
Class Misc

java.lang.Object
  extended by com.antelmann.util.Misc

public final class Misc
extends Object

just some miscellaneous stuff for convenience that doesn't fit anywhere else

Author:
Holger Antelmann

Field Summary
static UniversalComparator comparator
          a universally useful instance of a Comparator
 
Method Summary
static Properties asProperties(ResourceBundle bundle)
           
static KeyPair generateKeyPair()
           
static KeyPair generateKeyPair(int keySize)
           
static KeyPair generateKeyPair(String algorithm, int keySize)
           
static URLClassLoader loadClasses(File... dirOrJar)
          preloads all classes found in the given directories and/or Jar files
static URLClassLoader loadClasses(Monitor monitor, File... dirOrJar)
          preloads all classes found in the given directories and/or Jar files
static URLClassLoader loadFromClassPath(Monitor mon, String path)
          preloads all classes found in the given path
static URLClassLoader loadFromClassPath(String path)
          preloads all classes found in the given path
static String makeURLString(File file)
          generates a URL-like String of the form "file:///..
static void pause(long millisec)
          just simplifies a call to Thread.sleep()
static
<T> Comparator<T>
reverseComparator(Comparator<T> comp)
          returns an inversed filter to the given one
static
<T> Filter<T>
reverseFilter(Filter<T> filter)
          returns an inversed filter to the given one
static boolean same(Object s1, Object s2)
          returns true only if the the both objects are equal or both null, false otherwise
static Process start(String... params)
          starts a given file and other parameters with the platform specific application.startCommand in the settings.
static boolean start(URL url)
          This method attempts to start the given url with the associated default application (most likely a web-browser) by calling start urlPath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comparator

public static final UniversalComparator comparator
a universally useful instance of a Comparator

Method Detail

loadFromClassPath

public static URLClassLoader loadFromClassPath(String path)
                                        throws IOException
preloads all classes found in the given path

Returns:
the ClassLoader created to load the classes
Throws:
IOException

loadFromClassPath

public static URLClassLoader loadFromClassPath(Monitor mon,
                                               String path)
                                        throws IOException
preloads all classes found in the given path

Parameters:
mon - allows to individually monitor the loading process
path - the path to load the classes from
Returns:
the ClassLoader created to load the classes
Throws:
IOException

loadClasses

public static URLClassLoader loadClasses(File... dirOrJar)
                                  throws IOException
preloads all classes found in the given directories and/or Jar files

Parameters:
dirOrJar - Jar files or directories that are to be loaded
Returns:
the ClassLoader created to load the classes
Throws:
IOException

loadClasses

public static URLClassLoader loadClasses(Monitor monitor,
                                         File... dirOrJar)
                                  throws IOException
preloads all classes found in the given directories and/or Jar files

Parameters:
monitor - allows to individually monitor the loading process
dirOrJar - Jar files or directories that are to be loaded
Returns:
the ClassLoader created to load the classes
Throws:
IOException

makeURLString

public static String makeURLString(File file)
                            throws IOException
generates a URL-like String of the form "file:///.." using its canonical path and adds a slash at the end if the given file is a directory

Throws:
IOException

reverseFilter

public static <T> Filter<T> reverseFilter(Filter<T> filter)
returns an inversed filter to the given one


reverseComparator

public static <T> Comparator<T> reverseComparator(Comparator<T> comp)
returns an inversed filter to the given one


start

public static boolean start(URL url)
This method attempts to start the given url with the associated default application (most likely a web-browser) by calling start urlPath. If this doesn't work, nothing happens; errors are ignored. The method uses the parameter application.startCommand from the Properties obtained from Settings.getProperties() to start the url. Note that a successful call to this method is platform dependent; you may have to adjust the application.startCommand parameter to make this work for your platform. The different command parts of the application.startCommand are separated by a tab (\t). The default value for this parameter shipped with the antelmann.jar file works for Windows NT/2000/XP.

Returns:
true if no exceptions were thrown, false otherwise
See Also:
Settings.getProperties()

start

public static Process start(String... params)
                     throws IOException
starts a given file and other parameters with the platform specific application.startCommand in the settings. The different command parts of the application.startCommand are separated by a tab (\t) and the given params are added to the command list.

Throws:
IOException
See Also:
Settings.getProperties()

pause

public static void pause(long millisec)
just simplifies a call to Thread.sleep()


asProperties

public static Properties asProperties(ResourceBundle bundle)

generateKeyPair

public static KeyPair generateKeyPair()

generateKeyPair

public static KeyPair generateKeyPair(int keySize)

generateKeyPair

public static KeyPair generateKeyPair(String algorithm,
                                      int keySize)
                               throws NoSuchAlgorithmException
Throws:
NoSuchAlgorithmException

same

public static boolean same(Object s1,
                           Object s2)
returns true only if the the both objects are equal or both null, false otherwise



(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads