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 { 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 */ 34 public abstract String htmlPage(); 35 36 public boolean isHidden() { 37 return comment().isHidden(); 38 } 39 40 public boolean isDocOnly() { 41 return comment().isDocOnly(); 42 } 43 44 public String getRawCommentText() { 45 return mRawCommentText; 46 } 47 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 58 public Comment comment() { 59 if (mComment == null) { 60 mComment = new Comment(mRawCommentText, parent(), mPosition); 61 } 62 return mComment; 63 } 64 65 public SourcePositionInfo position() { 66 return mPosition; 67 } 68 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 78 public abstract ContainerInfo parent(); 79 80 public void setSince(String since) { 81 mSince = since; 82 } 83 84 public String getSince() { 85 return mSince; 86 } 87 88 public void setDeprecatedSince(String since) { 89 mDeprecatedSince = since; 90 } 91 92 public String getDeprecatedSince() { 93 return mDeprecatedSince; 94 } 95 96 public boolean isDeprecated() { 97 return mDeprecatedSince != null ? true : false; 98 } 99 100 public final void addFederatedReference(FederatedSite source) { 101 mFederatedReferences.add(source); 102 } 103 104 public final Set<FederatedSite> getFederatedReferences() { 105 return mFederatedReferences; 106 } 107 108 public final void setFederatedReferences(Data data, String base) { 109 int pos = 0; 110 for (FederatedSite source : getFederatedReferences()) { 111 data.setValue(base + ".federated." + pos + ".url", source.linkFor(htmlPage())); 112 data.setValue(base + ".federated." + pos + ".name", source.name()); 113 pos++; 114 } 115 } 116 117 private String mRawCommentText; 118 Comment mComment; 119 SourcePositionInfo mPosition; 120 private String mSince; 121 private String mDeprecatedSince; 122 private Set<FederatedSite> mFederatedReferences = new LinkedHashSet<FederatedSite>(); 123 } 124