org.jsesoft.jse
Class Root

java.lang.Object
  |
  +--org.jsesoft.jse.Root
Direct Known Subclasses:
Assert, CallbackData, CloseConnectionRequestData, CloseConnectionResponseData, CloseSessionRequestData, CloseSessionResponseData, CloseStreamRequestData, CloseStreamResponseData, ControlData, ExchangeService, ExchangeStatics, GenericData, InformationResponseData, JseglRoot, OpenConnectionRequestData, OpenConnectionResponseData, OpenSessionRequestData, OpenSessionResponseData, OpenStreamRequestData, OpenStreamResponseData, ProcessConnectionRequestData, ProcessConnectionResponseData, SendMessageRequestData, SendMessageResponseData, StatusData, Test

public abstract class Root
extends java.lang.Object

Base class of all jse classes.


This is the base class of all classes of the JSE project. It provides debugging support (log) and a few helper functions.


Field Summary
protected static org.apache.log4j.Logger logger
           
protected  java.util.ResourceBundle messages
           
protected  java.util.ResourceBundle resources
           
 
Constructor Summary
protected Root()
          Initializes the instance.
 
Method Summary
static java.lang.String decrementNumber(java.lang.String number, int digits)
          Decrements the number contained in a string.
static java.lang.String getResourceMessage(java.lang.String key)
          Returns the message specified by key.
static java.lang.String getResourceMessage(java.lang.String key, java.util.ResourceBundle bundle)
          Returns the message specified by key from the specified bundle.
 java.lang.Object getResourceObject(java.lang.String key)
          Returns the resource object specified by key.
 java.lang.String getResourceString(java.lang.String key)
          Returns the resource string specified by key.
static java.lang.String incrementNumber(java.lang.String number, int digits)
          Increments the number contained in a string.
static int intFromByteArray(byte[] data, int offset, boolean littleEndian)
          Converts byte array to int.
static byte[] intToByteArray(int value, boolean littleEndian)
          Converts integer to byte array.
static long longFromByteArray(byte[] data, int offset, boolean littleEndian)
          Converts byte array to long.
static byte[] longToByteArray(long value, boolean littleEndian)
          Converts long to byte array.
 void setMessageResourceBundle(java.util.ResourceBundle bundle)
          Specifies the message resource bundle used.
 void setPackageResourceBundle(java.util.ResourceBundle bundle)
          Specifies the package resource bundle used.
static short shortFromByteArray(byte[] data, int offset, boolean littleEndian)
          Converts byte array to short.
static byte[] shortToByteArray(short value, boolean littleEndian)
          Converts short to byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected java.util.ResourceBundle messages

resources

protected java.util.ResourceBundle resources

logger

protected static org.apache.log4j.Logger logger
Constructor Detail

Root

protected Root()
Initializes the instance.

Method Detail

incrementNumber

public static java.lang.String incrementNumber(java.lang.String number,
                                               int digits)
Increments the number contained in a string.

Parameters:
number - The string number
digits - The number of digits in the string
Returns:
a String containing the incremented number

decrementNumber

public static java.lang.String decrementNumber(java.lang.String number,
                                               int digits)
Decrements the number contained in a string.

Parameters:
number - The string number
digits - The number of digits in the string
Returns:
a String containing the decremented number

getResourceMessage

public static java.lang.String getResourceMessage(java.lang.String key,
                                                  java.util.ResourceBundle bundle)
Returns the message specified by key from the specified bundle.

Parameters:
bundle - the resource bundle to use
key - the key for the message
Returns:
the message

getResourceMessage

public static java.lang.String getResourceMessage(java.lang.String key)
Returns the message specified by key.

Parameters:
key - the key for the message
Returns:
the message

getResourceString

public java.lang.String getResourceString(java.lang.String key)
Returns the resource string specified by key.

Parameters:
key - the key for the resource string
Returns:
the resource string

getResourceObject

public java.lang.Object getResourceObject(java.lang.String key)
Returns the resource object specified by key.

Parameters:
key - the key for the resource object
Returns:
the resource object

setMessageResourceBundle

public void setMessageResourceBundle(java.util.ResourceBundle bundle)
Specifies the message resource bundle used.

Parameters:
bundle - the message resource bundle to use

setPackageResourceBundle

public void setPackageResourceBundle(java.util.ResourceBundle bundle)
Specifies the package resource bundle used.

Parameters:
bundle - the package resource bundle to use

shortToByteArray

public static byte[] shortToByteArray(short value,
                                      boolean littleEndian)
Converts short to byte array.

Returns:
the byte array

intToByteArray

public static byte[] intToByteArray(int value,
                                    boolean littleEndian)
Converts integer to byte array.

Returns:
the byte array

longToByteArray

public static byte[] longToByteArray(long value,
                                     boolean littleEndian)
Converts long to byte array.

Returns:
the byte array

shortFromByteArray

public static short shortFromByteArray(byte[] data,
                                       int offset,
                                       boolean littleEndian)
Converts byte array to short.

Parameters:
data - the byte array
offset - the starting offset
littleEndian - the endianess flag
Returns:
the short value

intFromByteArray

public static int intFromByteArray(byte[] data,
                                   int offset,
                                   boolean littleEndian)
Converts byte array to int.

Parameters:
data - the byte array
offset - the starting offset
littleEndian - the endianess flag
Returns:
the int value

longFromByteArray

public static long longFromByteArray(byte[] data,
                                     int offset,
                                     boolean littleEndian)
Converts byte array to long.

Parameters:
data - the byte array
offset - the starting offset
littleEndian - the endianess flag
Returns:
the long value