|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| FormalParameter.java | 25% | 50% | 62.5% | 47.1% |
|
||||||||||||||
| 1 | /* | |
| 2 | * DynamicJava - Copyright (C) 1999-2001 | |
| 3 | * | |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a | |
| 5 | * copy of this software and associated documentation files | |
| 6 | * (the "Software"), to deal in the Software without restriction, including | |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, | |
| 8 | * distribute, sublicense, and/or sell copies of the Software, and to permit | |
| 9 | * persons to whom the Software is furnished to do so, subject to the | |
| 10 | * following conditions: | |
| 11 | * The above copyright notice and this permission notice shall be included | |
| 12 | * in all copies or substantial portions of the Software. | |
| 13 | * | |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
| 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
| 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
| 17 | * IN NO EVENT SHALL DYADE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 20 | * DEALINGS IN THE SOFTWARE. | |
| 21 | * | |
| 22 | * Except as contained in this notice, the name of Dyade shall not be | |
| 23 | * used in advertising or otherwise to promote the sale, use or other | |
| 24 | * dealings in this Software without prior written authorization from | |
| 25 | * Dyade. | |
| 26 | * | |
| 27 | */ | |
| 28 | ||
| 29 | package koala.dynamicjava.tree; | |
| 30 | ||
| 31 | import koala.dynamicjava.tree.visitor.*; | |
| 32 | ||
| 33 | /** | |
| 34 | * This class represents the method parameters in the syntax tree | |
| 35 | * | |
| 36 | * @author Stephane Hillion | |
| 37 | * @version 1.0 - 1999/05/11 | |
| 38 | */ | |
| 39 | ||
| 40 | public class FormalParameter extends Declaration { | |
| 41 | /** | |
| 42 | * The type of this parameter | |
| 43 | */ | |
| 44 | private TypeName type; | |
| 45 | ||
| 46 | /** | |
| 47 | * The name of this parameter | |
| 48 | */ | |
| 49 | private String name; | |
| 50 | ||
| 51 | /** | |
| 52 | * Initializes the node | |
| 53 | * @param mods the modifiers | |
| 54 | * @param t the type of the parameter | |
| 55 | * @param n the name of the parameter | |
| 56 | * @exception IllegalArgumentException if t is null or n is null | |
| 57 | */ | |
| 58 | 1 | public FormalParameter(ModifierSet mods, TypeName t, String n) { |
| 59 | 1 | this(mods, t, n, SourceInfo.NONE); |
| 60 | } | |
| 61 | ||
| 62 | /** | |
| 63 | * Initializes the node | |
| 64 | * @param mods the modifiers | |
| 65 | * @param t the type of the parameter | |
| 66 | * @param n the name of the parameter | |
| 67 | * @exception IllegalArgumentException if t is null or n is null | |
| 68 | */ | |
| 69 | 428 | public FormalParameter(ModifierSet mods, TypeName t, String n, |
| 70 | SourceInfo si) { | |
| 71 | 428 | super(mods, si); |
| 72 | ||
| 73 | 0 | if (t == null) throw new IllegalArgumentException("t == null"); |
| 74 | 0 | if (n == null) throw new IllegalArgumentException("n == null"); |
| 75 | 428 | type = t; |
| 76 | 428 | name = n; |
| 77 | } | |
| 78 | ||
| 79 | /** | |
| 80 | * Returns the declaring type of this parameter | |
| 81 | */ | |
| 82 | 428 | public TypeName getType() { |
| 83 | 428 | return type; |
| 84 | } | |
| 85 | ||
| 86 | /** | |
| 87 | * Sets the type of this parameter | |
| 88 | * @exception IllegalArgumentException if t is null | |
| 89 | */ | |
| 90 | 0 | public void setType(TypeName t) { |
| 91 | 0 | if (t == null) throw new IllegalArgumentException("t == null"); |
| 92 | 0 | type = t; |
| 93 | } | |
| 94 | ||
| 95 | /** | |
| 96 | * The name of this parameter | |
| 97 | */ | |
| 98 | 428 | public String getName() { |
| 99 | 428 | return name; |
| 100 | } | |
| 101 | ||
| 102 | /** | |
| 103 | * Sets this parameter's name | |
| 104 | * @exception IllegalArgumentException if s is null | |
| 105 | */ | |
| 106 | 0 | public void setName(String s) { |
| 107 | 0 | if (s == null) throw new IllegalArgumentException("s == null"); |
| 108 | 0 | name = s; |
| 109 | } | |
| 110 | ||
| 111 | /** | |
| 112 | * Allows a visitor to traverse the tree | |
| 113 | * @param visitor the visitor to accept | |
| 114 | */ | |
| 115 | 0 | public <T> T acceptVisitor(Visitor<T> visitor) { |
| 116 | 0 | return visitor.visit(this); |
| 117 | } | |
| 118 | /** | |
| 119 | * Implementation of toString for use in unit testing | |
| 120 | */ | |
| 121 | 2 | public String toString() { |
| 122 | 2 | return "("+getClass().getName()+": "+getModifiers()+" "+getType()+" "+getName()+")"; |
| 123 | } | |
| 124 | } |
|
||||||||||