org.jboss.osgi.resolver.spi
Class AbstractPackageRequirement

java.lang.Object
  extended by org.jboss.osgi.resolver.spi.AbstractPackageRequirement
All Implemented Interfaces:
XAttachmentSupport, XAttributeSupport, XDirectiveSupport, XElement, XPackageRequirement, XRequirement, Requirement

public class AbstractPackageRequirement
extends Object
implements XPackageRequirement

The abstract implementation of a XPackageRequirement.

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

Constructor Summary
AbstractPackageRequirement(XRequirement delegate)
           
 
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.
 boolean equals(Object obj)
          Compares this Requirement to another Requirement.
<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()
          Returns the namespace of this requirement.
 String getPackageName()
          The package name
 Resource getResource()
          Returns the resource declaring this requirement.
 org.jboss.osgi.metadata.VersionRange getVersionRange()
          The package version range.
 int hashCode()
          Returns the hashCode of this Requirement.
 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(Capability cap)
          Matches this requirement against the given capability.
<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, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.osgi.resolver.XRequirement
adapt, isOptional, validate
 
Methods inherited from interface org.jboss.osgi.resolver.XAttachmentSupport
addAttachment, getAttachment, removeAttachment
 
Methods inherited from interface org.jboss.osgi.resolver.XAttributeSupport
getAttribute, getAttributes
 
Methods inherited from interface org.jboss.osgi.resolver.XDirectiveSupport
getDirective, getDirectives
 
Methods inherited from interface org.osgi.resource.Requirement
equals, getAttributes, getDirectives, getNamespace, getResource, hashCode
 

Constructor Detail

AbstractPackageRequirement

public AbstractPackageRequirement(XRequirement delegate)
Method Detail

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: XPackageRequirement
The package version range.

Specified by:
getVersionRange in interface XPackageRequirement

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

matches

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

Specified by:
matches in interface XRequirement

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

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.

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.

validate

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

Specified by:
validate in interface XRequirement

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

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

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

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.

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.

isOptional

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

Specified by:
isOptional in interface XRequirement

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

equals

public boolean equals(Object obj)
Description copied from interface: Requirement
Compares this Requirement to another Requirement.

This Requirement is equal to another Requirement if they have the same namespace, directives and attributes and are declared by the same resource.

Specified by:
equals in interface Requirement
Overrides:
equals in class Object
Parameters:
obj - The object to compare against this Requirement.
Returns:
true if this Requirement is equal to the other object; false otherwise.

hashCode

public int hashCode()
Description copied from interface: Requirement
Returns the hashCode of this Requirement.

Specified by:
hashCode in interface Requirement
Overrides:
hashCode in class Object
Returns:
The hashCode of this Requirement.

toString

public String toString()
Overrides:
toString in class Object


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