Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/maddyhome/idea/vim/key/ArgumentNode.java


1   package com.maddyhome.idea.vim.key;
2   
3   /*
4    * IdeaVim - A Vim emulator plugin for IntelliJ Idea
5    * Copyright (C) 2003 Rick Maddy
6    *
7    * This program is free software; you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation; either version 2
10   * of the License, or (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20   */
21  
22  import com.intellij.openapi.actionSystem.AnAction;
23  
24  /**
25   * This represents a command argument node in the key/action tree. Currently arguments of argType character
26   * and motion command are used.
27   */
28  public class ArgumentNode implements Node
29  {
30      /**
31       * Creates a node for the given action
32       * @param action The action this arguments is mapped to
33       * @param cmdType The type of the command this argument is for
34       * @param argType The type of the argument
35       * @param flags Any special flags associated with this argument
36       */
37      public ArgumentNode(AnAction action, int cmdType, int argType, int flags)
38      {
39          this.action = action;
40          this.argType = argType;
41          this.cmdType = cmdType;
42          this.flags = flags;
43      }
44  
45      /**
46       * Gets the action of the argument
47       * @return The argument's action
48       */
49      public AnAction getAction()
50      {
51          return action;
52      }
53  
54      /**
55       * Gets the argument type
56       * @return The argument's type
57       */
58      public int getArgType()
59      {
60          return argType;
61      }
62  
63      /**
64       * Gets the type of the command this arguments is for
65       * @return The argument's command type
66       */
67      public int getCmdType()
68      {
69          return cmdType;
70      }
71  
72      /**
73       * Gets the argument flags
74       * @return The argument's flags
75       */
76      public int getFlags()
77      {
78          return flags;
79      }
80  
81      public String toString()
82      {
83          StringBuffer res = new StringBuffer();
84          res.append("ArgumentNode[");
85          res.append("action=");
86          res.append(action);
87          res.append("argType=");
88          res.append(argType);
89          res.append("flags=");
90          res.append(flags);
91          res.append("]");
92  
93          return res.toString();
94      }
95  
96      public boolean equals(Object o)
97      {
98          if (this == o) return true;
99          if (!(o instanceof ArgumentNode)) return false;
100 
101         final ArgumentNode node = (ArgumentNode)o;
102 
103         if (argType != node.argType) return false;
104         if (cmdType != node.cmdType) return false;
105         if (flags != node.flags) return false;
106         if (!action.equals(node.action)) return false;
107 
108         return true;
109     }
110 
111     public int hashCode()
112     {
113         int result;
114         result = action.hashCode();
115         result = 29 * result + argType;
116         result = 29 * result + cmdType;
117         result = 29 * result + flags;
118         return result;
119     }
120 
121     protected AnAction action;
122     protected int argType;
123     protected int cmdType;
124     protected int flags;
125 }