|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knopflerfish.framework.Util
public class Util
Nested Class Summary | |
---|---|
static interface |
Util.Comparator
|
Field Summary | |
---|---|
protected static char |
CITCHAR
Default citation char for splitwords(). |
protected static java.lang.String |
WHITESPACE
Default whitespace string for splitwords(). |
Constructor Summary | |
---|---|
Util()
|
Method Summary | |
---|---|
static java.lang.String |
base64Encode(java.lang.String s)
|
static int |
binarySearch(java.util.List pl,
Util.Comparator c,
java.lang.Object p)
Do binary search for a package entry in the list with the same version number add the specifies package entry. |
static int |
compareStringVersion(java.lang.String ver1,
java.lang.String ver2)
Compare to strings formatted as ' |
static java.lang.String |
encode(byte[] in,
int len)
Encode a raw byte array to a Base64 String. |
static void |
encode(java.io.InputStream in,
java.io.OutputStream out,
int len)
|
static boolean |
filterMatch(java.lang.String filter,
java.lang.String s)
Check wildcard filter matches the string |
static java.lang.String |
getContent(java.io.File f)
|
static FileTree |
getFileStorage(java.lang.String name)
Check for local file storage directory. |
static java.util.Iterator |
parseEntries(java.lang.String a,
java.lang.String s,
boolean single,
boolean unique,
boolean single_entry)
Parse strings of format: ENTRY (, ENTRY)* ENTRY = key (; key)* (; PARAM)* PARAM = attribute '=' value PARAM = directive ':=' value |
static java.util.ArrayList |
parseEnumeration(java.lang.String d,
java.lang.String s)
Parse strings of format: ENTRY (, ENTRY)* |
static void |
putContent(java.io.File f,
java.lang.String content)
|
static void |
putContent(java.io.File f,
java.lang.String content,
boolean useUTF8)
|
static java.lang.String |
replace(java.lang.String s,
java.lang.String v1,
java.lang.String v2)
Replace all occurances of a substring with another string. |
static void |
sort(java.util.List a,
Util.Comparator cf,
boolean bReverse)
Sort a vector with objects compareble using a comparison function. |
static java.lang.String[] |
splitwords(java.lang.String s)
Utility method to split a string into words separated by whitespace. |
static java.lang.String[] |
splitwords(java.lang.String s,
java.lang.String whiteSpace)
Utility method to split a string into words separated by whitespace. |
static java.lang.String[] |
splitwords(java.lang.String s,
java.lang.String whiteSpace,
char citChar)
Split a string into words separated by whitespace. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.lang.String WHITESPACE
protected static char CITCHAR
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static FileTree getFileStorage(java.lang.String name)
name
- local directory name.
public static int compareStringVersion(java.lang.String ver1, java.lang.String ver2) throws java.lang.NumberFormatException
ver1
- First version string.ver2
- Second version string.
java.lang.NumberFormatException
- on syntax error in input.public static java.util.ArrayList parseEnumeration(java.lang.String d, java.lang.String s)
d
- Directive being parseds
- String to parse
java.lang.IllegalArgumentException
- If syntax error in input string.public static java.util.Iterator parseEntries(java.lang.String a, java.lang.String s, boolean single, boolean unique, boolean single_entry)
a
- Attribute being parseds
- String to parsesingle
- If true, only allow one key per ENTRYunique
- Only allow unique parameters for each ENTRY.single_entry
- If true, only allow one ENTRY is allowed.
java.lang.IllegalArgumentException
- If syntax error in input string.public static java.lang.String[] splitwords(java.lang.String s)
Equivalent to splitwords(s, WHITESPACE)
public static java.lang.String[] splitwords(java.lang.String s, java.lang.String whiteSpace)
Equivalent to splitwords(s, WHITESPACE, CITCHAR)
public static java.lang.String[] splitwords(java.lang.String s, java.lang.String whiteSpace, char citChar)
Citation chars may be used to group words with embedded whitespace.
s
- String to split.whiteSpace
- whitespace to use for splitting. Any of the
characters in the whiteSpace string are considered
whitespace between words and will be removed
from the result. If no words are found, return an
array of length zero.citChar
- Citation character used for grouping words with
embedded whitespace. Typically '"'public static java.lang.String replace(java.lang.String s, java.lang.String v1, java.lang.String v2)
The returned string will shrink or grow as necessary depending on the lengths of v1 and v2.
Implementation note: This method avoids using the standard String manipulation methods to increase execution speed. Using the replace method does however include two new operations in the case when matches are found.
s
- Source string.v1
- String to be replaced with v2
.v2
- String replacing v1
.
public static java.lang.String getContent(java.io.File f)
public static void putContent(java.io.File f, java.lang.String content) throws java.io.IOException
java.io.IOException
public static void putContent(java.io.File f, java.lang.String content, boolean useUTF8) throws java.io.IOException
java.io.IOException
public static void sort(java.util.List a, Util.Comparator cf, boolean bReverse)
a
- Vector to sortcf
- comparison functionpublic static int binarySearch(java.util.List pl, Util.Comparator c, java.lang.Object p)
pl
- Sorted list of package entries to search.p
- Package entry to search for.
public static java.lang.String base64Encode(java.lang.String s) throws java.io.IOException
java.io.IOException
public static java.lang.String encode(byte[] in, int len) throws java.io.IOException
in
- Byte array to encode.len
- Length of Base64 lines. 0 means no line breaks.
java.io.IOException
public static void encode(java.io.InputStream in, java.io.OutputStream out, int len) throws java.io.IOException
java.io.IOException
public static boolean filterMatch(java.lang.String filter, java.lang.String s)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |