jfrace
Class Util

java.lang.Object
  |
  +--jfrace.Util

public class Util
extends java.lang.Object

Collection of utility functions.

Author:
Franz-Josef Elmer

Constructor Summary
Util()
           
 
Method Summary
static void appendHex(java.lang.StringBuffer sb, byte number)
          Append a two-digit hexadecimal number (upper case) to the given string buffer.
static void appendHex(java.lang.StringBuffer sb, int number)
          Append an eight-digit hexadecimal number (upper case) to the given string buffer.
static void appendHex(java.lang.StringBuffer sb, int n, long number)
          Append a n-digit hexadecimal number (upper case) to the given string buffer.
static byte[] generateBinaryData(java.lang.String intelHexData)
          Generate binary data from Intel Hex Format.
static java.awt.Image loadImage(java.lang.String imgName)
          Load an image.
static int parseNumber(java.lang.String numberString)
          Parse a string as a number.
static byte[] readBinaryData(java.lang.String fileName)
          Read a binary file.
static byte[] readBinaryData(java.net.URL url)
          Read some binary data from an URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

parseNumber

public static int parseNumber(java.lang.String numberString)
Parse a string as a number. The number is given either as a binary one if it starts with '0b', or a decimal one if it starts with a nonzero digit, or an octal one if it starts with zero, or a hexdecimal one if it starts with '0x'. Return zero if the argument does not start with a digit (including '-' and white spaces).

appendHex

public static void appendHex(java.lang.StringBuffer sb,
                             byte number)
Append a two-digit hexadecimal number (upper case) to the given string buffer.
Parameters:
sb - string buffer.
number - 8-bit number.

appendHex

public static void appendHex(java.lang.StringBuffer sb,
                             int number)
Append an eight-digit hexadecimal number (upper case) to the given string buffer.
Parameters:
sb - string buffer.
number - 32-bit number.

appendHex

public static void appendHex(java.lang.StringBuffer sb,
                             int n,
                             long number)
Append a n-digit hexadecimal number (upper case) to the given string buffer.
Parameters:
sb - string buffer.
n - number of digits.
number - number.

readBinaryData

public static byte[] readBinaryData(java.net.URL url)
                             throws java.lang.Exception
Read some binary data from an URL.
Parameters:
url - URL of the source of the data.
Returns:
data in a byte array.

readBinaryData

public static byte[] readBinaryData(java.lang.String fileName)
Read a binary file. If file type is hex Intel-Hex-Format is assumed.

generateBinaryData

public static byte[] generateBinaryData(java.lang.String intelHexData)
Generate binary data from Intel Hex Format. Assumes correct Intel Hex Format and does not check checksums.
Parameters:
intelHexData - data in Intel Hex Format
Returns:
binary data.

loadImage

public static java.awt.Image loadImage(java.lang.String imgName)
Load an image. Use the Emulator singleton in order to decide whether this method is invoked inside an application or an applet.
Parameters:
imgName - file name of the image. Path is relative to codeBase.
Returns:
null if image not found.