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, XRequirement, Requirement
Direct Known Subclasses:
AbstractBundleRequirement, AbstractHostRequirement, AbstractPackageRequirement

public class AbstractRequirement
extends Object
implements XRequirement

The abstract implementation of a XRequirement.

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

Constructor Summary
protected AbstractRequirement(Resource resource, String namespace, Map<String,Object> atts, Map<String,String> dirs)
           
 
Method Summary
<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
protected  Set<String> getMandatoryAttributes()
           
 String getNamespace()
          Returns the namespace of this requirement.
 Resource getResource()
          Returns the resource declaring this requirement.
 boolean isOptional()
          A flag indicating that this is an optional requirement.
 boolean matches(XCapability cap)
          Matches this requirement against the given capability.
protected  boolean matchFilterValue(XCapability cap)
           
protected  boolean matchNamespaceValue(XCapability cap)
           
<T> T
removeAttachment(Class<T> clazz)
          Remove an attached object for a given key
 String toString()
           
protected  void validateAttributes(Map<String,Object> atts)
           
 
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

protected AbstractRequirement(Resource resource,
                              String namespace,
                              Map<String,Object> atts,
                              Map<String,String> dirs)
Method Detail

validateAttributes

protected void validateAttributes(Map<String,Object> atts)

getMandatoryAttributes

protected Set<String> getMandatoryAttributes()

getResource

public Resource getResource()
Description copied from interface: Requirement
Returns the resource declaring this requirement.

Specified by:
getResource in interface Requirement
Returns:
The resource declaring this requirement. This can be null if this requirement is synthesized.

getNamespace

public String getNamespace()
Description copied from interface: Requirement
Returns the namespace of this requirement.

Specified by:
getNamespace in interface Requirement
Returns:
The namespace of this 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 Requirement
Returns:
An unmodifiable map of directive names to directive values for this requirement, or an empty map if this requirement has no directives.

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 Requirement
Returns:
An unmodifiable map of attribute names to attribute values for this requirement, or an empty map if this requirement has no attributes.

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

matches

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

Specified by:
matches in interface XRequirement

matchNamespaceValue

protected boolean matchNamespaceValue(XCapability cap)

matchFilterValue

protected boolean matchFilterValue(XCapability cap)

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. All Rights Reserved.