FileDocCategorySizeDatePackage
CoreParser.javaAPI DocApache Lucene 2.1.05583Wed Feb 14 10:46:20 GMT 2007org.apache.lucene.xmlparser

CoreParser

public class CoreParser extends Object implements QueryBuilder
Assembles a QueryBuilder which uses only core Lucene Query objects
author
Mark

Fields Summary
protected Analyzer
analyzer
protected QueryParser
parser
protected QueryBuilderFactory
queryFactory
protected FilterBuilderFactory
filterFactory
public static int
maxNumCachedFilters
Constructors Summary
public CoreParser(Analyzer analyzer, QueryParser parser)



	    
	
		this.analyzer=analyzer;
		this.parser=parser;
		filterFactory = new FilterBuilderFactory();
		filterFactory.addBuilder("RangeFilter",new RangeFilterBuilder());
		
		
		queryFactory = new QueryBuilderFactory();
		queryFactory.addBuilder("TermQuery",new TermQueryBuilder());
		queryFactory.addBuilder("TermsQuery",new TermsQueryBuilder(analyzer));
		queryFactory.addBuilder("MatchAllDocsQuery",new MatchAllDocsQueryBuilder());
		queryFactory.addBuilder("BooleanQuery",new BooleanQueryBuilder(queryFactory));
		queryFactory.addBuilder("UserQuery",new UserInputQueryBuilder(parser));
		queryFactory.addBuilder("FilteredQuery",new FilteredQueryBuilder(filterFactory,queryFactory));
		queryFactory.addBuilder("ConstantScoreQuery",new ConstantScoreQueryBuilder(filterFactory));
		
		filterFactory.addBuilder("CachedFilter",new CachedFilterBuilder(queryFactory,
							filterFactory, maxNumCachedFilters));
		
		
		SpanQueryBuilderFactory sqof=new SpanQueryBuilderFactory();

		SpanNearBuilder snb=new SpanNearBuilder(sqof);
		sqof.addBuilder("SpanNear",snb);
		queryFactory.addBuilder("SpanNear",snb);

		SpanTermBuilder snt=new SpanTermBuilder();
		sqof.addBuilder("SpanTerm",snt);
		queryFactory.addBuilder("SpanTerm",snt);
		
		SpanOrBuilder sot=new SpanOrBuilder(sqof);
		sqof.addBuilder("SpanOr",sot);
		queryFactory.addBuilder("SpanOr",sot);

		SpanOrTermsBuilder sots=new SpanOrTermsBuilder(analyzer);
		sqof.addBuilder("SpanOrTerms",sots);
		queryFactory.addBuilder("SpanOrTerms",sots);		
		
		SpanFirstBuilder sft=new SpanFirstBuilder(sqof);
		sqof.addBuilder("SpanFirst",sft);
		queryFactory.addBuilder("SpanFirst",sft);
		
		SpanNotBuilder snot=new SpanNotBuilder(sqof);
		sqof.addBuilder("SpanNot",snot);
		queryFactory.addBuilder("SpanNot",snot);	
	
Methods Summary
public voidaddFilterBuilder(java.lang.String nodeName, FilterBuilder builder)

		filterFactory.addBuilder(nodeName,builder);
	
public voidaddQueryBuilder(java.lang.String nodeName, QueryBuilder builder)

		queryFactory.addBuilder(nodeName,builder);
	
public org.apache.lucene.search.QuerygetQuery(org.w3c.dom.Element e)

		return queryFactory.getQuery(e);
	
public org.apache.lucene.search.Queryparse(java.io.InputStream xmlStream)

		return getQuery(parseXML(xmlStream).getDocumentElement());
	
private static org.w3c.dom.DocumentparseXML(java.io.InputStream pXmlFile)

		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		DocumentBuilder db = null;
		try
		{
			db = dbf.newDocumentBuilder();
		}
		catch (Exception se)
		{
			throw new ParserException("XML Parser configuration error", se);
		}
		org.w3c.dom.Document doc = null;
		try
		{
			doc = db.parse(pXmlFile);
		}
		catch (Exception se)
		{
			throw new ParserException("Error parsing XML stream:" + se, se);
		}
		return doc;