当前位置: 首页>>代码示例>>Java>>正文


Java TagPluginContext.generateJavaSource方法代码示例

本文整理汇总了Java中org.apache.jasper.compiler.tagplugin.TagPluginContext.generateJavaSource方法的典型用法代码示例。如果您正苦于以下问题:Java TagPluginContext.generateJavaSource方法的具体用法?Java TagPluginContext.generateJavaSource怎么用?Java TagPluginContext.generateJavaSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jasper.compiler.tagplugin.TagPluginContext的用法示例。


在下文中一共展示了TagPluginContext.generateJavaSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
    String condV = ctxt.getTemporaryVariableName();
    ctxt.generateJavaSource("boolean " + condV + "=");
    ctxt.generateAttribute("test");
    ctxt.generateJavaSource(";");
    if (ctxt.isAttributeSpecified("var")) {
        String scope = "PageContext.PAGE_SCOPE";
        if (ctxt.isAttributeSpecified("scope")) {
            String scopeStr = ctxt.getConstantAttribute("scope");
            if ("request".equals(scopeStr)) {
                scope = "PageContext.REQUEST_SCOPE";
            } else if ("session".equals(scopeStr)) {
                scope = "PageContext.SESSION_SCOPE";
            } else if ("application".equals(scopeStr)) {
                scope = "PageContext.APPLICATION_SCOPE";
            }
        }
        ctxt.generateJavaSource("_jspx_page_context.setAttribute(");
        ctxt.generateAttribute("var");
        ctxt.generateJavaSource(", new Boolean(" + condV + ")," + scope + ");");
    }
    ctxt.generateJavaSource("if (" + condV + "){");
    ctxt.generateBody();
    ctxt.generateJavaSource("}");
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:27,代码来源:If.java

示例2: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
    
    //scope flag
    boolean hasScope = ctxt.isAttributeSpecified("scope");
    
    //the value of the "var"
    String strVar = ctxt.getConstantAttribute("var");
    
    //remove attribute from certain scope.
    //default scope is "page".
    if(hasScope){
        int iScope = Util.getScope(ctxt.getConstantAttribute("scope"));
        ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
    }else{
        ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\");");
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:Remove.java

示例3: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
	// Get the parent context to determine if this is the first <c:when>
	TagPluginContext parentContext = ctxt.getParentContext();
	if (parentContext == null) {
		ctxt.dontUseTagPlugin();
		return;
	}

	if ("true".equals(parentContext.getPluginAttribute("hasBeenHere"))) {
		ctxt.generateJavaSource("} else if(");
		// See comment below for the reason we generate the extra "}" here.
	} else {
		ctxt.generateJavaSource("if(");
		parentContext.setPluginAttribute("hasBeenHere", "true");
	}
	ctxt.generateAttribute("test");
	ctxt.generateJavaSource("){");
	ctxt.generateBody();

	// We don't generate the closing "}" for the "if" here because there
	// may be whitespaces in between <c:when>'s. Instead we delay
	// generating it until the next <c:when> or <c:otherwise> or
	// <c:choose>
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:26,代码来源:When.java

示例4: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
	String condV = ctxt.getTemporaryVariableName();
	ctxt.generateJavaSource("boolean " + condV + "=");
	ctxt.generateAttribute("test");
	ctxt.generateJavaSource(";");
	if (ctxt.isAttributeSpecified("var")) {
		String scope = "PageContext.PAGE_SCOPE";
		if (ctxt.isAttributeSpecified("scope")) {
			String scopeStr = ctxt.getConstantAttribute("scope");
			if ("request".equals(scopeStr)) {
				scope = "PageContext.REQUEST_SCOPE";
			} else if ("session".equals(scopeStr)) {
				scope = "PageContext.SESSION_SCOPE";
			} else if ("application".equals(scopeStr)) {
				scope = "PageContext.APPLICATION_SCOPE";
			}
		}
		ctxt.generateJavaSource("_jspx_page_context.setAttribute(");
		ctxt.generateAttribute("var");
		ctxt.generateJavaSource(", new Boolean(" + condV + ")," + scope + ");");
	}
	ctxt.generateJavaSource("if (" + condV + "){");
	ctxt.generateBody();
	ctxt.generateJavaSource("}");
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:If.java

示例5: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
public void doTag(TagPluginContext ctxt) {
    
    //scope flag
    boolean hasScope = ctxt.isAttributeSpecified("scope");
    
    //the value of the "var"
    String strVar = ctxt.getConstantAttribute("var");
    
    //remove attribute from certain scope.
    //default scope is "page".
    if(hasScope){
        int iScope = Util.getScope(ctxt.getConstantAttribute("scope"));
        ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
    }else{
        ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\");");
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:Remove.java

示例6: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {

    //scope flag
    boolean hasScope = ctxt.isAttributeSpecified("scope");

    //the value of the "var"
    String strVar = ctxt.getConstantAttribute("var");

    //remove attribute from certain scope.
    //default scope is "page".
    if(hasScope){
        int iScope = Util.getScope(ctxt.getConstantAttribute("scope"));
        ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
    }else{
        ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\");");
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:19,代码来源:Remove.java

示例7: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
    // Get the parent context to determine if this is the first <c:when>
    TagPluginContext parentContext = ctxt.getParentContext();
    if (parentContext == null) {
        ctxt.dontUseTagPlugin();
        return;
    }

    if ("true".equals(parentContext.getPluginAttribute("hasBeenHere"))) {
        ctxt.generateJavaSource("} else if(");
        // See comment below for the reason we generate the extra "}" here.
    }
    else {
        ctxt.generateJavaSource("if(");
        parentContext.setPluginAttribute("hasBeenHere", "true");
    }
    ctxt.generateAttribute("test");
    ctxt.generateJavaSource("){");
    ctxt.generateBody();

    // We don't generate the closing "}" for the "if" here because there
    // may be whitespaces in between <c:when>'s.  Instead we delay
    // generating it until the next <c:when> or <c:otherwise> or
    // <c:choose>
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:27,代码来源:When.java

示例8: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
    // Get the parent context to determine if this is the first <c:when>
    TagPluginContext parentContext = ctxt.getParentContext();
    if (parentContext == null) {
        ctxt.dontUseTagPlugin();
        return;
    }
    
    if ("true".equals(parentContext.getPluginAttribute("hasBeenHere"))) {
        ctxt.generateJavaSource("} else if(");
        // See comment below for the reason we generate the extra "}" here.
    }
    else {
        ctxt.generateJavaSource("if(");
        parentContext.setPluginAttribute("hasBeenHere", "true");
    }
    ctxt.generateAttribute("test");
    ctxt.generateJavaSource("){");
    ctxt.generateBody();
    
    // We don't generate the closing "}" for the "if" here because there
    // may be whitespaces in between <c:when>'s.  Instead we delay
    // generating it until the next <c:when> or <c:otherwise> or
    // <c:choose>
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:27,代码来源:When.java

示例9: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
    
    // Not much to do here, much of the work will be done in the
    // containing tags, <c:when> and <c:otherwise>.
    
    ctxt.generateBody();
    // See comments in When.java for the reason "}" is generated here.
    ctxt.generateJavaSource("}");
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:11,代码来源:Choose.java

示例10: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {

	// Not much to do here, much of the work will be done in the
	// containing tags, <c:when> and <c:otherwise>.

	ctxt.generateBody();
	// See comments in When.java for the reason "}" is generated here.
	ctxt.generateJavaSource("}");
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:11,代码来源:Choose.java

示例11: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
    
    // See When.java for the reason whey "}" is need at the beginng and
    // not at the end.
    ctxt.generateJavaSource("} else {");
    ctxt.generateBody();
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:9,代码来源:Otherwise.java

示例12: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {

    // See When.java for the reason whey "}" is need at the beginng and
    // not at the end.
    ctxt.generateJavaSource("} else {");
    ctxt.generateBody();
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:Otherwise.java

示例13: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {

    // Not much to do here, much of the work will be done in the
    // containing tags, <c:when> and <c:otherwise>.

    ctxt.generateBody();
    // See comments in When.java for the reason "}" is generated here.
    ctxt.generateJavaSource("}");
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:11,代码来源:Choose.java

示例14: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {

	String index = null;

	boolean hasVarStatus = ctxt.isAttributeSpecified("varStatus");
	if (hasVarStatus) {
		ctxt.dontUseTagPlugin();
		return;
	}

	hasVar = ctxt.isAttributeSpecified("var");
	hasBegin = ctxt.isAttributeSpecified("begin");
	hasEnd = ctxt.isAttributeSpecified("end");
	hasStep = ctxt.isAttributeSpecified("step");

	boolean hasItems = ctxt.isAttributeSpecified("items");
	if (hasItems) {
		doCollection(ctxt);
		return;
	}

	// We must have a begin and end attributes
	index = ctxt.getTemporaryVariableName();
	ctxt.generateJavaSource("for (int " + index + " = ");
	ctxt.generateAttribute("begin");
	ctxt.generateJavaSource("; " + index + " <= ");
	ctxt.generateAttribute("end");
	if (hasStep) {
		ctxt.generateJavaSource("; " + index + "+=");
		ctxt.generateAttribute("step");
		ctxt.generateJavaSource(") {");
	} else {
		ctxt.generateJavaSource("; " + index + "++) {");
	}

	// If var is specified and the body contains an EL, then sycn
	// the var attribute
	if (hasVar /* && ctxt.hasEL() */) {
		ctxt.generateJavaSource("_jspx_page_context.setAttribute(");
		ctxt.generateAttribute("var");
		ctxt.generateJavaSource(", String.valueOf(" + index + "));");
	}
	ctxt.generateBody();
	ctxt.generateJavaSource("}");
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:47,代码来源:ForEach.java

示例15: doTag

import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
    
    //don't support the body content
    
    //define names of all the temp variables
    String nameName = ctxt.getTemporaryVariableName();
    String valueName = ctxt.getTemporaryVariableName();
    String urlName = ctxt.getTemporaryVariableName();
    String encName = ctxt.getTemporaryVariableName();
    String index = ctxt.getTemporaryVariableName();
    
    //if the param tag has no parents, throw a exception
    TagPluginContext parent = ctxt.getParentContext();
    if(parent == null){
        ctxt.generateJavaSource(" throw new JspTagExcption" +
        "(\"&lt;param&gt; outside &lt;import&gt; or &lt;urlEncode&gt;\");");
        return;
    }
    
    //get the url string before adding this param
    ctxt.generateJavaSource("String " + urlName + " = " +
    "(String)pageContext.getAttribute(\"url_without_param\");");
    
    //get the value of "name"
    ctxt.generateJavaSource("String " + nameName + " = ");
    ctxt.generateAttribute("name");
    ctxt.generateJavaSource(";");
    
    //if the "name" is null then do nothing.
    //else add such string "name=value" to the url.
    //and the url should be encoded
    ctxt.generateJavaSource("if(" + nameName + " != null && !" + nameName + ".equals(\"\")){");
    ctxt.generateJavaSource("    String " + valueName + " = ");
    ctxt.generateAttribute("value");
    ctxt.generateJavaSource(";");
    ctxt.generateJavaSource("    if(" + valueName + " == null) " + valueName + " = \"\";");
    ctxt.generateJavaSource("    String " + encName + " = pageContext.getResponse().getCharacterEncoding();");
    ctxt.generateJavaSource("    " + nameName + " = java.net.URLEncoder.encode(" + nameName + ", " + encName + ");");
    ctxt.generateJavaSource("    " + valueName + " = java.net.URLEncoder.encode(" + valueName + ", " + encName + ");");
    ctxt.generateJavaSource("    int " + index + ";");
    ctxt.generateJavaSource("    " + index + " = " + urlName + ".indexOf(\'?\');");
    //if the current param is the first one, add a "?" ahead of it
    //else add a "&" ahead of it
    ctxt.generateJavaSource("    if(" + index + " == -1){");
    ctxt.generateJavaSource("        " + urlName + " = " + urlName + " + \"?\" + " + nameName + " + \"=\" + " + valueName + ";");
    ctxt.generateJavaSource("    }else{");
    ctxt.generateJavaSource("        " + urlName + " = " + urlName + " + \"&\" + " + nameName + " + \"=\" + " + valueName + ";");
    ctxt.generateJavaSource("    }");
    ctxt.generateJavaSource("    pageContext.setAttribute(\"url_without_param\"," + urlName + ");");
    ctxt.generateJavaSource("}");
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:53,代码来源:Param.java


注:本文中的org.apache.jasper.compiler.tagplugin.TagPluginContext.generateJavaSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。