com.redstarhackers.craftsman.util
Class CapabilityHelper

java.lang.Object
  extended by com.redstarhackers.craftsman.util.CapabilityHelper

public class CapabilityHelper
extends java.lang.Object

TODO Class summary sentence. Class documentation.

Version:
$Revision: 102 $
Author:
$Author: kostya $

Constructor Summary
protected CapabilityHelper(Project project)
           
 
Method Summary
 boolean containsCapabilityType(java.util.Set capabilities, java.lang.String typeName)
           
 java.util.Set extractOptionValues(CapabilityType capability, java.lang.String optionName)
           
 java.util.Set getCapabilitiesOfType(java.util.Set capabilities, java.lang.String typeName)
           
 CapabilityType getCapability(java.util.Set capabilities, java.lang.String name)
           
 CapabilityType getCapabilityOfType(java.util.Set capabilities, java.lang.String typeName)
           
 CapabilityDefinition getDefinition(java.lang.String name)
          Retrieve a definition, fully initialized and ready to use.
static CapabilityHelper getInstance(Project project)
          Retrieve the singleton instance.
 void initializeCapabilities(java.util.Set capabilities)
           
 boolean isRegistered(java.lang.String name)
          Return whether the name is a registered capability definition.
 void register(CapabilityDefinition def)
           
 void register(java.util.Set defs)
           
 void verifyAgainstDefinition(CapabilityType capability)
          Verifies a capability and its contained options and values against the registered definition, marking it initialilzed if it checks out.
 void verifyExclusivity(java.util.Set capabilities)
           
 void verifyRegistered(java.lang.String name)
          Verify the name is a registered capability definition, throwing a BuildException if it isn't (useful in verification steps).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CapabilityHelper

protected CapabilityHelper(Project project)
Method Detail

getInstance

public static CapabilityHelper getInstance(Project project)
Retrieve the singleton instance. This method calls the singleton initializer if the singleton is not initialized. The initializer is synchronized and thread safe.

Returns:
the singleton instance.

isRegistered

public boolean isRegistered(java.lang.String name)
Return whether the name is a registered capability definition.

Returns:
true if it is in the registry, false otherwise.

verifyRegistered

public void verifyRegistered(java.lang.String name)
                      throws BuildException
Verify the name is a registered capability definition, throwing a BuildException if it isn't (useful in verification steps).

Throws:
BuildException

register

public void register(CapabilityDefinition def)

register

public void register(java.util.Set defs)

getDefinition

public CapabilityDefinition getDefinition(java.lang.String name)
Retrieve a definition, fully initialized and ready to use. This may entail retrieving the parents this definition extends and initializing them, adding the parent options to this option. Initialization is done only once.

Parameters:
name - the name of the capability
Returns:
an initialized capability definition for the name, or null if it isn't found.

verifyAgainstDefinition

public void verifyAgainstDefinition(CapabilityType capability)
Verifies a capability and its contained options and values against the registered definition, marking it initialilzed if it checks out.

Parameters:
capability - the capability to verify
Throws:
BuildException - if there is anything wrong with the given capability when compared to its definition.

verifyExclusivity

public void verifyExclusivity(java.util.Set capabilities)

extractOptionValues

public java.util.Set extractOptionValues(CapabilityType capability,
                                         java.lang.String optionName)

getCapability

public CapabilityType getCapability(java.util.Set capabilities,
                                    java.lang.String name)

containsCapabilityType

public boolean containsCapabilityType(java.util.Set capabilities,
                                      java.lang.String typeName)

getCapabilitiesOfType

public java.util.Set getCapabilitiesOfType(java.util.Set capabilities,
                                           java.lang.String typeName)

getCapabilityOfType

public CapabilityType getCapabilityOfType(java.util.Set capabilities,
                                          java.lang.String typeName)

initializeCapabilities

public void initializeCapabilities(java.util.Set capabilities)