1 /* 2 * Copyright (C) 2010 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.doclava; 18 19 import com.google.clearsilver.jsilver.data.Data; 20 21 import java.util.HashSet; 22 23 public class ParameterInfo { 24 public ParameterInfo(String name, String typeName, TypeInfo type, boolean isVarArg, 25 SourcePositionInfo position) { 26 mName = name; 27 mTypeName = typeName; 28 mType = type; 29 mIsVarArg = isVarArg; 30 mPosition = position; 31 } 32 33 TypeInfo type() { 34 return mType; 35 } 36 37 String name() { 38 return mName; 39 } 40 41 String typeName() { 42 return mTypeName; 43 } 44 45 SourcePositionInfo position() { 46 return mPosition; 47 } 48 49 boolean isVarArg() { 50 return mIsVarArg; 51 } 52 53 public void makeHDF(Data data, String base, boolean isLastVararg, HashSet<String> typeVariables) { 54 data.setValue(base + ".name", this.name()); 55 type().makeHDF(data, base + ".type", isLastVararg, typeVariables); 56 } 57 58 public static void makeHDF(Data data, String base, ParameterInfo[] params, boolean isVararg, 59 HashSet<String> typeVariables) { 60 for (int i = 0; i < params.length; i++) { 61 params[i].makeHDF(data, base + "." + i, isVararg && (i == params.length - 1), typeVariables); 62 } 63 } 64 65 /** 66 * Returns true if this parameter's dimension information agrees 67 * with the represented callee's dimension information. 68 */ 69 public boolean matchesDimension(String dimension, boolean varargs) { 70 if (varargs) { 71 dimension += "[]"; 72 } 73 return mType.dimension().equals(dimension); 74 } 75 76 String mName; 77 String mTypeName; 78 TypeInfo mType; 79 boolean mIsVarArg; 80 SourcePositionInfo mPosition; 81 } 82