Xindice API

org.apache.xindice.util
Class StringUtilities

java.lang.Object
  |
  +--org.apache.xindice.util.StringUtilities

public final class StringUtilities
extends java.lang.Object

StringUtilities provides a set of commonly used String parsing and processing routines.


Method Summary
static int findWhiteSpace(java.lang.String value)
          findWhiteSpace scans a String value for whitespace characters and returns the location of the first whitespace character found.
static int findWhiteSpace(java.lang.String value, int start)
          findWhiteSpace scans a String value for whitespace characters from a specified starting position and returns the location of the first whitespace character found.
static java.lang.String javaEncode(java.lang.String value)
          javaEncode converts a String value to a Java-printable String.
static java.lang.String leftJustify(java.lang.String value, int width)
          leftJustify left-justifies a String value, space padding to width characters if the string is less than width.
static void parseBuffer(java.util.Map retprops, java.lang.String inbuffer, java.lang.String delimiters, boolean urldecode, boolean multivalue)
          parseBuffer parses through a String buffer and produces a Map table using the provided delimiters.
static java.lang.String rightJustify(java.lang.String value, int width)
          rightJustify right-justifies a String value, space padding to width characters if the string is less than width.
static int stringToInt(java.lang.String value)
          stringToInt quickly converts a String value to an int, returning 0 if a conversion error occurs.
static int stringToInt(java.lang.String value, int defvalue)
          stringToInt quickly converts a String value to an int, returning a default value if a conversion error occurs.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

stringToInt

public static int stringToInt(java.lang.String value,
                              int defvalue)
stringToInt quickly converts a String value to an int, returning a default value if a conversion error occurs.
Parameters:
value - The value to convert
defvalue - The default value to return
Returns:
The converted value

stringToInt

public static int stringToInt(java.lang.String value)
stringToInt quickly converts a String value to an int, returning 0 if a conversion error occurs.
Parameters:
value - The value to convert
Returns:
The converted value

leftJustify

public static java.lang.String leftJustify(java.lang.String value,
                                           int width)
leftJustify left-justifies a String value, space padding to width characters if the string is less than width.
Parameters:
value - The value to left-justify
width - The width to left-justify to
Returns:
The left-justified value

rightJustify

public static java.lang.String rightJustify(java.lang.String value,
                                            int width)
rightJustify right-justifies a String value, space padding to width characters if the string is less than width.
Parameters:
value - The value to right-justify
width - The width to right-justify to
Returns:
The right-justified value

parseBuffer

public static void parseBuffer(java.util.Map retprops,
                               java.lang.String inbuffer,
                               java.lang.String delimiters,
                               boolean urldecode,
                               boolean multivalue)
parseBuffer parses through a String buffer and produces a Map table using the provided delimiters. This method can also urldecode values and produce newline-delimited multi-value properties if multiple values for the same key are detected in the buffer.
Parameters:
retprops - The Map to populate
inbuffer - The String buffer to parse
delimiters - The delimiters to use
urldecode - Whether or not to URL-decode the values
multivalue - Whether or not to parse multiple values

findWhiteSpace

public static int findWhiteSpace(java.lang.String value,
                                 int start)
findWhiteSpace scans a String value for whitespace characters from a specified starting position and returns the location of the first whitespace character found.
Parameters:
value - The value to scan
start - The starting position
Returns:
The first whitespace location

findWhiteSpace

public static int findWhiteSpace(java.lang.String value)
findWhiteSpace scans a String value for whitespace characters and returns the location of the first whitespace character found.
Parameters:
value - The value to scan
Returns:
The first whitespace location

javaEncode

public static java.lang.String javaEncode(java.lang.String value)
javaEncode converts a String value to a Java-printable String. All non-printable characters, such as newline and backspace are converted to their respective escape sequences. This method does not convert UNICODE characters.
Parameters:
value - The value to convert
Returns:
The converted value

Xindice API

Copyright (c) 1999-2001 The Apache Software Foundation