org.jclouds.scriptbuilder
Class ScriptBuilder

java.lang.Object
  extended by org.jclouds.scriptbuilder.ScriptBuilder
All Implemented Interfaces:
AcceptsStatementVisitor, Statement
Direct Known Subclasses:
InitBuilder

public class ScriptBuilder
extends Object
implements Statement, AcceptsStatementVisitor

Creates a shell script.

Author:
Adrian Cole

Constructor Summary
ScriptBuilder()
           
 
Method Summary
 void accept(StatementVisitor visitor)
           
 ScriptBuilder addEnvironmentVariableScope(String scopeName, Map<String,String> variables)
          Exports a variable inside the script
 ScriptBuilder addStatement(Statement statement)
           
static Statement call(String fn, String... args)
           
static Statement findPid(String pid)
           
static Statement forget(String instanceName, String script, String logDir)
           
 Iterable<String> functionDependencies(OsFamily family)
           
 String render(OsFamily osFamily)
          builds the shell script, by adding the following shell declaration line variable exports case/switch
static Map<String,String> resolveFunctionDependenciesForStatements(Map<String,String> knownFunctions, Iterable<Statement> statements, OsFamily osFamily)
           
 ScriptBuilder unsetEnvironmentVariable(String name)
          Unsets a variable to ensure it is set within the script.
static void writeFunctions(Map<String,String> functionsToWrite, OsFamily osFamily, StringBuilder builder)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptBuilder

public ScriptBuilder()
Method Detail

addStatement

public ScriptBuilder addStatement(Statement statement)

unsetEnvironmentVariable

public ScriptBuilder unsetEnvironmentVariable(String name)
Unsets a variable to ensure it is set within the script.


addEnvironmentVariableScope

public ScriptBuilder addEnvironmentVariableScope(String scopeName,
                                                 Map<String,String> variables)
Exports a variable inside the script


forget

public static Statement forget(String instanceName,
                               String script,
                               String logDir)

findPid

public static Statement findPid(String pid)

call

public static Statement call(String fn,
                             String... args)

render

public String render(OsFamily osFamily)
builds the shell script, by adding the following
  1. shell declaration line
  2. variable exports
  3. case/switch

Specified by:
render in interface Statement
Parameters:
osFamily - whether to write a cmd or bash script.

writeFunctions

public static void writeFunctions(Map<String,String> functionsToWrite,
                                  OsFamily osFamily,
                                  StringBuilder builder)

resolveFunctionDependenciesForStatements

public static Map<String,String> resolveFunctionDependenciesForStatements(Map<String,String> knownFunctions,
                                                                          Iterable<Statement> statements,
                                                                          OsFamily osFamily)

functionDependencies

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

accept

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


Copyright © 2009-2012 jclouds. All Rights Reserved.