|
Knopflerfish OSGi 5.0.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.knopflerfish.ant.taskdefs.bundle.Util
public class Util
| Nested Class Summary | |
|---|---|
static class |
Util.HeaderEntry
A class that holds the parse result for one entry of a manifest header following the general OSGi manifest header syntax. |
| 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.util.Set<java.lang.String> |
parseEnumeration(java.lang.String d,
java.lang.String s)
Parse strings of format: ENTRY (, ENTRY)* |
static java.util.List<Util.HeaderEntry> |
parseManifestHeader(java.lang.String a,
java.lang.String s,
boolean single,
boolean unique,
boolean single_entry)
Parse manifest header values on format: |
static java.lang.String |
replace(java.lang.String s,
java.lang.String v1,
java.lang.String v2)
Replace all occurrences of a substring with another string. |
static java.lang.String[] |
splitwords(java.lang.String s)
Utility method to split a string into words separated by whitespace. |
static java.util.List<java.lang.String> |
splitWords(java.lang.String s,
char sepChar,
boolean trim)
Split a string into words separated by a separator char. |
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. |
static java.lang.String |
toString(java.util.List<Util.HeaderEntry> hes)
Convert a list of Util.HeaderEntry-objects into a valid manifest header
value. |
| 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 java.util.Set<java.lang.String> 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.List<Util.HeaderEntry> parseManifestHeader(java.lang.String a,
java.lang.String s,
boolean single,
boolean unique,
boolean single_entry)
ENTRY (',' ENTRY)*
ENTRY = key (';' key)* (';' PARAM)*
PARAM = attribute (':' TYPE)? '=' value
PARAM = directive ':=' value
TYPE = SCALAR | LIST
SCALAR = 'String' | 'Version' | 'Long' | 'Double'
LIST = 'List<' SCALAR '>'
The default attribute value type is 'String'. For list values the 'List'
and its following '<' are treated as separate tokens to comply with the
OSGi TCK.
The parse result is one Util.HeaderEntry-instance for each entry.
If single is true then the entry only contains one key that can be
accesses by calling Util.HeaderEntry.getKey().
If unique is true the attribute values in the map are scalars
otherwise the values from different attribute definitions with the same
name are wrapped in a List<?>.
a - Name of attribute being parsed, for error messages.s - String to parse.single - If true, only allow one key per ENTRY.unique - Only allow unique attributes for each ENTRY.single_entry - If true, only allow one ENTRY in s.
Util.HeaderEntry-object, one per entry in s.
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.util.List<java.lang.String> splitWords(java.lang.String s,
char sepChar,
boolean trim)
s - String to split.sepChar - separator char to split on.trim - trim whitespace from the words if true.
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 toString(java.util.List<Util.HeaderEntry> hes)
Util.HeaderEntry-objects into a valid manifest header
value.
hes - The list of header entries to make a string of.
|
Knopflerfish OSGi 5.0.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||