ptolemy.backtrack.util
Class Strings

java.lang.Object
  extended by ptolemy.backtrack.util.Strings

public class Strings
extends java.lang.Object

A tool for string manipulation.

Since:
Ptolemy II 5.1
Version:
$Id: Strings.java 47482 2007-12-06 18:33:55Z cxh $
Author:
Thomas Feng
Accepted Rating:
Red (tfeng)
Proposed Rating:
Red (tfeng)

Constructor Summary
Strings()
           
 
Method Summary
static java.lang.String[] combineArrays(java.lang.String[] array1, java.lang.String[] array2)
          Combine two arrays and return the result of their combination.
static java.lang.String[] decodeFileNames(java.lang.String encode)
          Decode a string encoded with file names (or directory names) in it.
static java.lang.String encodeFileNames(java.lang.String[] fileNames)
          Encode file names (or directory names) in to a string.
static java.net.URL[] stringsToUrls(java.lang.String[] strings)
          Convert an array of strings to an array of URLs with File.toURL().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Strings

public Strings()
Method Detail

combineArrays

public static java.lang.String[] combineArrays(java.lang.String[] array1,
                                               java.lang.String[] array2)
Combine two arrays and return the result of their combination. If any one of the two arrays is null, the other one is return. If both of them are null, null is returned. In the result, elements in array1 appears before those in array2.

Parameters:
array1 - The first array.
array2 - The second array.
Returns:
The combination result of the two array.

decodeFileNames

public static java.lang.String[] decodeFileNames(java.lang.String encode)
Decode a string encoded with file names (or directory names) in it. Each file name in the string is separated with a path separator (File.pathSeparator) or a new line character.

Parameters:
encode - The string with file names encoded in it.
Returns:
The array of decoded file names.
See Also:
encodeFileNames(String[])

encodeFileNames

public static java.lang.String encodeFileNames(java.lang.String[] fileNames)
Encode file names (or directory names) in to a string. Each file name is separated with a path separator (File.pathSeparator).

Parameters:
fileNames - The array of file names.
Returns:
The string with file names encoded in it.
See Also:
decodeFileNames(String)

stringsToUrls

public static java.net.URL[] stringsToUrls(java.lang.String[] strings)
                                    throws java.net.MalformedURLException
Convert an array of strings to an array of URLs with File.toURL().

Parameters:
strings - The array of strings.
Returns:
The array of urls.
Throws:
java.net.MalformedURLException - If a string is not a proper URL.