org.jboss.osgi.resolver.spi
Class AbstractCapability

java.lang.Object
  extended by org.jboss.osgi.resolver.spi.AbstractCapability
All Implemented Interfaces:
XAttachmentSupport, XAttributeSupport, XCapability, XDirectiveSupport, XElement, XHostCapability, XIdentityCapability, XPackageCapability, XResourceCapability, org.osgi.resource.Capability
Direct Known Subclasses:
AbstractBundleCapability

public class AbstractCapability
extends Object
implements XIdentityCapability, XHostCapability, XPackageCapability, XResourceCapability

The abstract implementation of a XCapability.

Since:
02-Jul-2010
Author:
thomas.diesler@jboss.com

Constructor Summary
AbstractCapability(XResource resource, String namespace, Map<String,Object> atts, Map<String,String> dirs)
           
 
Method Summary
<T extends XCapability>
T
adapt(Class<T> clazz)
          Adapt this capability to another type
<T> T
addAttachment(Class<T> clazz, T value)
          Attach an arbirtary object with this element.
<T> T
getAttachment(Class<T> clazz)
          Get the attached object for a given key
 Object getAttribute(String key)
          Get the value of the given attribute
 Map<String,Object> getAttributes()
          Get the attributes
 String getDirective(String key)
          Get the value of the given directive
 Map<String,String> getDirectives()
          Get the directives
 String getNamespace()
           
 String getPackageName()
          The package name
 XResource getResource()
           
 String getSymbolicName()
          The symbolic name of this resource.
 String getType()
          The resource type
 org.osgi.framework.Version getVersion()
          The version of this resource.
 boolean isSingleton()
          A flag to indicate that this resource is a singleton
<T> T
removeAttachment(Class<T> clazz)
          Remove an attached object for a given key
 String toString()
           
 void validate()
          Validate the capability
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.osgi.resolver.XAttachmentSupport
addAttachment, getAttachment, removeAttachment
 
Methods inherited from interface org.osgi.resource.Capability
equals, hashCode
 

Constructor Detail

AbstractCapability

public AbstractCapability(XResource resource,
                          String namespace,
                          Map<String,Object> atts,
                          Map<String,String> dirs)
Method Detail

getResource

public XResource getResource()
Specified by:
getResource in interface org.osgi.resource.Capability

getNamespace

public String getNamespace()
Specified by:
getNamespace in interface org.osgi.resource.Capability

getDirectives

public Map<String,String> getDirectives()
Description copied from interface: XDirectiveSupport
Get the directives

Specified by:
getDirectives in interface XDirectiveSupport
Specified by:
getDirectives in interface org.osgi.resource.Capability

getDirective

public String getDirective(String key)
Description copied from interface: XDirectiveSupport
Get the value of the given directive

Specified by:
getDirective in interface XDirectiveSupport
Returns:
null if no such directive is associated with this capability

getAttributes

public Map<String,Object> getAttributes()
Description copied from interface: XAttributeSupport
Get the attributes

Specified by:
getAttributes in interface XAttributeSupport
Specified by:
getAttributes in interface org.osgi.resource.Capability

getAttribute

public Object getAttribute(String key)
Description copied from interface: XAttributeSupport
Get the value of the given attribute

Specified by:
getAttribute in interface XAttributeSupport
Returns:
null if no such attribute is associated with this capability

validate

public void validate()
Description copied from interface: XCapability
Validate the capability

Specified by:
validate in interface XCapability

adapt

public <T extends XCapability> T adapt(Class<T> clazz)
Description copied from interface: XCapability
Adapt this capability to another type

Specified by:
adapt in interface XCapability

getPackageName

public String getPackageName()
Description copied from interface: XPackageCapability
The package name

Specified by:
getPackageName in interface XPackageCapability

getSymbolicName

public String getSymbolicName()
Description copied from interface: XIdentityCapability
The symbolic name of this resource.

Specified by:
getSymbolicName in interface XHostCapability
Specified by:
getSymbolicName in interface XIdentityCapability
Specified by:
getSymbolicName in interface XResourceCapability

getVersion

public org.osgi.framework.Version getVersion()
Description copied from interface: XIdentityCapability
The version of this resource.

Specified by:
getVersion in interface XHostCapability
Specified by:
getVersion in interface XIdentityCapability
Specified by:
getVersion in interface XPackageCapability
Specified by:
getVersion in interface XResourceCapability

getType

public String getType()
Description copied from interface: XIdentityCapability
The resource type

Specified by:
getType in interface XIdentityCapability
See Also:
IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE

isSingleton

public boolean isSingleton()
Description copied from interface: XIdentityCapability
A flag to indicate that this resource is a singleton

Specified by:
isSingleton in interface XIdentityCapability

toString

public String toString()
Overrides:
toString in class Object

addAttachment

public <T> T addAttachment(Class<T> clazz,
                           T value)
Description copied from interface: XAttachmentSupport
Attach an arbirtary object with this element.

Specified by:
addAttachment in interface XAttachmentSupport
Parameters:
clazz - key for the attachment
Returns:
The previously attachment object or null

getAttachment

public <T> T getAttachment(Class<T> clazz)
Description copied from interface: XAttachmentSupport
Get the attached object for a given key

Specified by:
getAttachment in interface XAttachmentSupport
Parameters:
clazz - key for the attachment
Returns:
The attached object or null

removeAttachment

public <T> T removeAttachment(Class<T> clazz)
Description copied from interface: XAttachmentSupport
Remove an attached object for a given key

Specified by:
removeAttachment in interface XAttachmentSupport
Parameters:
clazz - key for the attachment
Returns:
The attached object or null


Copyright © 2012 JBoss by Red Hat. All Rights Reserved.