/** * Determine whether the supplied {@link Tag} has any ancestor tag * of the supplied type. * @param tag the tag whose ancestors are to be checked * @param ancestorTagClass the ancestor {@link Class} being searched for * @return {@code true} if the supplied {@link Tag} has any ancestor tag * of the supplied type * @throws IllegalArgumentException if either of the supplied arguments is {@code null}; * or if the supplied {@code ancestorTagClass} is not type-assignable to * the {@link Tag} class */ public static boolean hasAncestorOfType(Tag tag, Class<?> ancestorTagClass) { Assert.notNull(tag, "Tag cannot be null"); Assert.notNull(ancestorTagClass, "Ancestor tag class cannot be null"); if (!Tag.class.isAssignableFrom(ancestorTagClass)) { throw new IllegalArgumentException( "Class '" + ancestorTagClass.getName() + "' is not a valid Tag type"); } Tag ancestor = tag.getParent(); while (ancestor != null) { if (ancestorTagClass.isAssignableFrom(ancestor.getClass())) { return true; } ancestor = ancestor.getParent(); } return false; }
@Override public void close() { if (closed) { return; } closed = true; if (needPop) { pageContext.popWriter(); } pageContext.popTopTag(); try { if (isTryCatchFinally) { ((TryCatchFinally) tag).doFinally(); } // No pooling yet tag.release(); } finally { if (needDoublePop) { pageContext.popWriter(); } } }
private void endEvaluation() throws JspException { if (needPop) { pageContext.popWriter(); needPop = false; } if (tag.doEndTag() == Tag.SKIP_PAGE) { LOG.warn("Tag.SKIP_PAGE was ignored from a " + tag.getClass().getName() + " tag."); } }
FreeMarkerPageContext pageContext = PageContextFactory.getCurrentPageContext(); Tag parentTag = (Tag) pageContext.peekTopTag(Tag.class); tag.setParent(parentTag); tag.setPageContext(pageContext); setupTag(tag, args, pageContext.getObjectWrapper());
private static void writeTagInternal( PageContext context, Tag tag, Tag parentTag ) throws JspException { tag.setPageContext( context ); tag.setParent( parentTag ); int returnCode = tag.doStartTag(); tag.doEndTag(); } finally { tag.release();
try int result = tag.doStartTag(); if(Tag.EVAL_BODY_INCLUDE == result) returnValue = tag.doEndTag(); if(doRelease) tag.release(); return returnValue;
@Override protected void doRender(TttWriter tw) throws Exception { // try { tag.doStartTag(); tag.doEndTag(); // } finally { // tag.release(); // } } }
tag.setPageContext(stringPageContext); tag.doStartTag(); tag.doEndTag();
public int onStart() throws TemplateModelException { try { int dst = tag.doStartTag(); switch(dst) { case Tag.SKIP_BODY:
/** * Constructor for a tag with the specified attribute map. * If the specified tag is not an instance of <code>TagSupport</code>, * the methods that delegate to <code>TagSupport</code> specific methods * throw an exception. * @param tag the tag * @param pageContext the corresponding <code>PageContext</code> * @param attributes the attribute map */ public NestedStandardTag(Tag tag, PageContext pageContext, Map attributes) { this.tag = tag; this.pageContext = pageContext; tag.setPageContext(pageContext); childs = new ArrayList(); this.attributes = attributes; doRelease = false; }
/** * Assert that the return value of doStartTag is equal to an expectedValue * @param expectedValue value to check against doStartTag */ public void assertDoStartTag(final int expectedValue) throws JspException { testSubject.setPageContext(pageContext); checkReturnValue("doStartTag", expectedValue, testSubject.doStartTag()); }
try int result = tag.doStartTag(); if(Tag.EVAL_BODY_INCLUDE == result) returnValue = tag.doEndTag(); if(doRelease) tag.release(); return returnValue;
public TagTemplate(PageContext pageContext, T tag, B parent) { this.tag = tag; tag.setPageContext(pageContext); if (parent != null) { tag.setParent(parent); } }
protected void processTag(final PageContext pageContext, final Tag tag) throws JspException { if (Tag.SKIP_BODY != tag.doStartTag()) { processChildren(pageContext, tag); tag.doEndTag(); } }
/** * Delegates to wrapped tag. */ public int doStartTag() throws JspException { return tag.doStartTag(); }
/** * Constructor for a tag with the specified attribute map. * If the specified tag is not an instance of <code>TagSupport</code>, * the methods that delegate to <code>TagSupport</code> specific methods * throw an exception. * @param tag the tag * @param pageContext the corresponding <code>PageContext</code> * @param attributes the attribute map */ public NestedStandardTag(Tag tag, PageContext pageContext, Map attributes) { this.tag = tag; this.pageContext = pageContext; tag.setPageContext(pageContext); childs = new ArrayList(); this.attributes = attributes; doRelease = false; }
/** * Determine whether the supplied {@link Tag} has any ancestor tag * of the supplied type. * @param tag the tag whose ancestors are to be checked * @param ancestorTagClass the ancestor {@link Class} being searched for * @return {@code true} if the supplied {@link Tag} has any ancestor tag * of the supplied type * @throws IllegalArgumentException if either of the supplied arguments is {@code null}; * or if the supplied {@code ancestorTagClass} is not type-assignable to * the {@link Tag} class */ public static boolean hasAncestorOfType(Tag tag, Class<?> ancestorTagClass) { Assert.notNull(tag, "Tag cannot be null"); Assert.notNull(ancestorTagClass, "Ancestor tag class cannot be null"); if (!Tag.class.isAssignableFrom(ancestorTagClass)) { throw new IllegalArgumentException( "Class '" + ancestorTagClass.getName() + "' is not a valid Tag type"); } Tag ancestor = tag.getParent(); while (ancestor != null) { if (ancestorTagClass.isAssignableFrom(ancestor.getClass())) { return true; } ancestor = ancestor.getParent(); } return false; }
/** * Calls the release() method of all available tag handlers in this tag * handler pool. */ public synchronized void release() { for (int i=current; i>=0; i--) { handlers[i].release(); } }