org.rhq.bundle.filetemplate.recipe
Class RecipeContext

java.lang.Object
  extended by org.rhq.bundle.filetemplate.recipe.RecipeContext

public class RecipeContext
extends Object

Contains information that is gleened from a recipe during and after it is parsed.

Author:
John Mazzitelli

Constructor Summary
RecipeContext(String recipe)
           
 
Method Summary
 void addCommand(String exe, List<String> exeArgs)
          Adds a command that the recipe wants invoked.
 void addDeployFile(String filename, String directory)
           
 void addFile(String source, String destination)
           
 void addRealizedFile(String file)
           
 void addReplacementVariables(Set<String> replacementVariables)
           
 void addReplacementVariableValue(String name, String value)
          Adds the given name/value pair to the set of replacement variable values associated with this context.
 void addScript(String exe, List<String> exeArgs)
          Adds a script that the recipe wants invoked.
 void assignDefaultValueToReplacementVariable(String replacementVariable, String defaultValue)
          If a replacement varaible is known to have a default value, call this to set that default value.
 Map<String,String> getDeployFiles()
          Returns all the files that are to be deployed.
 DeploymentProperties getDeploymentProperties()
          Returns the deployment properties as defined in the recipe.
 Map<String,String> getFiles()
          Returns all the files that are strictly to be copied to some location.
 RecipeParser getParser()
          If this context is currently in use by a parser, this will be the reference to that parser.
 Set<String> getRealizedFiles()
          Returns the pathnames of all files that are to be realized (meaning, those that should have replacement variables replaced).
 String getRecipe()
          The full recipe that this context represents.
 Map<String,String> getReplacementVariableDefaultValues()
          Returns a map keyed on replacement variables whose values are the default values for the replacement variables.
 Set<String> getReplacementVariables()
          The names of all replacement variables that are found in the recipe.
 Configuration getReplacementVariableValues()
          If known, the returned value will contain values that are to be used to replace replacement variables found in the recipe.
 Set<String> getScriptFiles()
          Returns a set of all the names of scripts found in the recipe.
 boolean isUnknownRecipe()
          Returns true if the recipe content does not look like a valid type that can be at least attempted to be parsed.
 void setParser(RecipeParser parser)
           
 void setReplacementVariableValues(Configuration configuration)
           
 void setUnknownRecipe(boolean unknownRecipe)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RecipeContext

public RecipeContext(String recipe)
Method Detail

getParser

public RecipeParser getParser()
If this context is currently in use by a parser, this will be the reference to that parser.

Returns:
parser currently using this context

setParser

public void setParser(RecipeParser parser)

isUnknownRecipe

public boolean isUnknownRecipe()
Returns true if the recipe content does not look like a valid type that can be at least attempted to be parsed. In other words, this returns true if the recipe does not look like a file template recipe. This returns false if it looks like its file template recipe (even though it may have syntax errors in it).

Returns:
flag to indicate if the recipe looks like it might be a file template recipe

setUnknownRecipe

public void setUnknownRecipe(boolean unknownRecipe)

getRecipe

public String getRecipe()
The full recipe that this context represents.

Returns:
the actual recipe text

getDeploymentProperties

public DeploymentProperties getDeploymentProperties()
Returns the deployment properties as defined in the recipe.

Returns:
the deployment properties

getDeployFiles

public Map<String,String> getDeployFiles()
Returns all the files that are to be deployed. The key is the bundle file's name, the value is the directory where the bundle is to be deployed to.

Returns:
map of all files to be deployed and the location where they are to be deployed

addDeployFile

public void addDeployFile(String filename,
                          String directory)

getFiles

public Map<String,String> getFiles()
Returns all the files that are strictly to be copied to some location. The key is the bundle file's name, the value is the full path and filename where the file should be copied to. No processing of these files will occur other than they are copied.

Returns:
map of all files to be deployed and the location where they are to be deployed

addFile

public void addFile(String source,
                    String destination)

getRealizedFiles

public Set<String> getRealizedFiles()
Returns the pathnames of all files that are to be realized (meaning, those that should have replacement variables replaced).

Returns:
set of all realized files

addRealizedFile

public void addRealizedFile(String file)

getReplacementVariables

public Set<String> getReplacementVariables()
The names of all replacement variables that are found in the recipe.

Returns:
the replacement variables

addReplacementVariables

public void addReplacementVariables(Set<String> replacementVariables)

assignDefaultValueToReplacementVariable

public void assignDefaultValueToReplacementVariable(String replacementVariable,
                                                    String defaultValue)
If a replacement varaible is known to have a default value, call this to set that default value.

Parameters:
replacementVariable - the variable whose default is being set
defaultValue - the value of the default for the given replacement variable

getReplacementVariableDefaultValues

public Map<String,String> getReplacementVariableDefaultValues()
Returns a map keyed on replacement variables whose values are the default values for the replacement variables. Note that not all replacement variables found in getReplacementVariables() will have an associated entry in the returned map (that is, not all variables have a default value).

Returns:
the map of all known default values for replacement variables

getReplacementVariableValues

public Configuration getReplacementVariableValues()
If known, the returned value will contain values that are to be used to replace replacement variables found in the recipe.

Returns:
the replacement variable values

setReplacementVariableValues

public void setReplacementVariableValues(Configuration configuration)

addReplacementVariableValue

public void addReplacementVariableValue(String name,
                                        String value)
Adds the given name/value pair to the set of replacement variable values associated with this context.

Parameters:
name -
value -

getScriptFiles

public Set<String> getScriptFiles()
Returns a set of all the names of scripts found in the recipe.

Returns:
script names

addScript

public void addScript(String exe,
                      List<String> exeArgs)
Adds a script that the recipe wants invoked.

Parameters:
exe - the script executable
exeArgs - the arguments to pass to the script

addCommand

public void addCommand(String exe,
                       List<String> exeArgs)
Adds a command that the recipe wants invoked. This command refers to an existing executable or shell command.

Parameters:
cmd - the main executable that this command wants to execute
exeArgs - the arguments to pass to the command executable

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008-2011 Red Hat, Inc.. All Rights Reserved.