Knopflerfish OSGi 2.4.0

org.knopflerfish.ant.taskdefs.bundle
Class Util

java.lang.Object
  extended byorg.knopflerfish.ant.taskdefs.bundle.Util

public class Util
extends java.lang.Object

Misc static utility code.


Constructor Summary
Util()
           
 
Method Summary
static java.lang.String getRelativePath(java.io.File fromFile, java.io.File toFile)
           
static java.lang.String load(java.lang.String fileOrURL)
          Load entire contents of a file or URL into a string.
static java.lang.String loadFile(java.lang.String fname)
           
static byte[] loadURL(java.net.URL url)
           
static java.util.Set makeSetFromStringList(java.lang.String s)
          Create a Set from a comma-separated string.
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.lang.String replace(java.lang.String s, java.lang.String v1, java.lang.String v2)
          Replace all occurences of a substring with another string.
static java.lang.String[] splitwords(java.lang.String s)
          Split a string into words separated by whitespace SPACE | TAB | NEWLINE | CR Citation chars '"' may be used to group words with embedded 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
 

Constructor Detail

Util

public Util()
Method Detail

loadURL

public static byte[] loadURL(java.net.URL url)
                      throws java.io.IOException
Throws:
java.io.IOException

loadFile

public static java.lang.String loadFile(java.lang.String fname)
                                 throws java.io.IOException
Throws:
java.io.IOException

load

public static java.lang.String load(java.lang.String fileOrURL)
                             throws java.io.IOException
Load entire contents of a file or URL into a string.

Throws:
java.io.IOException

makeSetFromStringList

public static java.util.Set makeSetFromStringList(java.lang.String s)
Create a Set from a comma-separated string.


getRelativePath

public static java.lang.String getRelativePath(java.io.File fromFile,
                                               java.io.File toFile)

replace

public static java.lang.String replace(java.lang.String s,
                                       java.lang.String v1,
                                       java.lang.String v2)
Replace all occurences of a substring with another string.

If no replacements are needed, the methods returns the original string.

Parameters:
s - Source string which will be scanned and modified. If null, return null
v1 - String to be replaced with v2. If null, return original string.
v2 - String replacing v1. If null, return original string.
Returns:
Modified string.

splitwords

public static java.lang.String[] splitwords(java.lang.String s)
Split a string into words separated by whitespace SPACE | TAB | NEWLINE | CR Citation chars '"' may be used to group words with embedded whitespace.


splitwords

public static java.lang.String[] splitwords(java.lang.String s,
                                            java.lang.String whiteSpace,
                                            char citchar)
Split a string into words separated by whitespace. Citation chars '"' may be used to group words with embedded whitespace.

Parameters:
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.
citchar - citation char used for enclosing words containing whitespace

parseEntries

public 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

Parameters:
a - Attribute being parsed
s - String to parse
single - If true, only allow one key per ENTRY
unique - Only allow unique parameters for each ENTRY.
single_entry - If true, only allow one ENTRY is allowed.
Returns:
Iterator(Map(param -> value)) or null if input string is null.
Throws:
java.lang.IllegalArgumentException - If syntax error in input string.

Knopflerfish OSGi 2.4.0