|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ArrayTypeName.java | 50% | 53.3% | 57.1% | 53.3% |
|
||||||||||||||
| 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 array type nodes of the syntax tree | |
| 35 | * | |
| 36 | * @author Stephane Hillion | |
| 37 | * @version 1.0 - 1999/04/24 | |
| 38 | */ | |
| 39 | ||
| 40 | public class ArrayTypeName extends TypeName { | |
| 41 | /** | |
| 42 | * The type of the elements of the arrays represented by this type | |
| 43 | */ | |
| 44 | private TypeName elementType; | |
| 45 | ||
| 46 | private boolean vararg; | |
| 47 | ||
| 48 | /** | |
| 49 | * Initializes the type | |
| 50 | * @param et the element type | |
| 51 | * @param dim the dimension of the arrays represented by this type (> 0) | |
| 52 | * @exception IllegalArgumentException if et is null or dim < 1 | |
| 53 | */ | |
| 54 | 0 | public ArrayTypeName(TypeName et, int dim, boolean varg) { |
| 55 | 0 | this(et, dim, varg, SourceInfo.NONE); |
| 56 | } | |
| 57 | ||
| 58 | /** | |
| 59 | * Initializes the type | |
| 60 | * @param et the element type | |
| 61 | * @param dim the dimension of the arrays represented by this type (> 0) | |
| 62 | * @exception IllegalArgumentException if et is null or dim < 1 | |
| 63 | */ | |
| 64 | 116 | public ArrayTypeName(TypeName et, int dim, boolean varg, SourceInfo si) { |
| 65 | 116 | super(si); |
| 66 | ||
| 67 | 0 | if (et == null) throw new IllegalArgumentException("et == null"); |
| 68 | 0 | if (dim < 1) throw new IllegalArgumentException("dim < 1"); |
| 69 | ||
| 70 | 116 | elementType = (dim > 1) ? new ArrayTypeName(et, dim - 1, false, si) : et; |
| 71 | 116 | vararg = varg; |
| 72 | } | |
| 73 | ||
| 74 | /** | |
| 75 | * Returns the type of the elements of the arrays represented by this type | |
| 76 | */ | |
| 77 | 116 | public TypeName getElementType() { |
| 78 | 116 | return elementType; |
| 79 | } | |
| 80 | ||
| 81 | /** | |
| 82 | * Sets the type of the elements of the arrays represented by this type | |
| 83 | * @exception IllegalArgumentException if t is null | |
| 84 | */ | |
| 85 | 0 | public void setElementType(TypeName t) { |
| 86 | 0 | if (t == null) throw new IllegalArgumentException("t == null"); |
| 87 | 0 | elementType = t; |
| 88 | } | |
| 89 | ||
| 90 | 116 | public boolean isVararg() { return vararg; } |
| 91 | ||
| 92 | /** | |
| 93 | * Allows a visitor to traverse the tree | |
| 94 | * @param visitor the visitor to accept | |
| 95 | */ | |
| 96 | 116 | public <T> T acceptVisitor(Visitor<T> visitor) { |
| 97 | 116 | return visitor.visit(this); |
| 98 | } | |
| 99 | /** | |
| 100 | * Implementation of toString for use in unit testing | |
| 101 | */ | |
| 102 | 0 | public String toString() { |
| 103 | 0 | return "("+getClass().getName()+": "+getElementType()+")"; |
| 104 | } | |
| 105 | } |
|
||||||||||