Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.osgi.util
Class ManifestElement


java.lang.Object
  extended by 
org.eclipse.osgi.util.ManifestElement

public class ManifestElement
extends Object

This class represents a single manifest element. A manifest element must consist of a single String value. The String value may be split up into component values each separated by a semi-colon (';'). A manifest element may optionally have a set of attribute values associated with it. The general syntax of a manifest element is as follows:

 ManifestElement ::= headervalues (';' attribute)*
 headervalues ::= headervalue (';' headervalue)*
 headervalue ::= 
 attribute ::= key '=' value
 key ::= token
 value ::= token | quoted-string
 

For example, The following is an example of a manifest element to the Export-Package header:

 org.osgi.framework; specification-version="1.2"; another-attr="examplevalue"
 

This manifest element has a value of org.osgi.framework and it has two attributes, specification-version and another-attr.

The following manifest element is an example of a manifest element that has multiple components to its value:

 code1.jar;code2.jar;code3.jar;attr1=value1;attr2=value2;attr3=value3
 

This manifest element has a value of code1.jar;code2.jar;code3.jar. This is an example of a multiple component value. This value has three components: code1.jar, code2.jar, and code3.jar.

This class is not intended to be subclassed by clients.

Since:
3.0
Restriction:
This class is not intended to be subclassed by clients.

Field Summary
protected   Hashtable attributes
          The table of attributes for the manifest element.
protected   Hashtable directives
          The table of directives for the manifest element.
protected   String value
          The value of the manifest element.
protected   String[] valueComponents
          The value components of the manifest element.
 
Constructor Summary
protected ManifestElement ()
          Constructs an empty manifest element with no value or attributes.
 
Method Summary
protected  void addAttribute ( String key, String value)
          Add an attribute to this manifest element.
protected  void addDirective ( String key, String value)
          Add a directive to this manifest element.
static  String[] getArrayFromList ( String stringList)
          Returns the result of converting a list of comma-separated tokens into an array.
static  String[] getArrayFromList ( String stringList, String separator)
          Returns the result of converting a list of tokens into an array.
  String getAttribute ( String key)
          Returns the value for the specified attribute or null if it does not exist.
  String[] getAttributes ( String key)
          Returns an array of values for the specified attribute or null if the attribute does not exist.
  String getDirective ( String key)
          Returns the value for the specified directive or null if it does not exist.
  Enumeration getDirectiveKeys ()
          Return an enumeration of directive keys for this manifest element or null if there are none.
  String[] getDirectives ( String key)
          Returns an array of string values for the specified directives or null if it does not exist.
  Enumeration getKeys ()
          Returns an enumeration of attribute keys for this manifest element or null if none exist.
  String getValue ()
          Returns the value of the manifest element.
  String[] getValueComponents ()
          Returns the value components of the manifest element.
static  Map parseBundleManifest ( InputStream manifest, Map headers)
          Parses a bundle manifest and puts the header/value pairs into the supplied Map.
static  ManifestElement[] parseHeader ( String header, String value)
          Parses a manifest header value into an array of ManifestElements.
  String toString ()
           
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected 
String value
The value of the manifest element.


valueComponents

protected 
String[] valueComponents
The value components of the manifest element.


attributes

protected 
Hashtable attributes
The table of attributes for the manifest element.


directives

protected 
Hashtable directives
The table of directives for the manifest element.

Constructor Detail

ManifestElement

protected ManifestElement()
Constructs an empty manifest element with no value or attributes.

Method Detail

getValue

public 
String getValue()
Returns the value of the manifest element. The value returned is the complete value up to the first attribute. For example, the following manifest element:

 test1.jar;test2.jar;test3.jar;selection-filter="(os.name=Windows XP)"
 

This manifest element has a value of test1.jar;test2.jar;test3.jar

Returns:
the value of the manifest element.

getValueComponents

public 
String[] getValueComponents()
Returns the value components of the manifest element. The value components returned are the complete list of value components up to the first attribute. For example, the folowing manifest element:

 test1.jar;test2.jar;test3.jar;selection-filter="(os.name=Windows XP)"
 

This manifest element has the value components array { "test1.jar", "test2.jar", "test3.jar" } Each value component is delemited by a semi-colon (';').

Returns:
the String[] of value components

getAttribute

public 
String getAttribute(
String key)
Returns the value for the specified attribute or null if it does not exist. If the attribute has multiple values specified then the last value specified is returned. For example the following manifest element:

 elementvalue; myattr="value1"; myattr="value2"
 

specifies two values for the attribute key myattr. In this case value2 will be returned because it is the last value specified for the attribute myattr.

Parameters:
key - the attribute key to return the value for
Returns:
the attribute value or null

getAttributes

public 
String[] getAttributes(
String key)
Returns an array of values for the specified attribute or null if the attribute does not exist.

Parameters:
key - the attribute key to return the values for
Returns:
the array of attribute values or null
See Also:
getAttribute(String)

getKeys

public 
Enumeration getKeys()
Returns an enumeration of attribute keys for this manifest element or null if none exist.

Returns:
the enumeration of attribute keys or null if none exist.

addAttribute

protected void addAttribute(
String key,
                            
String value)
Add an attribute to this manifest element.

Parameters:
key - the key of the attribute
value - the value of the attribute

getDirective

public 
String getDirective(
String key)
Returns the value for the specified directive or null if it does not exist. If the directive has multiple values specified then the last value specified is returned. For example the following manifest element:

 elementvalue; mydir:="value1"; mydir:="value2"
 

specifies two values for the directive key mydir. In this case value2 will be returned because it is the last value specified for the directive mydir.

Parameters:
key - the directive key to return the value for
Returns:
the directive value or null

getDirectives

public 
String[] getDirectives(
String key)
Returns an array of string values for the specified directives or null if it does not exist.

Parameters:
key - the directive key to return the values for
Returns:
the array of directive values or null
See Also:
getDirective(String)

getDirectiveKeys

public 
Enumeration getDirectiveKeys()
Return an enumeration of directive keys for this manifest element or null if there are none.

Returns:
the enumeration of directive keys or null

addDirective

protected void addDirective(
String key,
                            
String value)
Add a directive to this manifest element.

Parameters:
key - the key of the attribute
value - the value of the attribute

parseHeader

public static 
ManifestElement[] parseHeader(
String header,
                                            
String value)
                                     throws 
BundleException
Parses a manifest header value into an array of ManifestElements. Each ManifestElement returned will have a non-null value returned by getValue().

Parameters:
header - the header name to parse. This is only specified to provide error messages when the header value is invalid.
value - the header value to parse.
Returns:
the array of ManifestElements that are represented by the header value; null will be returned if the value specified is null or if the value does not parse into one or more ManifestElements.
Throws:
BundleException - if the header value is invalid

getArrayFromList

public static 
String[] getArrayFromList(
String stringList)
Returns the result of converting a list of comma-separated tokens into an array.

Parameters:
stringList - the initial comma-separated string
Returns:
the array of string tokens or null if there are none

getArrayFromList

public static 
String[] getArrayFromList(
String stringList,
                                        
String separator)
Returns the result of converting a list of tokens into an array. The tokens are split using the specified separator.

Parameters:
stringList - the initial string list
separator - the separator to use to split the list into tokens.
Returns:
the array of string tokens. If there are none then an empty array is returned.
Since:
3.2

parseBundleManifest

public static 
Map parseBundleManifest(
InputStream manifest,
                                      
Map headers)
                               throws 
IOException,
                                      
BundleException
Parses a bundle manifest and puts the header/value pairs into the supplied Map. Only the main section of the manifest is parsed (up to the first blank line). All other sections are ignored. If a header is duplicated then only the last value is stored in the map.

The supplied input stream is consumed by this method and will be closed. If the supplied Map is null then a Map is created to put the header/value pairs into.

Parameters:
manifest - an input stream for a bundle manifest.
headers - a map used to put the header/value pairs from the bundle manifest. This value may be null.
Returns:
the map with the header/value pairs from the bundle manifest
Throws:
BundleException - if the manifest has an invalid syntax
IOException - if an error occurs while reading the manifest

toString

public 
String toString()
Overrides:
toString in class Object

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire