Parsing Engine

danbikel.util
Class Text

java.lang.Object
  extended by danbikel.util.Text

public class Text
extends Object

A set of static utility functions that operate on String or StringBuffer objects.


Field Summary
static Character javadocHack
          Used so that external links to elements of the Character class will work.
 
Method Summary
static boolean expandVars(Properties props, StringBuffer sb)
          Expands the variables in the specified StringBuffer.
static boolean expandVars(StringBuffer sb)
          Expands the variables in the specified StringBuffer.
static int find(StringBuffer sb, String toFind)
          Finds the first occurrence of toFind in the characters contained in the string buffer sb.
static int find(StringBuffer sb, String toFind, int startIdx)
          Finds the first occurrence of toFind at or after startIdx in the characters of the string buffer sb.
static boolean isAllDigits(String s)
          Returns true if s is composed only of characters for which Character.isDigit(char) returns true; returns false otherwise.
static boolean isAllLettersOrDigits(String s)
          Returns true if s is composed only of characters for which Character.isLetterOrDigit(char) returns true; returns false otherwise.
static boolean isAllWhitespace(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

javadocHack

public static Character javadocHack
Used so that external links to elements of the Character class will work.

Method Detail

expandVars

public static final boolean expandVars(Properties props,
                                       StringBuffer sb)
Expands the variables in the specified StringBuffer. The syntax for a variable is ${var-name}. var-name can either be the name of a property in props, the name of a System property or /, which will expand to File.separator, allowing for platform-independent specification of paths. Variables cannot be nested, as this method simply looks for the first occurrence of ${ and the next occurence of }. This type of variable expansion is identical to the type allowed in Java security policy files, except that the specified Properties object is first consulted before that of the System object. If a variable does not exist as a property, then this method returns false and does not alter the StringBuffer object.

Parameters:
props - the Properties object, or null if only System properties are to be used for expansion
sb - the StringBuffer in which to attempt to expand variables
Returns:
true if successful, false if there were expansion problems

expandVars

public static final boolean expandVars(StringBuffer sb)
Expands the variables in the specified StringBuffer. The syntax for a variable is ${var-name}. var-name can either be the name of a System property, or /, which will expand to File.separator, allowing for platform-independent specification of paths. Variables cannot be nested, as this method simply looks for the first occurrence of ${ and the next occurence of }. This type of variable expansion is identical to the type allowed in Java security policy files. If a variable does not exist as a property, then this method returns false and does not alter the StringBuffer object. Calling this method is identical to calling
Text.expandVars(null, sb)

Parameters:
sb - the StringBuffer in which to attempt to expand variables
Returns:
true if successful, false if there were expansion problems

find

public static final int find(StringBuffer sb,
                             String toFind)
Finds the first occurrence of toFind in the characters contained in the string buffer sb.

Parameters:
sb - the string buffer to search
toFind - the string to search for
Returns:
the index of the first occurrence of toFind or -1 if toFind does not occur in sb

find

public static final int find(StringBuffer sb,
                             String toFind,
                             int startIdx)
Finds the first occurrence of toFind at or after startIdx in the characters of the string buffer sb.

Parameters:
sb - the string buffer to search
toFind - the string to search for
startIdx - the index in sb at which to start looking for toFind

isAllWhitespace

public static final boolean isAllWhitespace(String s)

isAllDigits

public static final boolean isAllDigits(String s)
Returns true if s is composed only of characters for which Character.isDigit(char) returns true; returns false otherwise.

Parameters:
s - the string to test
Returns:
true if s contains only digits

isAllLettersOrDigits

public static final boolean isAllLettersOrDigits(String s)
Returns true if s is composed only of characters for which Character.isLetterOrDigit(char) returns true; returns false otherwise.

Parameters:
s - the string to test
Returns:
true if s contains only letters or digits

Parsing Engine

Author: Dan Bikel.