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.manager;
18  
19  import net.sf.asterisk.AsteriskVersion;
20  import net.sf.asterisk.manager.action.ManagerAction;
21  
22  /***
23   * Transforms ManagerActions to Strings suitable to be sent to Asterisk.<br>
24   * The attributes are determined using reflection.
25   * 
26   * @author srt
27   * @version $Id: ActionBuilder.java,v 1.7 2005/11/08 15:25:18 srt Exp $
28   */
29  public interface ActionBuilder
30  {
31      /***
32       * Sets the version of the Asterisk server to built the action for.
33       * 
34       * @param asteriskVersion the version of the target Asterisk server.
35       * @since 0.2
36       */
37      public void setTargetVersion(AsteriskVersion targetVersion);
38  
39      /***
40       * Builds a String suitable to be sent to Asterisk based on the given action object.<br>
41       * Asterisk actions consist of an unordered set of key value pairs corresponding to the
42       * attributes of the ManagerActions. Key and value are separated by a colon (":"), key value
43       * pairs by a CR/NL ("\r\n"). An action is terminated by an empty line ("\r\n\r\n").
44       * 
45       * @param action the action to transform
46       * @return a String representing the given action in an asterisk compatible format
47       */
48      String buildAction(final ManagerAction action);
49  
50      /***
51       * Builds a String suitable to be sent to Asterisk based on the given action object.<br>
52       * Asterisk actions consist of an unordered set of key value pairs corresponding to the
53       * attributes of the ManagerActions. Key and value are separated by a colon (":"), key value
54       * pairs by a CR/NL ("\r\n"). An action is terminated by an empty line ("\r\n\r\n").
55       * 
56       * @param action the action to transform
57       * @param internalActionId the internal action id to add
58       * @return a String representing the given action in an asterisk compatible format
59       */
60      String buildAction(final ManagerAction action, final String internalActionId);
61  }