1 34 35 36 package com.micronova.jsp.tag; 37 38 import java.util.*; 39 import java.util.regex.*; 40 import java.sql.*; 41 import javax.servlet.jsp.*; 42 import org.apache.taglibs.standard.tag.common.sql.TransactionTagSupport; 43 import org.apache.taglibs.standard.tag.common.sql.ResultImpl; 44 import com.micronova.util.*; 45 46 47 48 public class QueryTag extends UpdateTag 49 { 50 private static final String DEFAULTPATTERN = "[%]\\{([^\\}]*)\\}"; 51 52 private static final Pattern defaultPattern = Pattern.compile(DEFAULTPATTERN); 53 54 protected int _startRow; 55 protected int _maxRows; 56 57 protected static Pattern getDefaultPattern(Object patternSpec) 58 { 59 if (DEFAULTPATTERN.equals(patternSpec)) 60 { 61 return defaultPattern; 62 } 63 else 64 { 65 return QueryTag.getDefaultPattern(patternSpec); 66 } 67 } 68 69 70 public void init() 71 { 72 super.init(); 73 74 _pattern = DEFAULTPATTERN; 75 _startRow = 0; 76 _maxRows = -1; 77 } 78 79 public void setStartRow(Object expression) throws Exception 80 { 81 _startRow = ((Integer )evaluateAttribute("startRow", expression, Integer .class)).intValue(); 82 } 83 84 public void setMaxRows(Object expression) throws Exception 85 { 86 _maxRows = ((Integer )evaluateAttribute("maxRows", expression, Integer .class)).intValue(); 87 } 88 89 protected Object doSql(PreparedStatement preparedStatement) throws Exception 90 { 91 return new ResultImpl(preparedStatement.executeQuery(), _startRow, _maxRows); 92 } 93 } 94 | Popular Tags |