aQute.lib.osgi
Class Processor
public
class
Processor
extends Object
implements Reporter, Constants, Closeable
Method Summary |
void | addClose(Closeable jar) |
void | addIncluded(File file) |
void | addProperties(File file) |
static String | appendPath(String... parts)
Append two strings to for a path in a ZIP or JAR file. |
protected void | begin() |
void | clear() |
void | close() |
void | error(String string, Object... args) |
void | error(String string, Throwable t, Object... args) |
boolean | exists() |
File | getBase() |
List<String> | getErrors() |
static File | getFile(File base, String file) |
File | getFile(String file) |
Properties | getFlattenedProperties()
Return the properties but expand all macros. |
void | getInfo(Processor processor, String prefix) |
void | getInfo(Processor processor) |
protected Object[] | getMacroDomains()
This should be overridden by subclasses to add extra macro command
domains on the search list.
|
static Properties | getManifestAsProperties(InputStream in)
Read a manifest but return a properties object.
|
Processor | getParent() |
<T> List<T> | getPlugins(Class<T> clazz)
Return a list of plugins that implement the given class.
|
protected List<Object> | getPlugins()
Return a list of plugins. |
Properties | getProperties()
Property handling ...
|
File | getPropertiesFile() |
String | getProperty(String key) |
String | getProperty(String key, String deflt)
Get a property with a proper default
|
Macro | getReplacer() |
Processor | getTop() |
List<String> | getWarnings() |
static boolean | isDuplicate(String name) |
boolean | isExceptions() |
boolean | isFailOk() |
boolean | isMissingPlugin(String name)
Answer if the name is a missing plugin's command name. |
boolean | isOk() |
boolean | isPedantic() |
boolean | isPerfect() |
static boolean | isTrue(String value) |
static String | join(Collection<?> list, String delimeter)
Join a list.
|
static String | join(Object[] list, String delimeter) |
static String | join(Collection<?> list) |
long | lastModified() |
Properties | loadProperties(File file)
Helper to load a properties file from disk.
|
static Map<String,Map<String,String>> | merge(String type, Map<String,Map<String,String>> instructions, Map<String,Map<String,String>> actual, Set<String> superfluous, Map<String,Map<String,String>> ignored)
Merge the attributes of two maps, where the first map can contain
wildcarded names. |
void | mergeProperties(File file, boolean override) |
void | mergeProperties(Properties properties, boolean override) |
static <K,V> Map<K,V> | newHashMap() |
<T> List<T> | newList() |
<T> List<T> | newList(Collection<T> t) |
static <K,V> Map<K,V> | newMap() |
<K,V> Map<K,V> | newMap(Map<K,V> t) |
<T> Set<T> | newSet() |
<T> Set<T> | newSet(Collection<T> t) |
String | normalize(String f)
Make the file short if it is inside our base directory, otherwise long.
|
String | normalize(File f) |
Map<String,Map<String,String>> | parseHeader(String value) |
Map<String,Map<String,String>> | parseHeader(String value, Processor logger)
Standard OSGi header parser.
|
static void | printClause(Map<String,String> map, String allowedDirectives, StringBuffer sb) |
static String | printClauses(Map<String,Map<String,String>> exports, String allowedDirectives)
Print a standard Map based OSGi header.
|
static String | printClauses(Map<String,Map<String,String>> exports, String allowedDirectives, boolean checkMultipleVersions) |
void | progress(String s, Object... args) |
void | propertiesChanged() |
static String | read(InputStream in) |
boolean | refresh() |
static String | removeDuplicateMarker(String key) |
static Properties | replaceAll(Properties p, String pattern, String replacement)
Replace a string in all the values of the map. |
static Map<Instruction,Map<String,String>> | replaceWitInstruction(Map<String,Map<String,String>> header, String type) |
void | setBase(File base) |
void | setExceptions(boolean exceptions) |
void | setFileMustExist(boolean mustexist) |
void | setForceLocal(Collection<String> local) |
void | setParent(Processor processor) |
void | setPedantic(boolean pedantic) |
void | setProperties(Properties properties) |
void | setProperties(File propertiesFile)
Set the properties by file. |
void | setProperties(File propertiesFile, File base) |
void | setProperty(String key, String value)
Add or override a new property.
|
void | setTrace(boolean x) |
static void | split(String s, Collection<String> set) |
static Collection<String> | split(String s) |
static Collection<String> | split(String s, String splitter) |
void | trace(String msg, Object... parms) |
void | unsetProperty(String string) |
void | updateModified(long time, String reason) |
void | warning(String string, Object... args) |
String | _basedir(String[] args) |
public static String DEFAULT_PLUGINS
public static String LIST_SPLITTER
public Processor()
public Processor(Properties parent)
public void addClose(Closeable jar)
public void addIncluded(File file)
public void addProperties(File file)
public static String appendPath(String... parts)
Append two strings to for a path in a ZIP or JAR file. It is guaranteed
to return a string that does not start, nor ends with a '/', while it is
properly separated with slashes. Double slashes are properly removed.
"/" + "abc/def/" becomes "abc/def"
Parameters: prefix suffix
Returns:
protected void begin()
public void clear()
public void close()
public void error(String string, Object... args)
public void error(String string, Throwable t, Object... args)
public boolean exists()
public File getBase()
public List<String> getErrors()
public static File getFile(File base, String file)
public File getFile(String file)
public Properties getFlattenedProperties()
Return the properties but expand all macros. This always returns a new
Properties object that can be used in any way.
Returns:
public void getInfo(
Processor processor, String prefix)
protected Object[] getMacroDomains()
This should be overridden by subclasses to add extra macro command
domains on the search list.
Returns:
public static Properties getManifestAsProperties(InputStream in)
Read a manifest but return a properties object.
Parameters: in
Returns:
Throws: IOException
public <
T> List<
T> getPlugins(Class<
T> clazz)
Return a list of plugins that implement the given class.
Parameters: clazz
Each returned plugin implements this class/interface
Returns: A list of plugins
protected List<Object> getPlugins()
Return a list of plugins. Plugins are defined with the -plugin command.
They are class names, optionally associated with attributes. Plugins can
implement the Plugin interface to see these attributes.
Any object can be a plugin.
Returns:
public Properties getProperties()
Property handling ...
Returns:
public File getPropertiesFile()
public String getProperty(String key)
public String getProperty(String key, String deflt)
Get a property with a proper default
Parameters: headerName deflt
Returns:
public
Macro getReplacer()
public List<String> getWarnings()
public static boolean isDuplicate(String name)
public boolean isExceptions()
public boolean isFailOk()
public boolean isMissingPlugin(String name)
Answer if the name is a missing plugin's command name. If a bnd file
contains the command name of a plugin, and that plugin is not available, then
an error is reported during manifest calculation. This allows the
plugin to fail to load when it is not needed.
We first get the plugins to ensure it is properly initialized.
Parameters: name
Returns:
public boolean isOk()
public boolean isPedantic()
public boolean isPerfect()
public static boolean isTrue(String value)
public static String join(Collection<?> list, String delimeter)
Join a list.
Parameters: args
Returns:
public static String join(Object[] list, String delimeter)
public static String join(Collection<?> list)
public long lastModified()
public Properties loadProperties(File file)
Helper to load a properties file from disk.
Parameters: file
Returns:
Throws: IOException
public static Map<String,Map<String,String>> merge(String type, Map<String,Map<String,String>> instructions, Map<String,Map<String,String>> actual, Set<String> superfluous, Map<String,Map<String,String>> ignored)
Merge the attributes of two maps, where the first map can contain
wildcarded names. The idea is that the first map contains patterns (for
example *) with a set of attributes. These patterns are matched against
the found packages in actual. If they match, the result is set with the
merged set of attributes. It is expected that the instructions are
ordered so that the instructor can define which pattern matches first.
Attributes in the instructions override any attributes from the actual.
A pattern is a modified regexp so it looks like globbing. The * becomes a .*
just like the ? becomes a .?. '.' are replaced with \\. Additionally, if
the pattern starts with an exclamation mark, it will remove that matches
for that pattern (- the !) from the working set. So the following
patterns should work:
- com.foo.bar
- com.foo.*
- com.foo.???
- com.*.[^b][^a][^r]
- !com.foo.* (throws away any match for com.foo.*)
Enough rope to hang the average developer I would say.
Parameters: instructions
the instructions with patterns. A actual
the actual found packages
public void mergeProperties(File file, boolean override)
public void mergeProperties(Properties properties, boolean override)
public static <
K,
V> Map<
K,
V> newHashMap()
public <
T> List<
T> newList()
public <
T> List<
T> newList(Collection<
T> t)
public static <
K,
V> Map<
K,
V> newMap()
public <
K,
V> Map<
K,
V> newMap(Map<
K,
V> t)
public <
T> Set<
T> newSet()
public <
T> Set<
T> newSet(Collection<
T> t)
public String normalize(String f)
Make the file short if it is inside our base directory, otherwise long.
Parameters: f
Returns:
public String normalize(File f)
public Map<String,Map<String,String>> parseHeader(String value)
public Map<String,Map<String,String>> parseHeader(String value,
Processor logger)
Standard OSGi header parser.
Parameters: value
Returns:
public static void printClause(Map<String,String> map, String allowedDirectives, StringBuffer sb)
public static String printClauses(Map<String,Map<String,String>> exports, String allowedDirectives)
Print a standard Map based OSGi header.
Parameters: exports
map { name => Map { attribute|directive => value } }
Returns: the clauses
public static String printClauses(Map<String,Map<String,String>> exports, String allowedDirectives, boolean checkMultipleVersions)
public void progress(String s, Object... args)
public void propertiesChanged()
public static String read(InputStream in)
public boolean refresh()
public static String removeDuplicateMarker(String key)
public static Properties replaceAll(Properties p, String pattern, String replacement)
Replace a string in all the values of the map. This can be used to
preassign variables that change. I.e. the base directory ${.} for a
loaded properties
public static Map<
Instruction,Map<String,String>> replaceWitInstruction(Map<String,Map<String,String>> header, String type)
public void setBase(File base)
public void setExceptions(boolean exceptions)
public void setFileMustExist(boolean mustexist)
public void setForceLocal(Collection<String> local)
public void setPedantic(boolean pedantic)
public void setProperties(Properties properties)
public void setProperties(File propertiesFile)
Set the properties by file. Setting the properties this way will also set
the base for this analyzer. After reading the properties, this will call
setProperties(Properties) which will handle the includes.
Parameters: propertiesFile
Throws: FileNotFoundException IOException
public void setProperties(File propertiesFile, File base)
public void setProperty(String key, String value)
Add or override a new property.
Parameters: key value
public void setTrace(boolean x)
public static void split(String s, Collection<String> set)
public static Collection<String> split(String s)
public static Collection<String> split(String s, String splitter)
public void trace(String msg, Object... parms)
public void unsetProperty(String string)
public void updateModified(long time, String reason)
public void warning(String string, Object... args)
public String _basedir(String[] args)