|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| TypeDeclaration.java | 12.5% | 45.5% | 50% | 40% |
|
||||||||||||||
| 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 java.util.*; | |
| 32 | ||
| 33 | import koala.dynamicjava.tree.tiger.TypeParameter; | |
| 34 | ||
| 35 | import edu.rice.cs.plt.tuple.Option; | |
| 36 | ||
| 37 | /** | |
| 38 | * This class represents a type declaration | |
| 39 | * | |
| 40 | * @author Stephane Hillion | |
| 41 | * @version 1.0 - 1999/05/10 | |
| 42 | */ | |
| 43 | ||
| 44 | public abstract class TypeDeclaration extends Declaration { | |
| 45 | private String name; | |
| 46 | private Option<List<TypeParameter>> typeParams; | |
| 47 | private List<? extends ReferenceTypeName> interfaces; // implements clause | |
| 48 | private List<Node> members; | |
| 49 | ||
| 50 | /** | |
| 51 | * Creates a new class declaration | |
| 52 | * @param mods the modifiers | |
| 53 | * @param name the name of the class to declare | |
| 54 | * @param tparams declared type parameters | |
| 55 | * @param impl the list of implemented interfaces. Can be null. | |
| 56 | * @param body the list of fields declarations | |
| 57 | * @exception IllegalArgumentException if name is null or body is null | |
| 58 | */ | |
| 59 | 93 | protected TypeDeclaration(ModifierSet mods, String name, Option<List<TypeParameter>> tparams, |
| 60 | List<? extends ReferenceTypeName> impl, List<Node> body, | |
| 61 | SourceInfo si) { | |
| 62 | 93 | super(mods, si); |
| 63 | 0 | if (name == null || tparams == null || body == null) throw new IllegalArgumentException(); |
| 64 | 93 | this.name = name; |
| 65 | 93 | typeParams = tparams; |
| 66 | 93 | interfaces = impl; |
| 67 | 93 | members = body; |
| 68 | } | |
| 69 | ||
| 70 | /** | |
| 71 | * Returns the name of this class | |
| 72 | */ | |
| 73 | 1876 | public String getName() { |
| 74 | 1876 | return name; |
| 75 | } | |
| 76 | ||
| 77 | /** | |
| 78 | * Sets the type's name | |
| 79 | * @exception IllegalArgumentException if s is null | |
| 80 | */ | |
| 81 | 0 | public void setName(String s) { |
| 82 | 0 | if (s == null) throw new IllegalArgumentException("s == null"); |
| 83 | 0 | name = s; |
| 84 | } | |
| 85 | ||
| 86 | 2790 | public Option<List<TypeParameter>> getTypeParams() { return typeParams; } |
| 87 | 0 | public void setTypeArgs(List<TypeParameter> tparams) { typeParams = Option.wrap(tparams); } |
| 88 | 0 | public void setTypeArgs(Option<List<TypeParameter>> tparams) { |
| 89 | 0 | if (tparams == null) throw new IllegalArgumentException(); |
| 90 | 0 | typeParams = tparams; |
| 91 | } | |
| 92 | ||
| 93 | /** | |
| 94 | * Returns a list that contains the names (String) of the implemented interfaces. | |
| 95 | * Can be null. | |
| 96 | */ | |
| 97 | 1577 | public List<? extends ReferenceTypeName> getInterfaces() { |
| 98 | 1577 | return interfaces; |
| 99 | } | |
| 100 | ||
| 101 | /** | |
| 102 | * Sets the interfaces (a list of strings) | |
| 103 | */ | |
| 104 | 0 | public void setInterfaces(List<? extends ReferenceTypeName> l) { |
| 105 | 0 | interfaces = l; |
| 106 | } | |
| 107 | ||
| 108 | /** | |
| 109 | * Returns the list of the declared members | |
| 110 | */ | |
| 111 | 395 | public List<Node> getMembers() { |
| 112 | 395 | return members; |
| 113 | } | |
| 114 | ||
| 115 | /** | |
| 116 | * Sets the members | |
| 117 | * @exception IllegalArgumentException if l is null | |
| 118 | */ | |
| 119 | 0 | public void setMembers(List<Node> l) { |
| 120 | 0 | if (l == null) throw new IllegalArgumentException("l == null"); |
| 121 | 0 | members = l; |
| 122 | } | |
| 123 | } |
|
||||||||||