com.bm.ejb3metadata.utils
Class MetadataUtils

java.lang.Object
  extended by com.bm.ejb3metadata.utils.MetadataUtils

public final class MetadataUtils
extends java.lang.Object

Util class for ejb3unit.

Author:
Daniel Wiese

Field Summary
static int OSTYPE_LINUX
          This field is used to OSTYPE_LINUX.
static int OSTYPE_MAC
          This field is used to OSTYPE_MAC.
static int OSTYPE_NETWARE
          This field is used to OSTYPE_NETWARE.
static int OSTYPE_OS2
          This field is used to OSTYPE_OS2.
static int OSTYPE_SOLARIS
          This field is used to OSTYPE_SOLARIS.
static int OSTYPE_UNKNOWN
          This field is used to OSTYPE_UNKNOWN.
static int OSTYPE_WINCE
          This field is used to OSTYPE_WINCE.
static int OSTYPE_WINDOWS
          This field is used to OSTYPE_WINDOWS.
static int OSTYPE_WINNT
          This field is used to OSTYPE_WINNT.
 
Method Summary
static java.lang.reflect.Field[] getAllFields(java.lang.Class forClass)
          Returns all fields (including fields from all superclasses) of a class.
static java.lang.reflect.Method[] getAllMethods(java.lang.Class forClass)
          Returns all fields (including fields from all superclasses) of a class.
static java.util.List<java.lang.Class> getLocalRemoteInterfaces(java.lang.Class toAnalyse)
          Returns all business (local, remote) interfaces of the class.
static java.lang.Class getNonPrimitiveType(java.lang.Class aktField)
          This method will do the transformation of primitive types if neccessary.
static int getOs()
          Determines the OS.
static java.lang.String getPackageName(java.lang.String longClassName)
          Retrun a short class name.
static java.io.File getRootPackageDir(java.io.File location, java.lang.String longPackageName)
          Retrurns the root package directory e.g com.ejb3unit.eg --> returns com.
static java.lang.String getShortClassName(java.lang.Class clazz)
          Retrun a short class name.
static java.lang.String getShortClassName(java.lang.String longClassName)
          Retrun a short class name.
static java.io.File getTempDirectory()
          Returns a path to an temp directory.
static java.lang.String isolateJarName(java.net.URL fileInJar)
          Isolates a jar file when a file was found inside a jar.
static java.util.List<java.lang.String> scanFileNamesInArchive(java.io.InputStream in)
          Scan for files in jar file.
static java.util.List<java.io.File> unjar(java.io.InputStream in, java.io.File dest)
          Dump the contents of a JarArchive to the dpecified destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OSTYPE_WINDOWS

public static final int OSTYPE_WINDOWS
This field is used to OSTYPE_WINDOWS.

See Also:
Constant Field Values

OSTYPE_WINNT

public static final int OSTYPE_WINNT
This field is used to OSTYPE_WINNT.

See Also:
Constant Field Values

OSTYPE_WINCE

public static final int OSTYPE_WINCE
This field is used to OSTYPE_WINCE.

See Also:
Constant Field Values

OSTYPE_LINUX

public static final int OSTYPE_LINUX
This field is used to OSTYPE_LINUX.

See Also:
Constant Field Values

OSTYPE_MAC

public static final int OSTYPE_MAC
This field is used to OSTYPE_MAC.

See Also:
Constant Field Values

OSTYPE_SOLARIS

public static final int OSTYPE_SOLARIS
This field is used to OSTYPE_SOLARIS.

See Also:
Constant Field Values

OSTYPE_NETWARE

public static final int OSTYPE_NETWARE
This field is used to OSTYPE_NETWARE.

See Also:
Constant Field Values

OSTYPE_OS2

public static final int OSTYPE_OS2
This field is used to OSTYPE_OS2.

See Also:
Constant Field Values

OSTYPE_UNKNOWN

public static final int OSTYPE_UNKNOWN
This field is used to OSTYPE_UNKNOWN.

See Also:
Constant Field Values
Method Detail

isolateJarName

public static java.lang.String isolateJarName(java.net.URL fileInJar)
Isolates a jar file when a file was found inside a jar.

Parameters:
fileInJar - - the path to the file inside the jar file
Returns:
- the name of the jar file

getOs

public static int getOs()
Determines the OS.

Returns:
an integer identifying the OS (one of the OSTYPE constants)

unjar

public static java.util.List<java.io.File> unjar(java.io.InputStream in,
                                                 java.io.File dest)
                                          throws java.io.IOException
Dump the contents of a JarArchive to the dpecified destination.

Parameters:
in - - the jar archive as input stream
dest - - the destination (to extract the content)
Returns:
- a list with all extracted files
Throws:
java.io.IOException - - in an error case

scanFileNamesInArchive

public static java.util.List<java.lang.String> scanFileNamesInArchive(java.io.InputStream in)
                                                               throws java.io.IOException
Scan for files in jar file.

Parameters:
in - - the jar archive as input stream
Returns:
- a list with all extracted files
Throws:
java.io.IOException - - in an error case

getLocalRemoteInterfaces

public static java.util.List<java.lang.Class> getLocalRemoteInterfaces(java.lang.Class toAnalyse)
Returns all business (local, remote) interfaces of the class.

Parameters:
toAnalyse - - the session bean /service to analyse
Returns:
- the interfaces
Since:
05.02.2006

getNonPrimitiveType

public static java.lang.Class getNonPrimitiveType(java.lang.Class aktField)
This method will do the transformation of primitive types if neccessary.

Parameters:
aktField - - the field to inspect
Returns:
the declaring type (or primitive representant)

getAllFields

public static java.lang.reflect.Field[] getAllFields(java.lang.Class forClass)
Returns all fields (including fields from all superclasses) of a class.

Parameters:
forClass - - for which class
Returns:
- all fields

getAllMethods

public static java.lang.reflect.Method[] getAllMethods(java.lang.Class forClass)
Returns all fields (including fields from all superclasses) of a class.

Parameters:
forClass - - for which class
Returns:
- all fields

getShortClassName

public static java.lang.String getShortClassName(java.lang.String longClassName)
Retrun a short class name. E.g. java.util.StringTokenizer will be StringTokenizer

Parameters:
longClassName - - the long fully qualified calss name
Returns:
- short class name

getPackageName

public static java.lang.String getPackageName(java.lang.String longClassName)
Retrun a short class name. E.g. java.util.StringTokenizer will be StringTokenizer

Parameters:
longClassName - - the long fully qualified calss name
Returns:
- short class name

getRootPackageDir

public static java.io.File getRootPackageDir(java.io.File location,
                                             java.lang.String longPackageName)
Retrurns the root package directory e.g com.ejb3unit.eg --> returns com.

Parameters:
location - - the location of th epackage
longPackageName - - the long fully qualified class name
Returns:
- root file name

getShortClassName

public static java.lang.String getShortClassName(java.lang.Class clazz)
Retrun a short class name. E.g. java.util.StringTokenizer will be StringTokenizer

Parameters:
clazz - - for class
Returns:
- short class name

getTempDirectory

public static java.io.File getTempDirectory()
Returns a path to an temp directory.

Returns:
- a path to a temp directory.
Since:
29.06.2006


Copyright © 2008. All Rights Reserved.