2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 import java.util.regex.Pattern;
18 import java.util.regex.Matcher;
19 import org.clearsilver.HDF;
20 import org.clearsilver.CS;
22 public class ParamTagInfo extends ParsedTagInfo
24 static final Pattern PATTERN = Pattern.compile(
25 "([^ \t\r\n]+)[ \t\r\n]+(.*)",
28 private boolean mIsTypeParameter;
29 private String mParameterComment;
30 private String mParameterName;
32 ParamTagInfo(String name, String kind, String text, ContainerInfo base,
33 SourcePositionInfo sp)
35 super(name, kind, text, base, sp);
37 Matcher m = PATTERN.matcher(text);
39 mParameterName = m.group(1);
40 mParameterComment = m.group(2);
41 int len = mParameterName.length();
42 mIsTypeParameter = len > 2
43 && mParameterName.charAt(0) == '<'
44 && mParameterName.charAt(len-1) == '>';
46 mParameterName = text.trim();
47 mParameterComment = "";
48 mIsTypeParameter = false;
50 setCommentText(mParameterComment);
53 ParamTagInfo(String name, String kind, String text,
54 boolean isTypeParameter, String parameterComment,
55 String parameterName, ContainerInfo base,
56 SourcePositionInfo sp)
58 super(name, kind, text, base, sp);
59 mIsTypeParameter = isTypeParameter;
60 mParameterComment = parameterComment;
61 mParameterName = parameterName;
64 public boolean isTypeParameter()
66 return mIsTypeParameter;
69 public String parameterComment()
71 return mParameterComment;
74 public String parameterName()
76 return mParameterName;
80 public void makeHDF(HDF data, String base)
82 data.setValue(base + ".name", parameterName());
83 data.setValue(base + ".isTypeParameter", isTypeParameter() ? "1" : "0");
84 TagInfo.makeHDF(data, base + ".comment", commentTags());
87 public static void makeHDF(HDF data, String base, ParamTagInfo[] tags)
89 for (int i=0; i<tags.length; i++) {
90 // don't output if the comment is ""
91 if (!"".equals(tags[i].parameterComment())) {
92 tags[i].makeHDF(data, base + "." + i);