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

Quick Search    Search Deep

Source code: openjava/ptree/Parameter.java


1   /*
2    * Parameter.java 1.0
3    *
4    * This interface is made to type ptree-node into
5    * the parameter in the body of class.
6    *
7    * Jun 20, 1997 by mich
8    * Sep 29, 1997 by bv
9    * Oct 10, 1997 by mich
10   *
11   * @see openjava.ptree.ParseTree
12   * @version 1.0 last updated:  Sep 29, 1997
13   * @author  Michiaki Tatsubori
14   */
15  package openjava.ptree;
16  
17  import openjava.ptree.util.ParseTreeVisitor;
18  
19  /**
20   * The Parameter class represents parameter node of parse tree.
21   * Modifiers of parameter are supported from JDK 1.1.
22   * The code like:
23   * <br><blockquote><pre>
24   *     void test( final int i ){
25   *         ....
26   *     }
27   * </pre></blockquote><br>
28   * is allowed from JDK 1.1.
29   *
30   * @see openjava.ptree.ParseTree
31   * @see openjava.ptree.NonLeaf
32   * @see openjava.ptree.ModifierList
33   */
34  public class Parameter extends NonLeaf {
35  
36    /**
37     * Allocates a new object.
38     *
39     * @param  modfiers  modifier list of the new parameter
40     * @param  type_specifier  type specifier includes array dimension info
41     * @param  declname  the parameter's name, including no array dim.
42     */
43    public Parameter(
44      ModifierList modiflist,
45      TypeName type_specifier,
46      String declname) {
47      super();
48      if (modiflist == null) {
49        modiflist = new ModifierList();
50      }
51      set(modiflist, type_specifier, declname);
52    }
53  
54    /**
55     * Allocates a new object.
56     * 
57     *
58     * @param type_specifier type specifier includes array dimension info
59     * @param declname the parameter's name, also includes array dim
60     *        arg modfier is null means parameter has no modifier
61     */
62    public Parameter(TypeName type_specifier, String declname) {
63      this(new ModifierList(), type_specifier, declname);
64    }
65  
66    /**
67     * Gets the modifiers of this parameter.
68     *
69     * @return the modfiers.
70     */
71    public ModifierList getModifiers() {
72      return (ModifierList) elementAt(0);
73    }
74  
75    /**
76     * Sets the modifiers of this parameter.
77     *
78     * @param  modifs  the modfiers to set.
79     */
80    public void setModifiers(ModifierList modifs) {
81      setElementAt(modifs, 0);
82    }
83  
84    /**
85     * Gets the type specifier of this parameter.
86     *
87     * @return the type specifier.
88     */
89    public TypeName getTypeSpecifier() {
90      return (TypeName) elementAt(1);
91    }
92  
93    /**
94     * Sets the type specifier of this parameter.
95     *
96     * @param  tspec  the type specifier to set.
97     */
98    public void setTypeSpecifier(TypeName tspec) {
99      setElementAt(tspec, 1);
100   }
101 
102   /**
103    * Gets the variable name of this parameter.
104    *
105    * @return the variable name.
106    */
107   public String getVariable() {
108     return (String) elementAt(2);
109   }
110 
111   /**
112    * Sets the variable name of this parameter.
113    *
114    * @param  varname  the variable name to set.
115    */
116   public void setVariable(String varname) {
117     setElementAt(varname, 2);
118   }
119 
120   public void accept(ParseTreeVisitor v) throws ParseTreeException {
121     v.visit(this);
122   }
123 
124 }