1 2 29 package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify; 30 31 32 33 import java.util.List ; 34 import java.util.Vector ; 35 36 37 45 public class MethodDef extends DefaultScope implements IMethod { 46 47 private IClass returnType; 48 private List exceptions; 49 50 private List parameters; 51 52 public MethodDef(String name, Scope parentScope, SymTabAST node) { 53 super(name, parentScope, node); 54 parameters = new Vector (); 55 } 56 57 62 public IClass getType() { 63 return returnType; 64 } 65 66 71 public void setType(IClass type) { 72 returnType = type; 73 } 74 75 80 public void addParameter(VariableDef parameter) { 81 parameters.add( parameter ); 82 addDefinition(parameter); 83 } 84 85 92 public boolean hasSameSignature(ISignature signature) { 93 return getSignature().equals(signature); 94 } 95 96 102 public boolean hasCompatibleSignature(ISignature signature) { 103 return signature.isCompatibleWith(getSignature()); 104 } 105 106 111 public ISignature getSignature() { 112 Vector argTypes = new Vector (); 113 114 for (int i = 0; i < parameters.size(); i++) { 115 argTypes.add(getParameterAt(i).getType()); 116 } 117 118 return new MethodSignature(argTypes); 119 } 120 121 128 private VariableDef getParameterAt( int i ) { 129 return (VariableDef)(parameters.get( i )); 130 } 131 132 137 public void addException(IClass exception) { 138 if (exceptions == null) { 139 exceptions = new Vector (); 140 } 141 142 exceptions.add(exception); 143 } 144 145 150 public IClass[] getExceptions() { 151 return (IClass[])exceptions.toArray(new IClass[0]); 152 } 153 154 public String getQualifiedName() { 155 return super.getQualifiedName() + getSignature(); 156 } 157 } | Popular Tags |