net.kwfgrid.gwes.util
Class StringUtils

java.lang.Object
  extended by net.kwfgrid.gwes.util.StringUtils

public class StringUtils
extends Object

Version:
$Id: StringUtils.java 1478 2011-02-10 14:49:57Z hoheisel $
Author:
Andreas Hoheisel (www.andreas-hoheisel.de)

Field Summary
static Pattern PATTERN_PROBABILITY
           
static Pattern PATTERN_SLASH_AND_COMMA
           
static Pattern PATTERN_SPACES_AND_MORE
           
 
Constructor Summary
StringUtils()
           
 
Method Summary
static void addXmlToStringBuffer(StringBuffer buffer, String elementName, int contents)
          Appends XML element to string buffer.
static void addXmlToStringBuffer(StringBuffer buffer, String elementName, long contents)
          Appends XML element to string buffer.
static void addXmlToStringBuffer(StringBuffer buffer, String elementName, String contents)
          Appends XML element to string buffer.
static String[][] convertListListToStringArrayArray(List<List<String>> listlist)
          Convert a List<List<String>> into String[][]
static String convertStreamToString(InputStream is)
           
static String expandContextVariables(String edgeExpression)
          Replaces "$" by "/gwdl:data/" and leading "*" by "/gwdl:data/*" in edgeExpressions.
static String extractFilteredCNFromDN(String userID)
          Extracts CN from DN and replaces chars that are not alphanumeric.
static String extractStringFromXML(String xml, String elementname)
          Extract the text contents of an XML element, e.g., <name>Hugo</name> = Hugo
static String filter(String message)
          Trim string and replace all string characters that are not within 0-9, a-z, A-Z by "-".
static double getProbability(String str)
           
static String[] splitSpacesAndMore(String str)
          Splits a string using as delimiter one ore more space-type characters (space, tab, etc.) or the characters "," and ";".
static String stripNamespacePrefix(String str)
           
static String stripOwl(String str)
          Replace URL edge expression ("http://host/dir/file#foo") with value after # ("foo").
static String stripProbability(String str)
          Strip the probability substring from string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATTERN_PROBABILITY

public static final Pattern PATTERN_PROBABILITY

PATTERN_SPACES_AND_MORE

public static final Pattern PATTERN_SPACES_AND_MORE

PATTERN_SLASH_AND_COMMA

public static final Pattern PATTERN_SLASH_AND_COMMA
Constructor Detail

StringUtils

public StringUtils()
Method Detail

stripNamespacePrefix

public static String stripNamespacePrefix(String str)

expandContextVariables

public static String expandContextVariables(String edgeExpression)
Replaces "$" by "/gwdl:data/" and leading "*" by "/gwdl:data/*" in edgeExpressions. This method also trims the edge expression.

Parameters:
edgeExpression -
Returns:

stripOwl

public static String stripOwl(String str)
Replace URL edge expression ("http://host/dir/file#foo") with value after # ("foo").

Parameters:
str -
Returns:
the edge expression without owl part

getProbability

public static double getProbability(String str)

stripProbability

public static String stripProbability(String str)
Strip the probability substring from string. E.g.: "x{50.3%}" -> "x"

Parameters:
str -
Returns:
String without the probability substring.

extractStringFromXML

public static String extractStringFromXML(String xml,
                                          String elementname)
Extract the text contents of an XML element, e.g., <name>Hugo</name> = Hugo

Parameters:
xml - The XML
elementname - The element name.
Returns:

splitSpacesAndMore

public static String[] splitSpacesAndMore(String str)
Splits a string using as delimiter one ore more space-type characters (space, tab, etc.) or the characters "," and ";".

Parameters:
str - The string to split.
Returns:
array of string without the delimiters

filter

public static String filter(String message)
Trim string and replace all string characters that are not within 0-9, a-z, A-Z by "-".

Parameters:
message - The message string to be filtered
Returns:
The clean string only containing 0-9, a-z, A-Z.

extractFilteredCNFromDN

public static String extractFilteredCNFromDN(String userID)
Extracts CN from DN and replaces chars that are not alphanumeric. Supports the following DN formats: "CN=..., OU=..., OU=..., O=..., C=.." "/C=../O=.../OU=.../OU=.../CN=..."

Parameters:
userID - The user ID, e.g., a DN extracted from a certificate.
Returns:
The CN or the useID if no "CN=" is available.

addXmlToStringBuffer

public static void addXmlToStringBuffer(StringBuffer buffer,
                                        String elementName,
                                        String contents)
Appends XML element to string buffer. If contents is null or an empty String, this method does NOT append an empty element! "<elementName>contents</elementName>"

Parameters:
buffer - The String Buffer to append.
elementName - Name of the Element.
contents - The contents.

addXmlToStringBuffer

public static void addXmlToStringBuffer(StringBuffer buffer,
                                        String elementName,
                                        long contents)
Appends XML element to string buffer. If contents is less than zero, this method does NOT append an element! "<elementName>contents</elementName>"

Parameters:
buffer - The String Buffer to append.
elementName - Name of the Element.
contents - The contents.

addXmlToStringBuffer

public static void addXmlToStringBuffer(StringBuffer buffer,
                                        String elementName,
                                        int contents)
Appends XML element to string buffer. If contents is less than zero, this method does NOT append an element! "<elementName>contents</elementName>"

Parameters:
buffer - The String Buffer to append.
elementName - Name of the Element.
contents - The contents.

convertStreamToString

public static String convertStreamToString(InputStream is)
                                    throws IOException
Throws:
IOException

convertListListToStringArrayArray

public static String[][] convertListListToStringArrayArray(List<List<String>> listlist)
Convert a List<List<String>> into String[][]

Parameters:
listlist - The input list of list of Strings
Returns:
the corresponding String[][] object.


Copyright © 2005-2011 Fraunhofer FIRST. All Rights Reserved.