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 { 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 } 42 43 public abstract boolean isExecutable(); 44 45 public String anchor() { 46 if (mSignature != null) { 47 return mName + mSignature; 48 } else { 49 return mName; 50 } 51 } 52 53 public String htmlPage() { 54 return mContainingClass.htmlPage() + "#" + anchor(); 55 } 56 57 public int compareTo(Object that) { 58 return this.htmlPage().compareTo(((MemberInfo) that).htmlPage()); 59 } 60 61 public String name() { 62 return mName; 63 } 64 65 public String signature() { 66 return mSignature; 67 } 68 69 public ClassInfo realContainingClass() { 70 return mRealContainingClass; 71 } 72 73 public ClassInfo containingClass() { 74 return mContainingClass; 75 } 76 77 public boolean isPublic() { 78 return mIsPublic; 79 } 80 81 public boolean isProtected() { 82 return mIsProtected; 83 } 84 85 public boolean isPackagePrivate() { 86 return mIsPackagePrivate; 87 } 88 89 public boolean isPrivate() { 90 return mIsPrivate; 91 } 92 93 public String scope() { 94 if (isPublic()) { 95 return "public"; 96 } else if (isProtected()) { 97 return "protected"; 98 } else if (isPackagePrivate()) { 99 return ""; 100 } else if (isPrivate()) { 101 return "private"; 102 } else { 103 throw new RuntimeException("invalid scope for object " + this); 104 } 105 } 106 107 public boolean isStatic() { 108 return mIsStatic; 109 } 110 111 public boolean isFinal() { 112 return mIsFinal; 113 } 114 115 public boolean isSynthetic() { 116 return mIsSynthetic; 117 } 118 119 @Override 120 public ContainerInfo parent() { 121 return mContainingClass; 122 } 123 124 public boolean checkLevel() { 125 return Doclava.checkLevel(mIsPublic, mIsProtected, mIsPackagePrivate, mIsPrivate, isHidden()); 126 } 127 128 public String kind() { 129 return mKind; 130 } 131 132 public ArrayList<AnnotationInstanceInfo> annotations() { 133 return mAnnotations; 134 } 135 136 ClassInfo mContainingClass; 137 ClassInfo mRealContainingClass; 138 String mName; 139 String mSignature; 140 boolean mIsPublic; 141 boolean mIsProtected; 142 boolean mIsPackagePrivate; 143 boolean mIsPrivate; 144 boolean mIsFinal; 145 boolean mIsStatic; 146 boolean mIsSynthetic; 147 String mKind; 148 private ArrayList<AnnotationInstanceInfo> mAnnotations; 149 150 } 151