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 java.util.regex.Pattern; 18 import java.util.regex.Matcher; 19 import org.clearsilver.HDF; 20 import org.clearsilver.CS; 21 import java.util.ArrayList; 22 23 public class SeeTagInfo extends TagInfo 24 { 25 private ContainerInfo mBase; 26 LinkReference mLink; 27 28 SeeTagInfo(String name, String kind, String text, ContainerInfo base, 29 SourcePositionInfo position) 30 { 31 super(name, kind, text, position); 32 mBase = base; 33 } 34 35 protected LinkReference linkReference() { 36 if (mLink == null) { 37 mLink = LinkReference.parse(text(), mBase, position(), 38 (!"@see".equals(name())) && (mBase != null ? mBase.checkLevel() : true)); 39 } 40 return mLink; 41 } 42 43 public String label() 44 { 45 return linkReference().label; 46 } 47 48 @Override 49 public void makeHDF(HDF data, String base) 50 { 51 LinkReference linkRef = linkReference(); 52 if (linkRef.kind != null) { 53 // if they have a better suggestion about "kind" use that. 54 // do this before super.makeHDF() so it picks it up 55 setKind(linkRef.kind); 56 } 57 58 super.makeHDF(data, base); 59 60 data.setValue(base + ".label", linkRef.label); 61 if (linkRef.href != null) { 62 data.setValue(base + ".href", linkRef.href); 63 } 64 } 65 66 public boolean checkLevel() { 67 return linkReference().checkLevel(); 68 } 69 70 public static void makeHDF(HDF data, String base, SeeTagInfo[] tags) 71 { 72 int j=0; 73 for (SeeTagInfo tag: tags) { 74 if (tag.mBase.checkLevel() && tag.checkLevel()) { 75 tag.makeHDF(data, base + "." + j); 76 j++; 77 } 78 } 79 } 80 } 81