|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microdeveloper.common.Str
public class Str
Provides extensive String manipulation, extensions, utilities, and new capabilities.
This class attempts to provide all of the functionality found in both String and StringBuffer, plus provide a wide collection of additional functionality.
If an Str object is appended and needs to grow beyond its current size, it will do so without programmer intervention. It also keeps a little extra buffer of size to accomodate small amounts of growth without needing memory re-allocation.
Constructor Summary | |
---|---|
Str()
The object has memory allocated to store an average size string. |
|
Str(char[] c)
The object is inititialized to have an exact copy of the character array. |
|
Str(int initialSize)
Set the object to have an initial capacity. |
|
Str(int initialSize,
int initialExtra)
Create an object with a specific initial capacity and to be able to grow by a specific increment. |
|
Str(Str s)
A new object is created that is an exact copy of the provided Str object. |
|
Str(String s)
A new object is created that contains a copy of the provided String object. |
Method Summary | |
---|---|
Str |
after(int index)
Get all of the substring that occurs after a particular character. |
static String |
after(String s,
int index)
Get all of the substring that occurs after a particular character. |
void |
append(char c)
Add one character to the end of the string. |
void |
append(Str s)
Append a string on to the end of your string. |
void |
append(String s)
Append a string on to the end of your string. |
static int |
Ascii(char c)
Method Ascii returns the decimal representation of the character given. |
static double |
atod(String s)
Like the ANSI c function atod(). |
static int |
atoi(char c)
Sort of like the ANSI c function atoi(). |
static int |
atoi(String s)
Like the ANSI c function atoi(). |
Str |
before(int index)
Get all of the substring that occurs before a particular character. |
static String |
before(String s,
int index)
Get all of the substring that occurs before a particular character. |
void |
center(int newLen)
Try to center the text in a pad of spaces. |
static String |
center(String s,
int newLen)
Try to center the text in a pad of spaces. |
char |
charAt(int Index)
Used for compatibility with String and StringBuffer. |
int |
charCount(char c)
Count how many times a particular character occurs within your string. |
static String |
CharToHex(char c)
Method CharToHex converts a character to a hexidecimal String that represents the characters ASCII integer representation. |
static int |
CharToInt(char c)
Method CharToInt returns the decimal representation of the character given. |
static char |
Chr(int i)
Method Chr returns the ASCII character with is the binary equivelant to the integer given. |
static String |
commaStr(double val)
Converts a double to a string with commas inserted for thousands, millions, etc. |
int |
compareTo(Str s)
A string comparison method that returns a numeric result. |
int |
compareTo(String s)
A string comparison method that returns a numeric result. |
int |
countDigits()
Counts the number of digits in this. |
int |
countRange(char low,
char high)
Determines the number of digits that occur within the given range within this. |
void |
delete(int index,
int howMany)
Remove characters from your string. |
void |
deleteFirst()
Remove first character from the beginning of your string. |
void |
deleteFirst(int howMany)
Remove characters from the beginning of your string. |
void |
deleteLast()
Remove the last character from the end of your string. |
void |
deleteLast(int howMany)
Remove characters from the end of your string. |
boolean |
endsWith(String s)
Does the string object end with this bit of text. |
boolean |
eq(Str s)
Test for equality between your string and the string in s. |
boolean |
eq(String s)
Test for equality between your string and the string in s. |
static boolean |
equal(String[] s1,
String[] s2)
Uses String.equals(), but will consider that either or both arrays/strings might be null. |
static boolean |
equal(String s1,
String s2)
Uses String.equals(), but will consider that either or both strings might be null. |
boolean |
equals(Object obj)
Compares equality with the object given |
Str |
extractWord()
Extract and return the first word. |
int |
firstDigit()
Returns the index of the first digit, or returns -1 if there are no digits. |
void |
forceNumeric()
Force string to be the first number found. |
static String |
formatDouble(double d,
int decimalPlaces)
Converts a double to a string with a specified number of decimal places. |
Str |
from(int index)
Get all of the substring that occurs from a particular character to the end of the string. |
static String |
from(String s,
int index)
Get all of the substring that occurs from a particular character to the end of the string. |
boolean |
ge(Str s)
Test for "greater than or equal to" between your string and the string in s. |
boolean |
ge(String s)
Test for "greater than or equal to" between your string and the string in s. |
char |
get(int Index)
Retrieve a copy of one character. |
Str |
get(int index,
int length)
Retrieve a copy of a substring. |
int |
getCapacity()
Get the number of characters this object can hold without doing a reallocation. |
static char |
getChar(String s,
int index)
Just like String.charAt() except for null strings or for strings that are too short, an exception will not be thrown and instead, a null char will be returned. |
String |
getCr()
Returns the current carriage return value. |
int |
getDefaultWrapPoint()
Returns the default wrap point property |
char |
getLast()
Retrieve a copy of the last character. |
boolean |
gt(Str s)
Test for "greater than" between your string and the string in s. |
boolean |
gt(String s)
Test for "greater than" between your string and the string in s. |
int |
hashCode()
Return this as a hashcode |
static char |
HexToChar(String hex)
Method HexToChar converts a 2-byte hexidecimal String to the ASCII character that it represents. |
static int |
HexToInt(String hex)
Method HexToInt converts an hexidecimal String to a integer. |
String |
HexToString()
Method HexToString non-static version of HexToString |
String |
HexToString(boolean pad)
Method HexToString non-static version of HexToSring. |
static String |
HexToString(String hex)
Method HexToString converts a Hexidecimal string to an ASCII string. |
static String |
HexToString(String hex,
boolean pad)
Method HexToString converts a Hexidecimal string to an ASCII string. |
String |
indent(int indentAmount,
char indentChar)
Indents a string s using character indentChar by int len |
static String |
indent(String s,
int indentAmount,
char indentChar)
Indents a string s using character indentChar by int len |
int |
indexOf(char c)
Find the position within your string of a particular character. |
int |
indexOf(char c,
int startPos)
Find the position within your string of a particular character. |
int |
indexOf(String s)
Find the position within your string of a particular sequence of characters. |
int |
indexOf(String s,
int startPos)
Find the position within your string of a particular sequence of characters. |
int |
indexOfIgnoreCase(char c)
Find the position within your string of a particular character, ignoring case. |
int |
indexOfIgnoreCase(char c,
int startPos)
Find the position within your string of a particular character, ignoring case. |
int |
indexOfIgnoreCase(String s)
Find the position within your string of a particular sequence of characters, ignoring case. |
int |
indexOfIgnoreCase(String s,
int startPos)
Find the position within your string of a particular sequence of characters, ignoring the case. |
void |
insert(char c,
int index)
Insert a character immediately before a particular character. |
void |
insert(String s,
int index)
Insert a String object immediately before a particular character. |
void |
insert(Str s,
int index)
Insert a Str object immediately before a particular character. |
static char |
IntToChar(int i)
Method IntToChar returns the ASCII character with is the binary equivelant to the integer given. |
static String |
IntToHex(int i)
Method IntToHex converts an integer to a hexidecimal String. |
boolean |
isLower(int index)
Is char at index lower case? |
boolean |
isUpper(int index)
Is char at index upper case? |
static String |
labelString(String s,
char labelChar,
int wrapWidth,
boolean encase)
Generates a centered 1 or 3 line label for text outputs. |
int |
lastIndexOf(char c)
Returns the last index of this where the given char is found starting from the end of the String. |
boolean |
le(Str s)
Test for "less than or equal to" between your string and the string in s. |
boolean |
le(String s)
Test for "less than or equal to" between your string and the string in s. |
void |
left(int newLen)
Force the length of the string and keep text to the left. |
static String |
left(String s,
int newLen)
Force the length of the string and keep text to the left. |
int |
leftSpaceCount()
Report how many leading spaces there are. |
int |
length()
Get the current length of your string - not the same as the amount of memory allocated. |
String |
lpad(int l,
char c)
Left pads this Str with Char c out to length Int l. |
static String |
lpad(String s,
int len,
char c)
Left pads String s with Char c out to length Int len. |
boolean |
lt(Str s)
Test for "less than" between your string and the string in s. |
boolean |
lt(String s)
Test for "less than" between your string and the string in s. |
static String |
moneyStr(double d)
Converts a double to a string with two decimal places. |
boolean |
ne(Str s)
Test for "not equal" between your string and the string in s. |
boolean |
ne(String s)
Test for "not equal" between your string and the string in s. |
static String |
normalize(Object s)
Return a string that is not null. |
static String |
nowStr()
Get the current local date and time. |
static String |
pad(char c,
int l)
Creates a string of characters to a given length for use in padding. |
String |
pad(int l)
Returns a padded string with a length of int len comprised of char c. |
char |
pop()
If you wish to treat your string like a stack, you can push and pop characters. |
void |
push(char c)
If you wish to treat your string like a stack, you can push and pop characters. |
void |
removeDoubleSpaces()
Eliminate all occurances of two more space in a row. |
void |
replace(char c1,
char c2)
Replace all instances of one character with another character. |
void |
replace(char c,
String s)
Replace all instances of one character with a String object. |
void |
replace(String s,
char c)
Search for a particular character sequence and replace it with one character. |
void |
replace(String s1,
String s2)
Search for a particular character sequence and replace it with a different character sequence. |
void |
reverse()
Reverse the order of all the characters. |
void |
right(int newLen)
Force the length of the string and keep text to the right. |
static String |
right(String s,
int newLen)
Force the length of the string and keep text to the right. |
int |
rightSpaceCount()
Report how many trailing spaces there are. |
String |
rpad(int l,
char c)
Right pads current Str with Char c out to length Int len. |
static String |
rpad(String s,
int len,
char c)
Right pads String s with Char c out to length Int len. |
void |
set(int index,
char c)
Set one character in the string. |
void |
set(Str s)
Force the contents of this object to be the same as another Str object. |
void |
set(String s)
Force the contents of this object to be the same as a String object. |
void |
setCapacity(int howMuch)
Force this object to be able to hold a specific number of characters without reallocation. |
void |
setCharAt(int index,
char c)
Provided for compatibility with StringBuffer. |
void |
setCr(String c)
Sets the carriage return property to the given String value. |
void |
setDefaultWrapPoint(int n)
Sets the default wrap point property |
void |
setExtra(int howMuch)
Set how much extra to grow when growth is needed. |
void |
setLength(int newLen)
Force the length of your string. |
void |
setSpacer(char c)
Set the spacer character property |
String |
spacer()
Establishes and converts the spacing character to a string. |
static String |
spacer(char c)
Returns the a char spacer as a String |
static Str |
spaces(int quan)
Create a Str object containing nothing but a quantity of spaces. |
boolean |
startsWith(String s)
Test to see if your string begins with a specific sequence of characters. |
static Str |
stringOf(int quan,
char c)
Create a Str object containing nothing but a quantity of one character. |
String |
StringToHex()
Method StringToHex the non-static version of StringToHex() |
String |
StringToHex(boolean pad)
Method StringToHex non-static version of StringToHex |
static String |
StringToHex(String s)
Method StringToHex converts a String object to a Hexidecimal version of the String object. |
static String |
StringToHex(String s,
boolean pad)
Method StringToHex converts a String object to a Hexidecimal version of the String object. |
Str |
substring(int index,
int length)
Provided for compatibility with String and StringBuffer and the case mixing Sun provides. |
Str |
subString(int index,
int length)
Provided for compatibility with String and StringBuffer and the case mixing many people expect. |
static String |
substring(String s,
int index,
int length)
Same as substring but uses mixed case nomenclature. |
static String |
subString(String s,
int index,
int length)
An improved String substring method that returns a portion of the given String. |
Str |
through(int index)
Get all of the substring that occurs through a particular character. |
static String |
through(String s,
int index)
Get all of the substring that occurs through a particular character. |
static boolean |
toBoolean(String s)
Try to convert a string to a boolean value. |
char[] |
toCharArray()
Generate a character array that contains a copy of the string. |
double |
toDouble()
Try to convert this string to a double value. |
static double |
toDouble(String s)
Try to convert a string to a double value. |
int |
toInt()
Try to convert this string to an integer value. |
static int |
toInt(String s)
Try to convert a string to an integer value. |
static int[] |
toIntArray(String[] values)
The inverse of toStringArray, builds a array of integers from an array of Strings. |
long |
toLong()
Try to convert this string to a long value. |
static long |
toLong(String s)
Try to convert a string to a long value. |
void |
toLower()
All characters are forced to lower case. |
void |
toLower(int index)
Char at index is forced to lower case. |
String |
toString()
Convert this Str object to a String object. |
static String[] |
toStringArray(int[] values)
Converts a series of integers to a series of corresponding Strings. |
static Timestamp |
toTimestamp(String s)
Try to convert a string to a Timestamp object. |
void |
toUpper()
All characters are forced to upper case. |
void |
toUpper(int index)
Char at index is forced to upper case. |
Vector |
toVector(char delimiter)
Method toVector converts a delimited representation into a vector of separate values. |
static Vector |
toVector(String s)
Convenience method variant of toVector that converts a comma delimited String into a vector of separate values. |
static Vector |
toVector(String s,
char delimiter)
Method toVector converts a delimited String into a vector of separate values. |
int |
trailingDigits()
Count the number of trailing digits. |
static int |
trailingDigits(String s)
Count the number of trailing digits in the given String. |
void |
trim()
Trims all leading spaces and all trailing spaces. |
static String |
trim(String s)
Return a string that is either null or has at least one character. |
void |
trimLead()
Trims all leading spaces, no trailing spaces. |
void |
trimLeadWhitespace()
Trims all leading spaces, newlines, returns and tabs. |
void |
trimTrail()
Trims all trailing spaces, no leading spaces. |
void |
trimTrailTo(char c)
Trims all characters from end of the string until a particular character is encountered. |
void |
trimTrailWhitespace()
Trims all trailing spaces, newlines, returns and tabs. |
void |
trimWhitespace()
Trims all leading spaces, newlines, returns and tabs and all trailing spaces, newlines, returns and tabs. |
static String |
trimWhitespace(String s)
Removes all whitespace from the given String. |
static boolean |
usable(String s)
Determines if the given String is useable. |
static Str |
verboseMoney(double x)
Convert a double to English ( 12.01 -> "twelve and 01/100" ). |
String |
wrap()
Wraps String s at position 80 using line terminator ascii 13 + ascii 11. |
String |
wrap(int l)
Wraps String s at break position int len using line terminator ascii 13 + ascii 11. |
String |
wrap(int l,
String c)
Wraps String s at wrap position int len using line terminator String cr. |
String |
wrap(int l,
String c,
int indentAmount,
char indentChar)
Wraps String s at position int len using line terminator String cr with indent character indentChar indented to indentAmount. |
static String |
wrap(String s)
Wraps String s at position 80 using line terminator ascii 13 + ascii 11. |
static String |
wrap(String s,
int len)
Wraps String s at break position int len using line terminator ascii 13 + ascii 11. |
static String |
wrap(String s,
int l,
String c)
Wraps String s at wrap position int len using line terminator String cr. |
static String |
wrap(String s,
int l,
String c,
int indentAmount,
char indentChar)
Wraps String s at position int len using line terminator String cr with indent character indentChar indented to indentAmount. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Str(int initialSize)
initialSize
- How many characters the object can initially hold.public Str(int initialSize, int initialExtra)
initialSize
- How many characters the object can initially hold. initialExtra
- How many characters the object will grow by when more memory is needed. public Str()
public Str(char[] c)
c
- the character array to copy. public Str(Str s)
Enough memory is allocated for some growth.
s
- The Str object to copy. public Str(String s)
s
- The String object to copy. Method Detail |
---|
public void set(Str s)
s
- The Str object to copy. public void set(String s)
s
- The String object to copy. public int length()
Works just like the length() methods in String and StringBuffer.
public void setLength(int newLen)
If you want to empty your string, use setLength(0);
If you specify a number that is longer than the current string length, the new characters will be null characters.
newLen
- what you want the new length of your string to be. public int compareTo(Str s)
A lot like the ANSI strcmp() function.
s
- The Str object to compare to.
public int compareTo(String s)
A lot like the ANSI strcmp() function.
s
- the String object to compare to.
public boolean eq(Str s)
This method is case sensitive.
s
- The Str object to compare to.
public boolean eq(String s)
This method is case sensitive.
s
- The String object to compare to.
public boolean ne(Str s)
This method is case sensitive.
s
- The Str object to compare to.
public boolean ne(String s)
This method is case sensitive.
s
- The String object to compare to.
public boolean lt(Str s)
This method is case sensitive.
s
- The Str object to compare to.
public boolean lt(String s)
This method is case sensitive.
s
- The String object to compare to.
public boolean le(Str s)
This method is case sensitive.
s
- The Str object to compare to.
public boolean le(String s)
This method is case sensitive.
s
- The String object to compare to.
public boolean ge(Str s)
This method is case sensitive.
s
- The Str object to compare to.
public boolean ge(String s)
This method is case sensitive.
s
- The String object to compare to.
public boolean gt(Str s)
This method is case sensitive.
s
- The Str object to compare to.
public boolean gt(String s)
This method is case sensitive.
s
- The String object to compare to.
public void setExtra(int howMuch)
Smaller values will usually save memory, but frequent reallocation may take a lot of time.
howMuch
- The number of extra characters to allocate when memory reallocation is required. Values must be greater than zero. public int getCapacity()
public void setCapacity(int howMuch)
Any attempt to make the string grow bigger than this size will succeed.
Setting the capacity to be smaller than the current string size will result in trailing characters being clipped.
howMuch
- How many characters will be the new capacity. public char get(int Index)
Index
- Which character (0 is the first character).
public char getLast()
public char charAt(int Index)
see get().
Index
- position within
public Str get(int index, int length)
index
- The character of the substring. length
- The length of the substring. Specifying a substring beyond the end of the string will return as much of the string as possible.
public Str subString(int index, int length)
index
- starting index pointlength
- length of string to return
public Str substring(int index, int length)
index
- starting index pointlength
- length of string to return
public Str before(int index)
index
- The character that marks the end of the substring. This character is not included in the substring.
public Str through(int index)
index
- The character that marks the end of the substring. This character is included in the substring.
public Str after(int index)
index
- The character that marks the beginning of the substring. This character is not included in the substring.
public Str from(int index)
index
- The character that marks the beginning of the substring. This character is included in the substring.
public char[] toCharArray()
public void set(int index, char c)
index
- Which character to set. If index references a character beyond the last character of the string, the string will be lengthened and the last character will be set appropriately (undefined characters will be set to a null character). c
- The character to be placed at index. public void setCharAt(int index, char c)
index
- index of the position to usec
- a character to set at the given index positionpublic void append(char c)
c
- The character to append to the end of the string. public void append(Str s)
s
- The Str object to be appended. public void append(String s)
s
- The String object to be appended. public void insert(char c, int index)
c
- The character to be inserted. index
- Where to insert c. The character currently at index will me moved to the right. public void insert(Str s, int index)
s
- The Str object to be inserted. index
- Where to insert s. The character currently at index will me moved to the right. public void insert(String s, int index)
s
- The String object to be inserted. index
- Where to insert s. The character currently at index will me moved to the right. public void delete(int index, int howMany)
index
- Referencing the first character to be removed. howMany
- The number of characters to remove. public void deleteFirst(int howMany)
howMany
- The number of characters to remove. public void deleteFirst()
public void deleteLast(int howMany)
howMany
- The number of characters to remove. public void deleteLast()
public void push(char c)
c
- The character that will be appended to the end of your string. public char pop()
Remember the old assembly programming pearl: May all your pushes be popped.
public boolean startsWith(String s)
This test is much faster than the equivalent in the regular expression library. And is also much faster than doing a substring comparison.
This test is case sensitive.
s
- A String object representing the first few characters being tested for.
public int indexOf(char c, int startPos)
This method is case sensitive.
c
- The character to search for. startPos
- The character position in your string to start looking for c.
public int indexOfIgnoreCase(char c, int startPos)
This method is not case sensitive.
c
- The character to search for. startPos
- The character position in your string to start looking for c.
public int indexOf(String s, int startPos)
This method is case sensitive.
s
- A String object representing the character sequence to search for. startPos
- The character position in your string to start looking for s.
public int indexOfIgnoreCase(String s, int startPos)
This method is not case sensitive.
s
- A String object representing the character sequence to search for. startPos
- The character position in your string to start looking for s.
public int indexOf(char c)
This method is case sensitive. Searching begins with the first character in your string.
c
- The character to search for.
public int indexOf(String s)
This method is case sensitive. Searching begins with the first character in your string.
s
- A String object representing the character sequence to search for.
public int indexOfIgnoreCase(char c)
This method is not case sensitive. Searching begins with the first character in your string.
c
- The character to search for.
public int indexOfIgnoreCase(String s)
This method is not case sensitive. Searching begins with the first character in your string.
s
- A String object representing the character sequence to search for.
public int lastIndexOf(char c)
Example (assume this is "abc"):
lastIndexOf('c') == 2
c
- a character
public boolean endsWith(String s)
s
- the suffix you are looking for.
public int firstDigit()
public void replace(char c1, char c2)
All occurances are replaced.
Searching for the "next instance" of character will begin immediately after the last replacement so that there is no chance of an infinite loop.
c1
- The character to search for. c2
- The character that is to replace c1. public void replace(char c, String s)
All occurances are replaced.
Searching for the "next instance" of character will begin immediately after the last replacement so that there is no chance of an infinite loop.
c
- The character to search for. s
- The String object that is to replace c. public void replace(String s, char c)
All occurances are replaced.
Searching for the "next instance" of a character sequence will begin immediately after the last replacement so that there is no chance of an infinite loop.
s
- A String object representing a character sequence to search for. c
- The character that is to replace s. public void replace(String s1, String s2)
All occurances are replaced.
Searching for the "next instance" of a character sequence will begin immediately after the last replacement so that there is no chance of an infinite loop.
s1
- A String object representing a character sequence to search for. s2
- A String object representing a character sequence that is to replace s1. public void removeDoubleSpaces()
When this method is done, there will not be an occurance of two spaces in a row. Anywhere that there was two or more spaces, there is now only one space.
public int charCount(char c)
As dumb as this sounds, the method does end up getting used a lot.
c
- The character to look for.
public void trimLead()
public void trimTrail()
public void trim()
public void trimLeadWhitespace()
public void trimTrailWhitespace()
public void trimWhitespace()
public void trimTrailTo(char c)
The character being searched for is also trimmed.
c
- The character to search for. public Str extractWord()
Space delimited (all double spaces are removed).
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
obj
- object to compare to
public String toString()
toString
in class Object
public void forceNumeric()
Everything that is not a number, period or hyphen is converted to a space. The resulting string is the first word extracted.
public int toInt()
public long toLong()
public double toDouble()
public int leftSpaceCount()
public int rightSpaceCount()
public void left(int newLen)
If the new length is longer, spaces will be added to the right.
If the new length is shorter, characters are chopped off from the right.
Useful for formatting text to be left justified.
newLen
- The desired new length. public void right(int newLen)
If the new length is longer, spaces will be added to the left.
If the new length is shorter, characters are chopped off from the right (not the left).
Useful for formatting text to be right justified.
newLen
- The desired new length. public void center(int newLen)
First, all leading and trailing spaces are removed.
If the new length is longer, spaces will be added to the left and right.
If the new length is shorter, the string is unchanged. In this case, the resulting string is longer than the new length!
Useful for formatting text to be centered.
newLen
- The desired new length. public void toUpper()
public void toUpper(int index)
index
- position within this to change to upper casepublic Vector toVector(char delimiter)
delimiter
- the delimiting character to use
public static Vector toVector(String s)
s
- a String
public static Vector toVector(String s, char delimiter)
s
- a Stringdelimiter
- the delimiting character to use
public boolean isUpper(int index)
index
- position within this to test
public void toLower()
public void toLower(int index)
index
- position within this to force to lowercasepublic boolean isLower(int index)
index
- position within this to test
public int trailingDigits()
Only values '0' through '9' are considered.
public int countRange(char low, char high)
low
- this char is included in the rangehigh
- this char is included in the range
public int countDigits()
public void reverse()
Designed to behave the same way as StringBuffer.reverse().
public static String moneyStr(double d)
Examples: In Out 0.0 "0.00" 1.9999 "2.00" 222.2222 "222.22"
d
- The double value.
public static String formatDouble(double d, int decimalPlaces)
d
- The double value. decimalPlaces
- The number of decimal places needed.
public static String commaStr(double val)
Fractional values are ignored.
val
- The double value.
public static int atoi(String s)
s
- The string that begins with a number.
public static int atoi(char c)
Instead of passing in a string, pass in a character.
c
- The char containing a single digit.
public static double atod(String s)
s
- The string that begins with a number.
public static Str verboseMoney(double x)
Examples: In Out 0.0 "zero and 00/100" 23.23 "twenty-three and 23/100" 12345678.90 "twelve million three hundred forty-five thousand six hundred seventy-eight and 90/100"
x
- The double to convert.
public static String nowStr()
EDate
.
EDate
public static Str stringOf(int quan, char c)
Example: calling stringOf( 20 , '-' ) returns a string of 20 hyphens.
quan
- The desired string length. c
- The desired character.
public static Str spaces(int quan)
quan
- The number of spaces desired.
public static String substring(String s, int index, int length)
s
- A String object that you want to extract a sub-string from. index
- Where the sub-string begins. length
- How long you want your sub-string to be.
public static String subString(String s, int index, int length)
Performs the same basic function as the String variant but is more robust and less likely to throw exceptions.
s
- A String object that you want to extract a sub-string from. index
- Where the sub-string begins. length
- How long you want your sub-string to be.
public static String before(String s, int index)
s
- The String object to extract the substring from. index
- The character that marks the end of the substring. This character is not included in the substring.
public static String through(String s, int index)
s
- The String object to extract the substring from. index
- The character that marks the end of the substring. This character is included in the substring.
public static String after(String s, int index)
s
- The String object to extract the substring from. index
- The character that marks the beginning of the substring. This character is not included in the substring.
public static String from(String s, int index)
s
- The String object to extract the substring from. index
- The character that marks the beginning of the substring. This character is included in the substring.
public static String left(String s, int newLen)
If the new length is longer, spaces will be added to the right.
If the new length is shorter, characters are chopped off from the right.
Useful for formatting text to be left justified.
s
- The String object to process. newLen
- The desired new length.
public static String right(String s, int newLen)
If the new length is longer, spaces will be added to the left.
If the new length is shorter, characters are chopped off from the right (not the left).
Useful for formatting text to be right justified.
s
- The String object to process. newLen
- The desired new length.
public static String center(String s, int newLen)
First, all leading and trailing spaces are removed.
If the new length is longer, spaces will be added to the left and right.
If the new length is shorter, the string is unchanged. In this case, the resulting string is longer than the new length!
Useful for formatting text to be centered.
s
- The String object to process. newLen
- The desired new length.
public static String trimWhitespace(String s)
s
- a String
public static int trailingDigits(String s)
Only values '0' through '9' are considered.
s
- a String
public static boolean usable(String s)
s
- a String
public static int toInt(String s)
s
- a String
public static long toLong(String s)
s
- a String
public static double toDouble(String s)
s
- a String
public static Timestamp toTimestamp(String s)
s
- a String
public static boolean toBoolean(String s)
s
- a String
public static String trim(String s)
s
- a String
usable(String)
public static String normalize(Object s)
s
- an Object
public static boolean equal(String s1, String s2)
s1
- a Strings2
- a String
public static boolean equal(String[] s1, String[] s2)
s1
- a Strings2
- a String
public static String[] toStringArray(int[] values)
values
- array of integers
public static int[] toIntArray(String[] values)
values
- array of Strings
public static char getChar(String s, int index)
s
- String to searchindex
- character position
public static String StringToHex(String s) throws IllegalArgumentException
s
- the String object to convert
IllegalArgumentException
- thrown if the String contains Control charactersHexToString(String)
,
HexToString(String,boolean)
public String StringToHex() throws IllegalArgumentException
IllegalArgumentException
public static String StringToHex(String s, boolean pad)
HexToString(String, boolean)
version with pad equal to true as well. For the narrow version, the
short form of HexToString(String)
will also work.
s
- the String object to convertpad
- a boolean parameter to indicate if the Hexidecimal String returned
should separate the Hexidecimal values for each character byte with a space
HexToString(String,boolean)
public String StringToHex(boolean pad)
pad
- true or false whether the result should be padded or not
public static String HexToString(String hex)
StringToHex
. There
are two versions of this method, one uses narrow notation and the other
may use either wide or narrow notation. Narrow notation is 2-digit hexidecimal
strings of even byte length represented as "4d7920537472696e67". Wide notation
is represented as "4d 79 20 53 74 72 69 6e 67".
hex
- the Hexidecimal String to convert to an ASCII String object
StringToHex(String)
,
StringToHex(String,boolean)
public String HexToString()
public static String HexToString(String hex, boolean pad)
StringToHex
. There
are two versions of this method, one uses narrow notation and the other
may use either wide or narrow notation. Narrow notation is 2-digit hexidecimal
strings of even byte length represented as "4d7920537472696e67". Wide notation
is represented as "4d 79 20 53 74 72 69 6e 67".
hex
- the Hexidecimal String to convert to an ASCII String objectpad
- indicates that the Hexidecimal String is padded (true) or in not padded
(false) meaning that it does or does not have a space between the Hex byte values.
StringToHex(String)
,
StringToHex(String,boolean)
public String HexToString(boolean pad)
pad
- true if the resulting hex should be padded
public static char Chr(int i) throws NumberFormatException
Ascii
method.
i
- the integer value of the character
NumberFormatException
- thrown if the integer i is less than 32 or greater than 255Ascii(char)
,
CharToInt(char)
,
IntToChar(int)
public static char IntToChar(int i)
Ascii
and CharToInt(char)
method. It is
equivilent to the Chr(int)
method.
i
- the integer value of the character
Ascii(char)
,
Chr(int)
,
CharToInt(char)
public static int Ascii(char c) throws IllegalArgumentException
Chr
method.
c
- the character to convert
IllegalArgumentException
- thrown if the character is a non-printable ISO Control characterChr(int)
,
IntToChar(int)
,
CharToInt(char)
public static int CharToInt(char c)
Chr
method or
IntToChar(int)
method. It is also the equivelant of the Ascii(char)
method.
c
- the character to convert
Chr(int)
,
IntToChar(int)
,
Ascii(char)
public static String CharToHex(char c) throws IllegalArgumentException
Ascii
method in that the character is converted to it's ASCII representative number. The difference
being that Ascii returns the value as an integer whereas CharToHex returns the value
as a hexidecimal number.
c
- the character to convert
IllegalArgumentException
- thrown when the character given is a non-printable ISO Control characterHexToChar(String)
public static char HexToChar(String hex) throws IllegalArgumentException
hex
- the 2-byte hexidecimal String to convert
IllegalArgumentException
- thrown if the string is longer than 2-bytes or contains non-hexidecimal characters
NumberFormatException
- thrown when the string contains the equivelant of ISO Control charactersCharToHex(char)
public static int HexToInt(String hex)
hex
- the hexidecimal String to convert
IntToHex(int)
public static String IntToHex(int i)
i
- the integer to convert
HexToInt(String)
public String spacer()
public void setSpacer(char c)
c
- character to set the spacer topublic void setCr(String c)
c
- a String to use as the carriage return.public String getCr()
public static String spacer(char c)
c
- char for spacing
public String pad(int l)
l
- The requested length of the resulting string.
lpad(int, char)
,
rpad(int, char)
public static String pad(char c, int l)
c
- a characterl
- length of the pad to create
rpad(int,char)
,
rpad(String,int,char)
,
lpad(int,char)
,
lpad(String,int,char)
public String rpad(int l, char c)
l
- The length you want the final string to be.c
- The character to use for padding String s.
pad(int)
public static String rpad(String s, int len, char c)
s
- String you wish to pad.len
- The length you want the final string to be.c
- The character to use for padding String s.
pad(int)
public String lpad(int l, char c)
l
- The length you want the final string to be expressed as total character length.c
- The character to use for padding String s.
pad(int)
public int getDefaultWrapPoint()
public void setDefaultWrapPoint(int n)
n
- wrap point positionpublic static String lpad(String s, int len, char c)
s
- String you wish to pad.len
- The length you want the final string to be expressed as total character length.c
- The character to use for padding String s.
pad(int)
public String wrap()
Examples:
wrap("1234567890...100") = "1234567890...80[\\r\\n]81...100"
public static String wrap(String s)
Examples:
wrap("1234567890...100") = "1234567890...80[\\r\\n]81...100"
s
- String you wish to wrap.
public String wrap(int l)
l
- The position to wrap the line at (default 80).
public static String wrap(String s, int len)
s
- String you wish to wrap.len
- The position to wrap the line at (default 80).
public String wrap(int l, String c)
l
- The position to break at (default 80).c
- The terminating string to use (default ascii 13 + ascii 11 - cr + lf).
public static String wrap(String s, int l, String c)
s
- String you wish to wrap.l
- The position to break at (default 80).c
- The terminating string to use (default ascii 13 + ascii 11 - cr + lf).
public String wrap(int l, String c, int indentAmount, char indentChar)
l
- The position to wrap at (default 80).c
- The terminating string to use (default ascii 13 + ascii 11 - cr + lf).indentAmount
- The amount to indent the returned stringindentChar
- The character to use for indentation
public static String wrap(String s, int l, String c, int indentAmount, char indentChar)
s
- String you wish to wrap.l
- The position to wrap at (default 80).c
- The terminating string to use (default ascii 13 + ascii 11 - cr + lf).indentAmount
- The amount to indent the returned stringindentChar
- The character to use for indentation
public String indent(int indentAmount, char indentChar)
indentAmount
- TThe amount to indent the returned string.indentChar
- The character to use for indentation
public static String indent(String s, int indentAmount, char indentChar)
s
- String you wish to indent.indentAmount
- TThe amount to indent the returned string.indentChar
- The character to use for indentation
public static String labelString(String s, char labelChar, int wrapWidth, boolean encase)
s
- String to turn into a labellabelChar
- the character to use for the label graphicwrapWidth
- the range at which the label is centeredencase
- optional flag to determine if the result is enclosed with label charaters on pre and post lines.
|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |