org.dmonix.util
Class ClassUtil

java.lang.Object
  extended byorg.dmonix.util.ClassUtil

public abstract class ClassUtil
extends java.lang.Object

Miscellaneus utility methods.

Copyright: Copyright (c) 2004

Company: dmonix.org

Version:
1.0
Author:
Peter Nerg

Constructor Summary
ClassUtil()
           
 
Method Summary
static boolean isInterfaceImplemention(java.lang.Class interfaceClass, java.lang.Class c, boolean checkParent)
          Checks if a class implements the requested interface.
static boolean isInterfaceImplemention(java.lang.String interfaceClass, java.lang.Class c, boolean checkParent)
          Checks if a class implements the requested interface.
static void openBrowser(java.lang.String url)
          Opens the default brower with the supplied URL.
static java.lang.String padNumber(int number, int length)
          Returns a string with a leading zero(es) if the input number is shorter than the requested length.
static java.lang.String padString(java.lang.String s, int size)
          Returns a string with a leading zero(es) if the input string is shorter than the requested length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassUtil

public ClassUtil()
Method Detail

isInterfaceImplemention

public static boolean isInterfaceImplemention(java.lang.Class interfaceClass,
                                              java.lang.Class c,
                                              boolean checkParent)
Checks if a class implements the requested interface.
If the class does not implements the requested interface and the checkParent is true then all the the parents will be checked until either a class that implements the interface or there are no more parent classes.

Parameters:
interfaceClass - The interface class
c - The class to check
checkParent - true - checks all parents, false checks only the provided class
Returns:
true if the class or parent class implements the interface, false otherwise
See Also:
isInterfaceImplemention(String, Class, boolean)

isInterfaceImplemention

public static boolean isInterfaceImplemention(java.lang.String interfaceClass,
                                              java.lang.Class c,
                                              boolean checkParent)
Checks if a class implements the requested interface.
If the class does not implements the requested interface and the checkParent is true then all the the parents will be checked until either a class that implements the interface or there are no more parent classes.

Parameters:
interfaceClass - The interface class
c - The class to check
checkParent - true - checks all parents, false checks only the provided class
Returns:
true if the class or parent class implements the interface, false otherwise

openBrowser

public static void openBrowser(java.lang.String url)
                        throws java.lang.ClassNotFoundException,
                               java.lang.NoSuchMethodException,
                               java.net.MalformedURLException,
                               java.lang.reflect.InvocationTargetException,
                               java.lang.IllegalAccessException
Opens the default brower with the supplied URL.
The method requires the com.sun.javaws.BrowserSupport class to be included in the classpath.
The above class will automatically be included in the classpath if the application invoking this method is running under Java Web Start.

Parameters:
url - The URL
Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
java.net.MalformedURLException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

padNumber

public static java.lang.String padNumber(int number,
                                         int length)
Returns a string with a leading zero(es) if the input number is shorter than the requested length.

Parameters:
number - The number to pad
length - The requested length of the string
Returns:
The padded string representation

padString

public static java.lang.String padString(java.lang.String s,
                                         int size)
Returns a string with a leading zero(es) if the input string is shorter than the requested length.

Parameters:
s - The string to pad
size - The requested length of the string
Returns:
The padded string representation


Copyright © 1998-2005 dmonix.org Peter Nerg, All Rights Reserved.