rebuild.util
Class Utilities

java.lang.Object
  extended by rebuild.util.Utilities

public final class Utilities
extends java.lang.Object

A collection of various utility functions.

Since:
BBX 1.1.0

Method Summary
static void assert(boolean condition)
          Checks for a condition; if the condition is false, outputs two specified messages and displays a message box that shows the message.
static void assert(boolean condition, java.lang.String message)
          Checks for a condition; if the condition is false, outputs two specified messages and displays a message box that shows the message.
static void assert(boolean condition, java.lang.String message, java.lang.String detailMessage)
          Checks for a condition; if the condition is false, outputs two specified messages and displays a message box that shows the message.
static java.lang.String ctime(java.util.Calendar timer)
          Format a Calendar in the same manner as the Standard C function "ctime"
static void getNonZeroBytes(byte[] data)
          Get multiple random numbers., no zeros
static void getNonZeroBytes(int[] data)
          Get multiple random numbers., no zeros
static boolean isDisabled(Field f)
          Determine if the specified field is disabled.
static void RNGGetBytes(byte[] data)
          Get multiple random numbers.
static void RNGGetBytes(int[] data)
          Get multiple random numbers.
static void setDisabled(Field f, boolean isDisabled)
          Set the field to either enabled/disabled.
static boolean setupPermissions(int[] requiredPerms)
          Setup application permissions, this will assign a set of permissions to a application.
static java.lang.Object singletonStorageGet(long uid)
          Get a singleton object.
static java.lang.Object singletonStorageSet(long uid, java.lang.Object obj)
          Set a singleton object.
static void singltonStorageCleanup()
          Remove all singleton objects.
static java.lang.Object[] toArray(java.util.Vector vect)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

RNGGetBytes

public static void RNGGetBytes(byte[] data)
Get multiple random numbers.

Parameters:
data - The array of bytes to fill with random numbers.
Throws:
java.lang.NullPointerException - If data is null.

getNonZeroBytes

public static void getNonZeroBytes(byte[] data)
Get multiple random numbers., no zeros

Parameters:
data - The array of bytes to fill with random numbers.
Throws:
java.lang.NullPointerException - If data is null.

RNGGetBytes

public static void RNGGetBytes(int[] data)
Get multiple random numbers.

Parameters:
data - The array of bytes to fill with random numbers.
Throws:
java.lang.NullPointerException - If data is null.

getNonZeroBytes

public static void getNonZeroBytes(int[] data)
Get multiple random numbers., no zeros

Parameters:
data - The array of bytes to fill with random numbers.
Throws:
java.lang.NullPointerException - If data is null.

toArray

public static java.lang.Object[] toArray(java.util.Vector vect)
Deprecated. 

Convert a Vector to an array.

Parameters:
vect - The Vector to convert to an array.
Returns:
If vect is null then null is returned. Else an array is returned of the items in vect.

assert

public static void assert(boolean condition)
Checks for a condition; if the condition is false, outputs two specified messages and displays a message box that shows the message.

Parameters:
condition - The conditional expression to evaluate. If this is true, the specified messages are not sent and the message box is not displayed.

assert

public static void assert(boolean condition,
                          java.lang.String message)
Checks for a condition; if the condition is false, outputs two specified messages and displays a message box that shows the message.

Parameters:
condition - The conditional expression to evaluate. If this is true, the specified messages are not sent and the message box is not displayed.
message - A general message.

assert

public static void assert(boolean condition,
                          java.lang.String message,
                          java.lang.String detailMessage)
Checks for a condition; if the condition is false, outputs two specified messages and displays a message box that shows the message.

Parameters:
condition - The conditional expression to evaluate. If this is true, the specified messages are not sent and the message box is not displayed.
message - A general message.
detailMessage - A detailed message.

setupPermissions

public static boolean setupPermissions(int[] requiredPerms)
Setup application permissions, this will assign a set of permissions to a application. If no permissions need to be set then nothing will change. If there are any permissions need to be assigned then the permission dialog is displayed to the user.

Parameters:
requiredPerms - An array of the required permissions, this should be permissions from ApplicationPermissions.
Returns:
true if the user accepts all of the requested permissions or no permissions are required, or false if the user or device policies reject at least one of the requested permissions.

setDisabled

public static void setDisabled(Field f,
                               boolean isDisabled)
Set the field to either enabled/disabled.

Parameters:
f - The field to enabled/disabled.
isDisabled - True if the field should be disabled, false if otherwise.

isDisabled

public static boolean isDisabled(Field f)
Determine if the specified field is disabled.

Parameters:
f - The field to check.
Returns:
True if the field is disabled, false if otherwise.

ctime

public static java.lang.String ctime(java.util.Calendar timer)
Format a Calendar in the same manner as the Standard C function "ctime"

Parameters:
timer - The calendar to format.
Returns:
The formatted calendar String.
Since:
BBX 1.2.0

singletonStorageGet

public static java.lang.Object singletonStorageGet(long uid)
Get a singleton object. This is not the same as just calling RuntimeStore and is managed for memory usage. It will be cleaned up when singltonStorageCleanup() is called.

Parameters:
uid - The ID of the object to get.
Returns:
The object (if it was set using singletonStorageSet(long, Object)) or null if it doesn't exist or was not set using singletonStorageSet(long, Object).
Since:
BBX 1.2.0

singletonStorageSet

public static java.lang.Object singletonStorageSet(long uid,
                                                   java.lang.Object obj)
Set a singleton object.

Parameters:
uid - The ID of the object to set. If this happens to be an object that already exists but was not set using this function then an exception will be thrown.
obj - The singleton object to set or null if the current object should be removed.
Returns:
The previous object (if it was set using singletonStorageSet(long, Object)) or null if it didn't exist or was not set using singletonStorageSet(long, Object).
Since:
BBX 1.2.0

singltonStorageCleanup

public static void singltonStorageCleanup()
Remove all singleton objects.

Since:
BBX 1.2.0