/** * Translation-time validation of the attributes. * This is a convenience method on the associated TagExtraInfo class. * * @param data The translation-time TagData instance. * @return Whether the data is valid. */ public boolean isValid(TagData data) { TagExtraInfo tei = getTagExtraInfo(); if (tei == null) { return true; } return tei.isValid(data); }
/** * Get the TagInfo for a given tag name, looking through all the * tags in this tag library. * * @param shortname The short name (no prefix) of the tag * @return the TagInfo for the tag with the specified short name, or * null if no such tag is found */ public TagInfo getTag(String shortname) { TagInfo tags[] = getTags(); if (tags == null || tags.length == 0) { return null; } for (int i=0; i < tags.length; i++) { if (tags[i].getTagName().equals(shortname)) { return tags[i]; } } return null; }
public void visit(Node.CustomTag n) throws JasperException { TagFileInfo tagFileInfo = n.getTagFileInfo(); if (tagFileInfo != null) { String tagFilePath = tagFileInfo.getPath(); if (tagFilePath.startsWith("/META-INF/")) { // For tags in JARs, add the TLD and the tag as a dependency String[] location = compiler.getCompilationContext().getTldLocation( tagFileInfo.getTagInfo().getTagLibrary().getURI()); // Add TLD pageInfo.addDependant("jar:" + location[0] + "!/" + location[1]); // Add Tag pageInfo.addDependant("jar:" + location[0] + "!" + tagFilePath); } else { pageInfo.addDependant(tagFilePath); } Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(), pageInfo); n.setTagHandlerClass(c); } visitBody(n); } }
this.tags = new TagInfo[otherTags.length]; for (int i=0; i<otherTags.length; i++) { this.tags[i] = new TagInfo( otherTags[i].getTagName(), otherTags[i].getTagClassName(), otherTags[i].getBodyContent(), otherTags[i].getInfoString(), this, otherTags[i].getTagExtraInfo(), otherTags[i].getAttributes(), otherTags[i].getDisplayName(), otherTags[i].getSmallIcon(), otherTags[i].getLargeIcon(), otherTags[i].getTagVariableInfos(), otherTags[i].hasDynamicAttributes());
/** * Full class name */ public String getFullClassName() { if (isTagFile()) { return tagInfo.getTagClassName(); } return getServletPackageName() + '.' + getServletClassName(); }
/** * Checks to see if the attribute of the given name is of type * JspFragment. */ public boolean checkIfAttributeIsJspFragment(String name) { boolean result = false; TagAttributeInfo[] attributes = tagInfo.getAttributes(); for (int i = 0; i < attributes.length; i++) { if (attributes[i].getName().equals(name) && attributes[i].isFragment()) { result = true; break; } } return result; }
private static String getBodyType(Node.CustomTag custom) { if (custom.getTagInfo() != null) { return custom.getTagInfo().getBodyContent(); } return custom.getTagFileInfo().getTagInfo().getBodyContent(); }
public CustomTag(String jspVersion, String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagFileInfo tagFileInfo) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.jspVersion = Double.valueOf(jspVersion).doubleValue(); this.uri = uri; this.prefix = prefix; this.tagFileInfo = tagFileInfo; this.tagInfo = tagFileInfo.getTagInfo(); this.customNestingLevel = makeCustomNestingLevel(); this.childInfo = new ChildInfo(); this.implementsIterationTag = false; this.implementsBodyTag = false; this.implementsTryCatchFinally = false; this.implementsSimpleTag = true; this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes(); }
public TagAttributeInfo getAttributeInfo(String name) { if (_tagInfo == null) return null; TagAttributeInfo attrs[] = _tagInfo.getAttributes(); if (attrs == null) return null; for (int i = 0; i < attrs.length; i++) { if (name.equals(attrs[i].getName())) return attrs[i]; } return null; }
/** * Information on the scripting objects created by this tag at runtime. * This is a convenience method on the associated TagExtraInfo class. * * @param data TagData describing this action. * @return if a TagExtraInfo object is associated with this TagInfo, the * result of getTagExtraInfo().getVariableInfo( data ), otherwise * null. */ public VariableInfo[] getVariableInfo(TagData data) { VariableInfo[] result = null; TagExtraInfo tei = getTagExtraInfo(); if (tei != null) { result = tei.getVariableInfo( data ); } return result; }
/** * Validates the tag. */ public ValidationMessage []validate(TagData data) { if (isValid(data)) return null; else { ValidationMessage msg; String prefix = getTagInfo().getTagLibrary().getShortName(); String name = getTagInfo().getTagName(); if (prefix != null) name = prefix + ':' + name; msg = new ValidationMessage(null, "tag <" + name + "> was not valid according to validator `" + getClass().getName() + "'"); return new ValidationMessage[] { msg }; } } }
boolean canBeRequestTime(String name) { TagAttributeInfo attrs[] = _tagInfo.getAttributes(); if (attrs == null) return true; for (int i = 0; i < attrs.length; i++) { if (name.equals(attrs[i].getName())) return attrs[i].canBeRequestTime(); } return false; }
private Class substitute(TagInfo tagInfo) { String prefix = tagInfo.getTagLibrary().getPrefixString(); String name = tagInfo.getTagName(); TagKey[] matchingOrder = new TagKey[] { new TagKey(prefix, name), new TagKey(prefix) }; return firstMatch(mocks, matchingOrder); }
private TagInfo createTagInfo(TagXml tagXml) throws JasperException { String teiClassName = tagXml.getTeiClass(); TagExtraInfo tei = null; if (teiClassName != null && !teiClassName.isEmpty()) { try { Class<?> teiClass = ctxt.getClassLoader().loadClass(teiClassName); tei = (TagExtraInfo) teiClass.getConstructor().newInstance(); } catch (Exception e) { err.jspError(e, "jsp.error.teiclass.instantiation", teiClassName); } } List<TagAttributeInfo> attributeInfos = tagXml.getAttributes(); List<TagVariableInfo> variableInfos = tagXml.getVariables(); return new TagInfo(tagXml.getName(), tagXml.getTagClass(), tagXml.getBodyContent(), tagXml.getInfo(), this, tei, attributeInfos.toArray(new TagAttributeInfo[attributeInfos.size()]), tagXml.getDisplayName(), tagXml.getSmallIcon(), tagXml.getLargeIcon(), variableInfos.toArray(new TagVariableInfo[variableInfos.size()]), tagXml.hasDynamicAttributes()); }
if (ctxt.isTagFile()) { String versionString = ctxt.getTagInfo().getTagLibrary().getRequiredVersion(); Double version = Double.valueOf(versionString).doubleValue(); if (version < 2.1) {
/** * Translation-time validation of the attributes. * This is a convenience method on the associated TagExtraInfo class. * * @param data The translation-time TagData instance. * @return A null object, or zero length array if no errors, an * array of ValidationMessages otherwise. * @since JSP 2.0 */ public ValidationMessage[] validate( TagData data ) { TagExtraInfo tei = getTagExtraInfo(); if( tei == null ) { return null; } return tei.validate( data ); }
public void setTagData(TagData tagData) { this.tagData = tagData; this.varInfos = tagInfo.getVariableInfo(tagData); if (this.varInfos == null) { this.varInfos = ZERO_VARIABLE_INFO; } }
public TagVariableInfo[] getTagVariableInfos() { return tagInfo.getTagVariableInfos(); }
@Override public boolean isPre21Taglib() { if (_tagInfo == null) return false; TagLibraryInfo library = _tagInfo.getTagLibrary(); if (library == null || library.getRequiredVersion() == null) return false; return "2.1".compareTo(library.getRequiredVersion()) > 0; }
/** * True if this is a jstl node. */ @Override public boolean isJstl() { String uri = _tag.getTagInfo().getTagLibrary().getURI(); return (JavaJspBuilder.JSTL_CORE_URI.equals(uri) || JavaJspBuilder.JSTL_EL_CORE_URI.equals(uri) || JavaJspBuilder.JSTL_FMT_URI.equals(uri) || JavaJspBuilder.JSTL_XML_URI.equals(uri) || JavaJspBuilder.JSTL_EL_XML_URI.equals(uri) || JavaJspBuilder.JSTL_SQL_URI.equals(uri) || JavaJspBuilder.JSTL_EL_SQL_URI.equals(uri)); }