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