Home | History | Annotate | Download | only in doclava
      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 final void addFederatedReference(FederatedSite source) {
     89     mFederatedReferences.add(source);
     90   }
     91 
     92   public final Set<FederatedSite> getFederatedReferences() {
     93     return mFederatedReferences;
     94   }
     95 
     96   public final void setFederatedReferences(Data data, String base) {
     97     int pos = 0;
     98     for (FederatedSite source : getFederatedReferences()) {
     99       data.setValue(base + ".federated." + pos + ".url", source.linkFor(htmlPage()));
    100       data.setValue(base + ".federated." + pos + ".name", source.name());
    101       pos++;
    102     }
    103   }
    104 
    105   private String mRawCommentText;
    106   Comment mComment;
    107   SourcePositionInfo mPosition;
    108   private String mSince;
    109   private Set<FederatedSite> mFederatedReferences = new LinkedHashSet<FederatedSite>();
    110 }
    111