ritopt API Documentation
by Damian Eads

gnu.dtools.ritopt
Class Utility

java.lang.Object
  |
  +--gnu.dtools.ritopt.Utility

public class Utility
extends java.lang.Object

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
 

Author:
Damian Eads

Constructor Summary
Utility()
           
 
Method Summary
static boolean contains(char check, java.lang.String list)
          Returns true if any of the characters in the list are equal to the check character.
static boolean contains(java.lang.String check, java.lang.String list)
          Returns true if any of the characters in the list appear in the check string passed.
static int count(java.lang.String check, char spec)
          Returns the number of occurances the character specification appears in the check string passed.
static java.lang.String expandString(java.lang.String s, int length)
          Returns a string with no more and no less than n characters where n is the length.
static java.lang.String getSpaces(int count)
          Returns a string containing the number of spaces passed as an argument.
static boolean isAlpha(char check)
          Returns true if the character is a letter in the phonetic alphabetic.
static boolean isAlpha(java.lang.String check)
          Returns true if the string only contains letters in the phonetic alphabet.
static boolean isAlphaLower(char check)
          Returns true if the character is a lower case letter in the phonetic alphabetic.
static boolean isAlphaLower(java.lang.String check)
          Returns true if the string only contains lower case letters in the phonetic alphabet.
static boolean isAlphaNumeric(char check)
          Returns true if the character is a letter in the phonetic alphabetic or is a decimal number.
static boolean isAlphaUpper(char check)
          Returns true if the character is a upper case letter in the phonetic alphabetic.
static boolean isAlphaUpper(java.lang.String check)
          Returns true if the string only contains upper case letters in the phonetic alphabet.
static boolean isNumeric(char check)
          Returns true if the character is a decimal number.
static java.lang.String ltrim(java.lang.String s)
          Trim spaces off the left side of this string.
static java.lang.String repeat(char c, int count)
          Returns a string with a character repeated based on a count passed.
static java.lang.String repeat(java.lang.String s, int count)
          Returns a string with the passed string repeated based on the integer count passed.
static java.lang.String rtrim(java.lang.String s)
          Trim spaces off the right side of this string.
static java.lang.String stripComments(java.lang.String s, char delim, char comment)
          Takes a line (presumably from a file) and removes a comment if one exists.
static java.lang.String trim(java.lang.String s)
          Trim spaces off both sides of this string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utility

public Utility()
Method Detail

contains

public static boolean contains(java.lang.String check,
                               java.lang.String list)
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

public static int count(java.lang.String check,
                        char spec)
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

public static boolean contains(char check,
                               java.lang.String list)
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

public static boolean isAlpha(java.lang.String check)
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

public static boolean isAlphaLower(java.lang.String check)
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

public static boolean isAlphaUpper(java.lang.String check)
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

public static java.lang.String expandString(java.lang.String s,
                                            int length)
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

public static java.lang.String getSpaces(int count)
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

public static java.lang.String repeat(char c,
                                      int count)
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

public static java.lang.String ltrim(java.lang.String s)
Trim spaces off the left side of this string.
Parameters:
s - The string to trim.
Returns:
The trimmed string.

rtrim

public static java.lang.String rtrim(java.lang.String s)
Trim spaces off the right side of this string.
Parameters:
s - The string to trim.
Returns:
The trimmed string.

trim

public static java.lang.String trim(java.lang.String s)
Trim spaces off both sides of this string.
Parameters:
s - The string to trim.
Returns:
The trimmed string.

stripComments

public static java.lang.String stripComments(java.lang.String s,
                                             char delim,
                                             char comment)
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

public static java.lang.String repeat(java.lang.String s,
                                      int count)
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.

Copyright (C) Damian Ryan Eads, 2001. All Rights Reserved.
SourceForge Logo