org.jclouds.scriptbuilder.domain
Class SwitchArg

java.lang.Object
  extended by org.jclouds.scriptbuilder.domain.SwitchArg
All Implemented Interfaces:
AcceptsStatementVisitor, Statement

public class SwitchArg
extends Object
implements Statement, AcceptsStatementVisitor

Statement used in a shell script

Author:
Adrian Cole

Field Summary
static Map<OsFamily,String> OS_TO_CASE_PATTERN
           
static Map<OsFamily,String> OS_TO_END_SWITCH_PATTERN
           
static Map<OsFamily,String> OS_TO_SWITCH_PATTERN
           
 
Constructor Summary
SwitchArg(int arg, Map<String,Statement> valueToActions)
          Generates a switch statement based on arg.
 
Method Summary
 void accept(StatementVisitor visitor)
           
 boolean equals(Object obj)
           
 Iterable<String> functionDependencies(OsFamily family)
           
 int hashCode()
           
 String render(OsFamily family)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OS_TO_SWITCH_PATTERN

public static final Map<OsFamily,String> OS_TO_SWITCH_PATTERN

OS_TO_END_SWITCH_PATTERN

public static final Map<OsFamily,String> OS_TO_END_SWITCH_PATTERN

OS_TO_CASE_PATTERN

public static final Map<OsFamily,String> OS_TO_CASE_PATTERN
Constructor Detail

SwitchArg

public SwitchArg(int arg,
                 Map<String,Statement> valueToActions)
Generates a switch statement based on arg. If its value is found to be a key in valueToActions, the corresponding action is invoked.

Ex. arg is 1 - the first argument to the script
and valueToActions is {"start" -> "echo hello", "stop" -> "echo goodbye"}
the script created will respond accordingly:
./script start
<< returns hello
./script stop
<< returns goodbye

Parameters:
arg - - shell arg to switch on
valueToActions - - case statements, if the value of the arg matches a key, the corresponding value will be invoked.
Method Detail

render

public String render(OsFamily family)
Specified by:
render in interface Statement

functionDependencies

public Iterable<String> functionDependencies(OsFamily family)
Specified by:
functionDependencies in interface Statement

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

accept

public void accept(StatementVisitor visitor)
Specified by:
accept in interface AcceptsStatementVisitor


Copyright © 2009-2011 jclouds. All Rights Reserved.