View Javadoc

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