org.activemath.util
Class Utilities

java.lang.Object
  extended by org.activemath.util.Utilities

public final class Utilities
extends Object

A class to group all utility "functions" useful at several places in the code. No instance can be built, methods are all final static.


Method Summary
static Exception deleteRecursively(File file)
          Erases the files in the directory, doesn't throw exceptions, just logs the error.
static String join2string(Collection c)
          Convenience method for constructing CSV strings
static String join2string(Collection c, String separator)
          Join collection to string by concatenating its elements, separated by some separator.
static String join2string(Object[] arr)
          Convenience method for constructing CSV strings
static String join2string(Object[] arr, String separator)
          Join array to string by concatenating its elements, separated by some separator.
static void main(String[] args)
           
static String pathDecode(String encodedString)
          Performs the inverse of #pathEncode().
static String pathEncode(String rawString)
          Uses an alternate encoder of URLs suitable to be part of another URL.
static List<String> splitCSV(String line)
          Split a CSV string into its constituents
static String urlDecode(String encodedString)
           
static String urlDecodeFor1_1(String encodedString)
          Makes the reverse of URLEncoder.encode(java.lang.String) method.
static String urlEncode(String rawString)
          Just calls the URLEncoder.encode(java.lang.String) method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

urlEncode

public static final String urlEncode(String rawString)
Just calls the URLEncoder.encode(java.lang.String) method.

Parameters:
rawString - Missing description of Parameter
Returns:
Missing description of the Returned Value

urlDecode

public static final String urlDecode(String encodedString)

join2string

public static final String join2string(Collection c,
                                       String separator)
Join collection to string by concatenating its elements, separated by some separator.

Parameters:
c - The collection to be joined
separator - Will be inserted between two elements
Returns:
A string representation of the collection, joined with provided separator, or the empty string if collection is null.

join2string

public static final String join2string(Collection c)
Convenience method for constructing CSV strings


join2string

public static final String join2string(Object[] arr,
                                       String separator)
Join array to string by concatenating its elements, separated by some separator.

Parameters:
arr - The array to be joined
separator - Will be inserted between two elements
Returns:
A string representation of the array, joined with provided separator

join2string

public static final String join2string(Object[] arr)
Convenience method for constructing CSV strings


splitCSV

public static final List<String> splitCSV(String line)
Split a CSV string into its constituents

Parameters:
line - The string
Returns:
A list of individual string tokens

pathEncode

public static String pathEncode(String rawString)
Uses an alternate encoder of URLs suitable to be part of another URL. Replaces the "/" by "__" and scapes "mbase://" to be "mbX_", uses urlEncode(java.lang.String) otheriwse. This was needed because URL-encoding is very quickly unreadable and browsers tend to URL-decode more than once a URL or parts thereof.

Parameters:
rawString - the URL to be encoded, supposed not to contain "__" (thus avoiding the possibility to apply twice this method)
Returns:
the URL encoded
Throws:
IllegalArgumentException - if the argument contains "__"
See Also:
pathDecode(java.lang.String)

pathDecode

public static String pathDecode(String encodedString)
Performs the inverse of #pathEncode().

Parameters:
encodedString - the String to be convereted
Returns:
the string decoded

main

public static void main(String[] args)

urlDecodeFor1_1

public static final String urlDecodeFor1_1(String encodedString)
Makes the reverse of URLEncoder.encode(java.lang.String) method. Needed to be implemented as it was not present in java 1.1 distribution (!).

Parameters:
encodedString - Missing description of Parameter
Returns:
Missing description of the Returned Value

deleteRecursively

public static final Exception deleteRecursively(File file)
Erases the files in the directory, doesn't throw exceptions, just logs the error.

Parameters:
file - Missing description of Parameter
Returns:
Missing description of the Returned Value