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 java.util.ArrayList; 20 21 public abstract class MemberInfo extends DocInfo implements Comparable, Scoped { MemberInfo(String rawCommentText, String name, String signature, ClassInfo containingClass, ClassInfo realContainingClass, boolean isPublic, boolean isProtected, boolean isPackagePrivate, boolean isPrivate, boolean isFinal, boolean isStatic, boolean isSynthetic, String kind, SourcePositionInfo position, ArrayList<AnnotationInstanceInfo> annotations)22 public MemberInfo(String rawCommentText, String name, String signature, 23 ClassInfo containingClass, ClassInfo realContainingClass, boolean isPublic, 24 boolean isProtected, boolean isPackagePrivate, boolean isPrivate, boolean isFinal, 25 boolean isStatic, boolean isSynthetic, String kind, SourcePositionInfo position, 26 ArrayList<AnnotationInstanceInfo> annotations) { 27 super(rawCommentText, position); 28 mName = name; 29 mSignature = signature; 30 mContainingClass = containingClass; 31 mRealContainingClass = realContainingClass; 32 mIsPublic = isPublic; 33 mIsProtected = isProtected; 34 mIsPackagePrivate = isPackagePrivate; 35 mIsPrivate = isPrivate; 36 mIsFinal = isFinal; 37 mIsStatic = isStatic; 38 mIsSynthetic = isSynthetic; 39 mKind = kind; 40 mAnnotations = annotations; 41 mShowAnnotations = AnnotationInstanceInfo.getShowAnnotationsIntersection(annotations); 42 } 43 isExecutable()44 public abstract boolean isExecutable(); 45 46 @Override isHidden()47 public boolean isHidden() { 48 if (mShowAnnotations.size() > 0) { 49 return false; 50 } 51 return super.isHidden(); 52 } 53 54 @Override isRemoved()55 public boolean isRemoved() { 56 if (mShowAnnotations.size() > 0) { 57 return false; 58 } 59 return super.isRemoved(); 60 } 61 62 @Override isHiddenOrRemoved()63 public boolean isHiddenOrRemoved() { 64 return isHidden() || isRemoved(); 65 } 66 anchor()67 public String anchor() { 68 if (mSignature != null) { 69 return mName + mSignature; 70 } else { 71 return mName; 72 } 73 } 74 htmlPage()75 public String htmlPage() { 76 return mContainingClass.htmlPage() + "#" + anchor(); 77 } 78 compareTo(Object that)79 public int compareTo(Object that) { 80 return this.htmlPage().compareTo(((MemberInfo) that).htmlPage()); 81 } 82 name()83 public String name() { 84 return mName; 85 } 86 signature()87 public String signature() { 88 return mSignature; 89 } 90 realContainingClass()91 public ClassInfo realContainingClass() { 92 return mRealContainingClass; 93 } 94 containingClass()95 public ClassInfo containingClass() { 96 return mContainingClass; 97 } 98 isPublic()99 public boolean isPublic() { 100 return mIsPublic; 101 } 102 isProtected()103 public boolean isProtected() { 104 return mIsProtected; 105 } 106 isPackagePrivate()107 public boolean isPackagePrivate() { 108 return mIsPackagePrivate; 109 } 110 isPrivate()111 public boolean isPrivate() { 112 return mIsPrivate; 113 } 114 scope()115 public String scope() { 116 if (isPublic()) { 117 return "public"; 118 } else if (isProtected()) { 119 return "protected"; 120 } else if (isPackagePrivate()) { 121 return ""; 122 } else if (isPrivate()) { 123 return "private"; 124 } else { 125 throw new RuntimeException("invalid scope for object " + this); 126 } 127 } 128 isStatic()129 public boolean isStatic() { 130 return mIsStatic; 131 } 132 isFinal()133 public boolean isFinal() { 134 return mIsFinal; 135 } 136 isSynthetic()137 public boolean isSynthetic() { 138 return mIsSynthetic; 139 } 140 141 @Override parent()142 public ContainerInfo parent() { 143 return mContainingClass; 144 } 145 146 /** 147 * Returns {@code true} if the member's scope is above the minimum requested scope passed to 148 * Doclava, <emph>or</emph> if the member is tagged with an annotation which was specified in a 149 * "-showAnnotation" argument to Doclava 150 */ checkLevel()151 public boolean checkLevel() { 152 if (Doclava.checkLevel(mIsPublic, mIsProtected, mIsPackagePrivate, mIsPrivate, 153 isHiddenOrRemoved())) { 154 return true; 155 } else if (mShowAnnotations != null && !mShowAnnotations.isEmpty()) { 156 return true; 157 } 158 159 return false; 160 } 161 kind()162 public String kind() { 163 return mKind; 164 } 165 annotations()166 public ArrayList<AnnotationInstanceInfo> annotations() { 167 return mAnnotations; 168 } 169 showAnnotations()170 public ArrayList<AnnotationInstanceInfo> showAnnotations() { 171 return mShowAnnotations; 172 } 173 174 ClassInfo mContainingClass; 175 ClassInfo mRealContainingClass; 176 String mName; 177 String mSignature; 178 boolean mIsPublic; 179 boolean mIsProtected; 180 boolean mIsPackagePrivate; 181 boolean mIsPrivate; 182 boolean mIsFinal; 183 boolean mIsStatic; 184 boolean mIsSynthetic; 185 String mKind; 186 private ArrayList<AnnotationInstanceInfo> mAnnotations; 187 private ArrayList<AnnotationInstanceInfo> mShowAnnotations; 188 189 } 190