org.apache.camel.util
Class StringHelper

java.lang.Object
  extended by org.apache.camel.util.StringHelper

public final class StringHelper
extends Object

Helper methods for working with Strings.


Method Summary
static int countChar(String s, char ch)
          Counts the number of times the given char is in the string
static boolean hasStartToken(String expression, String language)
          Does the expression have the language start token?
static boolean hasUpperCase(String text)
          Determines if the string has at least one letter in upper case
static boolean isQuoted(String s)
           
static String removeLeadingAndEndingQuotes(String s)
           
static String removeQuotes(String s)
           
static String sanitize(String s)
          Ensures that s is friendly for a URL or file system.
static String xmlEncode(String text)
          Encodes the text into safe XML by replacing < > and & with XML tokens
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sanitize

public static String sanitize(String s)
Ensures that s is friendly for a URL or file system.

Parameters:
s - String to be sanitized.
Returns:
sanitized version of s.
Throws:
NullPointerException - if s is null.

countChar

public static int countChar(String s,
                            char ch)
Counts the number of times the given char is in the string

Parameters:
s - the string
ch - the char
Returns:
number of times char is located in the string

removeQuotes

public static String removeQuotes(String s)

removeLeadingAndEndingQuotes

public static String removeLeadingAndEndingQuotes(String s)

isQuoted

public static boolean isQuoted(String s)

xmlEncode

public static String xmlEncode(String text)
Encodes the text into safe XML by replacing < > and & with XML tokens

Parameters:
text - the text
Returns:
the encoded text

hasUpperCase

public static boolean hasUpperCase(String text)
Determines if the string has at least one letter in upper case

Parameters:
text - the text
Returns:
true if at least one letter is upper case, false otherwise

hasStartToken

public static boolean hasStartToken(String expression,
                                    String language)
Does the expression have the language start token?

Parameters:
expression - the expression
language - the name of the language, such as simple
Returns:
true if the expression contains the start token, false otherwise


Apache CAMEL