|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| StaticFieldAccess.java | 25% | 45.5% | 50% | 42.9% |
|
||||||||||||||
| 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 field access nodes of the syntax tree | |
| 35 | * | |
| 36 | * @author Stephane Hillion | |
| 37 | * @version 1.0 - 1999/05/01 | |
| 38 | */ | |
| 39 | ||
| 40 | public class StaticFieldAccess extends FieldAccess { | |
| 41 | /** | |
| 42 | * The type on which this field access applies | |
| 43 | */ | |
| 44 | private ReferenceTypeName fieldType; | |
| 45 | ||
| 46 | /** | |
| 47 | * Creates a new field access node | |
| 48 | * @param typ the type on which this field access applies | |
| 49 | * @param fln the field name | |
| 50 | * @exception IllegalArgumentException if typ is null or fln is null | |
| 51 | */ | |
| 52 | 0 | public StaticFieldAccess(ReferenceTypeName typ, String fln) { |
| 53 | 0 | this(typ, fln, SourceInfo.NONE); |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * Creates a new field access node | |
| 58 | * @param typ the type on which this field access applies | |
| 59 | * @param fln the field name | |
| 60 | * @exception IllegalArgumentException if typ is null or fln is null | |
| 61 | */ | |
| 62 | 1 | public StaticFieldAccess(ReferenceTypeName typ, String fln, |
| 63 | SourceInfo si) { | |
| 64 | 1 | super(fln, si); |
| 65 | ||
| 66 | 0 | if (typ == null) throw new IllegalArgumentException("typ == null"); |
| 67 | ||
| 68 | 1 | fieldType = typ; |
| 69 | } | |
| 70 | ||
| 71 | /** | |
| 72 | * Returns the declaring type of the field | |
| 73 | */ | |
| 74 | 1 | public ReferenceTypeName getFieldType() { |
| 75 | 1 | return fieldType; |
| 76 | } | |
| 77 | ||
| 78 | /** | |
| 79 | * Sets the declaring type of the field | |
| 80 | * @exception IllegalArgumentException if t is null | |
| 81 | */ | |
| 82 | 0 | public void setFieldType(ReferenceTypeName t) { |
| 83 | 0 | if (t == null) throw new IllegalArgumentException("t == null"); |
| 84 | 0 | fieldType = t; |
| 85 | } | |
| 86 | ||
| 87 | /** | |
| 88 | * Allows a visitor to traverse the tree | |
| 89 | * @param visitor the visitor to accept | |
| 90 | */ | |
| 91 | 1 | public <T> T acceptVisitor(Visitor<T> visitor) { |
| 92 | 1 | return visitor.visit(this); |
| 93 | } | |
| 94 | /** | |
| 95 | * Implementation of toString for use in unit testing | |
| 96 | */ | |
| 97 | 0 | public String toString() { |
| 98 | 0 | return "("+getClass().getName()+": "+getFieldName()+" "+getFieldType()+")"; |
| 99 | } | |
| 100 | } |
|
||||||||||