taglib has been abandoned by the original author and is of questionable value

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@153428 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2005-02-11 18:09:36 +00:00
parent 6d5d317091
commit 5c6742ce72
17 changed files with 0 additions and 1918 deletions

View File

@ -1,53 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Lucene" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Lucene", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/

View File

@ -1,49 +0,0 @@
/*
* Created on May 18, 2003
*
*/
package com.netwebapps.taglib.search;
import java.lang.reflect.Method;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
;
/**
* @author blaplante
*
*/
public class CollectionTag extends TagSupport{
String directory = "";
/* (non-Javadoc)
* @see javax.servlet.jsp.tagext.Tag#doStartTag()
*/
public int doStartTag() throws JspException {
Object parent = getParent();
if(parent != null){
try{
Method call = parent.getClass().getMethod("addCollection", new Class[] {Class.forName("java.lang.String")});
call.invoke(parent, new String[] {directory});
}
catch(Exception e){
throw new JspException("An error occured while trying to add a new collection path: " + e.getCause());
}
}
return SKIP_BODY;
}
/* (non-Javadoc)
* @see javax.servlet.jsp.tagext.Tag#release()
*/
public void release() {
directory = null;
}
/**
* @param string
*/
public void setDirectory(String dir) {
this.directory = dir;
}
}

View File

@ -1,192 +0,0 @@
/*
* Created on May 24, 2003
*/
package com.netwebapps.taglib.search;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Set;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;
/**
* @company Network Web Application
* @url http://www.netwebapps.com
* @author Bryan LaPlante
*/
public class ColumnTag extends BodyTagSupport{
private Object parent = null;
private Set fieldSet = null;
private ArrayList fieldArray = new ArrayList();
private Iterator fieldNames = null;
private Iterator nextField = null;
private Method getFieldsMethod = null;
private boolean abort = false;
public boolean throwOnException = false;
public String columnName = "";
public boolean runOnce = false;
public int columnCount = 0;
public int doStartTag() throws JspException{
parent = findAncestorWithClass(this,com.netwebapps.taglib.search.SearchTag.class);
if(runOnce && getLoopCount() > 1){
abort = true;
return SKIP_BODY;
}
try {
getFieldsMethod = (Method) parent.getClass().getMethod("getFields",null);
fieldSet = (Set) getFieldsMethod.invoke(parent, null);
} catch (SecurityException e) {
if(throwOnException){
throw new JspException("A security violation occurred: " + e);
}
abort = true;
} catch (IllegalArgumentException e) {
if(throwOnException){
throw new JspException("IllegalArgumentException: " + e);
}
abort = true;
} catch (NoSuchMethodException e) {
if(throwOnException){
throw new JspException("Unable to declair the getField method : " + e);
}
abort = true;
} catch (IllegalAccessException e) {
if(throwOnException){
throw new JspException("Access denied: " + e);
}
abort = true;
} catch (InvocationTargetException e) {
if(throwOnException){
throw new JspException("This tag must be nested in a Search tag in order to work: " + e);
}
abort = true;
}catch(NullPointerException e){
if(throwOnException){
throw new JspException(e);
}
abort = true;
}
if(abort){
return SKIP_BODY;
}
if(fieldSet != null){
nextField = fieldSet.iterator();
while(nextField.hasNext()){
fieldArray.add(nextField.next());
}
columnCount = fieldSet.size();
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
return EVAL_BODY_AGAIN;
}
return SKIP_BODY;
}
public void doInitBody() throws JspException{
if(!abort){
if (fieldArray.size() > 0) {
fieldNames = fieldArray.iterator();
if(fieldNames.hasNext()){
columnName = (String) fieldNames.next();
columnCount = fieldSet.size();
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
}
}
}
}
public int doAfterBody() throws JspException{
if(abort){
return SKIP_BODY;
}
columnName = "";
try{
getBodyContent().writeOut(getPreviousOut());
getBodyContent().clearBody();
}
catch(IOException e){
throw new JspException(e.toString());
}
if(fieldNames != null){
if(fieldNames.hasNext()){
columnName = (String) fieldNames.next();
columnCount = fieldSet.size();
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
return EVAL_BODY_AGAIN;
}
}
return SKIP_BODY;
}
public void release(){
parent = null;
fieldSet = null;
fieldArray = null;
fieldNames = null;
nextField = null;
getFieldsMethod = null;
}
private int getLoopCount() throws JspException{
Field getLoopCountMember = null;
int rc = 0;
try {
getLoopCountMember = (Field) parent.getClass().getField("loopCount");
rc = new Integer(getLoopCountMember.get(parent).toString()).intValue();
} catch (SecurityException e) {
if(throwOnException){
throw new JspException("A security violation occurred: " + e);
}
} catch (NoSuchFieldException e) {
if(throwOnException){
throw new JspException("Unable to find the loopCount field : " + e);
}
}catch(IllegalAccessException e){
if(throwOnException){
throw new JspException("Access denied: " + e);
}
}catch(IllegalArgumentException e){
if(throwOnException){
throw new JspException("Bad argument: " + e);
}
}
return rc;
}
/**
* @param string
*/
public void setcolumnName(String columnName) {
this.columnName = columnName;
}
/**
* @param b
*/
public void setThrowOnException(String b) {
throwOnException = new Boolean(b).booleanValue();
}
public void setThrowOnException(boolean b) {
throwOnException = b;
}
public void setRunOnce(boolean b){
runOnce = b;
}
public void setRunOnce(String b){
runOnce = new Boolean(b).booleanValue();
}
}

View File

@ -1,29 +0,0 @@
/*
* Created on May 24, 2003
*/
package com.netwebapps.taglib.search;
/**
* @company Network Web Application
* @url http://www.netwebapps.com
* @author Bryan LaPlante
*/
import javax.servlet.jsp.tagext.*;
public class ColumnTagTei extends TagExtraInfo
{
public ColumnTagTei(){
}
/*
* VariableInfo is provided by the servlet container and allows the
* FieldTag class to output it's tag variables to the PageContext at runtime
* @see javax.servlet.jsp.tagext.TagExtraInfo#getVariableInfo(javax.servlet.jsp.tagext.TagData)
*/
public VariableInfo[] getVariableInfo(TagData tagdata)
{
VariableInfo avariableinfo[] = new VariableInfo[1];
avariableinfo[0] = new VariableInfo(tagdata.getId(),"com.netwebapps.taglib.search.ColumnTag", true, VariableInfo.NESTED);
return avariableinfo;
}
}

View File

@ -1,96 +0,0 @@
/*
* Created on May 23, 2003
*
*/
package com.netwebapps.taglib.search;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
/**
* @company Network Web Application
* @url http://www.netwebapps.com
* @author Bryan LaPlante
*/
public class FieldTag extends TagSupport{
public String name = "";
public boolean throwOnException = false;
public String value = "";
private boolean abort = false;
/* (non-Javadoc)
* @see javax.servlet.jsp.tagext.BodyTagSupport#doEndTag()
*/
public int doStartTag() throws JspException {
Object parent = findAncestorWithClass(this,com.netwebapps.taglib.search.SearchTag.class);
try {
Method getFieldMethod = parent.getClass().getMethod("getField", new Class[] {Class.forName("java.lang.String")});
value = getFieldMethod.invoke(parent, new String[] {name}).toString();
} catch (SecurityException e) {
if(throwOnException){
throw new JspException("A security violation occurred: " + e);
}
abort = true;
} catch (NoSuchMethodException e) {
if(throwOnException){
throw new JspException("Unable to declair the getField method : " + e);
}
abort = true;
} catch (ClassNotFoundException e) {
if(throwOnException){
throw new JspException("ClassNotFoundException: " + e);
}
}catch (IllegalAccessException e) {
if(throwOnException){
throw new JspException("Access denied: " + e);
}
abort = true;
}catch (InvocationTargetException e) {
if(throwOnException){
throw new JspException("This tag must be nested in a Search tag in order to work: " + e);
}
abort = true;
}catch(NullPointerException e){
if(throwOnException){
throw new JspException("This tag must be nested in a Search tag in order to work: " + e);
}
abort = true;
}
if(abort){
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
return SKIP_BODY;
}
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
return EVAL_BODY_INCLUDE;
}
public void release(){
name = "";
throwOnException = false;
value = "";
}
/**
* @param string
*/
public void setName(String string) {
name = string;
}
/**
* @param b
*/
public void setThrowOnException(String b) {
throwOnException = new Boolean(b).booleanValue();
}
public void setThrowOnException(boolean b) {
throwOnException = b;
}
}

View File

@ -1,29 +0,0 @@
/*
* Created on May 24, 2003
*/
package com.netwebapps.taglib.search;
/**
* @company Network Web Application
* @url http://www.netwebapps.com
* @author Bryan LaPlante
*/
import javax.servlet.jsp.tagext.*;
public class FieldTagTei extends TagExtraInfo
{
public FieldTagTei(){
}
/*
* VariableInfo is provided by the servlet container and allows the
* FieldTag class to output it's tag variables to the PageContext at runtime
* @see javax.servlet.jsp.tagext.TagExtraInfo#getVariableInfo(javax.servlet.jsp.tagext.TagData)
*/
public VariableInfo[] getVariableInfo(TagData tagdata)
{
VariableInfo avariableinfo[] = new VariableInfo[1];
avariableinfo[0] = new VariableInfo(tagdata.getId(),"com.netwebapps.taglib.search.FieldTag", true, VariableInfo.NESTED);
return avariableinfo;
}
}

View File

@ -1,485 +0,0 @@
package com.netwebapps.taglib.search;
import java.io.File;
import java.io.IOException;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.analysis.WhitespaceAnalyzer;
import org.apache.lucene.analysis.de.GermanAnalyzer;
import org.apache.lucene.analysis.de.WordlistLoader;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.queryParser.MultiFieldQueryParser;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MultiSearcher;
import org.apache.lucene.search.Query;
/*
*
* @company Network Web Application
* @url http://www.netwebapps.com
* @author Bryan LaPlante
*
*/
public class SearchTag extends BodyTagSupport{
private HashMap hitMap = null;
private ArrayList hitArray = null;
private IndexSearcher searcher = null;
private Query query = null;
private Hits hits = null;
private int thispage = 0;
private String criteria = "";
private Iterator searchItr = null;
private Enumeration fields = null;
private HashMap aField = new HashMap();
private int ROWCOUNT = 0;
private int PAGECOUNT = 0;
private int HITCOUNT = 0;
private boolean abort = false;
private Analyzer analyzer = null;
private Document doc = null;
private ArrayList idxArray = new ArrayList();
private MultiSearcher msearcher = null;
private final int GERMAN_ANALYZER = 0;
private final int SIMPLE_ANALYZER = 1;
private final int STANDARD_ANALYZER = 2;
private final int STOP_ANALYZER = 3;
private final int WHITESPACE_ANALYZER = 4;
public int startRow = 0;
public int maxRows = 50;
public int rowCount = 0;
public int pageCount = 1;
public int hitCount = 0;
public int loopCount = 0;
public String firstPage = "";
public String nextPage = "";
public String previousPage = "";
public String lastPage = "";
public LinkedList pageList = new LinkedList();
public boolean throwOnException = false;
public String[] stopWords = new String[0];
public String[] fieldList = new String[0];
public int[] flagList = new int[0];
public String search = "contents";
public int analyzerType = STANDARD_ANALYZER;
public int doStartTag() throws JspException{
rowCount = startRow + ROWCOUNT++;
loopCount++;
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
return EVAL_BODY_AGAIN;
}
public void doInitBody() throws JspException{
doSearch();
if(!abort){
searchItr = hitArray.iterator();
if(searchItr.hasNext()){
aField = (HashMap) searchItr.next();
rowCount = startRow + ROWCOUNT++;
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
}
}
}
public int doAfterBody() throws JspException{
if(abort){
hitCount = 0;
loopCount = 0;
rowCount = startRow + ROWCOUNT;
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
return SKIP_BODY;
}
try{
getBodyContent().writeOut(getPreviousOut());
getBodyContent().clearBody();
}
catch(IOException e){
throw new JspException(e.toString());
}
if(searchItr.hasNext()){
aField = (HashMap) searchItr.next();
rowCount = startRow + ROWCOUNT++;
loopCount++;
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
return EVAL_BODY_AGAIN;
}
return SKIP_BODY;
}
public int doEndTag() throws JspException{
if(abort){
hitCount = 0;
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
return EVAL_PAGE;
}
try{
HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
String relativePath = req.getRequestURI();
firstPage = relativePath + "?startRow=0&maxRows=" + maxRows;
nextPage = relativePath + "?startRow=" + ((startRow + maxRows <= HITCOUNT)? startRow + maxRows : startRow) + "&maxRows=" + maxRows;
previousPage = relativePath + "?startRow=" + ((startRow - maxRows >=0)? startRow - maxRows : 0 ) + "&maxRows=" + maxRows;
lastPage = relativePath + "?startRow=" + (((HITCOUNT - maxRows) >= 0)? HITCOUNT - maxRows : 0) + "&maxRows=" + maxRows;
if(HITCOUNT > 0){
pageList = new LinkedList();
for(int i=0; i < (HITCOUNT / maxRows); i++){
String tempURL = relativePath + "?startRow=" + (maxRows * i) + "&maxRows=" + maxRows;
pageList.add(tempURL);
}
}
}
catch(Exception e){
throw new JspException("A problem occured durring doEndTag: " + e.toString());
}
pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);
return EVAL_PAGE;
}
public void release(){
hitMap = null;
hitArray = null;
searcher = null;
query = null;
hits = null;
thispage = 0;
criteria = "";
searchItr = null;
fields = null;
aField = new HashMap();
ROWCOUNT = 0;
PAGECOUNT = 1;
HITCOUNT = 0;
abort = false;
analyzer = null;
doc = null;
idxArray = null;
msearcher = null;
}
public String getField(String name){
if(aField != null){
if(aField.containsKey(name)){
return aField.get(name).toString();
}
}
return "";
}
public Set getFields(){
return aField.keySet();
}
public void addCollection(String name) throws JspException{
try {
searcher = new IndexSearcher(IndexReader.open(name));
idxArray.add(searcher);
} catch (IOException e) {
if(throwOnException){
throw new JspException("Error occured while opening " + name + " ]: " + e);
}
}
}
public void doSearch() throws JspException{
try {
if(idxArray.size() > 0){
IndexSearcher[] idxToArray = new IndexSearcher[idxArray.size()];
Iterator idxIter = idxArray.iterator();
int arrayCount = 0;
while(idxIter.hasNext()){
idxToArray[arrayCount++] = (IndexSearcher) idxIter.next();
}
msearcher = new MultiSearcher(idxToArray);
}else{
throw new JspException("No collection has been specified");
}
} catch (IOException e) {
if(throwOnException){
throw new JspException("IndexSearcher(IndexReader.open(collection)): " + e);
}
abort = true;
}
if(!abort){
// choosing the type of analyzer to use in this search
switch (analyzerType) {
case GERMAN_ANALYZER:
if(stopWords.length > 0){
analyzer = new GermanAnalyzer(stopWords);
}else{
if(throwOnException){
throw new JspException("In order to use a GermanAnalyzer you must provide a list of stop words");
}
abort = true;
}
break;
case SIMPLE_ANALYZER:
analyzer = new SimpleAnalyzer();
break;
case STANDARD_ANALYZER:
if(stopWords.length > 0){
analyzer = new StandardAnalyzer(stopWords);
}else{
analyzer = new StandardAnalyzer();
}
break;
case STOP_ANALYZER:
if(stopWords.length > 0){
analyzer = new StopAnalyzer(stopWords);
}else{
analyzer = new StopAnalyzer();
}
break;
case WHITESPACE_ANALYZER:
analyzer = new WhitespaceAnalyzer();
break;
default :
if(stopWords.length > 0){
analyzer = new StandardAnalyzer(stopWords);
}else{
analyzer = new StandardAnalyzer();
}
break;
}
try {
// choose a query parser
if(fieldList.length > 0){
if(flagList.length > 0){
query = MultiFieldQueryParser.parse(criteria,fieldList,flagList,analyzer);
}else{
query = MultiFieldQueryParser.parse(criteria,fieldList,analyzer);
}
}else{
query = QueryParser.parse(criteria, search, analyzer);
}
} catch (ParseException e) {
if(throwOnException){
throw new JspException("If using fieldList and or flagList check to see you have the same number of items in each: " + e);
}
abort = true;
}
if(!abort){
try {
hits = msearcher.search(query);
} catch (IOException e) {
if(throwOnException){
throw new JspException("msearcher.search(query): " + e);
}
abort = true;
}
if(!abort){
hitCount = hits.length();
HITCOUNT = hits.length();
PAGECOUNT = (int) (( (double) startRow) / maxRows );
pageCount = PAGECOUNT;
thispage = maxRows;
if ((startRow + maxRows) > hits.length()) {
thispage = hits.length() - startRow;
}
hitArray = new ArrayList();
for (int i = startRow; i < (thispage + startRow); i++) {
hitMap = new HashMap();
try {
doc = hits.doc(i);
} catch (IOException e) {
if(throwOnException){
throw new JspException("hits.doc(i) : " + e);
}
abort = true;
}
if(!abort){
try {
hitMap.put("score",new Float(hits.score(i)).toString());
} catch (IOException e) {
if(throwOnException){
throw new JspException("hitMap.put(score,new Float(hits.score(i)).toString()); : " + e);
}
abort = true;
}
if(!abort){
fields = doc.fields();
while(fields.hasMoreElements()){
Field field = (Field) fields.nextElement();
String fieldName = field.name();
hitMap.put(fieldName,doc.get(fieldName));
}
hitArray.add(hitMap);
}
}
}
}
}
}
if(msearcher != null){
try {
msearcher.close();
} catch (IOException e) {
if(throwOnException){
throw new JspException("A problem occured trying to close the searcher : " + e);
}
}
}
}
public void setCriteria(String criteria){
this.criteria = criteria;
}
public void setStartRow(String startRow){
try{
this.startRow = Integer.parseInt(startRow);
}
catch(Exception e){
this.startRow = 0;
}
}
public void setStartRow(int startRow){
this.startRow = startRow;
}
public void setMaxRows(String maxRows){
try{
this.maxRows = Integer.parseInt(maxRows);
}
catch(Exception e){
this.maxRows = 10;
}
}
public void setMaxRows(int maxRows){
this.maxRows = maxRows;
}
public void setCollection(String collection) throws JspException{
idxArray = new ArrayList();
String[] collectionArray = collection.split(",");
for(int i=0; i<collectionArray.length; i++){
this.addCollection(collectionArray[i]);
}
}
public void setThrowOnException(String bool){
this.throwOnException = new Boolean(bool).booleanValue();
}
public void setThrowOnException(boolean b) {
throwOnException = b;
}
public int getStartRow(){
return startRow;
}
public int getMaxRows(){
return maxRows;
}
public void setStopWords(String swords) throws JspException{
Hashtable wordTable = new Hashtable();
String[] temp = new String[wordTable.size()];
if(swords.split(",").length > 0){
String[] words = swords.split(",");
for (int i = 0; i < words.length; i++) {
if(new File(words[i]).isFile()){
wordTable.putAll(WordlistLoader.getWordtable(words[i]));
}else{
wordTable.put(words[i], words[i]);
}
}
temp = new String[wordTable.size()];
int count = 0;
if(wordTable.size() > 0){
Iterator wtIter = wordTable.keySet().iterator();
while (wtIter.hasNext()){
temp[count++] = (String) wtIter.next();
}
}
}
stopWords = temp;
}
// public void setStopWords(String[] swords) throws JspException{
// stopWords = swords;
// }
public void setFlagList(String fg) {
int[] list = new int[0];
if(fg.split(",").length > 0){
String[] ssplit = fg.split(",");
Integer fsplit = new Integer(fg.split(",").length);
list = new int[fsplit.intValue()];
for(int i=0; i < fsplit.intValue(); i++){
if(ssplit[i].equalsIgnoreCase("NORMAL")){
list[i] = MultiFieldQueryParser.NORMAL_FIELD;
}else if(ssplit[i].equalsIgnoreCase("PROHIBITED")){
list[i] = MultiFieldQueryParser.PROHIBITED_FIELD;
}else if(ssplit[i].equalsIgnoreCase("REQUIRED")){
list[i] = MultiFieldQueryParser.REQUIRED_FIELD;
}
}
}
flagList = list;
}
public void setFieldList(String fl) {
if(fl.split(",").length > 0){
fieldList = fl.split(",");
}
}
public void setFieldList(String[] fl) {
fieldList = fl;
}
public void setSearch(String string) {
search = string;
}
/**
* @param atype
* @todo this is crying for constants, not string comparisons
*/
public void setAnalyzerType(String atype) {
if(atype.equalsIgnoreCase("GERMAN_ALYZER")){
analyzerType = 0;
}else if(atype.equalsIgnoreCase("SIMPLE_ANALYZER")){
analyzerType = 1;
}else if(atype.equalsIgnoreCase("STANDARD_ANALYZER")){
analyzerType = 2;
}else if(atype.equalsIgnoreCase("STOP_ANALYZER")){
analyzerType = 3;
}else if(atype.equalsIgnoreCase("WHITESPACE_ANALYZER")){
analyzerType = 4;
}else{
analyzerType = 2;
}
}
}

View File

@ -1,27 +0,0 @@
package com.netwebapps.taglib.search;
/**
* @company Network Web Application
* @url http://www.netwebapps.com
* @author Bryan LaPlante
*
*/
import javax.servlet.jsp.tagext.*;
public class SearchTagTei extends TagExtraInfo
{
public SearchTagTei(){
}
/*
* VariableInfo is provided by the servlet container and allows the
* SearchTag class to output it's tag variables to the PageContext at runtime
* @see javax.servlet.jsp.tagext.TagExtraInfo#getVariableInfo(javax.servlet.jsp.tagext.TagData)
*/
public VariableInfo[] getVariableInfo(TagData tagdata)
{
VariableInfo avariableinfo[] = new VariableInfo[1];
avariableinfo[0] = new VariableInfo(tagdata.getId(),"com.netwebapps.taglib.search.SearchTag", true, VariableInfo.AT_BEGIN);
return avariableinfo;
}
}

View File

@ -1,124 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.1</tlibversion>
<jspversion>1.2</jspversion>
<shortname>JSP</shortname>
<info>
Lucene search engine tag library
</info>
<tag>
<name>Search</name>
<tagclass>com.netwebapps.taglib.search.SearchTag</tagclass>
<teiclass>com.netwebapps.taglib.search.SearchTagTei</teiclass>
<bodycontent>JSP</bodycontent>
<info>
Outputs select options from a query.
</info>
<attribute>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>throwOnException</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>criteria</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>collection</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>startRow</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>maxRows</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>analyzerType</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>fieldList</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>flagList</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>search</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>stopWords</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>Column</name>
<tagclass>com.netwebapps.taglib.search.ColumnTag</tagclass>
<teiclass>com.netwebapps.taglib.search.ColumnTagTei</teiclass>
<bodycontent>JSP</bodycontent>
<info>
Adds an additional collection to the search tag.
</info>
<attribute>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>runOnce</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>throwOnException</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>Field</name>
<tagclass>com.netwebapps.taglib.search.FieldTag</tagclass>
<teiclass>com.netwebapps.taglib.search.FieldTagTei</teiclass>
<bodycontent>JSP</bodycontent>
<info>
Output the value for the named field in a search result, empty by default.
</info>
<attribute>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>throwOnException</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>

View File

@ -1,464 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>com.netwebapps.tablib.search</title>
</head>
<body>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="author" content="Bryan LaPlante">
<title>Lucene-Taglibs: Search engine Tag library (Beta 1)</title>
<style>
TD{ vertical-align:top; align:left; border-bottom:1px solid #C0C0C0; }
</style>
</head>
<body bgcolor="white">
<center>
<h1>Search engine Tag library (Beta 1)</h1>
<h3>Version: 1.0</h3>
<br><br>
</center>
<h3>Table of Contents</h3>
<ul>
<li>
<a href="#overview">Overview</a>
</li>
<li>
<a href="#requirements">Requirements</a>
</li>
<li>
<a href="#config">Configuration</a>
</li>
<li>
<a href="#summary">Tag Summary</a>
</li>
<li>
<a href="#reference">Tag Reference</a>
</li>
<li>
<a href="#examples">Examples</a>
</li>
<li>
<a href="#javadocs">Javadocs</a>
</li>
<li>
<a href="#history">Revision History</a>
</li>
</ul>
<a name="overview"></a>
<h3>Overview</h3>
<p>
The Search custom tag is an iteration tag that loops over the results of
criteria passed to the Lucene search engine.
<br><br>
This tag supports parameters for passing the search criteria to the search engine
and then returns information about the result set to the page programmer through the
name used in this tags ID attribute.
<br><br>
Any field stored in the search index will be accessible after the start tag has run
by calling the result set's someID.getField(String name) method which will locate the
value of the field and return it as a string. In the event that no such field exists
it will return an empty string.<br>
There is also a <a href="">&lt;LUCENE:Field&gt;</a> tag that does this for you.
<br><br>
If you need to get a list of the column names ahead of time you can call the tags's getFields()
method and it will return you a Set of field names that can be iterated over as you will
see in the result.jsp example provided with this documentation.<br>
There is also a <a href="">&lt;LUCNENE:Column&gt;</a> tag that does the same thing.
<br>
The object passed back through the tag's ID attribute is the current instance of the tag
itself, so all of the public information for this instance is available and you will see
more reference to this in the <a href="#reference">tag reference section.</a>
</p>
<br><br>
<a name="requirements"></a>
<h3>Requirements</h3>
<br><br>
<P>This custom tag requires no software other than a servlet
container that supports the JavaServer Applications Specification, version 1.2.
</P>
<br><br>
<a name="config"></a>
<h3>Configuration</h3>
<p>Follow these steps to configure your web application with this tag</p>
<ul>
<li>Copy the tag library descriptor file to the /WEB-INF subdirectory
of your web application.</li>
<li>Copy the tag library JAR file to the /WEB-INF/lib subdirectory
of your web application.</li>
</li>
</ul>
<p>To use the search tag in your JSP pages, add the following
directive at the top of each page: </p>
<pre>
&lt;%@ taglib uri="/WEB-INF/lucene-taglib.tld" prefix="LUCENE" %&gt;
</pre>
<p>where "<i>LUCENE</i>" is the tag
name prefix you wish to use for tags from this library. You can change
this value to any prefix you like.</p>
<br><br>
<a name="summary"></a>
<h3>Tag Summary</h3>
<table cellspacing=0 cellpadding=4>
<tr>
<td colspan=2><b>search tag attributes</b></td>
</tr>
<tr>
<td width="10%"><b>id</b></td>
<td width="75%">The name were the tag will return and instance of itself.</td>
</tr>
<tr>
<td><b>criteria</b></td>
<td>search criteria provided by the user to be search.</td>
</tr>
<tr>
<td><b>collection</b></td>
<td>path to the index to be searched.</td>
</tr>
<tr>
<td><b>startrow</b></td>
<td>The row of the result to start looping over.</td>
</tr>
<tr>
<td><b>maxrows</b></td>
<td>the number of results to output to the page.</td>
</tr>
<tr>
<td><b>analyzerType</b></td>
<td>chooses wich analyzer to use with the search.</td>
</tr>
<tr>
<td><b>search</b></td>
<td>changes the default searched content to another field.</td>
</tr>
<tr>
<td><b>stopWords</b></td>
<td>a comma seperated list of words to filter search results.</td>
</tr>
<tr>
<td><b>fieldList</b></td>
<td>comma seperated list of fields to be searched.</td>
</tr>
<tr>
<td><b>flagList</b></td>
<td>comma seperated list of rules to apply to the fieldList.</td>
</tr>
</table>
<br><br>
<a name="reference"></a>
<h3>Tag Reference</h3>
<br>
<table border=0 cellspacing=0 cellpadding=4>
<tr>
<td>Tag Body</td>
<td colspan=5>JSP</td>
</tr>
<tr>
<td>Restrictions</td>
<td colspan=5>none</td>
</tr>
<tr style="background-color:#C0C0C0">
<td width="15%"><b>Attributes</b></td>
<td><b>name</b></td>
<td><b>required</b></td>
<td colspan=2><b>params</b></td>
<td>Default</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>id</b></td>
<td>true</td>
<td colspan=2>String</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>criteria</b></td>
<td>true</td>
<td colspan=2>String</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>collection</b></td>
<td>true</td>
<td colspan=2>comma seperated String of one or more directory paths to the index(s) to be searched</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>startrow</b></td>
<td>false</td>
<td colspan=2>String | int</td>
<td>0</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>maxrows</b></td>
<td>false</td>
<td colspan=2>String | int</td>
<td>50</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>analyzerType</b></td>
<td>false</td>
<td colspan=2>String<br>
One of the following.
<ul>
<li>GERMANAN_ALYZER</li>
<li>SIMPLE_ANALYZER</li>
<li>STANDARD_ANALYZER</li>
<li>STOP_ANALYZER</li>
<li>WHITESPACE_ANALYZER</li>
</li>
</td>
<td>STANDARD_ANALYZER</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>search</b></td>
<td>false</td>
<td colspan=2>String</td>
<td>contents</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>stopWords</b></td>
<td>false</td>
<td colspan=2>String<br>
<ul>
<li>Abstract file path</li>
<li>comma seperated list of words</li>
</ul>
NOTE: you can also comma seperate any combination of file
paths and or words but the file path must point to a file
that contains one word per line.
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>fieldList</b></td>
<td>false</td>
<td colspan=2>String<br>
NOTE: if you also supply a flagList there must be an equal number of
elements as there are in fieldList.
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>flagList</b></td>
<td>false</td>
<td colspan=2>String</td>
<td>&nbsp;</td>
</tr>
<tr style="background-color:#C0C0C0">
<td><b>Variables</b></td>
<td><b>name</b></td>
<td><b>scope</b></td>
<td><b>return datatype</b></td>
<td><b>read / write</b></td>
<td><b>description</b></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>startRow</b></td>
<td>AT_BEGIN</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>String representing the number passed in as the startrow parameter</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>maxRows</b></td>
<td>AT_BEGIN</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>String representing the number passed in as the maxrows parameter</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>rowCount</b></td>
<td>AT_BEGIN</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>String representing on which iteration the tag is currently looping</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>pageCount</b></td>
<td>AT_BEGIN</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>String representing the offset between the maxrows and the total number of hits</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>hitCount</b></td>
<td>AT_BEGIN</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>String representing the total number of results</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>firstPage</b></td>
<td>AT_END</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>variable containing the query string needed by a navigation element to return you to the first page of the result</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>nextPage</b></td>
<td>AT_END</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>variable containing the query string needed by a navigation element to move to the next page of the result</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>previousPage</b></td>
<td>AT_END</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>variable containing the query string needed by a navigation element to return to the previous page of the result</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>lastPage</b></td>
<td>AT_BEGIN</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>variable containing the query string needed by a navigation element to move to the last page of the result</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>pageList</b></td>
<td>AT_BEGIN</td>
<td>LinkedList</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>
returns a LinkedList of query strings needed to produce links to the number of page
represented by the offset of the current page and the maxrows being displayed on each page.
In other words it is for the next 10x page links at the bottom of the page.
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>score</b></td>
<td>AT_BEGIN</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>
returns a string representation of the float value stored in every lucene index as the value score.
if you want to translate it into something useful to a user you will need to create new <br>
<nobr>Float(tagid.getField("score")).floatValue()</nobr>
and then you can use your own conversion method as this will return you the original float value that
was stored in the index.
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>getField(String name)</b></td>
<td>AT_BEGIN</td>
<td>String</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>
used to retreive the named field from the index for that iteration of the loop.
If no such name exists in the index such as author the method will return an empty string.
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><b>getFields()</b></td>
<td>AT_BEGIN</td>
<td>Set</td>
<td colspan=2>readonly</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan=4>used to retrieve a Set view of all of the fields contained in the index
for each iteration of the loop, most generally would be used to write your table headers
when the field names are not known until runtime.
</td>
</tr>
<tr>
<td><b>Example</b></td>
<td colspan=4>loop over the results outputing the value for the url field stored in the index</td>
</tr>
<tr>
<td colspan=6>
<pre>
&lt;LUCENE:Search id="rs" collection="C:/opt/lucene/index" criteria="user input" startRow="0" maxRows="10"&gt;
&lt;%= rs.getField("url") %&gt;
&lt;/LUCENE:Search&gt;
</pre>
<br><br>
<p>
</p>
</td>
</tr>
</table>
</body>
</html>

View File

@ -1,2 +0,0 @@
</body>
</html>

View File

@ -1,10 +0,0 @@
<html>
<header>
<title>Network Web Applications Search taglib</title>
</header>
<body>
<center>
<p>
Welcome to the Lucene Template application. (This is the header)
</p>
</center>

View File

@ -1,114 +0,0 @@
<html>
<head>
<title>Using Lucene Taglib</title>
<style>
BODY { background-color:#FFFFFF; font-size:12pt;}
TH { color:#009696; }
SPAN { color:color:#009696; font-size:8pt; }
SPAN.required { color:red; font-size:12pt;}
PRE { color:#7B007B; }
OPTION { color:blue; font-size:10pt; font-weight:bold; }
TD { vertical-align:top; color:blue; }
SELECT.data { color:blue; width:175px; }
INPUT { color:blue; width:175px; }
SPAN.default { color:Fuchsia; }
.default { color:Fuchsia; }
SPAN.object { color:Purple; font-size:12pt; }
SPAN.explained { color:black; font-size:10pt; }
</style>
</head>
<body>
<h2 align="center">Test page for Lucene-taglib</h2>
<table border=0 width="100%">
<tr>
<td colspan=3><b>Legend</b></td>
</tr>
<tr>
<td style="width:100px;">Required field</td>
<td style="background-color:red; width:5px;">&nbsp;</td>
<td rowspan="4" valign="top" style="padding-left:10px;" align="justify">
<span class="explained">
This page has been set up so that you can dynamically change the
parameters used by the taglib to produce different results. Hopefully
this tag library is abstract enough to address the majority of situations.
The ledgend on the left shows which parameters are required and there
default values. If you set throwOnException to false the errors caused by
bad input parameter should not crash the page rather no results will be returned.
On the other hand setting it to true will show any errors encountered by the tag.
Some knowledge of the Lucene search engine is required to take advantage of the
the search tags advanced features such as changing the analyzer and using
fieldList's and flagList's. more documentation on each tag can be found in
the docs directory in the index.html file.
</span>
</td>
</tr>
<tr>
<td>Default value</td>
<td style="background-color:Fuchsia">&nbsp;</td>
</tr>
<tr>
<td>String</td>
<td style="background-color:blue">&nbsp;</td>
</tr>
<tr>
<td>Object</td>
<td style="background-color:Purple;">&nbsp;</td>
</tr>
</table>
<form action="result.jsp" method="get">
<input type="submit">
<table cellpadding=0 cellspacing=0 border=0>
<tr><th>&lt;LUCENE:Search </th><td><span class="required">id="rs"</span></td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>throwOnException</td><td><select class="data" name="throwOnException"><option value="true">true</option><option class="default" value="false" SELECTED>false</option></select></td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td><span class="required">collection</span></td><td><input type="text" name="collection" value="E:/search/lucene/index,E:/opt/lucene/index"></td><td colspan=2><span>"comma separated directory/path(s)"</span></td></tr>
<tr><td><span class="required">criteria</span></td><td><input type="text" name="criteria"></td><td><span>"String"</span></td><td>&nbsp;</td></tr>
<tr><td>startRow</td><td><input type="text" name="startRow" value="0"></td><td><span class="default">"0"</span></td><td>&nbsp;</td></tr>
<tr><td>maxRows</td><td><input type="text" name="maxRows" value="50"></td><td><span class="default">"50"</span></td><td>&nbsp;</td></tr>
<tr><td>analyzerType</td>
<td>
<select class="data" name="analyzerType">
<option value="GERMAN_ANALYZER">GERMAN_ANALYZER</option>
<option value="SIMPLE_ANALYZER">SIMPLE_ANALYZER</option>
<option class="default" value="STANDARD_ANALYZER" selected>STANDARD_ANALYZER</option>
<option value="STOP_ANALYZER">STOP_ANALYZER</option>
<option value="WHITESPACE_ANALYZER">WHITESPACE_ANALYZER</option>
</select>
</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>search</td><td><input type="text" name="search" value="contents"></td><td><span class="default">"contents"</span></td><td>&nbsp;</td></tr>
<tr><td>stopWords</td><td><input type="text" name="stopWords"></td><td><span>"comma,separated,list"</span></td><td>&nbsp;</td></tr>
<tr><td>fieldList</td><td><input type="text" name="fieldList" value="contents"></td><td><span>"comma,separated,list"</span></td><td>&nbsp;</td></tr>
<tr><td>flagList</td><td><input type="text" name="flagList" value="NORMAL"></td><td><span>"NORMAL,PROHIBITED,REQUIRED"</span>&gt;</td><td>&nbsp;</td></tr>
<tr><td colspan=4>&lt;%= rs.loopCount %&gt; <br><span class="explained">int value of the current interation of the search tag</span></td></tr>
<tr><td colspan=4>&lt;%= rs.rowCount %&gt;<br><span class="explained">int value of the current result in hitCount</span></td></tr>
<tr><td colspan=4>&lt;%= rs.hitCount %&gt;<br><span class="explained">int value representing the total number of results</span></td></tr>
<tr><td colspan=4>&lt;%= rs.pageCount %&gt;<br><span class="explained">int value of the offset between the maxrows and the total number of hits</span></td></tr>
<tr><td colspan=4>&lt;%= rs.firstPage %&gt;<br><span class="explained">variable containing the query string needed by a navigation element to return you to the first page of the result</span></td></tr>
<tr><td colspan=4>&lt;%= rs.nextPage %&gt;<br><span class="explained">variable containing the query string needed by a navigation element to move to the next page of the result</span></td></tr>
<tr><td colspan=4>&lt;%= rs.previousPage %&gt;<br><span class="explained">variable containing the query string needed by a navigation element to return to the previous page of the result</span></td></tr>
<tr><td colspan=4>&lt;%= rs.lastPage %&gt;<br> <span class="explained">variable containing the query string needed by a navigation element to move to the last page of the result</span></td></tr>
<tr><td colspan=4>&lt;%= rs.score %&gt;<br> <span class="explained">returns a string representation of the float value stored in every lucene index as the value score. <br>if you want to translate it into something useful to a user you will need to create
<br>new Float(tagid.getField("score")).floatValue() and then you can use your own conversion method <br>
as this will return you the original float value that was stored in the index. </span></td></tr>
<tr><td colspan=4 style="color:black"><span class="object">&lt;%= rs.pageList %&gt;</span><br> <span style="font-size:10pt;">returns a LinkedList of query strings needed to produce links to the number of page represented <br>by the offset of the current page and the maxrows being displayed on each page. </span></td></tr>
<tr><td colspan=4>&lt;%= rs.getField(String name) %&gt; used by the Field tag<br> <span class="explained">used to retreive the named field from the index for that iteration of the loop. <br>If no such name exists in the index such as author the method will return an empty string.</span></td></tr>
<tr><td colspan=4>&lt;%= rs.getFields() %&gt; used by the Column tag<br> <span class="explained">used to retrieve a Set view of all of the fields contained in the index for each iteration of the loop, <br>most generally would be used to write your table headers when the field names are not known until runtime</span></td></tr>
<tr><td>&nbsp;</td><th>&lt;LUCENE:Column </th><td><span class="required">id="col"</span></td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>runOnce</td><td><select class="data" name="runOnce"><option value="true">true</option><option class="default" value="false" SELECTED>false</option></select></td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>throwOnException</td><td><select class="data" name="columnthrowOnException"><option value="true">true</option><option class="default" value="false" SELECTED>false</option></select>&gt;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td colspan=3>&lt;%= col.columnCount %&gt; <span class="explained">int value of the current iteration of the column tag</span></td></tr>
<tr><td>&nbsp;</td><td colspan=3>&lt;%= col.columnName %&gt;<span class="explained"> String value of the field name at columnCount</span></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><th>&lt;LUCENE:Field </th><td><span class="required">id="fld"</span></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td><span class="required">name</span></td><td>"&lt;%= col.columnName %&gt;"</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>throwOnException</td><td><select class="data" name="fieldthrowOnException"><option value="true">true</option><option class="default" value="false" SELECTED>false</option></select>&gt;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td colspan=2>&lt;%= fld.value %&gt; <span class="explained">String value of the columnName</span></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><th>&lt;/LUCENE:Field&gt;</th><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><th>&lt;/LUCENE:Column&gt;</th><td>&nbsp;</td><td>&nbsp;</td><tr>
<tr><th>&lt;/LUCENE:Search&gt;</th><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</table>
</form>
</body>
</html>

View File

@ -1,21 +0,0 @@
<%
response.setHeader("Pragma", "No-cache");
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Cache-Control", "private");
%>
<%@include file="header.jsp"%>
<% /* Author: Andrew C. Oliver (acoliver2@users.sourceforge.net) */ %>
<center>
<form name="search" action="result.jsp" method="get">
<p>
<input name="query" size="44"/>&nbsp;Search Criteria
</p>
<p>
<input name="maxRows" size="4" value="10"/>&nbsp;Results Per Page&nbsp;
<input type="submit" value="Search"/>
</p>
</form>
</center>
<%@include file="footer.jsp"%>

View File

@ -1,74 +0,0 @@
WARNING: THE CURRENT STATE OF THIS CODEBASE IS BROKEN! RESULTS.JSP
NEEDS A BIT OF WORK TO FUNCTION PROPERLY.
INTRODUCTION
The lucene-taglib project provides a tag library for searching
a lucene-index.
INSTRUCTIONS
1. download this project and create a context in your favorite
servelt container called lucene-taglib.
2. copy the file under the taglib directory into your new context.
3. open result.jsp and locate the collection attribute of the
<LUCENE:Search> tag.
4. change the collection attribute to point to a lucene-index
that you created using the system appropriate path.
5. open index.jsp in your browser and enter search criteria
and click the submit button.
DOCUMENTATION:
you will find documentation and an over view of the tag library in
the docs folder of this project and the javadocs in the api folder
respectively.
BUGS:
I tried to create a .war file for this project but I am having trouble
getting it to deploy properly.
More like a heads up than a bug I discovered that if you have tag pooling \
turned on in Tomcat that values passed to a custom tag will not change in
the event that an exception is thrown. Catching the exception inside of
the tag or page does not help, to update the values at this point you
have to turn off tag pooling. Follow the instructions below to do this
in Tomcat.
----------------------------------------------------------------------------
From: Bill Barker
Subject: Re: HELP:Tagpool sharing problems
Date: Mon, 28 Apr 2003 22:20:20 -0700
----------------------------------------------------------------------------
In $CATALINA_HOME/conf/web.xml, locate the <servlet-name>jsp</servlet-name>
servlet, and add:
<init-param>
<param-name>enablePooling</param-name>
<param-value>false</param-value>
</init-param>
This will turn off tag-pooling. You'll also need to clear out
$CATALINA_HOME/work so that the JSP pages get re-compiled.
If you just want it turned off for one context, then you can place the
definition of the jsp servlet in your own web.xml.
If you are using:
<servlet>
<servlet-name>myJspPage</servlet-name>
<jsp-page>myJspPage.jsp</jsp-page>
</servlet>
then you also need to add the enablePooling init-param to your servlet's
definition.
HISTORY:
1. Added more robust error handling and the ability to turn it on and
off with a throwOnException attribute. (All tags)
2. Added a Column tag for outputting the field names found in a
Lucene index.
3. Added a Field tag for retrieving a value for a field in a search
result either produced by the Column tag or known in advance.
4. Added new example pages to illustrate how to use the new tags
5. The Collection tag has been deprecated, use the collection attribute
of the Search tag instead.

View File

@ -1,135 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ taglib uri="/WEB-INF/lucene-taglib.tld" prefix="LUCENE"%>
<%@ page import="java.util.*"%>
<html>
<head>
<title>Using Lucene Taglib</title>
<style>
BODY{background-color:#F5F5F5}
</style>
</head>
<body>
<%
String startRow = "";
String maxRows = "";
String criteria = "";
int colCount = 0;
String analyzerType = "STANDARD_ANALYZER";
String search = "contents";
String stopWords="";
String fieldList="";
String flagList="";
String collection = "E:/search/lucene/index,E:/opt/lucene/index";
String throwOnException = "false";
String fieldthrowOnException = "false";
String columnthrowOnException = "false";
String runOnce = "false";
String query = "";
query = request.getQueryString();
criteria = request.getParameter("criteria");
startRow = request.getParameter("startRow");
maxRows = request.getParameter("maxRows");
analyzerType = request.getParameter("analyzerType");
search = request.getParameter("search");
stopWords = request.getParameter("stopWords");
fieldList = request.getParameter("fieldList");
flagList = request.getParameter("flagList");
throwOnException = request.getParameter("throwOnException");
fieldthrowOnException = request.getParameter("fieldthrowOnException");
columnthrowOnException = request.getParameter("columnthrowOnException");
runOnce = request.getParameter("runOnce");
%>
<h3> Search results for "<%= criteria %>"</h3>
<table border=3>
<LUCENE:Search id="rs"
throwOnException="<%= throwOnException %>"
collection="<%= collection %>"
criteria="<%= criteria %>"
startRow="<%= startRow %>"
maxRows="<%= maxRows %>"
analyzerType="<%= analyzerType %>"
search="<%= search %>"
stopWords="<%= stopWords %>"
fieldList="<%= fieldList %>"
flagList="<%= flagList %>">
<tr>
<LUCENE:Column id="header" runOnce="true" throwOnException="false">
<% colCount = header.columnCount; %>
<th><b><%= header.columnName %></b></th>
</LUCENE:Column>
</tr>
<LUCENE:Column id="col" throwOnException="<%= columnthrowOnException %>" runOnce="<%= runOnce %>">
<tr>
<td colspan="<%= col.columnCount %>"><b>[<%= rs.loopCount %>][<%= rs.rowCount %>]</b>&nbsp;
<LUCENE:Field id="fld" name="<%= col.columnName %>" throwOnException="<%= fieldthrowOnException %>">
<% if(col.columnName.equalsIgnoreCase("url")){ %>
<a href="<%= fld.value %>">
<% } %>
<%= fld.value %>
<% if(col.columnName.equalsIgnoreCase("url")){ %>
</a>
<% } %>
</LUCENE:Field>
</td>
</tr>
</LUCENE:Column>
</LUCENE:Search>
<%
if(rs.hitCount <= 0){
%>
<tr>
<td colspan=2>No results have been found</td>
</tr>
<%
}
%>
<tr>
<td><b>hitCount</b></td>
<td colspan="<%= colCount-1 %>"><%= rs.hitCount %></td>
</tr>
<tr>
<td><b>pageCount</b></td>
<td colspan="<%= colCount-1 %>"><%= rs.pageCount %></td>
</tr>
<tr>
<td><b>firstPage</b></td>
<td colspan="<%= colCount-1 %>"><a href="<%= rs.firstPage %><%= query %>"><%= rs.firstPage %></a></td>
</tr>
<tr>
<td><b>nextPage</b></td>
<td colspan="<%= colCount-1 %>"><a href="<%= rs.nextPage %><%= query %>"><%= rs.nextPage %></a></td>
</tr>
<tr>
<td><b>previousPage</b></td>
<td colspan="<%= colCount-1 %>"><a href="<%= rs.previousPage %><%= query %>"><%= rs.previousPage %></a></td>
</tr>
<tr>
<td><b>lastPage</b></td>
<td colspan="<%= colCount-1 %>"><a href="<%= rs.lastPage %><%= query %>"><%= rs.lastPage %></a></td>
</tr>
<tr>
<td colspan="<%= colCount %>">
<select name="pagelist" onchange="location.href=this.value">
<%
Iterator pages = rs.pageList.iterator();
while(pages.hasNext()){
String listNext = (String) pages.next();
%>
<option value="<%= listNext %><%= query %>"><%= listNext %></option>
<%
}
%>
</select>
</td>
</tr>
</table>
</body>
</html>