View Javadoc

1   /*
2    * Copyright  2004-2005 Stefan Reuter
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  package net.sf.asterisk.fastagi.command;
18  
19  /***
20   * Executes an application with the given options.<br>
21   * Returns whatever the application returns, or -2 if the application was not
22   * found.
23   * 
24   * @author srt
25   * @version $Id: ExecCommand.java,v 1.4 2005/04/10 07:44:48 srt Exp $
26   */
27  public class ExecCommand extends AGICommand
28  {
29      /***
30       * Serial version identifier.
31       */
32      private static final long serialVersionUID = 3904959746380281145L;
33  
34      /***
35       * The name of the application to execute.
36       */
37      private String application;
38  
39      /***
40       * The options to pass to the application.
41       */
42      private String options;
43  
44      /***
45       * Creates a new ExecCommand.
46       * 
47       * @param application the name of the application to execute.
48       */
49      public ExecCommand(String application)
50      {
51          this.application = application;
52      }
53  
54      /***
55       * Creates a new ExecCommand.
56       * 
57       * @param application the name of the application to execute.
58       * @param options the options to pass to the application.
59       */
60      public ExecCommand(String application, String options)
61      {
62          this.application = application;
63          this.options = options;
64      }
65  
66      /***
67       * Returns the name of the application to execute.
68       * 
69       * @return the name of the application to execute.
70       */
71      public String getApplication()
72      {
73          return application;
74      }
75  
76      /***
77       * Sets the name of the application to execute.
78       * 
79       * @param application the name of the application to execute.
80       */
81      public void setApplication(String application)
82      {
83          this.application = application;
84      }
85  
86      /***
87       * Returns the options to pass to the application.
88       * 
89       * @return the options to pass to the application.
90       */
91      public String getOptions()
92      {
93          return options;
94      }
95  
96      /***
97       * Sets the options to pass to the application.
98       * 
99       * @param options the options to pass to the application.
100      */
101     public void setOptions(String options)
102     {
103         this.options = options;
104     }
105 
106     public String buildCommand()
107     {
108         return "EXEC " + escapeAndQuote(application) + " "
109                 + escapeAndQuote(options);
110     }
111 }