|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.spot.util.Utils
public class Utils
Collection of utility functions
Field Summary | |
---|---|
static int |
SIZE_OF_INT
|
static int |
SIZE_OF_LONG
|
static int |
SIZE_OF_SHORT
|
Constructor Summary | |
---|---|
Utils()
|
Method Summary | |
---|---|
static int |
as6BitNumber(int number)
Truncates an int to 6 bits |
static byte[] |
copy(byte[] aByteArray)
Make a copy of a byte array |
static Vector |
enumToVector(Enumeration items)
Convert an Enumeration to a Vector |
static byte[] |
getDataWithCRC(DataInputStream dataInputStream)
Read data from a stream, checking the CRC. |
static int |
getManifestProperty(String manifestPropertyName,
int valueIfNotInManifest)
Get the value of a property from this suite's manifest (or the manifest of a parent suite). |
static String |
getManifestProperty(String manifestPropertyName,
String valueIfNotInManifest)
Get the value of a property from this suite's manifest (or the manifest of a parent suite). |
static int |
getSystemProperty(String propertyName,
int valueIfNotDefined)
Get the value of a system property. |
static boolean |
isOptionSelected(String optionName,
boolean defaultIfAbsent)
Test whether a boolean option is set in the system properties |
static void |
log(String message)
Display a log message if the "spot.diagnostics" property is set |
static void |
putDataWithCRC(DataOutputStream dataOutputStream,
byte[] data,
int offset,
int length)
Put data onto a stream, adding a CRC. |
static int |
readBigEndInt(byte[] byteArray,
int offset)
Read a big-endian int from an array |
static long |
readBigEndLong(byte[] byteArray,
int offset)
Read a big-endian long from an array |
static int |
readBigEndShort(byte[] byteArray,
int offset)
Read a big-endian short from an array |
static int |
readLittleEndInt(byte[] byteArray,
int offset)
Read a little-endian int from an array |
static long |
readLittleEndLong(byte[] byteArray,
int offset)
Read a little-endian long from an array |
static int |
readLittleEndShort(byte[] byteArray,
int offset)
Read a little-endian short from an array |
static long |
readLong(String number)
Parse a decimal or hexadecimal string to get a long. |
static int |
readNumber(String number)
Parse a decimal or hexadecimal string to get an int. |
static void |
sleep(long milliseconds)
Do a Thread.sleep(...), catching and ignoring any InterruptedException |
static String[] |
split(String s,
char marker)
Split a string into parts. |
static String |
stringify(byte[] b)
Generate a string representation of a byte array. |
static String |
withSpacesReplacedByZeros(String string)
Generate a String that is a copy of the supplied String but with all spaces replaced by nulls. |
static void |
writeBigEndInt(byte[] byteArray,
int offset,
int value)
Write a big-endian int into an array |
static void |
writeBigEndLong(byte[] byteArray,
int offset,
long value)
Write a big-endian long into an array |
static void |
writeBigEndShort(byte[] byteArray,
int offset,
int value)
Write a big-endian short into an array |
static void |
writeLittleEndInt(byte[] byteArray,
int offset,
int value)
Write a little-endian int into an array |
static void |
writeLittleEndLong(byte[] byteArray,
int offset,
long value)
Write a little-endian long into an array |
static void |
writeLittleEndShort(byte[] byteArray,
int offset,
int value)
Write a little-endian short into an array |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int SIZE_OF_SHORT
public static int SIZE_OF_INT
public static int SIZE_OF_LONG
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static void log(String message)
message
- the message to displaypublic static byte[] copy(byte[] aByteArray)
aByteArray
- the array to be copied
public static int readNumber(String number)
number
- the string to be parsed
public static long readLong(String number)
number
- the string to be parsed
public static long readLittleEndLong(byte[] byteArray, int offset)
byteArray
- the array containing the number as 8 consecutive bytesoffset
- the offset into the array of the number
public static int readLittleEndInt(byte[] byteArray, int offset)
byteArray
- the array containing the number as 4 consecutive bytesoffset
- the offset into the array of the number
public static int readBigEndInt(byte[] byteArray, int offset)
byteArray
- the array containing the number as 4 consecutive bytesoffset
- the offset into the array of the number
public static int readLittleEndShort(byte[] byteArray, int offset)
byteArray
- the array containing the number as 2 consecutive bytesoffset
- the offset into the array of the number
public static int readBigEndShort(byte[] byteArray, int offset)
byteArray
- the array containing the number as 2 consecutive bytesoffset
- the offset into the array of the number
public static long readBigEndLong(byte[] byteArray, int offset)
byteArray
- the array containing the number as 8 consecutive bytesoffset
- the offset into the array of the number
public static void writeBigEndLong(byte[] byteArray, int offset, long value)
byteArray
- the array to contain the numberoffset
- the offset into the array where the number is to be placedvalue
- the numberpublic static void writeLittleEndLong(byte[] byteArray, int offset, long value)
byteArray
- the array to contain the numberoffset
- the offset into the array where the number is to be placedvalue
- the numberpublic static void writeBigEndInt(byte[] byteArray, int offset, int value)
byteArray
- the array to contain the numberoffset
- the offset into the array where the number is to be placedvalue
- the numberpublic static void writeLittleEndInt(byte[] byteArray, int offset, int value)
byteArray
- the array to contain the numberoffset
- the offset into the array where the number is to be placedvalue
- the numberpublic static void writeLittleEndShort(byte[] byteArray, int offset, int value)
byteArray
- the array to contain the numberoffset
- the offset into the array where the number is to be placedvalue
- the numberpublic static void writeBigEndShort(byte[] byteArray, int offset, int value)
byteArray
- the array to contain the numberoffset
- the offset into the array where the number is to be placedvalue
- the numberpublic static int as6BitNumber(int number)
number
- the number to truncate
public static void sleep(long milliseconds)
milliseconds
- the period to sleeppublic static String getManifestProperty(String manifestPropertyName, String valueIfNotInManifest)
manifestPropertyName
- the name of the propertyvalueIfNotInManifest
- the value to return if not found
public static int getManifestProperty(String manifestPropertyName, int valueIfNotInManifest)
manifestPropertyName
- the name of the propertyvalueIfNotInManifest
- the value to return if not found
public static int getSystemProperty(String propertyName, int valueIfNotDefined)
propertyName
- the name of the propertyvalueIfNotDefined
- the value to return if not found
public static Vector enumToVector(Enumeration items)
items
- the Enumeration to convert
public static String stringify(byte[] b)
b
- the array
public static String withSpacesReplacedByZeros(String string)
string
- the input String
public static boolean isOptionSelected(String optionName, boolean defaultIfAbsent)
optionName
- defaultIfAbsent
- the value to return if optionName is absent from system properties
public static String[] split(String s, char marker)
s
- the string to splitmarker
- the character that marks the separation between parts
public static byte[] getDataWithCRC(DataInputStream dataInputStream) throws IOException
dataInputStream
- the stream holding the data
IOException
SpotFatalException
- if the length is improbable or the CRC is incorrectpublic static void putDataWithCRC(DataOutputStream dataOutputStream, byte[] data, int offset, int length) throws IOException
dataOutputStream
- the stream to receive the datadata
- the array containing the dataoffset
- the offset into the array at which the data startslength
- the number of bytes of data
IOException
|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |