Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      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 import org.clearsilver.HDF;
     18 import org.clearsilver.CS;
     19 
     20 public class TagInfo
     21 {
     22     private String mName;
     23     private String mText;
     24     private String mKind;
     25     private SourcePositionInfo mPosition;
     26 
     27     TagInfo(String n, String k, String t, SourcePositionInfo sp)
     28     {
     29         mName = n;
     30         mText = t;
     31         mKind = k;
     32         mPosition = sp;
     33     }
     34 
     35     String name()
     36     {
     37         return mName;
     38     }
     39 
     40     String text()
     41     {
     42         return mText;
     43     }
     44 
     45     String kind()
     46     {
     47         return mKind;
     48     }
     49 
     50     SourcePositionInfo position() {
     51         return mPosition;
     52     }
     53 
     54     void setKind(String kind) {
     55         mKind = kind;
     56     }
     57 
     58     public void makeHDF(HDF data, String base)
     59     {
     60         data.setValue(base + ".name", name());
     61         data.setValue(base + ".text", text());
     62         data.setValue(base + ".kind", kind());
     63     }
     64 
     65     public static void makeHDF(HDF data, String base, TagInfo[] tags)
     66     {
     67         makeHDF(data, base, tags, null, 0, 0);
     68     }
     69 
     70     public static void makeHDF(HDF data, String base, InheritedTags tags)
     71     {
     72         makeHDF(data, base, tags.tags(), tags.inherited(), 0, 0);
     73     }
     74 
     75     private static int makeHDF(HDF data, String base, TagInfo[] tags,
     76                                 InheritedTags inherited, int j, int depth)
     77     {
     78         int i;
     79         int len = tags.length;
     80         if (len == 0 && inherited != null) {
     81             j = makeHDF(data, base, inherited.tags(), inherited.inherited(), j, depth+1);
     82         } else {
     83             for (i=0; i<len; i++, j++) {
     84                 TagInfo t = tags[i];
     85                 if (inherited != null && t.name().equals("@inheritDoc")) {
     86                     j = makeHDF(data, base, inherited.tags(),
     87                                     inherited.inherited(), j, depth+1);
     88                 } else {
     89                     if (t.name().equals("@inheritDoc")) {
     90                         Errors.error(Errors.BAD_INHERITDOC, t.mPosition,
     91                                 "@inheritDoc on class/method that is not inherited");
     92                     }
     93                     t.makeHDF(data, base + "." + j);
     94                 }
     95             }
     96         }
     97         return j;
     98     }
     99 }
    100 
    101