/** * Creates a deep copy of this instance. * * @see Cloneable#clone() */ public ProcessBuilder copy() { final ProcessBuilder builder = new ProcessBuilder(); builder.inherit_parent_environment = inherit_parent_environment; builder.parent_environment = parent_environment; builder.executable = executable; builder.env = env.copy(); builder.arguments.addAll(arguments); builder.listeners.addAll(listeners); return builder; }
public IProcess start() { if (executable == null) { throw new IllegalStateException("executable must be set before launching a child process"); } return impl.launch( inherit_parent_environment, env.toCoalescedEnvironmentVariableBlock(getParentEnvironmentVariableBlock()), getCommandLine(), getListeners()); }
/** * Returns an unmodifiable {@link Map} holding the list of environment variables (their name and * value) that will be provided to the child process upon creation. * * @return An unmodifiable {@link Map} containing the list of currently set environment variables. */ public Map<String, String> produceEnvironmentVariableMap() { final Map<String, String> vars = new LinkedHashMap<String, String>(10, 0.8f); env.coalescedView( getParentEnvironmentVariableBlock(), new EnvironmentVariableBlockBuilder.IVisitor() { @Override public boolean visit(String name, String value) { vars.put(name, value); return true; } }); return Collections.unmodifiableMap(vars); }
/** * Returns an array of {@link IEnvironmentVariable} instances representing environment variables * (their name and value) that will be provided to the child process upon creation. * * @return An unmodifiable {@link Set} of {@link IEnvironmentVariable} instances representing the * list of currently set environment variables. */ public Set<IEnvironmentVariable> getEnvironmentVariables() { final Set<IEnvironmentVariable> vars = new LinkedHashSet<IEnvironmentVariable>(10, 0.8f); env.coalescedView( getParentEnvironmentVariableBlock(), new EnvironmentVariableBlockBuilder.IVisitor() { @Override public boolean visit(String name, String value) { vars.add(new EnvironmentVariable(name, value)); return true; } }); return Collections.unmodifiableSet(vars); }