net.sf.crispy.util
Class Util

java.lang.Object
  extended bynet.sf.crispy.util.Util

public class Util
extends java.lang.Object

Utility (helper) class.

Author:
Linke

Constructor Summary
Util()
           
 
Method Summary
static java.lang.String array2String(java.lang.Object[] pvStrArray)
           
static java.lang.Object createObject(java.lang.String pvObjectString)
          Create a object with the reflection API.
static javax.xml.namespace.QName createQNameByClass(java.lang.Class pvClass)
          Create a javax.xml.namespace.QName by the class.
static void createTree(java.lang.Object pvObject, javax.swing.tree.DefaultMutableTreeNode pvRoot)
           
static void createTreeByCollection(java.util.Collection pvCollection, javax.swing.tree.DefaultMutableTreeNode pvRoot, java.lang.String pvPropertyName)
           
static void createTreeByMap(java.util.Map pvMap, javax.swing.tree.DefaultMutableTreeNode pvRoot, java.lang.String pvPropertyName)
           
static java.lang.String cutString(java.lang.String pvString, java.lang.String pvCuttingString)
          Cut a String on the end of a input-String.
static java.lang.Throwable findDeepestThrowable(java.lang.Throwable pvThrowable)
          Find the deepest Exception by nested Exception.
static java.util.Map getAllPropertiesByPrefixAndSort(java.util.Properties pvProperties, java.lang.String pvPrefix)
          Get from the properites all properties, that begins with the prefix and sorted this properties to the property keys.
static java.lang.String getClassNameWithOutPackage(java.lang.Class pvClass)
           
static java.lang.String getClassNameWithOutPackage(java.lang.String pvClassName)
           
static boolean initJdkLogger()
           
static boolean initJdkLogger(java.lang.String pvFileName)
           
static boolean initJdkLogger2(java.io.InputStream pvInputStream)
           
static byte[] inputStream2ByteArray(java.io.InputStream is)
           
static boolean isClassInArray(java.lang.Class[] pvClassArray, java.lang.Class pvSearchClass)
          Test as search class is exist in the class array.
static boolean isPortFree(int pvPort)
          Test to free port.
static java.lang.String map2String(java.util.Map pvMap, java.lang.String pvPropertyName)
           
static java.lang.String printArray(java.lang.Object[] pvArray)
           
static void printMapInfo(java.util.Map pvMap)
           
static java.lang.String reverse(java.lang.Class pvClass)
          Reverse the package fro class.
static java.lang.String[] separateHostAndPort(java.lang.String pvUrlAndPort)
          Separate from url the url and the port: localhost:8080 --> http://localhost and 8080
static void visualisationTree(java.lang.Object pvObject)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

findDeepestThrowable

public static java.lang.Throwable findDeepestThrowable(java.lang.Throwable pvThrowable)
Find the deepest Exception by nested Exception. Example:
 Exception e0 = new Exception ();
 Exception e1 = new Exception (e0);
 
 Exception eFind = findDeepestThrowable(e1);
 The result: eFind == e0
 

Parameters:
pvThrowable - Root-Exception.
Returns:
The deepest Exception.

isPortFree

public static boolean isPortFree(int pvPort)
Test to free port.

Parameters:
pvPort - tested port
Returns:
true, if the port is free, else false.

separateHostAndPort

public static java.lang.String[] separateHostAndPort(java.lang.String pvUrlAndPort)
Separate from url the url and the port: localhost:8080 --> http://localhost and 8080

Parameters:
pvUrlAndPort -
Returns:
String-Array with pos 0 = URL and pos 1 = the Port

cutString

public static java.lang.String cutString(java.lang.String pvString,
                                         java.lang.String pvCuttingString)
Cut a String on the end of a input-String. Example: Input-String rmi://localhost:1099/, Cutting-String /, New-String rmi://localhost:1099.

Parameters:
pvString - Input-String
pvCuttingString - Cutting-String
Returns:
New String, without Cutting-String.

createObject

public static java.lang.Object createObject(java.lang.String pvObjectString)
                                     throws java.lang.Exception
Create a object with the reflection API.

Parameters:
pvObjectString - String from the object.
Returns:
Created object.
Throws:
java.lang.Exception

isClassInArray

public static boolean isClassInArray(java.lang.Class[] pvClassArray,
                                     java.lang.Class pvSearchClass)
Test as search class is exist in the class array.

Parameters:
pvClassArray - class array
pvSearchClass - search class
Returns:
if the class is finding than true, else false

printArray

public static java.lang.String printArray(java.lang.Object[] pvArray)

array2String

public static java.lang.String array2String(java.lang.Object[] pvStrArray)

printMapInfo

public static void printMapInfo(java.util.Map pvMap)

getClassNameWithOutPackage

public static java.lang.String getClassNameWithOutPackage(java.lang.Class pvClass)

getClassNameWithOutPackage

public static java.lang.String getClassNameWithOutPackage(java.lang.String pvClassName)

reverse

public static java.lang.String reverse(java.lang.Class pvClass)
Reverse the package fro class. For example: test.crispy.example.model.Kunde -> model.example.crispy.test. By a class without a package, is the return value a empty String.

Parameters:
pvClass -
Returns:
reverse string.

createQNameByClass

public static javax.xml.namespace.QName createQNameByClass(java.lang.Class pvClass)
Create a javax.xml.namespace.QName by the class. For example class: test.crispy.example.model.Kunde -> LocalPart: test.crispy.example.model.Kunde and NamespaceURI: model.example.crispy.test.

Parameters:
pvClass - The class for create a QName.
Returns:
The created QName object.

getAllPropertiesByPrefixAndSort

public static java.util.Map getAllPropertiesByPrefixAndSort(java.util.Properties pvProperties,
                                                            java.lang.String pvPrefix)
Get from the properites all properties, that begins with the prefix and sorted this properties to the property keys.

Parameters:
pvProperties - all properties
pvPrefix - filter = prefix from property key
Returns:
sorted Map from all properties with correct prefix.

inputStream2ByteArray

public static byte[] inputStream2ByteArray(java.io.InputStream is)
                                    throws java.io.IOException
Throws:
java.io.IOException

visualisationTree

public static void visualisationTree(java.lang.Object pvObject)

createTree

public static void createTree(java.lang.Object pvObject,
                              javax.swing.tree.DefaultMutableTreeNode pvRoot)

map2String

public static java.lang.String map2String(java.util.Map pvMap,
                                          java.lang.String pvPropertyName)

createTreeByMap

public static void createTreeByMap(java.util.Map pvMap,
                                   javax.swing.tree.DefaultMutableTreeNode pvRoot,
                                   java.lang.String pvPropertyName)

createTreeByCollection

public static void createTreeByCollection(java.util.Collection pvCollection,
                                          javax.swing.tree.DefaultMutableTreeNode pvRoot,
                                          java.lang.String pvPropertyName)

initJdkLogger

public static boolean initJdkLogger()

initJdkLogger

public static boolean initJdkLogger(java.lang.String pvFileName)

initJdkLogger2

public static boolean initJdkLogger2(java.io.InputStream pvInputStream)


Copyright © 2005-2006 Crispy. All Rights Reserved.