• 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 com.google.clearsilver.jsilver.data.Data;
20 
21 import java.util.ArrayList;
22 import java.util.LinkedHashSet;
23 import java.util.Set;
24 
25 public abstract class DocInfo {
DocInfo(String rawCommentText, SourcePositionInfo sp)26   public DocInfo(String rawCommentText, SourcePositionInfo sp) {
27     mRawCommentText = rawCommentText;
28     mPosition = sp;
29   }
30 
31   /**
32    * The relative path to a web page representing this item.
33    */
htmlPage()34   public abstract String htmlPage();
35 
isHidden()36   public boolean isHidden() {
37     return comment().isHidden();
38   }
39 
isDocOnly()40   public boolean isDocOnly() {
41     return comment().isDocOnly();
42   }
43 
getRawCommentText()44   public String getRawCommentText() {
45     return mRawCommentText;
46   }
47 
setRawCommentText(String rawCommentText)48   public void setRawCommentText(String rawCommentText) {
49       mRawCommentText = rawCommentText;
50 
51       // so that if we've created one prior to changing, we recreate it
52       if (mComment != null) {
53           mComment = new Comment(mRawCommentText, parent(), mPosition);
54       }
55 
56   }
57 
comment()58   public Comment comment() {
59     if (mComment == null) {
60       mComment = new Comment(mRawCommentText, parent(), mPosition);
61     }
62     return mComment;
63   }
64 
position()65   public SourcePositionInfo position() {
66     return mPosition;
67   }
68 
setPosition(SourcePositionInfo position)69   public void setPosition(SourcePositionInfo position) {
70       mPosition = position;
71 
72       // so that if we've created one prior to changing, we recreate it
73       if (mComment != null) {
74           mComment = new Comment(mRawCommentText, parent(), mPosition);
75       }
76   }
77 
parent()78   public abstract ContainerInfo parent();
79 
setSince(String since)80   public void setSince(String since) {
81     mSince = since;
82   }
83 
getSince()84   public String getSince() {
85     return mSince;
86   }
87 
setDeprecatedSince(String since)88   public void setDeprecatedSince(String since) {
89     mDeprecatedSince = since;
90   }
91 
getDeprecatedSince()92   public String getDeprecatedSince() {
93     return mDeprecatedSince;
94   }
95 
addFederatedReference(FederatedSite source)96   public final void addFederatedReference(FederatedSite source) {
97     mFederatedReferences.add(source);
98   }
99 
getFederatedReferences()100   public final Set<FederatedSite> getFederatedReferences() {
101     return mFederatedReferences;
102   }
103 
setFederatedReferences(Data data, String base)104   public final void setFederatedReferences(Data data, String base) {
105     int pos = 0;
106     for (FederatedSite source : getFederatedReferences()) {
107       data.setValue(base + ".federated." + pos + ".url", source.linkFor(htmlPage()));
108       data.setValue(base + ".federated." + pos + ".name", source.name());
109       pos++;
110     }
111   }
112 
113   private String mRawCommentText;
114   Comment mComment;
115   SourcePositionInfo mPosition;
116   private String mSince;
117   private String mDeprecatedSince;
118   private Set<FederatedSite> mFederatedReferences = new LinkedHashSet<FederatedSite>();
119 }
120