com.sybase.uep.bobclient.utils
Class Util

java.lang.Object
  extended by com.sybase.uep.bobclient.utils.Util

public class Util
extends java.lang.Object

This is the Utility class Contains static helper methods

Author:
tdang

Field Summary
static java.lang.String ASTERISK_MARK
           
static long KEY
           
static java.lang.String QUESTION_MARK
           
 
Constructor Summary
Util()
           
 
Method Summary
static void addAll(java.util.Vector target, java.lang.Object[] source)
          Collection util method, Add all source elements to target Vector
static void addAll(java.util.Vector target, java.util.Vector source)
          Collection util method, Add all elements of source Vecotr to target Vector
static void addVariable(java.lang.String key, java.lang.Object value, java.lang.String type, java.lang.String schemaType)
          Add variables to persistent store
static void addVariables(java.util.Hashtable variables)
          Add a hashtable of variables
static java.lang.String appendInternalPackageString(java.lang.String fullDatabaseClassName)
          Appends 'intrnl' as package name
static void applyAllProfileInfo2ObjectAPI(ClientProfileList profileList, java.lang.String clientName)
          Apply all profile info to the static fields of MyDatabase class of Object API
static void applyProfileInfo2ObjectAPI(ClientProfileList profileList, java.lang.String profileId, java.lang.String clientName)
          Apply profile info of specified profile ID to the static fields of MyDatabase class of Object API
static void applyProfileInfo2ObjectAPI(ClientProfile clientProfile, java.lang.String clientName)
          Apply the properties of spcified client profile into to Object API
static void callBlackberryBrowser(java.lang.String url)
           
static boolean canLoginToSync(java.lang.String packageName)
          Checks whether the specified package can call loginToSync.
static void changeLinkParamOptions(IBOBScreen screen, java.lang.String mobileAppID, LinkParamNode linkParam, java.lang.String name, java.lang.String value)
          Change the link parameter select box options when it has been changed
static int checkColorString(java.lang.String str, int defaultColor)
          Check the color string if it has pound sign or not.
static void checkNonEmpty(java.lang.String str, java.lang.String errmsg)
           
static void checkNonNull(java.lang.Object obj, java.lang.String errmsg)
           
static void checkWirelessConnection()
          Check device radio states
static boolean containsFocusableControlsAfterTable(java.lang.String tableFieldMobileAppID)
          This is mainly used in the TableField where we want to check if there are controls after the table If there are controls we would want to move the focus to that control
static java.lang.Object convert2ScalarArrayIfNeed(java.lang.String schemaType, java.lang.Object value)
          Check if the value need to be converted to a scalar array.
static java.lang.String converToValidName(java.lang.String oldName)
          Remove "_" from name
static java.lang.String convertPackageName(java.lang.String packageName)
          Converts the server version of package name to its realy package name.
static java.lang.Object convertToAFXObject(java.lang.Object value, DataType datatype)
          Convert J2ME type to AFX type.
static java.lang.String convertToDataTypeName(java.lang.String schemaType)
          Convert the name of schema_type to the name which can be recognized by the method of DataType.forName().
static java.lang.Object convertToJ2MEObject(java.lang.Object value, int datatype)
          Convert AFX type to J2ME type.
static long convertToLong(java.lang.String valueToConvert)
           
static java.lang.Object convertValueBySchemaType(java.lang.String schemaType, java.lang.Object value)
          Converts value to a specific java type based on schemaType Support convertion from String value to object of specified schematype ( For SCHEMA_TYPE_STRING, just return value ), byte[] value to SCHEMA_TYPE_BINARY, call getStringValue(Object) to convert value to corresponding String instance when specified schameType is SCHEMA_TYPE_STRING.
static void deleteAllMobileApplicationLogs()
          Delete all the mobile application logs when exiting the client
static void deleteAllMobileApplications(MBOModel[] mobileApps)
          Delete a list of mobile application objects
static void elementsToArray(java.util.Hashtable h, java.lang.Object[] array)
           
static boolean equals(java.lang.Object obj1, java.lang.Object obj2)
          Indicates whether two objects are equal to each other.
static boolean equals(java.util.Vector vect1, java.util.Vector vect2)
          Indicates whether two Vector objects are equal to each other.
static MobileAppTable findTableControl(net.rim.device.api.ui.Field f)
          Find table control widget
static TwoColumnLayout findTwoColumnLayoutControl(net.rim.device.api.ui.Field f)
          Find two column layout control widget
static void getAllControls(net.rim.device.api.ui.Field f, java.util.Vector controls)
          Get the list of controls on this manager field
static Control[] getAllControlsOnScreen(IBOBScreen screen)
          Get all the controls on the screen
static Control[] getAllControlsOnScreen(net.rim.device.api.ui.Screen screen)
          Get all the controls on the screen
static java.lang.String getAppID()
          Gets the client application ID
static java.lang.String getAssociationKey(java.lang.String packageName, java.lang.String name)
          We need the package name and association name to identify an association.
static AttributeMetaData getAttributeMetaData(MBOModel mboModel, java.lang.String attrName)
          Gets attribute meta data
static boolean getBooleanByString(java.lang.String value)
          Get the boolean value by string If the string isn't "true" or "false", return true
static boolean getBooleanByString(java.lang.String value, boolean defaultBoolean)
          Get the boolean value by string If the string isn't "true" or "false", return the default boolean value
static Control getControlByName(Control[] listControls, java.lang.Object key)
          Loops through the list of controls on the screen and check for matching control name
static Control getControlsByID(java.lang.String controlID)
          Get all the controls on the screen
static Control[] getControlsByID(java.lang.String[] controlIDs)
          Get all the controls on the screen
static java.lang.Object getDataFromSPMBO(java.lang.String id, boolean isAll)
          Retrieve the data stored in the structured parameter(complex datatype) mbo
static java.lang.String getDeviceEmail()
          Get the device email address
static java.lang.String getDeviceID()
          Get the device identification number
static net.rim.device.api.system.EncodedImage getEncodedImage(java.lang.String imageStr)
          Get the EncodedImage object based on the image name.
static net.rim.device.api.system.EncodedImage getEncodedImage(java.lang.String moduleName, java.lang.String imageName)
          For custom coding, we are not sure what module name is, the deal is to first retrieve the image without module name, and if nothing is returned we then try the module name.
static net.rim.device.api.ui.Field[] getFieldControls(net.rim.device.api.ui.Field f)
          Get controls from field object
static net.rim.device.api.ui.Field getFieldFocusOnScreen(net.rim.device.api.ui.Screen screen)
          Get field with focus on screen
static int getFieldIndexOnScreen(net.rim.device.api.ui.Screen screen, net.rim.device.api.ui.Field field)
          Gets the field index among all fields on the screen
static int getFieldMaxWidth(net.rim.device.api.ui.Font font, MBOAttribute[] columns)
           
static net.rim.device.api.ui.Field getFieldWithFocus(net.rim.device.api.ui.Field f)
           
static net.rim.device.api.ui.Field getFocusField(net.rim.device.api.ui.Screen screen)
          return the control with focus in specific screen.
static java.lang.Integer getGUID()
          Get a GUID
static long getHorizontalAlignment(long style)
          Get the horizontal alignment
static long getHorizontalAlignment(long style, long defaultAlignment)
          Get the horizontal alignment
static java.lang.String getHTTPPushAddress()
          Get the HTTP push address
static net.rim.device.api.system.Bitmap getImageBitmap(java.lang.String imageStr)
          Get the Bitmap object based on the image name.
static net.rim.device.api.system.Bitmap getImageBitmap(java.lang.String imageStr, net.rim.device.api.system.Bitmap defaultImage)
          Get the Bitmap object based on the image name.
static net.rim.device.api.system.Bitmap getImageBitmap(java.lang.String moduleName, java.lang.String imageStr, net.rim.device.api.system.Bitmap defaultImage)
          Get the Bitmap object based on the image name.
static int getMaxNumberOfPersistentObjects()
           
static java.util.Vector getMDCList(IBOBScreen screen, boolean currentTabOnly)
          Gets all MobileDataControl contained in the given screen
static ClassMetaData getMetaData(java.lang.String packageName, java.lang.String complexDataType)
          Get the meta data for a given complex data type class
static java.lang.String[] getMobileAppIDsByPublication(java.lang.String packageName, java.lang.String publication)
          Obtains an array of ids of all mobile business objects within the given publication
static MobileDataControl getMobileDataControlByMobileAppID(IBOBScreen screen, java.lang.String mobileAppID, boolean onCurrentTabOnly)
          Get only the mobile data controls
static void getMobileDataControls(net.rim.device.api.ui.Field f, java.util.Vector results, boolean currentTabOnly)
          Search for Mobile data controls
static java.lang.String getObjectAPIPath()
          Gets the package name of generated Object API
static java.lang.Object getObjectFromString(DataType dataType, java.lang.Object value)
           
static java.lang.String getOSVersionNumber()
           
static java.lang.String getPackageName(java.lang.String mboId)
          Gets the name of the package that contains the given MBO
static java.util.Hashtable getParametersFromSubmitElement(java.util.Vector submitElements)
          Returns a hashtable of parameters from the submit elements.
static MobileDataControl getParentMDC(IBOBScreen screen, java.lang.String mboId)
          Finds the MobileDataControl with the mbo id on parent screen or parent tab
static DataType getPrimitiveDatatype(DataType listType)
           
static java.lang.String getPublicationByMobileApp(MBOMobileApplication application)
          Utility method to get the publication name by mobile application id
static java.lang.String getResourceString(int resourceID)
          Get the resource string
static java.lang.String getResourceString(int resourceID, net.rim.device.api.i18n.ResourceBundle res)
          Get the resource string
static java.lang.String getResourceString(int resourceID, java.lang.String defaultValue)
          Get the resource string
static java.lang.String getServerURL(java.lang.String serverName, int serverPort)
           
static java.lang.String getStockScreenLabel(java.lang.Object obj)
          Get the stock screen label value based on the object being passed in
static java.lang.String getStockScreenLabel(java.lang.Object obj, net.rim.device.api.i18n.ResourceBundle res)
          Get the stock screen label value based on the object being passed in
static java.lang.String getStringValue(java.lang.Object varValue)
          Return String object representing specified varValue.
static java.lang.String getStringValue(java.lang.Object varValue, boolean needTrim)
          Return String object representing specified varValue.
static TabLayoutManager getTabLayoutManager(net.rim.device.api.ui.Field f)
          Finds tab layout manager on the field
static TabLayoutManager getTabLayoutManager(IBOBScreen screen)
          Finds tab layout manager on the BOB screen
static java.lang.String getTextWithinRowspan(net.rim.device.api.ui.Field field, int rowSpan, java.lang.String text)
          Gets truncated text that can be displayed within the RowSpan of the specified field
static java.lang.String getTruncatedText(java.lang.String text, int availableWidth, FontStyle displayFont)
          Truncates a text by given width, and appends ellipsis at the end of the truncated text.
static java.lang.String getTruncatedText(java.lang.String text, int availableWidthPerRow, int rowCount, FontStyle displayFont)
           
static java.lang.String getTruncatedTextWithinRowspan(net.rim.device.api.ui.Field field, int rowSpan, java.lang.String text, FontStyle displayFont)
           
static java.lang.String getUniqueID()
           
static java.lang.Object getVariableValue(ControlVariable variable)
          Get the variable value stroed in the persistent store
static long getVerticalAlignment(long style)
          Get the vertical alignment
static long getVerticalAlignment(long style, long defaultAlignment)
          Get the vertical alignment
static boolean hasFocusableControlBeside(net.rim.device.api.ui.Screen screen, net.rim.device.api.ui.Field control, boolean isForward)
          Gets if there is focusable control besides the current focus control
static boolean hasFreePersistentObjHandlers(int numOfObjectsToPersist)
           
static boolean hasRelationship(IBOBScreen screen)
          Whether any mbo referenced by this screen has relationship
static boolean hasVariables()
          Check to see if there are varables
static boolean hasWirelessConnection()
           
static void initAppLoggerWrapper()
          Initializes the logger wrapper for Util
static void initAppLoggerWrapperForUnitTest()
          Initializes the logger wrapper for Util in the case of UnitTest
static void invokeAddressBook()
          Invoke the address book application
static void invokeBrowser(java.lang.String location)
           
static void invokeCamera()
          Invoke the camera application
static void invokeEmail()
          Invoke the email application
static void invokeEmail(java.lang.String email)
          Invoke the email application
static void invokePhone(java.lang.String phoneNumber)
          Invoke the phone application
static boolean isConnected(java.lang.String sourceMBOId, java.lang.String targetMBOId, java.lang.String relationship)
          Checks whether the 2 mbo is connected by the given relationship
static boolean isInteger(java.lang.String value)
          Check if the given string value is an Integer
static boolean isOS38AndUp()
           
static boolean isSource(java.lang.String sourceMBOId, java.lang.String relationship)
          Check if the given source mbo is the source node of the relationship
static boolean isStormDevice()
          Check if this device is storm device
static long parseCalendarDate(java.lang.String dateStr)
           
static java.lang.Object[] parseChoices(java.lang.Object obj)
           
static java.lang.String parseDate(java.lang.String schemaType, java.util.Date value)
          Parse the date
static java.lang.String parseDate(java.lang.String schemaType, long longVal)
          Parse the date
static java.lang.String parseDate(java.lang.String schemaType, java.lang.String value)
          Parse the date
static long parseDateString(java.lang.String date)
           
static java.util.Vector parseOSVersionNumber(java.lang.String strOSVersion)
           
static void postGlobalEvent(long guid, java.lang.String clientName, java.lang.Object object0)
           
static void printMemoryStats()
           
static void pushLoginScreen(UIController controller)
          Push the login screen.
static byte[] readBinaryData(java.lang.String fileName)
          Read binary data from device
static byte[] readBinaryData(java.lang.String fileName, boolean reportErrors)
          Read binary data from device
static void refreshAllMobileApplicationOnScreen(IBOBScreen screen)
          Refresh all the mobile data controls on screen
static void refreshControls(net.rim.device.api.ui.Field f)
          Refresh all controls within given field object
static void refreshLinkParameterControls(IBOBScreen screen)
          Refresh the link parameters controls on the screen supplied
static void removeDuplicateMenuItems(java.util.Vector menus)
          Removes duplicate menu items from menu list
static void reorganizeMenuItems(java.util.Vector menus, int length)
          Sorts menu items by alpha and remove duplicate menu items
static int replace(java.lang.String str, java.lang.String pattern)
           
static java.lang.String replaceInputString(java.lang.String origStr, java.lang.String[] inputStr)
          Replace '{0}' with input string
static int replacePoundColor(java.lang.String str, int defaultColor)
           
static int replacePoundColor(java.lang.String str, java.lang.String pattern, int defaultColor)
           
static net.rim.device.api.system.EncodedImage scaleImage(net.rim.device.api.system.EncodedImage image, int scalingWidth, int scalingHeight, boolean isPreserveRatio)
          Scales an image to a certain size
static void setApplicationData(IBOBScreen screen, MBOModel appData)
          Set the application data object to mobile object table on the screen
static void setApplicationDataByMobileAppID(IBOBScreen screen, java.lang.String mobileAppID, MBOModel appData)
          Set the application data with any matching mobile data control on the screen
static void setCurrentAssociationName(java.lang.String associationName)
          Save he current association name for relationship
static void setMBODataProperties(IBOBScreen screen, java.lang.Object[] properties)
          Set the MOB data properties to any matching mobile data control on the screen
static boolean setPushConnectionProfile(java.lang.String packageName)
          Sets up push settings for specified package's synchronization profile.
static void setTableVariableValues(java.lang.String mobileAppID, java.util.Hashtable columnValues)
          Set the current table variable values
static void setupTableContextVariables(MobileDataControl control)
          Setup the mobile data control context variables
static void synchronizeMeta(java.lang.String mboMobileAppID)
          Synchronize meta for a specific mobile business object ID
static void syncPackages(java.lang.String[] packageNames)
          Synchronize the packages
static void updateMobileDataControlContextVariables(MBOModel model, java.lang.Object data, boolean isAddtoContext)
          Update the context variable for the given mbo
static java.lang.String uppercaseFirstChar(java.lang.String value)
          Change the first character of the string to uppercase
static java.lang.String validateStr(java.lang.String str)
          This method converts XML 'Unsafe' characters to XML 'Safe' characters.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASTERISK_MARK

public static java.lang.String ASTERISK_MARK

QUESTION_MARK

public static java.lang.String QUESTION_MARK

KEY

public static final long KEY
See Also:
Constant Field Values
Constructor Detail

Util

public Util()
Method Detail

parseDateString

public static long parseDateString(java.lang.String date)

getUniqueID

public static java.lang.String getUniqueID()

checkWirelessConnection

public static void checkWirelessConnection()
                                    throws net.rim.device.api.system.RadioException
Check device radio states

Throws:
net.rim.device.api.system.RadioException

hasWirelessConnection

public static boolean hasWirelessConnection()
Returns:
if device in coverage and turn radio on

checkNonEmpty

public static void checkNonEmpty(java.lang.String str,
                                 java.lang.String errmsg)

checkNonNull

public static void checkNonNull(java.lang.Object obj,
                                java.lang.String errmsg)

elementsToArray

public static void elementsToArray(java.util.Hashtable h,
                                   java.lang.Object[] array)

callBlackberryBrowser

public static void callBlackberryBrowser(java.lang.String url)

invokeBrowser

public static void invokeBrowser(java.lang.String location)

isOS38AndUp

public static boolean isOS38AndUp()

getOSVersionNumber

public static java.lang.String getOSVersionNumber()

parseOSVersionNumber

public static java.util.Vector parseOSVersionNumber(java.lang.String strOSVersion)

parseCalendarDate

public static long parseCalendarDate(java.lang.String dateStr)

convertToLong

public static long convertToLong(java.lang.String valueToConvert)

validateStr

public static java.lang.String validateStr(java.lang.String str)
This method converts XML 'Unsafe' characters to XML 'Safe' characters. This method currently handles is the following conversions. '&' --> "&" '<' --> "<" '>' --> ">" '\'' --> "'" '\"' --> """

Parameters:
str - The String to examine for the occurance of 'Unsafe' characters
Returns:
A String that contains all 'Safe' characters.

getMaxNumberOfPersistentObjects

public static int getMaxNumberOfPersistentObjects()

hasFreePersistentObjHandlers

public static boolean hasFreePersistentObjHandlers(int numOfObjectsToPersist)

printMemoryStats

public static void printMemoryStats()

checkColorString

public static int checkColorString(java.lang.String str,
                                   int defaultColor)
Check the color string if it has pound sign or not. If not we will get the hex value, otherwise parse out the pound sign

Parameters:
str - - string value for the color
defaultColor - - default color is the string color is not found
Returns:
integer value for the color

replacePoundColor

public static int replacePoundColor(java.lang.String str,
                                    int defaultColor)

replacePoundColor

public static int replacePoundColor(java.lang.String str,
                                    java.lang.String pattern,
                                    int defaultColor)

replace

public static int replace(java.lang.String str,
                          java.lang.String pattern)

parseChoices

public static final java.lang.Object[] parseChoices(java.lang.Object obj)

getGUID

public static java.lang.Integer getGUID()
Get a GUID

Returns:
GUID

getDeviceID

public static java.lang.String getDeviceID()
Get the device identification number

Returns:
device ID

isStormDevice

public static boolean isStormDevice()
Check if this device is storm device

Returns:
True if device is storm device, else false

getDeviceEmail

public static java.lang.String getDeviceEmail()
Get the device email address

Returns:
String value of the email address

setCurrentAssociationName

public static void setCurrentAssociationName(java.lang.String associationName)
Save he current association name for relationship

Parameters:
associationName - - association name used for relationship

setupTableContextVariables

public static void setupTableContextVariables(MobileDataControl control)
Setup the mobile data control context variables

Parameters:
control - - Mobile Data Control object

findTableControl

public static MobileAppTable findTableControl(net.rim.device.api.ui.Field f)
Find table control widget

Parameters:
f - - Field control
Returns:
MobileAppTable control widget

findTwoColumnLayoutControl

public static TwoColumnLayout findTwoColumnLayoutControl(net.rim.device.api.ui.Field f)
Find two column layout control widget

Parameters:
f - - Field control
Returns:
TwoColumnLayout control widget

getFieldWithFocus

public static net.rim.device.api.ui.Field getFieldWithFocus(net.rim.device.api.ui.Field f)

setTableVariableValues

public static void setTableVariableValues(java.lang.String mobileAppID,
                                          java.util.Hashtable columnValues)
Set the current table variable values

Parameters:
columnValues - - select row column values

hasVariables

public static boolean hasVariables()
Check to see if there are varables

Returns:
True if the are variables set in the repository

addVariable

public static void addVariable(java.lang.String key,
                               java.lang.Object value,
                               java.lang.String type,
                               java.lang.String schemaType)
Add variables to persistent store

Parameters:
key - - key of the variable
value - - value of the key
type - - type of variable

addVariables

public static void addVariables(java.util.Hashtable variables)
Add a hashtable of variables

Parameters:
variables - - hashtable of variables

getVariableValue

public static java.lang.Object getVariableValue(ControlVariable variable)
Get the variable value stroed in the persistent store

Parameters:
variable - - the control variable object
Returns:
the value based on this control variable object

getServerURL

public static java.lang.String getServerURL(java.lang.String serverName,
                                            int serverPort)

getFieldFocusOnScreen

public static net.rim.device.api.ui.Field getFieldFocusOnScreen(net.rim.device.api.ui.Screen screen)
Get field with focus on screen

Parameters:
screen - - screen to check field on focus
Returns:
Field that is being focused on

getAllControlsOnScreen

public static Control[] getAllControlsOnScreen(IBOBScreen screen)
Get all the controls on the screen

Parameters:
screen - - screen to search for controls
Returns:
array of Controls

getAllControlsOnScreen

public static Control[] getAllControlsOnScreen(net.rim.device.api.ui.Screen screen)
Get all the controls on the screen

Parameters:
screen - - screen to search for controls
Returns:
array of Controls

hasFocusableControlBeside

public static boolean hasFocusableControlBeside(net.rim.device.api.ui.Screen screen,
                                                net.rim.device.api.ui.Field control,
                                                boolean isForward)
Gets if there is focusable control besides the current focus control

Parameters:
screen -
control - - current focus control
isForward - - true means to get if there is focusable control in front of the current control
Returns:
true means there is focusable control on the direction

getFieldIndexOnScreen

public static int getFieldIndexOnScreen(net.rim.device.api.ui.Screen screen,
                                        net.rim.device.api.ui.Field field)
Gets the field index among all fields on the screen

Parameters:
screen -
field -
Returns:
field index

getMobileDataControlByMobileAppID

public static MobileDataControl getMobileDataControlByMobileAppID(IBOBScreen screen,
                                                                  java.lang.String mobileAppID,
                                                                  boolean onCurrentTabOnly)
Get only the mobile data controls

Parameters:
screen - - BOB screen to search
mobileAppID - - mobile application to search
onCurrentTabOnly - - search on current tab panel only if there is tabs

getControlsByID

public static Control getControlsByID(java.lang.String controlID)
Get all the controls on the screen

Parameters:
controlID - - control ID
Returns:
array of Controls

getControlsByID

public static Control[] getControlsByID(java.lang.String[] controlIDs)
Get all the controls on the screen

Parameters:
controlIDs - - string array of control IDs
Returns:
array of Controls

containsFocusableControlsAfterTable

public static boolean containsFocusableControlsAfterTable(java.lang.String tableFieldMobileAppID)
This is mainly used in the TableField where we want to check if there are controls after the table If there are controls we would want to move the focus to that control

Parameters:
tableFieldMobileAppID - - Mobile Application ID of the current table
Returns:
True if there is a control that is focusable after the current table

getAllControls

public static void getAllControls(net.rim.device.api.ui.Field f,
                                  java.util.Vector controls)
Get the list of controls on this manager field

Parameters:
manager - - manager field to search through
controls - - vector of found controls

getFieldMaxWidth

public static int getFieldMaxWidth(net.rim.device.api.ui.Font font,
                                   MBOAttribute[] columns)

getBooleanByString

public static boolean getBooleanByString(java.lang.String value)
Get the boolean value by string If the string isn't "true" or "false", return true

Parameters:
value - - string boolean value
Returns:
boolean value

getBooleanByString

public static boolean getBooleanByString(java.lang.String value,
                                         boolean defaultBoolean)
Get the boolean value by string If the string isn't "true" or "false", return the default boolean value

Parameters:
value - - string boolean value
defaultBoolean - - default boolean value if undefined
Returns:
boolean value

getImageBitmap

public static net.rim.device.api.system.Bitmap getImageBitmap(java.lang.String imageStr)
Get the Bitmap object based on the image name.

Parameters:
imageStr - - image name
Returns:
Image Bitmap object

getEncodedImage

public static net.rim.device.api.system.EncodedImage getEncodedImage(java.lang.String imageStr)
Get the EncodedImage object based on the image name.

Parameters:
imageStr - - image name
Returns:
Image Bitmap object

getImageBitmap

public static net.rim.device.api.system.Bitmap getImageBitmap(java.lang.String imageStr,
                                                              net.rim.device.api.system.Bitmap defaultImage)
Get the Bitmap object based on the image name.

Parameters:
imageStr - - image name
defaultImage - - this image gets returned if image is not found or undefined
Returns:
Image Bitmap object

getImageBitmap

public static net.rim.device.api.system.Bitmap getImageBitmap(java.lang.String moduleName,
                                                              java.lang.String imageStr,
                                                              net.rim.device.api.system.Bitmap defaultImage)
Get the Bitmap object based on the image name.

Parameters:
imageStr - - image name
defaultImage - - this image gets returned if image is not found or undefined
Returns:
Image Bitmap object

getEncodedImage

public static net.rim.device.api.system.EncodedImage getEncodedImage(java.lang.String moduleName,
                                                                     java.lang.String imageName)
For custom coding, we are not sure what module name is, the deal is to first retrieve the image without module name, and if nothing is returned we then try the module name.

Parameters:
moduleName - the module that contains the image
imageName - the image name
Returns:
EncodedImage based on the module name and image name.

getHorizontalAlignment

public static long getHorizontalAlignment(long style)
Get the horizontal alignment

Parameters:
style - - style that contains the horizontal alignment value
Returns:
return the horizontal alignment eg. Field.FIELD_LEFT, Field.FIELD_RIGHT, or Field.FIELD_HCENTER

getHorizontalAlignment

public static long getHorizontalAlignment(long style,
                                          long defaultAlignment)
Get the horizontal alignment

Parameters:
style - - style that contains the horizontal alignment value
defaultAlignment - - default horizontal aignment eg. Field.FIELD_LEFT, Field.FIELD_RIGHT, or Field.FIELD_HCENTER
Returns:
return the horizontal alignment eg. Field.FIELD_LEFT, Field.FIELD_RIGHT, or Field.FIELD_HCENTER

getVerticalAlignment

public static long getVerticalAlignment(long style)
Get the vertical alignment

Parameters:
style - - style that contains the vertical alignment value
Returns:
return the horizontal alignment eg. Field.FIELD_TOP, Field.FIELD_BOTTOM, or Field.FIELD_VCENTER

getVerticalAlignment

public static long getVerticalAlignment(long style,
                                        long defaultAlignment)
Get the vertical alignment

Parameters:
style - - style that contains the vertical alignment value
defaultAlignment - - default vertical aignment eg. Field.FIELD_TOP, Field.FIELD_BOTTOM, or Field.FIELD_VCENTER
Returns:
return the horizontal alignment eg. Field.FIELD_TOP, Field.FIELD_BOTTOM, or Field.FIELD_VCENTER

getHTTPPushAddress

public static java.lang.String getHTTPPushAddress()
Get the HTTP push address

Parameters:
settings - - settings object that holds push information
Returns:
string value of the http push address info

synchronizeMeta

public static void synchronizeMeta(java.lang.String mboMobileAppID)
Synchronize meta for a specific mobile business object ID

Parameters:
mboMobileAppID - - mobile business object ID

deleteAllMobileApplicationLogs

public static void deleteAllMobileApplicationLogs()
Delete all the mobile application logs when exiting the client


syncPackages

public static void syncPackages(java.lang.String[] packageNames)
Synchronize the packages

Parameters:
packageNames - - packages that are synchronizing

replaceInputString

public static java.lang.String replaceInputString(java.lang.String origStr,
                                                  java.lang.String[] inputStr)
Replace '{0}' with input string

Parameters:
origStr - - original string that contains place holder like '{0}'
inputStrs - - string array to replace the place holder

getMobileDataControls

public static void getMobileDataControls(net.rim.device.api.ui.Field f,
                                         java.util.Vector results,
                                         boolean currentTabOnly)
Search for Mobile data controls

Parameters:
f - - control
results - - mobile data control result list
currentTabOnly - - search on current tab panel only if there is tab

refreshAllMobileApplicationOnScreen

public static void refreshAllMobileApplicationOnScreen(IBOBScreen screen)
Refresh all the mobile data controls on screen

Parameters:
screen - - IBOBScreen reference

hasRelationship

public static boolean hasRelationship(IBOBScreen screen)
Whether any mbo referenced by this screen has relationship

Parameters:
screen -
Returns:

getFieldControls

public static net.rim.device.api.ui.Field[] getFieldControls(net.rim.device.api.ui.Field f)
Get controls from field object

Parameters:
f - - Field object
Returns:
list of fields in this field object

refreshControls

public static void refreshControls(net.rim.device.api.ui.Field f)
Refresh all controls within given field object

Parameters:
f - - field object to refresh

setMBODataProperties

public static void setMBODataProperties(IBOBScreen screen,
                                        java.lang.Object[] properties)
Set the MOB data properties to any matching mobile data control on the screen

Parameters:
screen - - IBOBScreen reference
properties - - array of mobile app ID and data properties object

setApplicationData

public static void setApplicationData(IBOBScreen screen,
                                      MBOModel appData)
Set the application data object to mobile object table on the screen

Parameters:
screen - - IBOBScreen reference
appData - - MBOModel object

setApplicationDataByMobileAppID

public static void setApplicationDataByMobileAppID(IBOBScreen screen,
                                                   java.lang.String mobileAppID,
                                                   MBOModel appData)
Set the application data with any matching mobile data control on the screen

Parameters:
screen - - IBOBScreen reference
mobileAppID - - mobile application ID
appData - - MBOModel object to set

refreshLinkParameterControls

public static void refreshLinkParameterControls(IBOBScreen screen)
Refresh the link parameters controls on the screen supplied

Parameters:
screen - - IBOBScreen reference

changeLinkParamOptions

public static void changeLinkParamOptions(IBOBScreen screen,
                                          java.lang.String mobileAppID,
                                          LinkParamNode linkParam,
                                          java.lang.String name,
                                          java.lang.String value)
Change the link parameter select box options when it has been changed

Parameters:
screen - - IBOBScreen reference
mobileAppID - - mobile application ID
linkParam - - Link Parameter object
name - - select box display name
value - - select box selected value

deleteAllMobileApplications

public static void deleteAllMobileApplications(MBOModel[] mobileApps)
Delete a list of mobile application objects

Parameters:
mobileApps - - list of mobile applications to delete

parseDate

public static java.lang.String parseDate(java.lang.String schemaType,
                                         java.util.Date value)
Parse the date

Parameters:
schemaType - - schema type
value - - date value as String for the date
Returns:
formatted date string value

parseDate

public static java.lang.String parseDate(java.lang.String schemaType,
                                         java.lang.String value)
Parse the date

Parameters:
schemaType - - schema type
value - - long value as String for the date
Returns:
formatted date string value

parseDate

public static java.lang.String parseDate(java.lang.String schemaType,
                                         long longVal)
Parse the date

Parameters:
schemaType - - schema type
value - - long value for the date
Returns:
formatted date string value

readBinaryData

public static byte[] readBinaryData(java.lang.String fileName)
Read binary data from device

Parameters:
fileName - - file path
Returns:
byte array

readBinaryData

public static byte[] readBinaryData(java.lang.String fileName,
                                    boolean reportErrors)
Read binary data from device

Parameters:
fileName - - file path
reportErrors - - if true, will log an errors that occur
Returns:
byte array

getStringValue

public static java.lang.String getStringValue(java.lang.Object varValue,
                                              boolean needTrim)
Return String object representing specified varValue. If varValue is null, empty String will return. The return value will be trimmed or not depend on needTrim parameter.

Parameters:
varValue - The variable value object
needTrim - indicate the return result need to be trimmed or not
Returns:
The String representation of the variable value

getStringValue

public static java.lang.String getStringValue(java.lang.Object varValue)
Return String object representing specified varValue. If varValue is null, empty String will return. The return value will be trimmed.

Parameters:
varValue - The variable value object
Returns:
The String representation of the variable value

convertToJ2MEObject

public static java.lang.Object convertToJ2MEObject(java.lang.Object value,
                                                   int datatype)
Convert AFX type to J2ME type. AFX uses Date to represent Date, Time and DateTime, and uses String to represent Decimal. So we need to convert the object returned by object api to the right J2ME type.

Parameters:
value -
datatype -
Returns:

convertToAFXObject

public static java.lang.Object convertToAFXObject(java.lang.Object value,
                                                  DataType datatype)
Convert J2ME type to AFX type. AFX uses Date to represent Date, Time and DateTime, and uses String to represent Decimal. So before we pass the data to object api, we need to convert it to afx type.

Parameters:
value -
datatype -
Returns:

convertToDataTypeName

public static java.lang.String convertToDataTypeName(java.lang.String schemaType)
Convert the name of schema_type to the name which can be recognized by the method of DataType.forName().

Parameters:
schemaType -
Returns:

getObjectFromString

public static java.lang.Object getObjectFromString(DataType dataType,
                                                   java.lang.Object value)

getStockScreenLabel

public static java.lang.String getStockScreenLabel(java.lang.Object obj)
Get the stock screen label value based on the object being passed in

Parameters:
obj - - this can be a String or a Integer object. If Integer, it means it a localization resource ID
Returns:
string value of the label

getStockScreenLabel

public static java.lang.String getStockScreenLabel(java.lang.Object obj,
                                                   net.rim.device.api.i18n.ResourceBundle res)
Get the stock screen label value based on the object being passed in

Parameters:
obj - - this can be a String or a Integer object. If Integer, it means it a localization resource ID
bundle - - the resouce bundle
Returns:
string value of the label

getResourceString

public static java.lang.String getResourceString(int resourceID)
Get the resource string

Parameters:
resourceID - - localization resouce ID
Returns:
string value

getResourceString

public static java.lang.String getResourceString(int resourceID,
                                                 net.rim.device.api.i18n.ResourceBundle res)
Get the resource string

Parameters:
resourceID - - localization resouce ID
Returns:
string value

getResourceString

public static java.lang.String getResourceString(int resourceID,
                                                 java.lang.String defaultValue)
Get the resource string

Parameters:
resourceID - - localization resouce ID
defaultValue - - default value if the localization resource ID is invalid or null
Returns:
string value

invokePhone

public static void invokePhone(java.lang.String phoneNumber)
Invoke the phone application

Parameters:
phoneNumber - - phone number

invokeEmail

public static void invokeEmail()
Invoke the email application


invokeEmail

public static void invokeEmail(java.lang.String email)
Invoke the email application

Parameters:
email - - email address

invokeAddressBook

public static void invokeAddressBook()
Invoke the address book application


invokeCamera

public static void invokeCamera()
Invoke the camera application


getPackageName

public static java.lang.String getPackageName(java.lang.String mboId)
Gets the name of the package that contains the given MBO

Parameters:
mboId -
Returns:
empty string if package is not found.

getObjectAPIPath

public static java.lang.String getObjectAPIPath()
Gets the package name of generated Object API

Returns:

getAppID

public static java.lang.String getAppID()
Gets the client application ID


initAppLoggerWrapper

public static void initAppLoggerWrapper()
Initializes the logger wrapper for Util


initAppLoggerWrapperForUnitTest

public static void initAppLoggerWrapperForUnitTest()
Initializes the logger wrapper for Util in the case of UnitTest


convertValueBySchemaType

public static java.lang.Object convertValueBySchemaType(java.lang.String schemaType,
                                                        java.lang.Object value)
Converts value to a specific java type based on schemaType Support convertion from String value to object of specified schematype ( For SCHEMA_TYPE_STRING, just return value ), byte[] value to SCHEMA_TYPE_BINARY, call getStringValue(Object) to convert value to corresponding String instance when specified schameType is SCHEMA_TYPE_STRING. (the result will be trimmed) If the specified value is null, return null.

Parameters:
schemaType - - Defines in MBOAttribute, eg. MBOAttribute.SCHEMA_TYPE_STRING
value -
Returns:
- specific java type
See Also:
getStringValue(Object)

getPublicationByMobileApp

public static java.lang.String getPublicationByMobileApp(MBOMobileApplication application)
Utility method to get the publication name by mobile application id

Parameters:
id - of the mobile application
Returns:
synchronization group name of the specific mbo

getMobileAppIDsByPublication

public static java.lang.String[] getMobileAppIDsByPublication(java.lang.String packageName,
                                                              java.lang.String publication)
Obtains an array of ids of all mobile business objects within the given publication

Parameters:
packageName - String value for the package name
publication - String value for the publication name
Returns:

getTabLayoutManager

public static TabLayoutManager getTabLayoutManager(IBOBScreen screen)
Finds tab layout manager on the BOB screen

Parameters:
screen - BOB screen
Returns:
the TabLayoutManager on the BOB screen and null if not found

getTabLayoutManager

public static TabLayoutManager getTabLayoutManager(net.rim.device.api.ui.Field f)
Finds tab layout manager on the field

Parameters:
f - the Field
Returns:
the TabLayoutManager on the Filed and null if not found

getParentMDC

public static MobileDataControl getParentMDC(IBOBScreen screen,
                                             java.lang.String mboId)
Finds the MobileDataControl with the mbo id on parent screen or parent tab

Parameters:
screen - BOB screen
mboId - mbo id
Returns:

getMDCList

public static java.util.Vector getMDCList(IBOBScreen screen,
                                          boolean currentTabOnly)
Gets all MobileDataControl contained in the given screen

Parameters:
screen - the screen to search on
currentTabOnly - search on current active tab panel only if there are tab panels
Returns:

pushLoginScreen

public static void pushLoginScreen(UIController controller)
Push the login screen.


isConnected

public static boolean isConnected(java.lang.String sourceMBOId,
                                  java.lang.String targetMBOId,
                                  java.lang.String relationship)
Checks whether the 2 mbo is connected by the given relationship

Parameters:
sourceMBOId -
targetMBOId -
relationship -
Returns:
true if source mbo and target mbo is connected by relationship, otherwise return false

isSource

public static boolean isSource(java.lang.String sourceMBOId,
                               java.lang.String relationship)
Check if the given source mbo is the source node of the relationship

Parameters:
sourceMBOId -
relationship -

getTruncatedTextWithinRowspan

public static java.lang.String getTruncatedTextWithinRowspan(net.rim.device.api.ui.Field field,
                                                             int rowSpan,
                                                             java.lang.String text,
                                                             FontStyle displayFont)

getTextWithinRowspan

public static java.lang.String getTextWithinRowspan(net.rim.device.api.ui.Field field,
                                                    int rowSpan,
                                                    java.lang.String text)
Gets truncated text that can be displayed within the RowSpan of the specified field

Parameters:
field - - the field that has RowSpan set
rowSpan - - value of RowSpan
text - - the text that the field contains
Returns:
the truncated text that is displayed within the RowSpan, returns null if the text doesn't need to be truncated to be displayed in the field

getControlByName

public static Control getControlByName(Control[] listControls,
                                       java.lang.Object key)
Loops through the list of controls on the screen and check for matching control name

Parameters:
listControls - - the list of controls
key - - key to match the name of the control
Returns:
the matching control

updateMobileDataControlContextVariables

public static void updateMobileDataControlContextVariables(MBOModel model,
                                                           java.lang.Object data,
                                                           boolean isAddtoContext)
Update the context variable for the given mbo

Parameters:
model -
data -
isAddtoContext - whether to create new context item if no context exists for this mbo

uppercaseFirstChar

public static java.lang.String uppercaseFirstChar(java.lang.String value)
Change the first character of the string to uppercase

Parameters:
value -
Returns:

converToValidName

public static java.lang.String converToValidName(java.lang.String oldName)
Remove "_" from name

Parameters:
oldName -
Returns:

addAll

public static void addAll(java.util.Vector target,
                          java.lang.Object[] source)
Collection util method, Add all source elements to target Vector

Parameters:
target -
source -

addAll

public static void addAll(java.util.Vector target,
                          java.util.Vector source)
Collection util method, Add all elements of source Vecotr to target Vector

Parameters:
target -
source -

equals

public static boolean equals(java.util.Vector vect1,
                             java.util.Vector vect2)
Indicates whether two Vector objects are equal to each other.

Parameters:
vect1 -
vect2 -
Returns:

equals

public static boolean equals(java.lang.Object obj1,
                             java.lang.Object obj2)
Indicates whether two objects are equal to each other.

Parameters:
obj1 -
obj2 -
Returns:

getPrimitiveDatatype

public static DataType getPrimitiveDatatype(DataType listType)
Parameters:
listType -
Returns:
primitive DataType value of listType

appendInternalPackageString

public static java.lang.String appendInternalPackageString(java.lang.String fullDatabaseClassName)
Appends 'intrnl' as package name

Parameters:
fullDatabaseClassName -
Returns:

setPushConnectionProfile

public static boolean setPushConnectionProfile(java.lang.String packageName)
Sets up push settings for specified package's synchronization profile.

Parameters:
packageName - the specified package name
Returns:
true if set up succesfully.

getDataFromSPMBO

public static java.lang.Object getDataFromSPMBO(java.lang.String id,
                                                boolean isAll)
Retrieve the data stored in the structured parameter(complex datatype) mbo

Parameters:
id - structured parameter mbo id
isAll - if it's true return all data, otherwise, only return the first one.
Returns:

removeDuplicateMenuItems

public static void removeDuplicateMenuItems(java.util.Vector menus)
Removes duplicate menu items from menu list

Parameters:
menus - Vector list of menus

getTruncatedText

public static java.lang.String getTruncatedText(java.lang.String text,
                                                int availableWidth,
                                                FontStyle displayFont)
Truncates a text by given width, and appends ellipsis at the end of the truncated text.

Parameters:
text - - original text
availableWidth - - width that the text is truncated to
displayFont - - font style by which the text is displayed
Returns:
truncated text

getTruncatedText

public static java.lang.String getTruncatedText(java.lang.String text,
                                                int availableWidthPerRow,
                                                int rowCount,
                                                FontStyle displayFont)

getAssociationKey

public static java.lang.String getAssociationKey(java.lang.String packageName,
                                                 java.lang.String name)
We need the package name and association name to identify an association. This method generate the key for an association based on its name and its package name

Parameters:
packageName -
name -
Returns:

scaleImage

public static net.rim.device.api.system.EncodedImage scaleImage(net.rim.device.api.system.EncodedImage image,
                                                                int scalingWidth,
                                                                int scalingHeight,
                                                                boolean isPreserveRatio)
Scales an image to a certain size

Parameters:
image - - image that is scaling
scalingWidth - - width that the image is scaling to
scalingHeight - - height that the image is scaling to
isPreserveRatio - - true means to scale as aspect fit, false as aspect fill
Returns:
scaled image

applyProfileInfo2ObjectAPI

public static void applyProfileInfo2ObjectAPI(ClientProfile clientProfile,
                                              java.lang.String clientName)
Apply the properties of spcified client profile into to Object API

Parameters:
clientProfile -

applyProfileInfo2ObjectAPI

public static void applyProfileInfo2ObjectAPI(ClientProfileList profileList,
                                              java.lang.String profileId,
                                              java.lang.String clientName)
Apply profile info of specified profile ID to the static fields of MyDatabase class of Object API

Parameters:
profileList -
profileId -
clientName - parameter clientName represent the name of client application in options module, while this method called in client application module, its value should be null

applyAllProfileInfo2ObjectAPI

public static void applyAllProfileInfo2ObjectAPI(ClientProfileList profileList,
                                                 java.lang.String clientName)
Apply all profile info to the static fields of MyDatabase class of Object API

Parameters:
profileList -
clientName -

postGlobalEvent

public static void postGlobalEvent(long guid,
                                   java.lang.String clientName,
                                   java.lang.Object object0)
Parameters:
guid - The guid of event ID
clientName - The name of the client application
object0 - Additional information associated with the event

getParametersFromSubmitElement

public static java.util.Hashtable getParametersFromSubmitElement(java.util.Vector submitElements)
Returns a hashtable of parameters from the submit elements.

Parameters:
submitElements - submit element list
Returns:
a hashtable of parameters mapping from display name to value.

convertPackageName

public static java.lang.String convertPackageName(java.lang.String packageName)
Converts the server version of package name to its realy package name.

Parameters:
packageName - server version of package name
Returns:
the package's real name.

canLoginToSync

public static boolean canLoginToSync(java.lang.String packageName)
Checks whether the specified package can call loginToSync.

Parameters:
packageName - the package to check
Returns:
true if it can call loginToSync and false otherwise.

reorganizeMenuItems

public static void reorganizeMenuItems(java.util.Vector menus,
                                       int length)
Sorts menu items by alpha and remove duplicate menu items

Parameters:
menus - Vector list of menus
length - int value for the end index

getMetaData

public static ClassMetaData getMetaData(java.lang.String packageName,
                                        java.lang.String complexDataType)
Get the meta data for a given complex data type class

Parameters:
packageName -
complexDataType -
Returns:

getAttributeMetaData

public static AttributeMetaData getAttributeMetaData(MBOModel mboModel,
                                                     java.lang.String attrName)
Gets attribute meta data

Parameters:
mboModel -
attrName - - attribute display name
Returns:
AttributeMetaData

convert2ScalarArrayIfNeed

public static java.lang.Object convert2ScalarArrayIfNeed(java.lang.String schemaType,
                                                         java.lang.Object value)
Check if the value need to be converted to a scalar array. If it is, convert and return the array, otherwise, return the value itself.

Parameters:
schemaType -
value -
Returns:

getFocusField

public static net.rim.device.api.ui.Field getFocusField(net.rim.device.api.ui.Screen screen)
return the control with focus in specific screen.

Parameters:
screen -
Returns:

isInteger

public static boolean isInteger(java.lang.String value)
Check if the given string value is an Integer

Parameters:
value -
Returns: