blob: 76087ebfbd8759d793ec306159e429e3b22bf21c [file] [log] [blame]
Ben Dodson920dbbb2010-08-04 15:21:06 -07001/*
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
17package com.google.doclava;
18
Andrew Sappersteind6eaacb2011-05-20 13:14:56 -070019import java.util.ArrayList;
20
Ben Dodson920dbbb2010-08-04 15:21:06 -070021public 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,
Andrew Sappersteind6eaacb2011-05-20 13:14:56 -070026 ArrayList<AnnotationInstanceInfo> annotations) {
Ben Dodson920dbbb2010-08-04 15:21:06 -070027 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;
Jeff Arnesonb84c41b2014-08-12 15:22:00 -070041 mShowAnnotations = AnnotationInstanceInfo.getShowAnnotationsIntersection(annotations);
Ben Dodson920dbbb2010-08-04 15:21:06 -070042 }
43
44 public abstract boolean isExecutable();
45
Jeff Hamiltonca151a92012-11-12 17:11:27 -060046 @Override
47 public boolean isHidden() {
Jeff Arnesonb84c41b2014-08-12 15:22:00 -070048 if (mShowAnnotations.size() > 0) {
49 return false;
Jeff Hamiltonca151a92012-11-12 17:11:27 -060050 }
51 return super.isHidden();
52 }
53
Hui Shu5118ffe2014-02-18 14:06:42 -080054 @Override
55 public boolean isRemoved() {
Jeff Arnesonb84c41b2014-08-12 15:22:00 -070056 if (mShowAnnotations.size() > 0) {
57 return false;
Hui Shu5118ffe2014-02-18 14:06:42 -080058 }
59 return super.isRemoved();
60 }
61
62 @Override
63 public boolean isHiddenOrRemoved() {
64 return isHidden() || isRemoved();
65 }
66
Ben Dodson920dbbb2010-08-04 15:21:06 -070067 public String anchor() {
68 if (mSignature != null) {
69 return mName + mSignature;
70 } else {
71 return mName;
72 }
73 }
74
75 public String htmlPage() {
76 return mContainingClass.htmlPage() + "#" + anchor();
77 }
78
79 public int compareTo(Object that) {
80 return this.htmlPage().compareTo(((MemberInfo) that).htmlPage());
81 }
82
83 public String name() {
84 return mName;
85 }
86
87 public String signature() {
88 return mSignature;
89 }
90
91 public ClassInfo realContainingClass() {
92 return mRealContainingClass;
93 }
94
95 public ClassInfo containingClass() {
96 return mContainingClass;
97 }
98
99 public boolean isPublic() {
100 return mIsPublic;
101 }
102
103 public boolean isProtected() {
104 return mIsProtected;
105 }
106
107 public boolean isPackagePrivate() {
108 return mIsPackagePrivate;
109 }
110
111 public boolean isPrivate() {
112 return mIsPrivate;
113 }
Hui Shu5118ffe2014-02-18 14:06:42 -0800114
Ben Dodson920dbbb2010-08-04 15:21:06 -0700115 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
129 public boolean isStatic() {
130 return mIsStatic;
131 }
132
133 public boolean isFinal() {
134 return mIsFinal;
135 }
136
137 public boolean isSynthetic() {
138 return mIsSynthetic;
139 }
140
141 @Override
142 public ContainerInfo parent() {
143 return mContainingClass;
144 }
145
146 public boolean checkLevel() {
Hui Shu5118ffe2014-02-18 14:06:42 -0800147 return Doclava.checkLevel(mIsPublic, mIsProtected, mIsPackagePrivate, mIsPrivate,
148 isHiddenOrRemoved());
Ben Dodson920dbbb2010-08-04 15:21:06 -0700149 }
150
151 public String kind() {
152 return mKind;
153 }
154
Andrew Sappersteind6eaacb2011-05-20 13:14:56 -0700155 public ArrayList<AnnotationInstanceInfo> annotations() {
Ben Dodson920dbbb2010-08-04 15:21:06 -0700156 return mAnnotations;
157 }
158
Jeff Arnesonb84c41b2014-08-12 15:22:00 -0700159 public ArrayList<AnnotationInstanceInfo> showAnnotations() {
160 return mShowAnnotations;
161 }
162
Ben Dodson920dbbb2010-08-04 15:21:06 -0700163 ClassInfo mContainingClass;
164 ClassInfo mRealContainingClass;
165 String mName;
166 String mSignature;
167 boolean mIsPublic;
168 boolean mIsProtected;
169 boolean mIsPackagePrivate;
170 boolean mIsPrivate;
171 boolean mIsFinal;
172 boolean mIsStatic;
173 boolean mIsSynthetic;
174 String mKind;
Andrew Sappersteind6eaacb2011-05-20 13:14:56 -0700175 private ArrayList<AnnotationInstanceInfo> mAnnotations;
Jeff Arnesonb84c41b2014-08-12 15:22:00 -0700176 private ArrayList<AnnotationInstanceInfo> mShowAnnotations;
Ben Dodson920dbbb2010-08-04 15:21:06 -0700177
178}