MicroTAPAS.util
Class Util

java.lang.Object
  |
  +--MicroTAPAS.util.Util
All Implemented Interfaces:
java.io.Serializable

public class Util
extends java.lang.Object
implements java.io.Serializable

A collection of utilities for the TAPAS support functions

See Also:
Serialized Form

Field Summary
static java.lang.String LF
          LineFeed contstant.
 
Constructor Summary
Util()
           
 
Method Summary
static java.lang.String boolToString(boolean b)
          Convert to textual representation of boolean values
static int[] centerScreen(int x, int y)
          Calculates the coordinates of the upper left corner of the window so that it is placed in the middle of the screen.
static java.lang.String[] concatStringArrays(java.lang.String[] first, java.lang.String[] second)
          Function to concatenate string arrays.
static java.lang.String exceptionDump(java.lang.Exception ex)
          Function to convert an exception stack dump to a string representation
static CapabilitySet getActorCapabilitySet(java.lang.String file)
          The method to retrieve the REQUIRED capabilities of an actor.
static java.util.Hashtable getActorProperties(java.lang.String file)
          Method to return an actor's properties as a hashtable.
static CapabilitySet getNodeCapabilitySet()
          The method to retrieve the capabilities of a node from the 'nodecap' file.
static GAI getPropertyGAI(java.lang.String key)
          Method to return one specific microtapas property as a GAI
static java.lang.String getPropertyString(java.lang.String key)
          Method to return one specific microtapas property as a String
static int[] getScreenSize()
          Method to return the size of the terminal's screen.
static java.util.Hashtable getTAPASProperties()
          Method to feth the TAPAS specific properties only
static java.lang.String millisToHours(long time)
          Method to convert a long of milliseconds to a String on the form 'Xh, Ymin, Zsec'.
static java.lang.String replace(java.lang.String haystack, java.lang.String needle, java.lang.String replacement)
          Replaces the FIRST occurance of 'needle' with 'repalcement' in 'haystack' The J2SE v1.4.1 String String.replaceFirst(String regexp, String replacement) and String String.replaceAll(String regexp, String replacement) are not defined in the J9 API for PocketPC.
static java.lang.String replaceAll(java.lang.String haystack, java.lang.String needle, java.lang.String replacement)
          Replaces the ALL occurances of 'needle' with 'repalcement' in 'haystack'.
static void replaceProperty(java.lang.String key, java.lang.String element)
          Replaces one specific property.
static boolean stringToBool(java.lang.String s)
          Conversion from string boolean representation to boolean value
static java.lang.String timestampToDate(long time)
          Utilitiy to transform a timestamp (long) to a human readable date.
static java.lang.String toString(java.lang.String[] pStrings, java.lang.String separator)
          Converts an array of Strings into one concatenated String with a specified separator String in between
static java.util.Hashtable updateProperties(java.util.Hashtable ht)
          Update system properties with TAPAS parameters
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LF

public static final java.lang.String LF
LineFeed contstant.

See Also:
Constant Field Values
Constructor Detail

Util

public Util()
Method Detail

replace

public static java.lang.String replace(java.lang.String haystack,
                                       java.lang.String needle,
                                       java.lang.String replacement)
Replaces the FIRST occurance of 'needle' with 'repalcement' in 'haystack' The J2SE v1.4.1 String String.replaceFirst(String regexp, String replacement) and String String.replaceAll(String regexp, String replacement) are not defined in the J9 API for PocketPC.

Returns:
The new string

replaceAll

public static java.lang.String replaceAll(java.lang.String haystack,
                                          java.lang.String needle,
                                          java.lang.String replacement)
Replaces the ALL occurances of 'needle' with 'repalcement' in 'haystack'. The J2SE v1.4.1 String String.replaceFirst(String regexp, String replacement) and String String.replaceAll(String regexp, String replacement) are not defined in the J9 API for PocketPC.

Returns:
The new string

toString

public static java.lang.String toString(java.lang.String[] pStrings,
                                        java.lang.String separator)
Converts an array of Strings into one concatenated String with a specified separator String in between

Parameters:
pStrings - To array of Strings to be concatenated
separator - A String to be placed in between
Returns:
The concatenated String

boolToString

public static java.lang.String boolToString(boolean b)
Convert to textual representation of boolean values

Parameters:
b - The boolean value to convert
Returns:
The converted boolean value, true gives "true", "false" else.

stringToBool

public static boolean stringToBool(java.lang.String s)
Conversion from string boolean representation to boolean value

Parameters:
s - The string boolean value to convert
Returns:
Converted boolean value, "true" gives true, false else.

concatStringArrays

public static java.lang.String[] concatStringArrays(java.lang.String[] first,
                                                    java.lang.String[] second)
Function to concatenate string arrays.

Parameters:
first - First array
second - Second array
Returns:
New array that is the concatenation of the first and second array

exceptionDump

public static java.lang.String exceptionDump(java.lang.Exception ex)
Function to convert an exception stack dump to a string representation

Parameters:
ex - The exception to retrieve the trace from
Returns:
The converted string representation

timestampToDate

public static java.lang.String timestampToDate(long time)
Utilitiy to transform a timestamp (long) to a human readable date. Used by DebugFrame, amongst others.

Parameters:
time - The timestamp in milliseconds.
Returns:
The human readable date as a string.

millisToHours

public static java.lang.String millisToHours(long time)
Method to convert a long of milliseconds to a String on the form 'Xh, Ymin, Zsec'.

Parameters:
time - The time in milliseconds to be converted into a String,
Returns:
A string with the hours, minutes and seconds split up

centerScreen

public static int[] centerScreen(int x,
                                 int y)
Calculates the coordinates of the upper left corner of the window so that it is placed in the middle of the screen.

Parameters:
x - Width of window
y - Height of window
Returns:
The coordinates of the upper left corner, int[0]=x, int[1]=y

getScreenSize

public static int[] getScreenSize()
Method to return the size of the terminal's screen.

Returns:
The width and heigh of the screen in pixels: int[0] = widht, int[1] = height.

updateProperties

public static java.util.Hashtable updateProperties(java.util.Hashtable ht)
Update system properties with TAPAS parameters

Parameters:
ht - The Hashtable of properties to be added
Returns:
A Hashtable containing the MicroTAPAS specific properties

replaceProperty

public static void replaceProperty(java.lang.String key,
                                   java.lang.String element)
Replaces one specific property.

Parameters:
key - The key of the property
element - The replacement property

getTAPASProperties

public static java.util.Hashtable getTAPASProperties()
Method to feth the TAPAS specific properties only

Returns:
The properties specific to MicroTAPAS

getPropertyGAI

public static GAI getPropertyGAI(java.lang.String key)
Method to return one specific microtapas property as a GAI

Parameters:
key - The property key
Returns:
The property value converted to GAI

getPropertyString

public static java.lang.String getPropertyString(java.lang.String key)
Method to return one specific microtapas property as a String

Parameters:
key - The property key
Returns:
The property value as a String

getActorProperties

public static java.util.Hashtable getActorProperties(java.lang.String file)
Method to return an actor's properties as a hashtable. If no local property exisit, read property from url.

playID/playVer/roleId.cfg
or playID/playVer/roleId.cfg

Parameters:
file - The path/URL of the property/config file.
Returns:
A Hashtable containing all the actor properties

getNodeCapabilitySet

public static CapabilitySet getNodeCapabilitySet()
The method to retrieve the capabilities of a node from the 'nodecap' file.

Returns:
A CapabilitySet containing the specific capabilities OFFERED by the node.

getActorCapabilitySet

public static CapabilitySet getActorCapabilitySet(java.lang.String file)
The method to retrieve the REQUIRED capabilities of an actor. If no local capabilities exisit, read capabilities from url. playID/playVer/roleId.cap or playID/playVer/roleId.cap

Parameters:
file - The path/URL address of the file containing the capabilities.
Returns:
A CapabilitySet containing the specific capabilities REQUIRED by the actor.