Package gnu.dtools.ritopt
Class Utility
java.lang.Object
gnu.dtools.ritopt.Utility
This class provides static utility members for some basic string operations.
Copyright (C) Damian Ryan Eads, 2001. All Rights Reserved. ritopt is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ritopt is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ritopt; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns true if any of the characters in the list are equal to the check character.static booleanReturns true if any of the characters in the list appear in the check string passed.static intReturns the number of occurances the character specification appears in the check string passed.static StringexpandString(String s, int length) Returns a string with no more and no less than n characters where n is the length.static StringgetSpaces(int count) Returns a string containing the number of spaces passed as an argument.static booleanisAlpha(char check) Returns true if the character is a letter in the phonetic alphabetic.static booleanReturns true if the string only contains letters in the phonetic alphabet.static booleanisAlphaLower(char check) Returns true if the character is a lower case letter in the phonetic alphabetic.static booleanisAlphaLower(String check) Returns true if the string only contains lower case letters in the phonetic alphabet.static booleanisAlphaNumeric(char check) Returns true if the character is a letter in the phonetic alphabetic or is a decimal number.static booleanisAlphaUpper(char check) Returns true if the character is a upper case letter in the phonetic alphabetic.static booleanisAlphaUpper(String check) Returns true if the string only contains upper case letters in the phonetic alphabet.static booleanisNumeric(char check) Returns true if the character is a decimal number.static StringTrim spaces off the left side of this string.static Stringrepeat(char c, int count) Returns a string with a character repeated based on a count passed.static StringReturns a string with the passed string repeated based on the integer count passed.static StringTrim spaces off the right side of this string.static StringstripComments(String s, char delim, char comment) Takes a line (presumably from a file) and removes a comment if one exists.static StringTrim spaces off both sides of this string.
-
Constructor Details
-
Utility
public Utility()
-
-
Method Details
-
contains
Returns true if any of the characters in the list appear in the check string passed.- Parameters:
check- The string to check.list- The list of valid characters.- Returns:
- true if the criteria of this method is satisfied.
-
count
Returns the number of occurances the character specification appears in the check string passed.- Parameters:
check- The string to check.spec- The character specification.- Returns:
- the number of occurances of the character specification.
-
contains
Returns true if any of the characters in the list are equal to the check character.- Parameters:
check- The character to check.list- The list of valid characters.- Returns:
- true if any of the characters in the list equal the check character.
-
isAlpha
Returns true if the string only contains letters in the phonetic alphabet.- Parameters:
check- The string to check.- Returns:
- If this method's criteria is matched.
-
isAlphaLower
Returns true if the string only contains lower case letters in the phonetic alphabet.- Parameters:
check- The string to check.- Returns:
- If this method's criteria is matched.
-
isAlphaUpper
Returns true if the string only contains upper case letters in the phonetic alphabet.- Parameters:
check- The string to check.- Returns:
- If this method's criteria is matched.
-
isAlpha
public static boolean isAlpha(char check) Returns true if the character is a letter in the phonetic alphabetic.- Parameters:
check- The character to check.- Returns:
- true if this method's criteria is matched.
-
isAlphaLower
public static boolean isAlphaLower(char check) Returns true if the character is a lower case letter in the phonetic alphabetic.- Parameters:
check- The character to check.- Returns:
- true if this method's criteria is matched.
-
isAlphaUpper
public static boolean isAlphaUpper(char check) Returns true if the character is a upper case letter in the phonetic alphabetic.- Parameters:
check- The character to check.- Returns:
- true if this method's criteria is matched.
-
isAlphaNumeric
public static boolean isAlphaNumeric(char check) Returns true if the character is a letter in the phonetic alphabetic or is a decimal number.- Parameters:
check- The character to check.- Returns:
- true if this method's criteria is matched.
-
isNumeric
public static boolean isNumeric(char check) Returns true if the character is a decimal number.- Parameters:
check- The character to check.- Returns:
- true if this method's criteria is matched.
-
expandString
Returns a string with no more and no less than n characters where n is the length. If the string passed is less than this length, an appropriate number of spaces is concatenated. If the string is longer than the length passed, a substring of the length passed is returned.- Parameters:
s- The string to expand.length- The required length.- Returns:
- The expanded string.
-
getSpaces
Returns a string containing the number of spaces passed as an argument.- Parameters:
count- The number of spaces in the string returned.- Returns:
- a string containing the number of spaces passed.
-
repeat
Returns a string with a character repeated based on a count passed.- Parameters:
c- The character to repeat.count- The number of times to repeat the character.
-
ltrim
Trim spaces off the left side of this string.- Parameters:
s- The string to trim.- Returns:
- The trimmed string.
-
rtrim
Trim spaces off the right side of this string.- Parameters:
s- The string to trim.- Returns:
- The trimmed string.
-
trim
Trim spaces off both sides of this string.- Parameters:
s- The string to trim.- Returns:
- The trimmed string.
-
stripComments
Takes a line (presumably from a file) and removes a comment if one exists. If the comment character is enclosed within a literal string defined by the delimiter passed, then the character is ignored.- Parameters:
s- The string to strip comments off.delim- The string delimiter.comment- The comment character.- Returns:
- A string stripped of comments.
-
repeat
Returns a string with the passed string repeated based on the integer count passed.- Parameters:
s- The string to repeat.count- The number of times to repeat the string.- Returns:
- The repeated string.
-