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
17package com.google.doclava;
18
19import java.util.ArrayList;
20
21public class ParsedTagInfo extends TagInfo {
22  private ContainerInfo mContainer;
23  private String mCommentText;
24  private Comment mComment;
25
26  ParsedTagInfo(String name, String kind, String text, ContainerInfo base, SourcePositionInfo sp) {
27    super(name, kind, text, SourcePositionInfo.findBeginning(sp, text));
28    mContainer = base;
29    mCommentText = text;
30  }
31
32  public TagInfo[] commentTags() {
33    if (mComment == null) {
34      mComment = new Comment(mCommentText, mContainer, position());
35    }
36    return mComment.tags();
37  }
38
39  protected void setCommentText(String comment) {
40    mCommentText = comment;
41  }
42
43  public static <T extends ParsedTagInfo> TagInfo[] joinTags(T[] tags) {
44    ArrayList<TagInfo> list = new ArrayList<TagInfo>();
45    final int N = tags.length;
46    for (int i = 0; i < N; i++) {
47      TagInfo[] t = tags[i].commentTags();
48      final int M = t.length;
49      for (int j = 0; j < M; j++) {
50        list.add(t[j]);
51      }
52    }
53    return list.toArray(new TagInfo[list.size()]);
54  }
55}
56