📄 notequaltag.java
字号:
package com.trulytech.mantis.tag;
import javax.servlet.jsp.tagext.*;
import java.io.IOException;
import javax.servlet.jsp.JspTagException;
import com.trulytech.mantis.result.DBColumn;
import com.trulytech.mantis.result.DBResult;
import java.util.ArrayList;
/*********************************************
*
<bean:notequal name="Result" col="0" row="0" key="22">
<%String a="aa";%>
<%=a%>
</bean:notequal>
*
*
*
*
**************************/
/**
* <p>Title: Mantis</p>
*
* <p>Description: 不等于标签</p>
*
* <p>Copyright: Copyright (c) 2002</p>
*
* <p>Company: </p>
*
* @author Wang Xian
* @version 1.1
*/
public class NotEqualTag
extends BodyTagSupport {
//行号
private int Col = 0;
//列号
private int Row = 0;
//是否等于标志
private boolean flag = false;
//Bean的名称
private String Name = null;
//等于的字符
private String Key = null;
public void setCol(int Col) {
this.Col = Col;
}
public void setKey(String Key) {
this.Key = Key;
}
public void setName(String Name) {
this.Name = Name;
}
public void setRow(int Row) {
this.Row = Row;
}
/**
* 覆盖doStartTag方法
* @return int
* @throws JspTagException
*/
public int doStartTag() throws JspTagException {
String tmpStr = null;
if (this.pageContext.findAttribute(Name) != null) {
//如果是DBResult
if (this.pageContext.findAttribute(Name) instanceof DBResult) {
if ( ( (DBResult)this.pageContext.findAttribute(Name)).ResultBuffer.
size() > Row) {
ArrayList rec = (ArrayList) ( ( (DBResult)this.pageContext.
findAttribute(Name)).ResultBuffer).
get(Row);
if (Col >= rec.size())
tmpStr = "";
else
tmpStr = ( (DBColumn) rec.get(Col)).Value;
}
else
tmpStr = "";
}
//如果是字符串
else if (this.pageContext.findAttribute(Name) instanceof String) {
tmpStr = (String)this.pageContext.findAttribute(Name);
}
else {
tmpStr = "";
}
}
else
tmpStr = "";
if (tmpStr == null || Key == null) {
flag = false;
return SKIP_BODY;
}
else if (tmpStr.equals(Key)) {
flag = false;
return SKIP_BODY;
}
else {
flag = true;
return EVAL_BODY_AGAIN;
}
}
public int doEndTag() throws JspTagException {
if (flag) {
try {
bodyContent.writeOut(bodyContent.getEnclosingWriter());
}
catch (IOException e) {
throw new JspTagException("Fatal error");
}
}
return EVAL_PAGE;
}
/**
* 结束body
* @return int
* @throws JspTagException
*/
public int doAfterBody() throws JspTagException {
return EVAL_PAGE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -