View Javadoc
1   /*
2    * Copyright 2011 FatWire Corporation. All Rights Reserved.
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  package com.fatwire.gst.foundation.controller.action.support;
17  
18  import org.apache.commons.lang.StringUtils;
19  
20  import COM.FutureTense.Interfaces.ICS;
21  
22  import com.fatwire.gst.foundation.controller.action.ActionNameResolver;
23  
24  /**
25   * ActionNameResolver that looks up variable name value from ICS scope. Default
26   * variable name is 'cmd'.
27   * 
28   * @author Dolf.Dijkstra
29   * @since May 26, 2011
30   */
31  public class CommandActionNameResolver implements ActionNameResolver {
32      private static final String CMD_VAR = "cmd";
33  
34      private String varName;
35  
36      public CommandActionNameResolver() {
37          varName = "cmd";
38      }
39  
40      public CommandActionNameResolver(String name) {
41          this.varName = name;
42      }
43  
44      public final String getVarName() {
45          return StringUtils.isNotBlank(varName) ? varName : CMD_VAR;
46      }
47  
48      public String resolveActionName(ICS ics) {
49          return ics.GetVar(getVarName());
50      }
51  
52      /**
53       * @param varName the varName to set
54       */
55      public final void setVarName(String varName) {
56          this.varName = varName;
57      }
58  }