1 29 30 package com.caucho.jsp.java; 31 32 import com.caucho.jsp.JspParseException; 33 import com.caucho.util.L10N; 34 import com.caucho.vfs.WriteStream; 35 import com.caucho.xml.QName; 36 37 import java.io.IOException ; 38 39 public class JspDirectiveTaglib extends JspNode { 40 final static L10N L = new L10N(JspDirectiveTaglib.class); 41 42 private static final QName PREFIX = new QName("prefix"); 43 private static final QName URI = new QName("uri"); 44 private static final QName TAGDIR = new QName("tagdir"); 45 46 private String _prefix; 47 private String _uri; 48 private String _tagDir; 49 50 56 public void addAttribute(QName name, String value) 57 throws JspParseException 58 { 59 if (PREFIX.equals(name)) 60 _prefix = value; 61 else if (URI.equals(name)) 62 _uri = value; 63 else if (TAGDIR.equals(name)) 64 _tagDir = value; 65 else { 66 throw error(L.l("`{0}' is an unknown JSP taglib directive attributes. See the JSP documentation for a complete list of page directive attributes.", 67 name.getName())); 68 } 69 } 70 71 74 public void endElement() 75 throws JspParseException 76 { 77 if (_prefix == null) 78 throw error(L.l("<{0}> needs a `prefix' attribute.", 79 getTagName())); 80 81 if (_uri == null && _tagDir == null) 82 throw error(L.l("<{0}> needs a `uri' or `tagdir' attribute.", 83 getTagName())); 84 85 if (_uri != null && _tagDir != null) 86 throw error(L.l("<{0}> can't have both a `uri' an a `tagdir' attribute.", 87 getTagName())); 88 89 if (_uri != null) { 90 _gen.addTaglib(_prefix, _uri); 91 addNamespace(_prefix, _uri); 92 } 93 else { 94 _gen.addTaglibDir(_prefix, _tagDir); 95 addNamespace(_prefix, "urn:jsptld:" + _tagDir); 96 } 97 } 98 99 102 public boolean isStatic() 103 { 104 return true; 105 } 106 107 112 public void printXml(WriteStream os) 113 throws IOException 114 { 115 123 } 124 125 130 public void generate(JspJavaWriter out) 131 throws Exception 132 { 133 } 134 } 135 | Popular Tags |