org.jboss.osgi.resolver.spi
Class AbstractRequirement

java.lang.Object
  extended by org.jboss.osgi.resolver.spi.AbstractRequirement
All Implemented Interfaces:
XAttachmentSupport, XAttributeSupport, XDirectiveSupport, XElement, XHostRequirement, XPackageRequirement, XRequirement, XResourceRequirement, org.osgi.resource.Requirement
Direct Known Subclasses:
AbstractBundleRequirement

public class AbstractRequirement
extends Object
implements XHostRequirement, XPackageRequirement, XResourceRequirement

The abstract implementation of a XRequirement.

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

Constructor Summary
AbstractRequirement(XResource resource, String namespace, Map<String,Object> atts, Map<String,String> dirs)
           
 
Method Summary
<T extends XRequirement>
T
adapt(Class<T> clazz)
          Adapt this requirement 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
static org.osgi.framework.Filter getFilterFromDirective(org.osgi.resource.Requirement req)
           
 String getNamespace()
           
 String getPackageName()
          The package name
 org.osgi.resource.Resource getResource()
           
 String getSymbolicName()
          The bundle symbolic name
 org.jboss.osgi.metadata.VersionRange getVersionRange()
          The bundle version range
 String getVisibility()
          Get the value of the visibility directive
 boolean isDynamic()
          A flag indicating that this is a dynamic package requirement
 boolean isOptional()
          A flag indicating that this is an optional requirement.
 boolean matches(org.osgi.resource.Capability cap)
          Matches this requirement against the given capability.
static String namespaceValueFromFilter(org.osgi.framework.Filter filter, String namespace)
           
<T> T
removeAttachment(Class<T> clazz)
          Remove an attached object for a given key
 String toString()
           
 void validate()
          Validate the requirement
 
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.Requirement
equals, hashCode
 

Constructor Detail

AbstractRequirement

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

getResource

public org.osgi.resource.Resource getResource()
Specified by:
getResource in interface org.osgi.resource.Requirement

validate

public void validate()
Description copied from interface: XRequirement
Validate the requirement

Specified by:
validate in interface XRequirement

getFilterFromDirective

public static org.osgi.framework.Filter getFilterFromDirective(org.osgi.resource.Requirement req)

namespaceValueFromFilter

public static String namespaceValueFromFilter(org.osgi.framework.Filter filter,
                                              String namespace)

getNamespace

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

isOptional

public boolean isOptional()
Description copied from interface: XRequirement
A flag indicating that this is an optional requirement.

Specified by:
isOptional in interface XRequirement

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.Requirement

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.Requirement

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

adapt

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

Specified by:
adapt in interface XRequirement

matches

public boolean matches(org.osgi.resource.Capability cap)
Description copied from interface: XRequirement
Matches this requirement against the given capability.

Specified by:
matches in interface XRequirement

getVisibility

public String getVisibility()
Description copied from interface: XResourceRequirement
Get the value of the visibility directive

Specified by:
getVisibility in interface XResourceRequirement
See Also:
BundleNamespace#REQUIREMENT_VISIBILITY_DIRECTIVE}

getSymbolicName

public String getSymbolicName()
Description copied from interface: XHostRequirement
The bundle symbolic name

Specified by:
getSymbolicName in interface XHostRequirement
Specified by:
getSymbolicName in interface XResourceRequirement

getPackageName

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

Specified by:
getPackageName in interface XPackageRequirement

getVersionRange

public org.jboss.osgi.metadata.VersionRange getVersionRange()
Description copied from interface: XHostRequirement
The bundle version range

Specified by:
getVersionRange in interface XHostRequirement
Specified by:
getVersionRange in interface XPackageRequirement
Specified by:
getVersionRange in interface XResourceRequirement

isDynamic

public boolean isDynamic()
Description copied from interface: XPackageRequirement
A flag indicating that this is a dynamic package requirement

Specified by:
isDynamic in interface XPackageRequirement

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.