Author: mturk Date: Wed Apr 15 15:33:07 2009 New Revision: 765242 URL: http://svn.apache.org/viewvc?rev=765242&view=rev Log: Add CommandType Enum
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/CommandType.java (with props) Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/CommandType.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/CommandType.java?rev=765242&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/CommandType.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/CommandType.java Wed Apr 15 15:33:07 2009 @@ -0,0 +1,83 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.runtime; + +/** + * Set what type of command the child process will call. + * @param cmd The type of command. One of: + * <PRE> + * SHELLCMD -- Anything that the shell can handle + * PROGRAM -- Executable program (default) + * PROGRAM_ENV -- Executable program, copy environment + * PROGRAM_PATH -- Executable program on PATH, copy env + * </PRE> + */ +public enum CommandType +{ + /** Use the shell to invoke the program. + * <br/>Defined integer value is: <code>0</code> + */ + SHELLCMD( 0), + /** Invoke the program directly, no copied env. + * <br/>Defined integer value is: <code>1</code> + */ + PROGRAM( 1), + /** Invoke the program, replicating our environment. + * <br/>Defined integer value is: <code>2</code> + */ + PROGRAM_ENV( 2), + /** Find program on PATH, use our environment. + * <br/>Defined integer value is: <code>3</code> + */ + PROGRAM_PATH( 3), + /** Use the shell to invoke the program, + * replicating our environment. + * <br/>Defined integer value is: <code>4</code> + */ + SHELLCMD_ENV( 4); + + + private int value; + private CommandType(int v) + { + value = v; + } + + /** Integer representing the value of this Enum. + */ + public int valueOf() + { + return value; + } + + /** Return the <code>CommandType</code> matching the specified <code>value</code>. + * @param value Integer value matching one of the + * <code>CommandType</code> enums. + * @throws IllegalArgumentException if <code>value</code> does not match + * to and of the <code>CommandType</code> enums. + */ + public static CommandType valueOf(int value) + throws IllegalArgumentException + { + for (CommandType e : values()) { + if (e.value == value) + return e; + } + throw new IllegalArgumentException("Invalid initializer: " + value); + } + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/CommandType.java ------------------------------------------------------------------------------ svn:eol-style = native