DESY ACOP Beans Home

com.cosylab.util
Class StringUtilities

java.lang.Object
  extended by com.cosylab.util.StringUtilities

public final class StringUtilities
extends java.lang.Object

Usefull methods for working with strings.

Version:
$id$
Author:
Miha Kadunc, Ales Pucelj

Method Summary
static java.lang.Object arrayFromString(java.lang.String arrayString, java.lang.Class arrayClass)
          DOCUMENT ME!
static java.lang.Object arrayFromString(java.lang.String arrayString, java.lang.Class arrayClass, java.lang.String separator, boolean parentheses)
          DOCUMENT ME!
static java.lang.Class classFromString(java.lang.String sValue)
          DOCUMENT ME!
static java.lang.Object fromString(java.lang.String sValue, java.lang.Class targetClass)
          DOCUMENT ME!
static boolean isTrueNumber(java.lang.String value)
          Checks if string unambiguously represents double value.
static double parseDouble(java.lang.String s)
          Simple, robust floating point number parsing, it returns NaN if parsing fails, no exception thrown.
static java.lang.String printBytes(long bytes)
          Prints bytes with human readable format.
static void printBytes(long bytes, java.io.PrintWriter pr)
          Prints bytes with human readable format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fromString

public static java.lang.Object fromString(java.lang.String sValue,
                                          java.lang.Class targetClass)
                                   throws CommonException
DOCUMENT ME!

Parameters:
sValue - DOCUMENT ME!
targetClass - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
CommonException - DOCUMENT ME!

classFromString

public static java.lang.Class classFromString(java.lang.String sValue)
                                       throws CommonException
DOCUMENT ME!

Parameters:
sValue - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
CommonException - DOCUMENT ME!

arrayFromString

public static java.lang.Object arrayFromString(java.lang.String arrayString,
                                               java.lang.Class arrayClass)
                                        throws CommonException
DOCUMENT ME!

Parameters:
arrayString - DOCUMENT ME!
arrayClass - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
CommonException - DOCUMENT ME!

arrayFromString

public static java.lang.Object arrayFromString(java.lang.String arrayString,
                                               java.lang.Class arrayClass,
                                               java.lang.String separator,
                                               boolean parentheses)
                                        throws CommonException
DOCUMENT ME!

Parameters:
arrayString - DOCUMENT ME!
arrayClass - DOCUMENT ME!
separator - DOCUMENT ME!
parentheses - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
CommonException - DOCUMENT ME!

parseDouble

public static final double parseDouble(java.lang.String s)
Simple, robust floating point number parsing, it returns NaN if parsing fails, no exception thrown.

The parser is derived from the following regular expression:

[+-]?[0-9](\.[0-9])?((e[+-]?)[0-9])?

Parameters:
s - input string
Returns:
double value

isTrueNumber

public static boolean isTrueNumber(java.lang.String value)
Checks if string unambiguously represents double value. If string can not be transformed to unique double, then false is returned. Method parseDouble tries to convert to double any

Parameters:
value - the String to be tested
Returns:
true only if string unambiguously represents double value

printBytes

public static void printBytes(long bytes,
                              java.io.PrintWriter pr)
Prints bytes with human readable format.

Parameters:
bytes - file or memory size in bytes
pr - print writer

printBytes

public static java.lang.String printBytes(long bytes)
Prints bytes with human readable format.

Parameters:
bytes - file or memory size in bytes


Copyright © 2010. All Rights Reserved.