com.eightmotions.util
Class UtilMidp

java.lang.Object
  extended by com.eightmotions.util.UtilMidp

public class UtilMidp
extends java.lang.Object

Utility classes designed to manage some of the differences between MIDP1.0 and 2.0, and a random set of usefull function....


Field Summary
static boolean DEBUG
          Set to TRUE to enable more debugging information
static java.lang.StringBuffer debugInfo
          A stringBuffer that contains some debugging information
static boolean isCLDC11
          True if handset is CLDC1.1 or later
static boolean isMIDP2
          True is handset is MIDP2.0 (which should be the only case in this version)
static boolean m_bluetoothEnabled
          True is handset haves JSR82 (Bluetooth) capacities
static javax.microedition.lcdui.Display m_display
          Reference to the current display (used to display alerts)
static boolean m_isFileAPIEnabled
          TRUE is handset haves JSR75 File API
static boolean m_locationAware
          True is handset is JSR179 enabled
static javax.microedition.midlet.MIDlet m_midlet
          Reference to the main midlet
static boolean m_obexEnabled
          True if handset is able to do OBEX/Bluetooth (part of JSR82, but not mandatory)
static javax.microedition.lcdui.Font m_smallFont
          A reference to a small font
static boolean m_useOldFormImage
          Use MIDP1.0 method for creating images....Useless now
static java.lang.String urlServices
           
 
Constructor Summary
UtilMidp()
           
 
Method Summary
static void addDebug(java.lang.String text)
           
static void addInfo(java.lang.String text)
          add information to the debug output
static boolean checkAvail(java.lang.String inClassName)
          check the avilability of a certain class.
static boolean checkMIDP(javax.microedition.midlet.MIDlet inMidlet)
          Initiaisation function, that must be called before calling MapCanvas!
static boolean checkProp(java.lang.String inPropName)
          Check the presence of a property in the handset.
static java.lang.String checkString(java.lang.String inDesc)
          set description and remove html tags if any
static java.lang.String decode_entities(java.lang.String inString)
           
static java.lang.String[] explode(java.lang.String theString)
          utility function convert a string into an array of string, '!'
static java.lang.String[] explode(java.lang.String theString, char separator)
          utility function convert a string into an array of string,
static java.lang.String getImgUrl(java.lang.String inDesc)
           
static javax.microedition.lcdui.Image getThumbnail(javax.microedition.lcdui.Graphics g, int inx, int iny, javax.microedition.lcdui.Image inIma, int width)
           
static javax.microedition.lcdui.Image getThumbnail(javax.microedition.lcdui.Graphics g, int inx, int iny, javax.microedition.lcdui.Image inIma, int width, boolean processAlpha)
          Return a thumbnail of in image.
static java.util.Hashtable getUrlParams(java.lang.String request)
          Return an array containg the value pair of paramters commands.
static javax.microedition.lcdui.Image ImagecreateImage(java.io.InputStream is)
          "safe" way to create image, either using MIDP2.0 form directly from input streal or more manually in MIDP1.0
static java.lang.String implode(javax.microedition.lcdui.ChoiceGroup cg, java.lang.String currentSel)
          concatenate strings into a a single string
static boolean isRIM()
          Return true if we are running on a blackberry platform (based of the "platform" property )...
static void MsgBox(java.lang.String name, java.lang.String text, javax.microedition.lcdui.AlertType type, int time)
          Utility function to create and display an alert
static float parseFloat(java.lang.String inString)
           
static boolean platformRequest(java.lang.String url)
           
static void setDebug(boolean mode)
           
static void setIndicator(javax.microedition.lcdui.Alert a, javax.microedition.lcdui.Gauge g)
          Manage MIDP2.0 jauge, but as there is a bug in Backberry, this function is disabled for Blackberry only
static void showException(java.lang.Exception e)
          Show a MsgBox with the content of an exception....
static java.lang.String strReplace(java.lang.String inString, java.lang.String inPattern, float infloat)
          Same but with floats
static java.lang.String strReplace(java.lang.String inString, java.lang.String inPattern, int inVal)
          Replace a pattern of a string with an int value for instance, strReplace("I will do the rep","rep",100) will produce: "I will do the 100"
static java.lang.String strReplace(java.lang.String inString, java.lang.String inPattern, java.lang.String inVal)
          Replace the content of a pattern present in a string by another one.
static java.lang.String toString(double f)
           
static java.lang.String toString(float f)
          String representation of a float
static void updateGauge(javax.microedition.lcdui.Gauge inGauge)
           
static java.lang.String urlEncode(java.lang.String inUrl)
          URL encoding Will replace specific characters with their ascii form..
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

urlServices

public static java.lang.String urlServices

m_useOldFormImage

public static boolean m_useOldFormImage
Use MIDP1.0 method for creating images....Useless now


DEBUG

public static boolean DEBUG
Set to TRUE to enable more debugging information


isMIDP2

public static boolean isMIDP2
True is handset is MIDP2.0 (which should be the only case in this version)


isCLDC11

public static boolean isCLDC11
True if handset is CLDC1.1 or later


debugInfo

public static java.lang.StringBuffer debugInfo
A stringBuffer that contains some debugging information


m_locationAware

public static boolean m_locationAware
True is handset is JSR179 enabled


m_bluetoothEnabled

public static boolean m_bluetoothEnabled
True is handset haves JSR82 (Bluetooth) capacities


m_obexEnabled

public static boolean m_obexEnabled
True if handset is able to do OBEX/Bluetooth (part of JSR82, but not mandatory)


m_isFileAPIEnabled

public static boolean m_isFileAPIEnabled
TRUE is handset haves JSR75 File API


m_display

public static javax.microedition.lcdui.Display m_display
Reference to the current display (used to display alerts)


m_smallFont

public static javax.microedition.lcdui.Font m_smallFont
A reference to a small font


m_midlet

public static javax.microedition.midlet.MIDlet m_midlet
Reference to the main midlet

Constructor Detail

UtilMidp

public UtilMidp()
Method Detail

setDebug

public static void setDebug(boolean mode)

checkAvail

public static boolean checkAvail(java.lang.String inClassName)
check the avilability of a certain class.

Parameters:
inClassName - Name of the classe to check. Return true if the class is present in the handset
Returns:

checkProp

public static boolean checkProp(java.lang.String inPropName)
Check the presence of a property in the handset. Return true if this property is defined

Parameters:
inPropName -
Returns:

MsgBox

public static void MsgBox(java.lang.String name,
                          java.lang.String text,
                          javax.microedition.lcdui.AlertType type,
                          int time)
Utility function to create and display an alert

Parameters:
name -
text -
type -
time -

checkMIDP

public static boolean checkMIDP(javax.microedition.midlet.MIDlet inMidlet)
Initiaisation function, that must be called before calling MapCanvas!


isRIM

public static boolean isRIM()
Return true if we are running on a blackberry platform (based of the "platform" property )...

Returns:

addDebug

public static void addDebug(java.lang.String text)

addInfo

public static void addInfo(java.lang.String text)
add information to the debug output


ImagecreateImage

public static javax.microedition.lcdui.Image ImagecreateImage(java.io.InputStream is)
"safe" way to create image, either using MIDP2.0 form directly from input streal or more manually in MIDP1.0


setIndicator

public static void setIndicator(javax.microedition.lcdui.Alert a,
                                javax.microedition.lcdui.Gauge g)
Manage MIDP2.0 jauge, but as there is a bug in Backberry, this function is disabled for Blackberry only


updateGauge

public static void updateGauge(javax.microedition.lcdui.Gauge inGauge)
See Also:
updateGauge

explode

public static java.lang.String[] explode(java.lang.String theString)
utility function convert a string into an array of string, '!' as a sperator. Example: toto!titi!tata will return an array of 3 string:"toto","titi","tata"

Parameters:
theString -
Returns:

explode

public static java.lang.String[] explode(java.lang.String theString,
                                         char separator)
utility function convert a string into an array of string,

Parameters:
theString -
Returns:

implode

public static java.lang.String implode(javax.microedition.lcdui.ChoiceGroup cg,
                                       java.lang.String currentSel)
concatenate strings into a a single string

Parameters:
cg -
currentSel -
Returns:
See Also:
explode

showException

public static void showException(java.lang.Exception e)
Show a MsgBox with the content of an exception....

Parameters:
e -

platformRequest

public static boolean platformRequest(java.lang.String url)
                               throws javax.microedition.io.ConnectionNotFoundException
Parameters:
url -
Throws:
javax.microedition.io.ConnectionNotFoundException

getThumbnail

public static javax.microedition.lcdui.Image getThumbnail(javax.microedition.lcdui.Graphics g,
                                                          int inx,
                                                          int iny,
                                                          javax.microedition.lcdui.Image inIma,
                                                          int width)

getThumbnail

public static javax.microedition.lcdui.Image getThumbnail(javax.microedition.lcdui.Graphics g,
                                                          int inx,
                                                          int iny,
                                                          javax.microedition.lcdui.Image inIma,
                                                          int width,
                                                          boolean processAlpha)
Return a thumbnail of in image. There are two forms in the same function. If Graphics is given as a paremter, than the thumbnail is created and displayed on the fly, and nothing is returned. If g is null, then an Image is create and returned. The resulting image (or displayed image) will be of the size width, inIma.height*width/inIma.width.

Parameters:
g -
inx -
iny -
inIma -
width -
Returns:

urlEncode

public static java.lang.String urlEncode(java.lang.String inUrl)
URL encoding Will replace specific characters with their ascii form..


toString

public static java.lang.String toString(float f)
String representation of a float


toString

public static java.lang.String toString(double f)

strReplace

public static java.lang.String strReplace(java.lang.String inString,
                                          java.lang.String inPattern,
                                          int inVal)
Replace a pattern of a string with an int value for instance, strReplace("I will do the rep","rep",100) will produce: "I will do the 100"

Parameters:
inString -
inPattern -
inVal -
Returns:

strReplace

public static java.lang.String strReplace(java.lang.String inString,
                                          java.lang.String inPattern,
                                          java.lang.String inVal)
Replace the content of a pattern present in a string by another one.

Parameters:
inString -
inPattern -
inVal -
Returns:

strReplace

public static java.lang.String strReplace(java.lang.String inString,
                                          java.lang.String inPattern,
                                          float infloat)
Same but with floats

Parameters:
inString -
inPattern -
infloat -
Returns:

decode_entities

public static java.lang.String decode_entities(java.lang.String inString)

checkString

public static java.lang.String checkString(java.lang.String inDesc)
set description and remove html tags if any


getImgUrl

public static java.lang.String getImgUrl(java.lang.String inDesc)

getUrlParams

public static java.util.Hashtable getUrlParams(java.lang.String request)
Return an array containg the value pair of paramters commands.
For instance, if request is http://anurl?toto=a&titi=b the return will be an hashtable wih two keys, toto and titi, and two values, a and b.


parseFloat

public static float parseFloat(java.lang.String inString)