|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object avrora.util.StringUtil
The StringUtil
class implements several useful functions for dealing with strings such as
parsing pieces of syntax, formatting, etc.
Field Summary | |
static java.lang.String |
COMMA
|
static java.lang.String |
COMMA_SPACE
|
static int |
DAYS
|
static int[] |
DAYSECS
|
static int[] |
DENOM
|
static java.lang.String[] |
EMPTY_STRING_ARRAY
|
static char[] |
HEX_CHARS
|
static int |
HOURS
|
static int |
ID_LENGTH
|
static java.lang.String |
LPAREN
|
static int |
MILLIS
|
static long |
MILLISECS_PER_DAY
|
static long |
MILLISECS_PER_HOUR
|
static long |
MILLISECS_PER_MIN
|
static long |
MILLISECS_PER_SEC
|
static int |
MINS
|
static java.lang.String |
QUOTE
|
static boolean |
REPORT_SECONDS
|
static java.lang.String |
RPAREN
|
static int |
SECONDS_PRECISION
|
static int |
SECS
|
static int |
SECS_PER_DAY
|
static int |
SECS_PER_HOUR
|
static int |
SECS_PER_MIN
|
static java.lang.String |
SQUOTE
|
static int |
TIME_LENGTH
|
Constructor Summary | |
StringUtil()
|
Method Summary | |
static java.lang.String |
addrToString(int address)
The addToString() method converts a numerical address (represented as a signed 32-bit
integer) and converts it to a string in the format 0xXXXX where 'X' represents a hexadecimal character.
|
static char |
alpha(int num)
|
static java.lang.String |
commalist(java.util.List l)
|
static java.lang.String |
commalist(java.lang.Object o1,
java.lang.Object o2)
|
static java.lang.String |
commalist(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3)
|
static java.lang.String |
commalist(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4)
|
static java.lang.String |
dup(char c,
int len)
The dup() method takes a character and a count and returns a string where that character
has been duplicated the specified number of times. |
static java.lang.String |
embed(java.lang.Object s)
The embed() method simply adds parentheses around a string. |
static java.lang.String |
embed(java.lang.Object lead,
java.lang.Object arg)
|
static java.lang.String |
embed(java.lang.Object lead,
java.lang.Object arg1,
java.lang.Object arg2)
|
static java.lang.String |
embed(java.lang.Object lead,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3)
|
static java.lang.String |
embed(java.lang.Object lead,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4)
|
static char |
evaluateCharLiteral(java.lang.String literal)
|
static int |
evaluateIntegerLiteral(java.lang.String val)
|
static java.lang.String |
evaluateStringLiteral(java.lang.String literal)
|
static java.lang.String |
getIDTimeString(Simulator s)
|
static void |
getIDTimeString(java.lang.StringBuffer buf,
Simulator s)
|
static int |
hexValueOf(char c)
|
static java.lang.String |
interval(int low,
int high)
|
static boolean |
isHexDigit(char c)
The isHexDigit() method tests whether the given character corresponds to one of the
characters used in the hexadecimal representation (i.e. is '0'-'9' or 'a'-'b', case insensitive. |
static boolean |
isOctalDigit(char c)
|
static java.lang.String |
leftJustify(float v,
int width)
The leftJustify() method pads a string to a specified length by adding spaces on the
right, thus justifying the string to the left margin. |
static java.lang.String |
leftJustify(long v,
int width)
The leftJustify() method pads a string to a specified length by adding spaces on the
right, thus justifying the string to the left margin. |
static java.lang.String |
leftJustify(java.lang.String s,
int width)
The leftJustify() method pads a string to a specified length by adding spaces on the
right, thus justifying the string to the left margin. |
static java.lang.String |
linelist(java.util.List l)
|
static void |
linelist(java.lang.StringBuffer buf,
java.util.List l)
|
static java.lang.String |
makeParagraphs(java.lang.String s,
int leftJust,
int indent,
int width)
|
static long[] |
millisToDays(long millis)
The millisToDays() method converts the given milliseconds into a breakdown of days, hours,
minutes, seconds, and milliseconds, returning a long array where the expr 0 corresponds to days, expr 1
corresponds to hours, etc. |
static java.lang.String |
milliToSecs(long millis)
|
static int |
octalValueOf(char c)
|
static char |
peek(java.text.CharacterIterator i)
|
static boolean |
peekAndEat(java.text.CharacterIterator i,
char c)
|
static java.lang.String |
qembed(java.lang.String s1,
java.lang.String s2,
java.lang.String s3)
|
static java.lang.String |
quote(java.lang.Object s)
The quote() method simply adds double quotes around a string. |
static java.lang.String |
readDecimalString(java.text.CharacterIterator i,
int max_chars)
|
static int |
readDecimalValue(java.text.CharacterIterator i,
int max_chars)
|
static java.lang.String |
readDotIdentifier(java.text.CharacterIterator i)
|
static int |
readHexValue(java.text.CharacterIterator i,
int max_chars)
|
static java.lang.String |
readIdentifier(java.text.CharacterIterator i)
|
static int |
readOctalValue(java.text.CharacterIterator i,
int max_chars)
|
static java.lang.String |
rightJustify(float v,
int width)
The rightJustify() method pads a string to a specified length by adding spaces on the
left, thus justifying the string to the right margin. |
static java.lang.String |
rightJustify(long v,
int width)
The rightJustify() method pads a string to a specified length by adding spaces on the
left, thus justifying the string to the right margin. |
static java.lang.String |
rightJustify(java.lang.String s,
int width)
The rightJustify() method pads a string to a specified length by adding spaces on the
left, thus justifying the string to the right margin. |
static void |
skipWhiteSpace(java.text.CharacterIterator i)
|
static java.lang.String |
splice(java.lang.String[] a,
java.lang.String[] b)
|
static java.lang.String |
squote(char c)
The squote() method simply adds single quotes around a character. |
static java.lang.String |
to0xHex(long value,
int width)
|
static java.lang.String |
toBin(long value,
int width)
|
static char |
toBit(boolean f)
|
static java.lang.String |
toDecimal(long val,
int places)
|
static java.lang.String |
toFixedFloat(float fval,
int places)
|
static java.lang.String |
toHex(long value,
int width)
The toHex() converts the specified long value into a hexadecimal string of the given with.
|
static void |
toHex(java.lang.StringBuffer buf,
long value,
int width)
|
static java.lang.String |
toIDTimeString(int id,
Clock clk)
|
static void |
toIDTimeString(java.lang.StringBuffer buf,
int id,
Clock clk)
|
static java.lang.String |
toMultirepString(int value,
int bits)
|
static java.lang.String |
trimquotes(java.lang.String s)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final char[] HEX_CHARS
public static final java.lang.String QUOTE
public static final java.lang.String SQUOTE
public static final java.lang.String LPAREN
public static final java.lang.String RPAREN
public static final java.lang.String COMMA
public static final java.lang.String COMMA_SPACE
public static final java.lang.String[] EMPTY_STRING_ARRAY
public static final int[] DENOM
public static final int[] DAYSECS
public static final int SECS_PER_DAY
public static final int SECS_PER_HOUR
public static final int SECS_PER_MIN
public static final long MILLISECS_PER_DAY
public static final long MILLISECS_PER_HOUR
public static final long MILLISECS_PER_MIN
public static final long MILLISECS_PER_SEC
public static final int DAYS
public static final int HOURS
public static final int MINS
public static final int SECS
public static final int MILLIS
public static int ID_LENGTH
public static int TIME_LENGTH
public static boolean REPORT_SECONDS
public static int SECONDS_PRECISION
Constructor Detail |
public StringUtil()
Method Detail |
public static java.lang.String addrToString(int address)
addToString()
method converts a numerical address (represented as a signed 32-bit
integer) and converts it to a string in the format 0xXXXX where 'X' represents a hexadecimal character.
The address is assumed to fit in 4 hexadecimal characters. If it does not, the string will have as many
characters as necessary (max 8) to represent the address.
address
- the address value as an integer
public static java.lang.String readIdentifier(java.text.CharacterIterator i)
public static java.lang.String readDotIdentifier(java.text.CharacterIterator i)
public static int readHexValue(java.text.CharacterIterator i, int max_chars)
public static int readOctalValue(java.text.CharacterIterator i, int max_chars)
public static int readDecimalValue(java.text.CharacterIterator i, int max_chars)
public static java.lang.String readDecimalString(java.text.CharacterIterator i, int max_chars)
public static void skipWhiteSpace(java.text.CharacterIterator i)
public static char peek(java.text.CharacterIterator i)
public static boolean peekAndEat(java.text.CharacterIterator i, char c)
public static boolean isHexDigit(char c)
isHexDigit()
method tests whether the given character corresponds to one of the
characters used in the hexadecimal representation (i.e. is '0'-'9' or 'a'-'b', case insensitive. This
method is generally used in parsing and lexing of input.
c
- the character to test
public static int hexValueOf(char c)
public static int octalValueOf(char c)
public static boolean isOctalDigit(char c)
public static java.lang.String rightJustify(long v, int width)
rightJustify()
method pads a string to a specified length by adding spaces on the
left, thus justifying the string to the right margin. This is extremely useful in generating columnar
output in textual tables.
v
- a long value to convert to a string and justifywidth
- the number of characters to pad the string to
public static java.lang.String rightJustify(float v, int width)
rightJustify()
method pads a string to a specified length by adding spaces on the
left, thus justifying the string to the right margin. This is extremely useful in generating columnar
output in textual tables.
v
- a floating point value to convert to a string and justifywidth
- the number of characters to pad the string to
public static java.lang.String rightJustify(java.lang.String s, int width)
rightJustify()
method pads a string to a specified length by adding spaces on the
left, thus justifying the string to the right margin. This is extremely useful in generating columnar
output in textual tables.
s
- a string to justifywidth
- the number of characters to pad the string to
public static java.lang.String leftJustify(long v, int width)
leftJustify()
method pads a string to a specified length by adding spaces on the
right, thus justifying the string to the left margin. This is extremely useful in generating columnar
output in textual tables.
v
- a long value to convert to a string and justifywidth
- the number of characters to pad the string to
public static java.lang.String leftJustify(float v, int width)
leftJustify()
method pads a string to a specified length by adding spaces on the
right, thus justifying the string to the left margin. This is extremely useful in generating columnar
output in textual tables.
v
- a floating point value to convert to a string and justifywidth
- the number of characters to pad the string to
public static java.lang.String leftJustify(java.lang.String s, int width)
leftJustify()
method pads a string to a specified length by adding spaces on the
right, thus justifying the string to the left margin. This is extremely useful in generating columnar
output in textual tables.
s
- a string to justifywidth
- the number of characters to pad the string to
public static java.lang.String milliToSecs(long millis)
public static long[] millisToDays(long millis)
millisToDays()
method converts the given milliseconds into a breakdown of days, hours,
minutes, seconds, and milliseconds, returning a long array where the expr 0 corresponds to days, expr 1
corresponds to hours, etc.
millis
- the number of milliseconds to convert
public static java.lang.String toHex(long value, int width)
toHex()
converts the specified long value into a hexadecimal string of the given with.
The value will be padded on the left with zero values to achieve the desired with.
value
- the long value to convert to a stringwidth
- the desired length of the string
public static java.lang.String to0xHex(long value, int width)
public static java.lang.String toBin(long value, int width)
public static void toHex(java.lang.StringBuffer buf, long value, int width)
public static java.lang.String splice(java.lang.String[] a, java.lang.String[] b)
public static java.lang.String quote(java.lang.Object s)
quote()
method simply adds double quotes around a string.
s
- the string to add double quotes to
public static java.lang.String squote(char c)
squote()
method simply adds single quotes around a character.
c
- the character to add double quotes to
public static java.lang.String embed(java.lang.Object s)
embed()
method simply adds parentheses around a string.
s
- the string to add parentheses to
public static java.lang.String embed(java.lang.Object lead, java.lang.Object arg)
public static java.lang.String embed(java.lang.Object lead, java.lang.Object arg1, java.lang.Object arg2)
public static java.lang.String embed(java.lang.Object lead, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
public static java.lang.String embed(java.lang.Object lead, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
public static java.lang.String commalist(java.util.List l)
public static java.lang.String linelist(java.util.List l)
public static void linelist(java.lang.StringBuffer buf, java.util.List l)
public static java.lang.String commalist(java.lang.Object o1, java.lang.Object o2)
public static java.lang.String commalist(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3)
public static java.lang.String commalist(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.Object o4)
public static java.lang.String interval(int low, int high)
public static char alpha(int num)
public static java.lang.String qembed(java.lang.String s1, java.lang.String s2, java.lang.String s3)
public static int evaluateIntegerLiteral(java.lang.String val)
public static java.lang.String evaluateStringLiteral(java.lang.String literal)
public static char evaluateCharLiteral(java.lang.String literal)
public static java.lang.String trimquotes(java.lang.String s)
public static java.lang.String makeParagraphs(java.lang.String s, int leftJust, int indent, int width)
public static java.lang.String dup(char c, int len)
dup()
method takes a character and a count and returns a string where that character
has been duplicated the specified number of times.
c
- the character to duplicatelen
- the number of times to duplicate the character
public static java.lang.String toFixedFloat(float fval, int places)
public static java.lang.String toDecimal(long val, int places)
public static java.lang.String toMultirepString(int value, int bits)
public static char toBit(boolean f)
public static void toIDTimeString(java.lang.StringBuffer buf, int id, Clock clk)
public static java.lang.String toIDTimeString(int id, Clock clk)
public static java.lang.String getIDTimeString(Simulator s)
public static void getIDTimeString(java.lang.StringBuffer buf, Simulator s)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |