ru.novosoft.dc.core.util
Class Utilities

java.lang.Object
  |
  +--ru.novosoft.dc.core.util.Utilities

public final class Utilities
extends java.lang.Object

The class contains miscellaneous static utility methods.


Method Summary
static int clearBit(int value, int bitNumber)
          Set a specified bit in the value to 0 and return the result.
static boolean equal(java.lang.Object obj1, java.lang.Object obj2)
          Compare objects to be both null or equal to each other (use the equals() method) and return true if any of this conditions fulfilled.
static boolean hasBit(int value, int bitNumber)
          Return true if a specified bit is equal to 1.
static boolean isEqual(java.util.Properties properties, java.lang.String name, java.lang.String value)
          Return true if a property is specified and its value is equal to the given value.
static boolean isTrue(java.util.Properties properties, java.lang.String name)
          Return true if a property is specified and its value is equal to "true".
static int setBit(int value, int bitNumber)
          Set a specified bit in the value to 1 and return the result.
static java.lang.String toANSIString(java.lang.String s)
          Convert a string to ANSI string representation.
static int toInt(java.lang.Object obj)
          Convert an object to an integer value and return it.
static int toInt(java.lang.Object obj, int defaultValue)
          Try to convert an object to an integer value and return the result or the defaultValue if conversion fails.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toANSIString

public static java.lang.String toANSIString(java.lang.String s)
Convert a string to ANSI string representation. The result will be enclosed in braces "{...}". Non-ANSI symbols are represented in the form "{xxxx}" with hexadecimal representation of its content. Open and close braces are represented in hexadecimal form also.

equal

public static final boolean equal(java.lang.Object obj1,
                                  java.lang.Object obj2)
Compare objects to be both null or equal to each other (use the equals() method) and return true if any of this conditions fulfilled.

toInt

public static int toInt(java.lang.Object obj)
Convert an object to an integer value and return it. The object must be an instance of the Number or String class. A string could contain a decimal or hexadecimal value. In the last case, it must start from "0x" or "0X". Before testing the string value, surrounding white spaces are removed. If conversion fails, an appropriate runtime exception is thrown.

toInt

public static final int toInt(java.lang.Object obj,
                              int defaultValue)
Try to convert an object to an integer value and return the result or the defaultValue if conversion fails.

setBit

public static final int setBit(int value,
                               int bitNumber)
Set a specified bit in the value to 1 and return the result.
Parameters:
value - a value to set a bit in
bitNumber - a bit number (from 0 to 31)

clearBit

public static final int clearBit(int value,
                                 int bitNumber)
Set a specified bit in the value to 0 and return the result.
Parameters:
value - a value to set a bit in
bitNumber - a bit number (from 0 to 31)

hasBit

public static final boolean hasBit(int value,
                                   int bitNumber)
Return true if a specified bit is equal to 1.
Parameters:
value - a value to test a bit in
bitNumber - a bit number (from 0 to 31)

isTrue

public static boolean isTrue(java.util.Properties properties,
                             java.lang.String name)
Return true if a property is specified and its value is equal to "true".

isEqual

public static boolean isEqual(java.util.Properties properties,
                              java.lang.String name,
                              java.lang.String value)
Return true if a property is specified and its value is equal to the given value.