|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.cmpware.cmp.Util
public class Util
This class contains various utility methods thay may be used in various different places. These methods are typically static.
Copyright (c) 2004, 2005 Cmpware, Inc. All Rights Reserved.
| Field Summary | |
|---|---|
static java.lang.String |
copyright
Copyright string |
| Constructor Summary | |
|---|---|
Util()
|
|
| Method Summary | |
|---|---|
static int |
bitsToBytes(int a)
This routine converts a bit count to a byte count, where the byte count is the minimum number of bytes to hold this many bits. |
static java.lang.String[] |
concatenate(java.lang.String[] a,
java.lang.String[] b)
This method concatenates two arrays of strings. |
static java.lang.String |
get(java.lang.String s1,
java.lang.String s2)
This method returns a string from two input strings. |
static java.lang.String |
getHostName()
This method returns the host name. |
static org.eclipse.swt.graphics.Image |
getImage(java.lang.String pathName)
This method returns a bitmap image. |
static org.eclipse.jface.resource.ImageDescriptor |
getImageDescriptor(java.lang.String pathName)
This method returns a bitmap image descriptor. |
static java.lang.String |
getPath(java.lang.String pathname)
This method returns the path from a full pathname string. |
static long |
pack(int a,
int b)
This method packs two 32-bit integers into a 64-bit long. |
static int |
parseInt(java.lang.String s)
This method parses a string and returns an integer. |
static byte[] |
readFile(java.lang.String fileName)
This method reads in a text file and returns the contents as an ArrayList with one line of text per entry. |
static java.lang.String[] |
readTextFile(java.lang.String fileName)
This method read in a text file and returns it as an array of strings. |
static int |
signExtend(int a,
int bits)
This method is used to take a value 'a' of bit length 'bits' and sign extend it, making it a proper signed integer value. |
static long |
signExtend(long a,
int bits)
This method is used to take a value 'a' of bit length 'bits' and sign extend it, making it a proper signed integer value. |
static int |
signExtend16(int x)
This method returns an 16-bit value sign extended to to a 32-bit integer. |
static int |
signExtend8(int x)
This method returns an 8-bit value sign extended to to a 32-bit integer. |
static int |
swap(int a)
This static method swaps the bytes in a 32-bit word. |
static long |
swap(long a)
This static method swaps the bytes in a 64-bit word. |
static short |
swap(short a)
This static method swaps the bytes in a 16-bit word. |
static java.lang.String |
toHexString(byte b)
This method returns a two character string representing a byte. |
static java.lang.String |
toHexString(byte[] b)
This method returns a hexadecimal String representation of an array of bytes. |
static java.lang.String |
toHexString(byte[] b,
int index,
int bytes)
This method returns a hexadecimal String representation from a subset of an array of bytes. |
static java.lang.String |
toHexString(int i)
This method returns an eight character string representing a 32-bit int. |
static java.lang.String |
toHexString(long i)
This method returns a sixteen character string representing a 64-bit long. |
static java.lang.String |
toHexString(short b)
This method returns a four character string representing a 16-bit short. |
static long |
toLong(byte[] b,
boolean endian)
This method converts a byte array to a long. |
static char |
toPrintable(byte b)
This method convers a byte to a printable character. |
static long |
unsigned(int a)
When Java converts an int to a long, sign extension is performed. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String copyright
| Constructor Detail |
|---|
public Util()
| Method Detail |
|---|
public static byte[] readFile(java.lang.String fileName)
throws java.io.IOException
fileName - The name of the input text file.
java.io.IOException - if an error is encountered opening,
reading of closing the input file.
public static java.lang.String[] readTextFile(java.lang.String fileName)
throws java.io.IOException
fileName - The name of the file to be read.
java.io.IOException - if an error is encountered opening,
reading of closing the input file.
public static final java.lang.String get(java.lang.String s1,
java.lang.String s2)
s1 - The first input string.s2 - The second input string.
public static final java.lang.String getPath(java.lang.String pathname)
pathname - The full pathname of a file.
public static final org.eclipse.swt.graphics.Image getImage(java.lang.String pathName)
pathName - The pathname to the bitmapge image file
from the bundle root ("/").
public static final org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String pathName)
pathName - The pathname to the bitmapge image descriptor
from the bundle root ("/").
public static final java.lang.String getHostName()
public static int parseInt(java.lang.String s)
throws java.lang.NumberFormatException
s - The string to be converted into an integer.
java.lang.NumberFormatException - if the string is not a proper
decimal or hexadecimal integer.public static final int signExtend8(int x)
x - The input value.
public static final int signExtend16(int x)
x - The input value.
public static int signExtend(int a,
int bits)
a - The value to be sign extended.bits - the number of bits in the input value.
public static long signExtend(long a,
int bits)
a - The value to be sign extended.bits - the number of bits in the input value.
public static int bitsToBytes(int a)
a - The number of bits.
public static java.lang.String[] concatenate(java.lang.String[] a,
java.lang.String[] b)
a - the first array of strings.b - the second array of strings.
public static long toLong(byte[] b,
boolean endian)
b - The byte array. If this araray is longer
than eight bytes, the result is undefined.endian - The endian of the memory.
public static short swap(short a)
a - The 16-bit input value.
public static int swap(int a)
a - The 32-bit input value.
public static long swap(long a)
a - The 64-bit input value.
public static char toPrintable(byte b)
b - The byte to be converted to a printable
character.
public static java.lang.String toHexString(byte b)
b - The byte to be converted into a string.
public static java.lang.String toHexString(short b)
b - The 16-bit short to be converted into a string.
public static java.lang.String toHexString(int i)
i - The 32-bit int to be converted into a string.
public static java.lang.String toHexString(long i)
i - The 64-bit long to be converted into a string.
public static java.lang.String toHexString(byte[] b)
b - The byte array to be converted into a string.
public static java.lang.String toHexString(byte[] b,
int index,
int bytes)
b - The byte array.index - the start of the byte array.bytes - the number of bytes in the returned hex string.
public static long pack(int a,
int b)
a - the upper 32 bits of the returned long.b - the lower 32 bits of the returned long.
public static long unsigned(int a)
a - the integer value.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||