davmail.util
Class StringUtil

java.lang.Object
  extended by davmail.util.StringUtil

public final class StringUtil
extends Object

Various string handling methods


Method Summary
static String base64ToHex(String value)
          Convert base64 value to hex.
static String base64ToUrl(String value)
          Encode EWS base64 itemId to url compatible value.
static String convertZuluDateTimeToAllDay(String value)
          Get allday date value from zulu timestamp.
static String davSearchEncode(String value)
          Encode quotes in Dav search parameter.
static String decodeUrlcompname(String urlcompname)
          Decode urlcompname to get item name.
static String encodePlusSign(String value)
          Urlencode plus sign in encoded href. '+' is decoded as ' ' by URIUtil.decode, the workaround is to force urlencoding to '%2B' first
static String encodeUrlcompname(String value)
          Encode item name to get actual value stored in urlcompname MAPI property.
static String getLastToken(String value, String startDelimiter, String endDelimiter)
          Return the sub string between startDelimiter and endDelimiter or null, look for last token in string.
static String getToken(String value, String startDelimiter, String endDelimiter)
          Return the sub string between startDelimiter and endDelimiter or null.
static String hexToBase64(String value)
          Convert hex value to base64.
static String join(Set<String> values, String separator)
          Join values with given separator.
static String removeQuotes(String value)
          Remove quotes if present on value.
static String replaceToken(String value, String startDelimiter, String endDelimiter, String newToken)
          Return the sub string between startDelimiter and endDelimiter with newToken.
static String urlToBase64(String value)
          Encode EWS url compatible itemId back to base64 value.
static String xmlDecode(String name)
          Need to decode xml for iCal
static String xmlEncode(String name)
          Xml encode content.
static String xmlEncodeAttribute(String name)
          Xml encode inside attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getToken

public static String getToken(String value,
                              String startDelimiter,
                              String endDelimiter)
Return the sub string between startDelimiter and endDelimiter or null.

Parameters:
value - String value
startDelimiter - start delimiter
endDelimiter - end delimiter
Returns:
token value

getLastToken

public static String getLastToken(String value,
                                  String startDelimiter,
                                  String endDelimiter)
Return the sub string between startDelimiter and endDelimiter or null, look for last token in string.

Parameters:
value - String value
startDelimiter - start delimiter
endDelimiter - end delimiter
Returns:
token value

replaceToken

public static String replaceToken(String value,
                                  String startDelimiter,
                                  String endDelimiter,
                                  String newToken)
Return the sub string between startDelimiter and endDelimiter with newToken.

Parameters:
value - String value
startDelimiter - start delimiter
endDelimiter - end delimiter
newToken - new token value
Returns:
token value

join

public static String join(Set<String> values,
                          String separator)
Join values with given separator.

Parameters:
values - value set
separator - separator
Returns:
joined values

xmlEncode

public static String xmlEncode(String name)
Xml encode content.

Parameters:
name - decoded name
Returns:
name encoded name

xmlEncodeAttribute

public static String xmlEncodeAttribute(String name)
Xml encode inside attribute.

Parameters:
name - decoded name
Returns:
name encoded name

xmlDecode

public static String xmlDecode(String name)
Need to decode xml for iCal

Parameters:
name - encoded name
Returns:
name decoded name

base64ToHex

public static String base64ToHex(String value)
Convert base64 value to hex.

Parameters:
value - base64 value
Returns:
hex value

hexToBase64

public static String hexToBase64(String value)
                          throws org.apache.commons.codec.DecoderException
Convert hex value to base64.

Parameters:
value - hex value
Returns:
base64 value
Throws:
org.apache.commons.codec.DecoderException - on error

encodeUrlcompname

public static String encodeUrlcompname(String value)
Encode item name to get actual value stored in urlcompname MAPI property.

Parameters:
value - decoded value
Returns:
urlcompname encoded value

decodeUrlcompname

public static String decodeUrlcompname(String urlcompname)
Decode urlcompname to get item name.

Parameters:
urlcompname - encoded value
Returns:
decoded value

encodePlusSign

public static String encodePlusSign(String value)
Urlencode plus sign in encoded href. '+' is decoded as ' ' by URIUtil.decode, the workaround is to force urlencoding to '%2B' first

Parameters:
value - encoded href
Returns:
encoded href

base64ToUrl

public static String base64ToUrl(String value)
Encode EWS base64 itemId to url compatible value.

Parameters:
value - base64 value
Returns:
url compatible value

urlToBase64

public static String urlToBase64(String value)
Encode EWS url compatible itemId back to base64 value.

Parameters:
value - url compatible value
Returns:
base64 value

davSearchEncode

public static String davSearchEncode(String value)
Encode quotes in Dav search parameter.

Parameters:
value - search parameter
Returns:
escaped value

convertZuluDateTimeToAllDay

public static String convertZuluDateTimeToAllDay(String value)
Get allday date value from zulu timestamp.

Parameters:
value - zulu datetime
Returns:
yyyyMMdd allday date value

removeQuotes

public static String removeQuotes(String value)
Remove quotes if present on value.

Parameters:
value - input value
Returns:
unquoted string


Copyright © 2001-2013 MickaĆ«l Guessant. All Rights Reserved.