com.springsource.util.osgi.manifest.internal
Class StandardBundleManifest

java.lang.Object
  extended by com.springsource.util.osgi.manifest.internal.StandardBundleManifest
All Implemented Interfaces:
BundleManifest

public class StandardBundleManifest
extends java.lang.Object
implements BundleManifest

Concurrent Semantics
Not thread-safe.


Nested Class Summary
static class StandardBundleManifest.WriterOutputStream
           
 
Field Summary
private  CaseInsensitiveMap<java.lang.String> contents
           
private  CaseInsensitiveMap<Parseable> headers
           
private static java.lang.String MANIFEST_VERSION
           
 
Fields inherited from interface com.springsource.util.osgi.manifest.BundleManifest
IMPORT_BUNDLE, IMPORT_LIBRARY, MODULE_SCOPE, MODULE_TYPE
 
Constructor Summary
StandardBundleManifest(ParserLogger logger)
           
StandardBundleManifest(ParserLogger logger, java.util.Dictionary<java.lang.String,java.lang.String> contents)
           
StandardBundleManifest(ParserLogger logger, ManifestContents manifestContents)
           
StandardBundleManifest(ParserLogger logger, java.util.Map<java.lang.String,java.lang.String> contents)
           
StandardBundleManifest(ParserLogger logger, java.io.Reader reader)
           
 
Method Summary
private static CaseInsensitiveMap<Parseable> createHeadersMap(HeaderParser parser)
           
private static java.util.Map<java.lang.String,java.lang.String> dictionaryToMap(java.util.Dictionary<java.lang.String,java.lang.String> contents)
           
 BundleActivationPolicy getBundleActivationPolicy()
          Returns the Bundle-ActivationPolicy header, never null.
 java.util.List<java.lang.String> getBundleClasspath()
          Returns a List containing an item for each entry in the comma-separated Bundle-Classpath header.
 java.lang.String getBundleDescription()
          Returns the value of the Bundle-Description header, or null if no description is specified.
 int getBundleManifestVersion()
          Returns the Bundle-ManifestVersion header, or 1 if no manifest version is specified.
 java.lang.String getBundleName()
          Returns the Bundle-Name header, or null if no name is specified.
 BundleSymbolicName getBundleSymbolicName()
          Returns the Bundle-SymbolicName header, never null.
 java.net.URL getBundleUpdateLocation()
          Returns the value of the Bundle-UpdateLocation header, or null if no update location is specified.
 org.osgi.framework.Version getBundleVersion()
          Returns the value of the Bundle-Version header, or null if no version is specified.
 DynamicImportPackage getDynamicImportPackage()
          Returns the DynamicImport-Package header, never null.
 ExportPackage getExportPackage()
          Returns the Export-Package header, never null.
 FragmentHost getFragmentHost()
          Returns the Fragment-Host header, never null.
 java.lang.String getHeader(java.lang.String name)
          Returns the value of the header identified by the supplied name.
 ImportBundle getImportBundle()
          Returns the Import-Bundle header, never null.
 ImportLibrary getImportLibrary()
          Returns the Import-Library header, never null.
 ImportPackage getImportPackage()
          Returns the Import-Package header, never null.
 java.lang.String getModuleScope()
          Returns the value of the Module-Scope header, or null if no module scope is specified.
 java.lang.String getModuleType()
          Returns the value of the Module-Type header, or null if no module type is specified.
 RequireBundle getRequireBundle()
          Returns the Require-Bundle header, never null.
private static CaseInsensitiveMap<Parseable> initializeHeaders(java.util.Map<java.lang.String,java.lang.String> contents, HeaderParser parser)
           
private static ManifestContents parseContents(java.io.Reader reader)
           
 void setBundleDescription(java.lang.String bundleDescription)
          Sets the value of the Bundle-Description header.
 void setBundleManifestVersion(int bundleManifestVersion)
          Sets the value of the Bundle-ManifestVersion header.
 void setBundleName(java.lang.String bundleName)
          Sets the value of the Bundle-Name header.
 void setBundleUpdateLocation(java.net.URL bundleUpdateLocation)
          Sets the value of the Bundle-UpdateLocation header.
 void setBundleVersion(org.osgi.framework.Version bundleVersion)
          Set the value of the Bundle-Version header.
 void setHeader(java.lang.String name, java.lang.String value)
          Sets the header with the supplied name to have the supplied value.
 void setModuleScope(java.lang.String moduleScope)
          Sets the value of the Module-Scope header.
 void setModuleType(java.lang.String moduleType)
          Sets the value of the Module-Type header.
private  void synchroniseContentsWithHeaders()
           
 java.util.Dictionary<java.lang.String,java.lang.String> toDictionary()
          Returns a snapshot of this manifest as a Dictionary
 java.lang.String toString()
          
 void write(java.io.Writer writer)
          Writes the contents of this manifest to the supplied writer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MANIFEST_VERSION

private static final java.lang.String MANIFEST_VERSION
See Also:
Constant Field Values

contents

private final CaseInsensitiveMap<java.lang.String> contents

headers

private final CaseInsensitiveMap<Parseable> headers
Constructor Detail

StandardBundleManifest

public StandardBundleManifest(ParserLogger logger)

StandardBundleManifest

public StandardBundleManifest(ParserLogger logger,
                              java.util.Map<java.lang.String,java.lang.String> contents)

StandardBundleManifest

public StandardBundleManifest(ParserLogger logger,
                              java.util.Dictionary<java.lang.String,java.lang.String> contents)

StandardBundleManifest

public StandardBundleManifest(ParserLogger logger,
                              java.io.Reader reader)
                       throws java.io.IOException
Throws:
java.io.IOException

StandardBundleManifest

public StandardBundleManifest(ParserLogger logger,
                              ManifestContents manifestContents)
Method Detail

dictionaryToMap

private static java.util.Map<java.lang.String,java.lang.String> dictionaryToMap(java.util.Dictionary<java.lang.String,java.lang.String> contents)

parseContents

private static ManifestContents parseContents(java.io.Reader reader)
                                       throws java.io.IOException
Throws:
java.io.IOException

initializeHeaders

private static CaseInsensitiveMap<Parseable> initializeHeaders(java.util.Map<java.lang.String,java.lang.String> contents,
                                                               HeaderParser parser)

createHeadersMap

private static CaseInsensitiveMap<Parseable> createHeadersMap(HeaderParser parser)

getBundleActivationPolicy

public BundleActivationPolicy getBundleActivationPolicy()
Returns the Bundle-ActivationPolicy header, never null.

Specified by:
getBundleActivationPolicy in interface BundleManifest
Returns:
the Bundle-ActivationPolicy header.

getBundleClasspath

public java.util.List<java.lang.String> getBundleClasspath()
Returns a List containing an item for each entry in the comma-separated Bundle-Classpath header. Returns an empty list if the manifest does not contain a Bundle-Classpath header.

Specified by:
getBundleClasspath in interface BundleManifest
Returns:
a List of the entries in the Bundle-Classpath header.

getBundleDescription

public java.lang.String getBundleDescription()
Returns the value of the Bundle-Description header, or null if no description is specified.

Specified by:
getBundleDescription in interface BundleManifest
Returns:
the value of the Bundle-Description header.

getBundleManifestVersion

public int getBundleManifestVersion()
Returns the Bundle-ManifestVersion header, or 1 if no manifest version is specified.

Specified by:
getBundleManifestVersion in interface BundleManifest
Returns:
the value of the Bundle-ManifestVersion header.

getBundleName

public java.lang.String getBundleName()
Returns the Bundle-Name header, or null if no name is specified.

Specified by:
getBundleName in interface BundleManifest
Returns:
the value of the Bundle-Name header.

getBundleSymbolicName

public BundleSymbolicName getBundleSymbolicName()
Returns the Bundle-SymbolicName header, never null.

Specified by:
getBundleSymbolicName in interface BundleManifest
Returns:
the Bundle-SymbolicName header.

getBundleUpdateLocation

public java.net.URL getBundleUpdateLocation()
Returns the value of the Bundle-UpdateLocation header, or null if no update location is specified.

Specified by:
getBundleUpdateLocation in interface BundleManifest
Returns:
the value of the Bundle-UpdateLocation header.

getDynamicImportPackage

public DynamicImportPackage getDynamicImportPackage()
Returns the DynamicImport-Package header, never null.

Specified by:
getDynamicImportPackage in interface BundleManifest
Returns:
the DynamicImport-Package header.

getExportPackage

public ExportPackage getExportPackage()
Returns the Export-Package header, never null.

Specified by:
getExportPackage in interface BundleManifest
Returns:
the Export-Package header.

getFragmentHost

public FragmentHost getFragmentHost()
Returns the Fragment-Host header, never null.

Specified by:
getFragmentHost in interface BundleManifest
Returns:
the Fragment-Host header.

getImportBundle

public ImportBundle getImportBundle()
Returns the Import-Bundle header, never null.

Specified by:
getImportBundle in interface BundleManifest
Returns:
the Import-Bundle header.

getImportLibrary

public ImportLibrary getImportLibrary()
Returns the Import-Library header, never null.

Specified by:
getImportLibrary in interface BundleManifest
Returns:
the Import-Library header.

getImportPackage

public ImportPackage getImportPackage()
Returns the Import-Package header, never null.

Specified by:
getImportPackage in interface BundleManifest
Returns:
the Import-Package header.

getModuleScope

public java.lang.String getModuleScope()
Returns the value of the Module-Scope header, or null if no module scope is specified.

Specified by:
getModuleScope in interface BundleManifest
Returns:
the value of the Module-Scope header.

getModuleType

public java.lang.String getModuleType()
Returns the value of the Module-Type header, or null if no module type is specified.

Specified by:
getModuleType in interface BundleManifest
Returns:
the value of the Module-Type header.

getRequireBundle

public RequireBundle getRequireBundle()
Returns the Require-Bundle header, never null.

Specified by:
getRequireBundle in interface BundleManifest
Returns:
the Require-Bundle header.

setBundleDescription

public void setBundleDescription(java.lang.String bundleDescription)
Sets the value of the Bundle-Description header.

Specified by:
setBundleDescription in interface BundleManifest
Parameters:
bundleDescription - The bundle's description

setBundleManifestVersion

public void setBundleManifestVersion(int bundleManifestVersion)
Sets the value of the Bundle-ManifestVersion header.

Specified by:
setBundleManifestVersion in interface BundleManifest
Parameters:
bundleManifestVersion - The bundle's bundle manifest version

setBundleName

public void setBundleName(java.lang.String bundleName)
Sets the value of the Bundle-Name header.

Specified by:
setBundleName in interface BundleManifest
Parameters:
bundleName - The bundle's name

setBundleUpdateLocation

public void setBundleUpdateLocation(java.net.URL bundleUpdateLocation)
Sets the value of the Bundle-UpdateLocation header.

Specified by:
setBundleUpdateLocation in interface BundleManifest
Parameters:
bundleUpdateLocation - The bundle's update location

setModuleScope

public void setModuleScope(java.lang.String moduleScope)
Sets the value of the Module-Scope header.

Specified by:
setModuleScope in interface BundleManifest
Parameters:
moduleScope - The bundle's module scope

setModuleType

public void setModuleType(java.lang.String moduleType)
Sets the value of the Module-Type header.

Specified by:
setModuleType in interface BundleManifest
Parameters:
moduleType - The bundle's module type

toDictionary

public java.util.Dictionary<java.lang.String,java.lang.String> toDictionary()
Returns a snapshot of this manifest as a Dictionary

Specified by:
toDictionary in interface BundleManifest
Returns:
This manifest in Dictionary form.

getBundleVersion

public org.osgi.framework.Version getBundleVersion()
Returns the value of the Bundle-Version header, or null if no version is specified.

Specified by:
getBundleVersion in interface BundleManifest
Returns:
the bundle's version

setBundleVersion

public void setBundleVersion(org.osgi.framework.Version bundleVersion)
Set the value of the Bundle-Version header.

Specified by:
setBundleVersion in interface BundleManifest
Parameters:
bundleVersion - bundle's version

getHeader

public java.lang.String getHeader(java.lang.String name)
Returns the value of the header identified by the supplied name.

Specified by:
getHeader in interface BundleManifest
Parameters:
name - the name of the header
Returns:
the value of the header

synchroniseContentsWithHeaders

private void synchroniseContentsWithHeaders()

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Sets the header with the supplied name to have the supplied value.

Specified by:
setHeader in interface BundleManifest
Parameters:
name - The name of the header
value - The value of the header

write

public void write(java.io.Writer writer)
           throws java.io.IOException
Description copied from interface: BundleManifest
Writes the contents of this manifest to the supplied writer

Specified by:
write in interface BundleManifest
Parameters:
writer - the writer to which the manifest is written
Throws:
java.io.IOException - if a problem occurs when writing out the manifest

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object