org.apache.aries.util.manifest
Class ManifestHeaderProcessor

java.lang.Object
  extended by org.apache.aries.util.manifest.ManifestHeaderProcessor

public class ManifestHeaderProcessor
extends Object


Nested Class Summary
static class ManifestHeaderProcessor.GenericMetadata
          A GenericMetadata is either a Generic Capability or a Generic Requirement
static interface ManifestHeaderProcessor.NameValueCollection
          Intended to provide a standard way to add Name/Value's to aggregations of Name/Value's.
static class ManifestHeaderProcessor.NameValueList
          List of Name/Value
static class ManifestHeaderProcessor.NameValueMap
          Map of Name -> Value.
static class ManifestHeaderProcessor.NameValuePair
          A simple class to associate two types.
 
Field Summary
static String NESTED_FILTER_ATTRIBUTE
           
 
Constructor Summary
ManifestHeaderProcessor()
           
 
Method Summary
static String generateFilter(Map<String,String> attribs)
          Generate a filter from a set of attributes.
static String generateFilter(String type, String name, Map<String,String> attribs)
          Generate a filter from a set of attributes.
static ManifestHeaderProcessor.NameValuePair parseBundleSymbolicName(String s)
          Parse a bundle symbolic name.
static List<ManifestHeaderProcessor.GenericMetadata> parseCapabilityString(String s)
          Parse a generic capability header.
static List<ManifestHeaderProcessor.NameValuePair> parseExportList(List<String> list)
          Parse an export style header in a list.
static List<ManifestHeaderProcessor.NameValuePair> parseExportString(String s)
          Parse an export style header.
static Map<String,String> parseFilter(String filter)
           
static Map<String,Map<String,String>> parseImportString(String s)
          Parse an import style header.
static List<ManifestHeaderProcessor.GenericMetadata> parseRequirementString(String s)
          Parse a generic capability header.
static VersionRange parseVersionRange(String s)
          Parse a version range..
static VersionRange parseVersionRange(String s, boolean exactVersion)
          Parse a version range and indicate if the version is an exact version
static List<String> split(String value, String delimiter)
          Splits a delimiter separated string, tolerating presence of non separator commas within double quoted segments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NESTED_FILTER_ATTRIBUTE

public static final String NESTED_FILTER_ATTRIBUTE
See Also:
Constant Field Values
Constructor Detail

ManifestHeaderProcessor

public ManifestHeaderProcessor()
Method Detail

split

public static List<String> split(String value,
                                 String delimiter)
Splits a delimiter separated string, tolerating presence of non separator commas within double quoted segments. Eg. com.ibm.ws.eba.helloWorldService;version="[1.0.0, 1.0.0]" & com.ibm.ws.eba.helloWorldService;version="1.0.0" com.ibm.ws.eba.helloWorld;version="2";bundle-version="[2,30)" com.acme.foo;weirdAttr="one;two;three";weirdDir:="1;2;3"

Parameters:
value - the value to be split
delimiter - the delimiter string such as ',' etc.
Returns:
List the components of the split String in a list

parseExportString

public static List<ManifestHeaderProcessor.NameValuePair> parseExportString(String s)
Parse an export style header.

pkg1;attrib=value;attrib=value,pkg2;attrib=value,pkg3;attrib=value2

Result is returned as a list, as export does allow duplicate package exports.

Parameters:
list - The data to parse.
Returns:
List of NameValuePairs, where each Name in the list is an exported package, with its associated Value being a NameValueMap of any attributes declared.

parseExportList

public static List<ManifestHeaderProcessor.NameValuePair> parseExportList(List<String> list)
Parse an export style header in a list.

pkg1;attrib=value;attrib=value pkg2;attrib=value pkg3;attrib=value2

Result is returned as a list, as export does allow duplicate package exports.

Parameters:
list - The data to parse.
Returns:
List of NameValuePairs, where each Name in the list is an exported package, with its associated Value being a NameValueMap of any attributes declared.

parseImportString

public static Map<String,Map<String,String>> parseImportString(String s)
Parse an import style header.

pkg1;attrib=value;attrib=value,pkg2;attrib=value,pkg3;attrib=value

Result is returned as a set, as import does not allow duplicate package imports.

Parameters:
s - The data to parse.
Returns:
Map of NameValuePairs, where each Key in the Map is an imported package, with its associated Value being a NameValueMap of any attributes declared.

parseCapabilityString

public static List<ManifestHeaderProcessor.GenericMetadata> parseCapabilityString(String s)
Parse a generic capability header. For example
com.acme.myns;mylist:List="nl,be,fr,uk";myver:Version=1.3;long:Long="1234";d:Double="3.14";myattr=xyz, com.acme.myns;myattr=abc

Parameters:
s - The header to be parsed
Returns:
A list of GenericMetadata objects each representing an individual capability. The values in the attribute map are of the specified datatype.

parseRequirementString

public static List<ManifestHeaderProcessor.GenericMetadata> parseRequirementString(String s)
Parse a generic capability header. For example
com.acme.myns;mylist:List="nl,be,fr,uk";myver:Version=1.3;long:Long="1234";d:Double="3.14";myattr=xyz, com.acme.myns;myattr=abc

Parameters:
s - The header to be parsed
Returns:
A list of GenericMetadata objects each representing an individual capability. The values in the attribute map are of the specified datatype.

parseBundleSymbolicName

public static ManifestHeaderProcessor.NameValuePair parseBundleSymbolicName(String s)
Parse a bundle symbolic name.

bundlesymbolicname;attrib=value;attrib=value

Parameters:
s - The data to parse.
Returns:
NameValuePair with Name being the BundleSymbolicName, and Value being any attribs declared for the name.

parseVersionRange

public static VersionRange parseVersionRange(String s)
                                      throws IllegalArgumentException
Parse a version range..

Parameters:
s -
Returns:
VersionRange object.
Throws:
IllegalArgumentException - if the String could not be parsed as a VersionRange

parseVersionRange

public static VersionRange parseVersionRange(String s,
                                             boolean exactVersion)
                                      throws IllegalArgumentException
Parse a version range and indicate if the version is an exact version

Parameters:
s -
exactVersion -
Returns:
VersionRange object.
Throws:
IllegalArgumentException - if the String could not be parsed as a VersionRange

generateFilter

public static String generateFilter(Map<String,String> attribs)
Generate a filter from a set of attributes. This filter will be suitable for presentation to OBR This means that, due to the way OBR works, it will include a stanza of the form, (mandatory:<*mandatoryAttribute) Filter strings generated by this method will therefore tend to break the standard OSGi Filter class. The OBR stanza can be stripped out later if required.

Parameters:
attribs -
Returns:
filter string

generateFilter

public static String generateFilter(String type,
                                    String name,
                                    Map<String,String> attribs)
Generate a filter from a set of attributes. This filter will be suitable for presentation to OBR. This means that, due to the way OBR works, it will include a stanza of the form, (mandatory:<*mandatoryAttribute) Filter strings generated by this method will therefore tend to break the standard OSGi Filter class. The OBR stanza can be stripped out later if required. We may wish to consider relocating this method since VersionRange has its own top level class.

Parameters:
type -
name -
attribs -
Returns:
filter string

parseFilter

public static Map<String,String> parseFilter(String filter)


Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved.