com.ibm.sensorevent.model.generic
Class GenericUtils

java.lang.Object
  extended by com.ibm.sensorevent.model.generic.GenericUtils

public class GenericUtils
extends java.lang.Object

GenericUtils contains helper methods used throughout the sensor event model.


Field Summary
static java.lang.String COPYRIGHT
           
 
Constructor Summary
protected GenericUtils()
          Constructs a new GenericUtils
 
Method Summary
static java.lang.String decode(java.lang.String s)
          Decode the value
static java.lang.String[] decode(java.lang.String[] s)
          For all strings in the array, decode the values
static java.lang.String encode(java.lang.String s)
          Encode the string
static java.lang.String[] encode(java.lang.String[] s)
          For all strings in the array, encode the strings
static java.lang.String[] encode(java.lang.String[] s, int max)
          For all strings in the array, encode the strings then truncate to max characters
static java.lang.String encode(java.lang.String s, int max)
          Encode the string then truncate to max characters
static java.lang.String formatISO8601Date(java.util.Date d)
          Converts the given java.util.Date value as an ISO 8601 date string.
static java.lang.String formatISO8601Date(long date)
          Converts the given long millisecond value as an ISO 8601 date string.
static java.util.Date parseISO8601Date(java.lang.String s)
          Converts the given ISO 8601 date string into a java.util.Date.
static java.lang.String replaceAll(java.lang.String target, java.lang.String toReplace, java.lang.String toReplaceWith)
          Replaces all occurrences of String toReplace with String toReplaceWith in String target
static java.lang.String[] split(java.lang.String s, java.lang.String delim)
          Splits the string at the delimiter (this method is necessary for J2ME environments instead of calling String.split)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values
Constructor Detail

GenericUtils

protected GenericUtils()
Constructs a new GenericUtils

Method Detail

split

public static java.lang.String[] split(java.lang.String s,
                                       java.lang.String delim)
                                throws SensorEventException
Splits the string at the delimiter (this method is necessary for J2ME environments instead of calling String.split)

Parameters:
s -
delim -
Returns:
String[] of tokens
Throws:
SensorEventException

encode

public static java.lang.String encode(java.lang.String s)
Encode the string

Parameters:
s -

encode

public static java.lang.String encode(java.lang.String s,
                                      int max)
Encode the string then truncate to max characters

Parameters:
s -

encode

public static java.lang.String[] encode(java.lang.String[] s)
For all strings in the array, encode the strings

Parameters:
s -

encode

public static java.lang.String[] encode(java.lang.String[] s,
                                        int max)
For all strings in the array, encode the strings then truncate to max characters

Parameters:
s -

decode

public static java.lang.String decode(java.lang.String s)
Decode the value

Parameters:
s -

decode

public static java.lang.String[] decode(java.lang.String[] s)
For all strings in the array, decode the values

Parameters:
s -

replaceAll

public static java.lang.String replaceAll(java.lang.String target,
                                          java.lang.String toReplace,
                                          java.lang.String toReplaceWith)
                                   throws SensorEventException
Replaces all occurrences of String toReplace with String toReplaceWith in String target

Parameters:
target - The string to search
toReplace - The string to search for within target
toReplaceWith - The string to replace occurrences of toReplace within target
Returns:
String
Throws:
SensorEventException

formatISO8601Date

public static java.lang.String formatISO8601Date(long date)
                                          throws SensorEventException
Converts the given long millisecond value as an ISO 8601 date string.

ISO 8601 date strings have the form

yyyy-MM-ddTHH:mm:ss.MMMZ

Parameters:
date - The long millisecond value to format
Returns:
String
Throws:
SensorEventException

formatISO8601Date

public static java.lang.String formatISO8601Date(java.util.Date d)
                                          throws SensorEventException
Converts the given java.util.Date value as an ISO 8601 date string.

ISO 8601 date strings have the form

yyyy-MM-ddTHH:mm:ss.MMMZ

Parameters:
d - The java.util.Date value to format
Returns:
String
Throws:
SensorEventException

parseISO8601Date

public static java.util.Date parseISO8601Date(java.lang.String s)
                                       throws SensorEventException
Converts the given ISO 8601 date string into a java.util.Date.

ISO 8601 date strings have the form

yyyy-MM-ddTHH:mm:ss.MMMZ

Parameters:
s - The string to convert
Returns:
java.util.Date
Throws:
SensorEventException


Copyright © 2005 - 2009 IBM Corp. All Rights Reserved.