lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r712922 [7/9] - in /lucene/java/trunk: contrib/analyzers/src/java/org/apache/lucene/analysis/el/ contrib/analyzers/src/java/org/apache/lucene/analysis/fr/ contrib/analyzers/src/java/org/apache/lucene/analysis/miscellaneous/ contrib/analyzer...
Date Tue, 11 Nov 2008 02:35:52 GMT
Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/CorePlusExtensionsParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/CorePlusExtensionsParser.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/CorePlusExtensionsParser.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/CorePlusExtensionsParser.java Mon Nov 10 18:35:46 2008
@@ -1,62 +1,62 @@
-package org.apache.lucene.xmlparser;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.xmlparser.builders.BooleanFilterBuilder;
-import org.apache.lucene.xmlparser.builders.BoostingQueryBuilder;
-import org.apache.lucene.xmlparser.builders.DuplicateFilterBuilder;
-import org.apache.lucene.xmlparser.builders.FuzzyLikeThisQueryBuilder;
-import org.apache.lucene.xmlparser.builders.LikeThisQueryBuilder;
-import org.apache.lucene.xmlparser.builders.TermsFilterBuilder;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-public class CorePlusExtensionsParser extends CoreParser
-{
-
-	/**
-	 * Construct an XML parser that uses a single instance QueryParser for handling 
-	 * UserQuery tags - all parse operations are synchronised on this parser
-	 * @param analyzer
-	 * @param parser A QueryParser which will be synchronized on during parse calls.
-	 */
-	public CorePlusExtensionsParser(Analyzer analyzer, QueryParser parser)
-	{
-		this(null,analyzer, parser);
-	}
-	/**
-	 * Constructs an XML parser that creates a QueryParser for each UserQuery request.
-	 * @param defaultField The default field name used by QueryParsers constructed for UserQuery tags 
-	 * @param analyzer 
-	 */
-	public CorePlusExtensionsParser(String defaultField,Analyzer analyzer)
-	{
-		this(defaultField,analyzer, null);
-	}
-
-	private CorePlusExtensionsParser(String defaultField,Analyzer analyzer, QueryParser parser)
-	{
-		super(defaultField,analyzer, parser);
-		filterFactory.addBuilder("TermsFilter",new TermsFilterBuilder(analyzer));
-		filterFactory.addBuilder("BooleanFilter",new BooleanFilterBuilder(filterFactory));
-		filterFactory.addBuilder("DuplicateFilter",new DuplicateFilterBuilder());
-		String fields[]={"contents"};
-		queryFactory.addBuilder("LikeThisQuery",new LikeThisQueryBuilder(analyzer,fields));
-		queryFactory.addBuilder("BoostingQuery", new BoostingQueryBuilder(queryFactory));
-		queryFactory.addBuilder("FuzzyLikeThisQuery", new FuzzyLikeThisQueryBuilder(analyzer));
-		
-	}
-}
+package org.apache.lucene.xmlparser;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.xmlparser.builders.BooleanFilterBuilder;
+import org.apache.lucene.xmlparser.builders.BoostingQueryBuilder;
+import org.apache.lucene.xmlparser.builders.DuplicateFilterBuilder;
+import org.apache.lucene.xmlparser.builders.FuzzyLikeThisQueryBuilder;
+import org.apache.lucene.xmlparser.builders.LikeThisQueryBuilder;
+import org.apache.lucene.xmlparser.builders.TermsFilterBuilder;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+public class CorePlusExtensionsParser extends CoreParser
+{
+
+	/**
+	 * Construct an XML parser that uses a single instance QueryParser for handling 
+	 * UserQuery tags - all parse operations are synchronised on this parser
+	 * @param analyzer
+	 * @param parser A QueryParser which will be synchronized on during parse calls.
+	 */
+	public CorePlusExtensionsParser(Analyzer analyzer, QueryParser parser)
+	{
+		this(null,analyzer, parser);
+	}
+	/**
+	 * Constructs an XML parser that creates a QueryParser for each UserQuery request.
+	 * @param defaultField The default field name used by QueryParsers constructed for UserQuery tags 
+	 * @param analyzer 
+	 */
+	public CorePlusExtensionsParser(String defaultField,Analyzer analyzer)
+	{
+		this(defaultField,analyzer, null);
+	}
+
+	private CorePlusExtensionsParser(String defaultField,Analyzer analyzer, QueryParser parser)
+	{
+		super(defaultField,analyzer, parser);
+		filterFactory.addBuilder("TermsFilter",new TermsFilterBuilder(analyzer));
+		filterFactory.addBuilder("BooleanFilter",new BooleanFilterBuilder(filterFactory));
+		filterFactory.addBuilder("DuplicateFilter",new DuplicateFilterBuilder());
+		String fields[]={"contents"};
+		queryFactory.addBuilder("LikeThisQuery",new LikeThisQueryBuilder(analyzer,fields));
+		queryFactory.addBuilder("BoostingQuery", new BoostingQueryBuilder(queryFactory));
+		queryFactory.addBuilder("FuzzyLikeThisQuery", new FuzzyLikeThisQueryBuilder(analyzer));
+		
+	}
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/CorePlusExtensionsParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/DOMUtils.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/DOMUtils.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/DOMUtils.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/DOMUtils.java Mon Nov 10 18:35:46 2008
@@ -1,276 +1,276 @@
-package org.apache.lucene.xmlparser;
-import java.io.Reader;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.InputSource;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-public class DOMUtils
-{
-    public static Element getChildByTagOrFail(Element e, String name)	throws ParserException
-	{
-		Element kid = getChildByTagName(e, name);
-		if (null == kid)
-		{
-			throw new ParserException(e.getTagName() + " missing \"" + name
-					+ "\" child element");
-		}
-		return kid;
-	}
-     
-     public static Element getFirstChildOrFail(Element e) throws ParserException
-	{
-		Element kid = getFirstChildElement(e);
-		if (null == kid)
-		{
-			throw new ParserException(e.getTagName()
-					+ " does not contain a child element");
-		}
-		return kid;
-	}
-     
-	public static String getAttributeOrFail(Element e, String name)	throws ParserException
-	{
-		String v = e.getAttribute(name);
-		if (null == v)
-		{
-			throw new ParserException(e.getTagName() + " missing \"" + name
-					+ "\" attribute");
-		}
-		return v;
-	}
-    public static String getAttributeWithInheritanceOrFail(Element e,	String name) throws ParserException
-	{
-		String v = getAttributeWithInheritance(e, name);
-		if (null == v)
-		{
-			throw new ParserException(e.getTagName() + " missing \"" + name
-					+ "\" attribute");
-		}
-		return v;
-	}
-    public static String getNonBlankTextOrFail(Element e) throws ParserException
-	{
-		String v = getText(e);
-		if (null != v)
-			v = v.trim();
-		if (null == v || 0 == v.length())
-		{
-			throw new ParserException(e.getTagName() + " has no text");
-		}
-		return v;
-	}
- 
-     
-     
-     
-	
-	
-	/* Convenience method where there is only one child Element of a given name */
-	public static Element getChildByTagName(Element e, String name)
-	{
-	       for (Node kid = e.getFirstChild(); kid != null; kid = kid.getNextSibling())
-		{
-			if( (kid.getNodeType()==Node.ELEMENT_NODE) && (name.equals(kid.getNodeName())) )
-			{
-				return (Element)kid;
-			}
-		}
-		return null;
-	}
-
-	/**
-	 * Returns an attribute value from this node, or first parent node with this attribute defined
-	 * @param element 
-	 * @param attributeName
-	 * @return A non-zero-length value if defined, otherwise null
-	 */
-	public static String getAttributeWithInheritance(Element element, String attributeName)
-	{
-		String result=element.getAttribute(attributeName);
-		if( (result==null)|| ("".equals(result) ) )
-		{
-			Node n=element.getParentNode();
-			if((n==element)||(n==null))
-			{
-				return null;
-			}
-			if(n instanceof Element)
-			{
-				Element parent=(Element) n;
-				return getAttributeWithInheritance(parent,attributeName);
-			}
-			return null; //we reached the top level of the document without finding attribute
-		}
-		return result;		
-	}
-
-
-
-	/* Convenience method where there is only one child Element of a given name */
-	public static String getChildTextByTagName(Element e, String tagName)
-	{
-		Element child=getChildByTagName(e,tagName);
-		if(child!=null)
-		{
-			return getText(child);
-		}
-		return null;
-	}
-
-	/* Convenience method to append a new child with text*/
-	public static Element insertChild(Element parent, String tagName, String text)
-	{
-	  	Element child = parent.getOwnerDocument().createElement(tagName);
-		parent.appendChild(child);
-		if(text!=null)
-		{
-		  	child.appendChild(child.getOwnerDocument().createTextNode(text));
-		}
-		return child;
-	}
-
-	public static String getAttribute(Element element, String attributeName, String deflt)
-	{
-		String result=element.getAttribute(attributeName);
-		if( (result==null)|| ("".equals(result) ) )
-		{
-			return deflt;
-		}
-		return result;
-	}
-	public static float getAttribute(Element element, String attributeName, float deflt)
-	{
-		String result=element.getAttribute(attributeName);
-		if( (result==null)|| ("".equals(result) ) )
-		{
-			return deflt;
-		}
-		return Float.parseFloat(result);
-	}	
-
-	public static int getAttribute(Element element, String attributeName, int deflt)
-	{
-		String result=element.getAttribute(attributeName);
-		if( (result==null)|| ("".equals(result) ) )
-		{
-			return deflt;
-		}
-		return Integer.parseInt(result);
-	}
-	
-	public static boolean getAttribute(Element element, String attributeName,
-			boolean deflt)
-	{
-		String result = element.getAttribute(attributeName);
-		if ((result == null) || ("".equals(result)))
-		{
-			return deflt;
-		}
-		return Boolean.valueOf(result).booleanValue();
-	}	
-
-	/* Returns text of node and all child nodes - without markup */
-	//MH changed to Node from Element 25/11/2005
-	public static String getText(Node e)
-	{
-		StringBuffer sb=new StringBuffer();
-		getTextBuffer(e, sb);
-		return sb.toString();
-	}
-	
-	public static Element getFirstChildElement(Element element)
-	{
-		for (Node kid = element.getFirstChild(); kid != null; kid = kid
-				.getNextSibling())
-		{
-			if (kid.getNodeType() == Node.ELEMENT_NODE) 
-			{
-				return (Element) kid;
-			}
-		}
-		return null;
-	}	
-
-	private static void getTextBuffer(Node e, StringBuffer sb)
-	{
-	    for (Node kid = e.getFirstChild(); kid != null; kid = kid.getNextSibling())
-		{
-			switch(kid.getNodeType())
-			{
-				case Node.TEXT_NODE:
-				{
-					sb.append(kid.getNodeValue());
-					break;
-				}
-				case Node.ELEMENT_NODE:
-				{
-					getTextBuffer(kid, sb);
-					break;
-				}
-				case Node.ENTITY_REFERENCE_NODE:
-				{
-					getTextBuffer(kid, sb);
-					break;
-				}
-			}
-		}
-	}
-
-	/**
-	* Helper method to parse an XML file into a DOM tree, given a reader.
-	* @param is reader of the XML file to be parsed
-	* @return an org.w3c.dom.Document object
-	*/
-	public static Document loadXML(Reader is)
-	{
-
-		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-		DocumentBuilder db = null;
-		
-		try
-		{
-			db = dbf.newDocumentBuilder();
-		}
-		catch (Exception se)
-		{
-			throw new RuntimeException("Parser configuration error", se);
-		}
-
-		// Step 3: parse the input file
-		org.w3c.dom.Document doc = null;
-		try
-		{
-			doc = db.parse(new InputSource(is));
-			//doc = db.parse(is);
-		}
-		catch (Exception se)
-		{
-			throw new RuntimeException("Error parsing file:" + se, se);
-		}
-
-		return doc;
-	}	
-}
-
-
-
+package org.apache.lucene.xmlparser;
+import java.io.Reader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+public class DOMUtils
+{
+    public static Element getChildByTagOrFail(Element e, String name)	throws ParserException
+	{
+		Element kid = getChildByTagName(e, name);
+		if (null == kid)
+		{
+			throw new ParserException(e.getTagName() + " missing \"" + name
+					+ "\" child element");
+		}
+		return kid;
+	}
+     
+     public static Element getFirstChildOrFail(Element e) throws ParserException
+	{
+		Element kid = getFirstChildElement(e);
+		if (null == kid)
+		{
+			throw new ParserException(e.getTagName()
+					+ " does not contain a child element");
+		}
+		return kid;
+	}
+     
+	public static String getAttributeOrFail(Element e, String name)	throws ParserException
+	{
+		String v = e.getAttribute(name);
+		if (null == v)
+		{
+			throw new ParserException(e.getTagName() + " missing \"" + name
+					+ "\" attribute");
+		}
+		return v;
+	}
+    public static String getAttributeWithInheritanceOrFail(Element e,	String name) throws ParserException
+	{
+		String v = getAttributeWithInheritance(e, name);
+		if (null == v)
+		{
+			throw new ParserException(e.getTagName() + " missing \"" + name
+					+ "\" attribute");
+		}
+		return v;
+	}
+    public static String getNonBlankTextOrFail(Element e) throws ParserException
+	{
+		String v = getText(e);
+		if (null != v)
+			v = v.trim();
+		if (null == v || 0 == v.length())
+		{
+			throw new ParserException(e.getTagName() + " has no text");
+		}
+		return v;
+	}
+ 
+     
+     
+     
+	
+	
+	/* Convenience method where there is only one child Element of a given name */
+	public static Element getChildByTagName(Element e, String name)
+	{
+	       for (Node kid = e.getFirstChild(); kid != null; kid = kid.getNextSibling())
+		{
+			if( (kid.getNodeType()==Node.ELEMENT_NODE) && (name.equals(kid.getNodeName())) )
+			{
+				return (Element)kid;
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Returns an attribute value from this node, or first parent node with this attribute defined
+	 * @param element 
+	 * @param attributeName
+	 * @return A non-zero-length value if defined, otherwise null
+	 */
+	public static String getAttributeWithInheritance(Element element, String attributeName)
+	{
+		String result=element.getAttribute(attributeName);
+		if( (result==null)|| ("".equals(result) ) )
+		{
+			Node n=element.getParentNode();
+			if((n==element)||(n==null))
+			{
+				return null;
+			}
+			if(n instanceof Element)
+			{
+				Element parent=(Element) n;
+				return getAttributeWithInheritance(parent,attributeName);
+			}
+			return null; //we reached the top level of the document without finding attribute
+		}
+		return result;		
+	}
+
+
+
+	/* Convenience method where there is only one child Element of a given name */
+	public static String getChildTextByTagName(Element e, String tagName)
+	{
+		Element child=getChildByTagName(e,tagName);
+		if(child!=null)
+		{
+			return getText(child);
+		}
+		return null;
+	}
+
+	/* Convenience method to append a new child with text*/
+	public static Element insertChild(Element parent, String tagName, String text)
+	{
+	  	Element child = parent.getOwnerDocument().createElement(tagName);
+		parent.appendChild(child);
+		if(text!=null)
+		{
+		  	child.appendChild(child.getOwnerDocument().createTextNode(text));
+		}
+		return child;
+	}
+
+	public static String getAttribute(Element element, String attributeName, String deflt)
+	{
+		String result=element.getAttribute(attributeName);
+		if( (result==null)|| ("".equals(result) ) )
+		{
+			return deflt;
+		}
+		return result;
+	}
+	public static float getAttribute(Element element, String attributeName, float deflt)
+	{
+		String result=element.getAttribute(attributeName);
+		if( (result==null)|| ("".equals(result) ) )
+		{
+			return deflt;
+		}
+		return Float.parseFloat(result);
+	}	
+
+	public static int getAttribute(Element element, String attributeName, int deflt)
+	{
+		String result=element.getAttribute(attributeName);
+		if( (result==null)|| ("".equals(result) ) )
+		{
+			return deflt;
+		}
+		return Integer.parseInt(result);
+	}
+	
+	public static boolean getAttribute(Element element, String attributeName,
+			boolean deflt)
+	{
+		String result = element.getAttribute(attributeName);
+		if ((result == null) || ("".equals(result)))
+		{
+			return deflt;
+		}
+		return Boolean.valueOf(result).booleanValue();
+	}	
+
+	/* Returns text of node and all child nodes - without markup */
+	//MH changed to Node from Element 25/11/2005
+	public static String getText(Node e)
+	{
+		StringBuffer sb=new StringBuffer();
+		getTextBuffer(e, sb);
+		return sb.toString();
+	}
+	
+	public static Element getFirstChildElement(Element element)
+	{
+		for (Node kid = element.getFirstChild(); kid != null; kid = kid
+				.getNextSibling())
+		{
+			if (kid.getNodeType() == Node.ELEMENT_NODE) 
+			{
+				return (Element) kid;
+			}
+		}
+		return null;
+	}	
+
+	private static void getTextBuffer(Node e, StringBuffer sb)
+	{
+	    for (Node kid = e.getFirstChild(); kid != null; kid = kid.getNextSibling())
+		{
+			switch(kid.getNodeType())
+			{
+				case Node.TEXT_NODE:
+				{
+					sb.append(kid.getNodeValue());
+					break;
+				}
+				case Node.ELEMENT_NODE:
+				{
+					getTextBuffer(kid, sb);
+					break;
+				}
+				case Node.ENTITY_REFERENCE_NODE:
+				{
+					getTextBuffer(kid, sb);
+					break;
+				}
+			}
+		}
+	}
+
+	/**
+	* Helper method to parse an XML file into a DOM tree, given a reader.
+	* @param is reader of the XML file to be parsed
+	* @return an org.w3c.dom.Document object
+	*/
+	public static Document loadXML(Reader is)
+	{
+
+		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+		DocumentBuilder db = null;
+		
+		try
+		{
+			db = dbf.newDocumentBuilder();
+		}
+		catch (Exception se)
+		{
+			throw new RuntimeException("Parser configuration error", se);
+		}
+
+		// Step 3: parse the input file
+		org.w3c.dom.Document doc = null;
+		try
+		{
+			doc = db.parse(new InputSource(is));
+			//doc = db.parse(is);
+		}
+		catch (Exception se)
+		{
+			throw new RuntimeException("Error parsing file:" + se, se);
+		}
+
+		return doc;
+	}	
+}
+
+
+

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/DOMUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilterBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilterBuilder.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilterBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilterBuilder.java Mon Nov 10 18:35:46 2008
@@ -1,27 +1,27 @@
-/*
- * Created on 25-Jan-2006
- */
-package org.apache.lucene.xmlparser;
-
-import org.apache.lucene.search.Filter;
-import org.w3c.dom.Element;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public interface FilterBuilder {
-	 public Filter getFilter(Element e) throws ParserException;
-}
+/*
+ * Created on 25-Jan-2006
+ */
+package org.apache.lucene.xmlparser;
+
+import org.apache.lucene.search.Filter;
+import org.w3c.dom.Element;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public interface FilterBuilder {
+	 public Filter getFilter(Element e) throws ParserException;
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilterBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilterBuilderFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilterBuilderFactory.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilterBuilderFactory.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilterBuilderFactory.java Mon Nov 10 18:35:46 2008
@@ -1,47 +1,47 @@
-/*
- * Created on 25-Jan-2006
- */
-package org.apache.lucene.xmlparser;
-
-import java.util.HashMap;
-
-import org.apache.lucene.search.Filter;
-import org.w3c.dom.Element;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class FilterBuilderFactory implements FilterBuilder {
-
-	HashMap builders=new HashMap();
-	
-	public Filter getFilter(Element n) throws ParserException {
-		FilterBuilder builder=(FilterBuilder) builders.get(n.getNodeName());
-		if(builder==null)
-		{
-			throw new ParserException("No FilterBuilder defined for node "+n.getNodeName()); 
-		}
-		return builder.getFilter(n); 
-	}
-	public void addBuilder(String nodeName,FilterBuilder builder)
-	{
-		builders.put(nodeName,builder);
-	}
-	public FilterBuilder getFilterBuilder(String nodeName)
-	{
-		return (FilterBuilder) builders.get(nodeName);		
-	}	
-}
+/*
+ * Created on 25-Jan-2006
+ */
+package org.apache.lucene.xmlparser;
+
+import java.util.HashMap;
+
+import org.apache.lucene.search.Filter;
+import org.w3c.dom.Element;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class FilterBuilderFactory implements FilterBuilder {
+
+	HashMap builders=new HashMap();
+	
+	public Filter getFilter(Element n) throws ParserException {
+		FilterBuilder builder=(FilterBuilder) builders.get(n.getNodeName());
+		if(builder==null)
+		{
+			throw new ParserException("No FilterBuilder defined for node "+n.getNodeName()); 
+		}
+		return builder.getFilter(n); 
+	}
+	public void addBuilder(String nodeName,FilterBuilder builder)
+	{
+		builders.put(nodeName,builder);
+	}
+	public FilterBuilder getFilterBuilder(String nodeName)
+	{
+		return (FilterBuilder) builders.get(nodeName);		
+	}	
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilterBuilderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/ParserException.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/ParserException.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/ParserException.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/ParserException.java Mon Nov 10 18:35:46 2008
@@ -1,49 +1,49 @@
-/*
- * Created on 25-Jan-2006
- */
-package org.apache.lucene.xmlparser;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ParserException extends Exception {
-
-	/**
-	 * 
-	 */
-	public ParserException() {
-		super();
-	}
-	/**
-	 * @param message
-	 */
-	public ParserException(String message) {
-		super(message);
-	}
-	/**
-	 * @param message
-	 * @param cause
-	 */
-	public ParserException(String message, Throwable cause) {
-		super(message, cause);
-	}
-	/**
-	 * @param cause
-	 */
-	public ParserException(Throwable cause) {
-		super(cause);
-	}
-}
+/*
+ * Created on 25-Jan-2006
+ */
+package org.apache.lucene.xmlparser;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class ParserException extends Exception {
+
+	/**
+	 * 
+	 */
+	public ParserException() {
+		super();
+	}
+	/**
+	 * @param message
+	 */
+	public ParserException(String message) {
+		super(message);
+	}
+	/**
+	 * @param message
+	 * @param cause
+	 */
+	public ParserException(String message, Throwable cause) {
+		super(message, cause);
+	}
+	/**
+	 * @param cause
+	 */
+	public ParserException(Throwable cause) {
+		super(cause);
+	}
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/ParserException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryBuilder.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryBuilder.java Mon Nov 10 18:35:46 2008
@@ -1,29 +1,29 @@
-package org.apache.lucene.xmlparser;
-
-import org.apache.lucene.search.Query;
-import org.w3c.dom.Element;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * Implemented by objects that produce Lucene Query objects from XML streams. Implementations are
- * expected to be thread-safe so that they can be used to simultaneously parse multiple XML documents.
- */
-public interface QueryBuilder {
-	
-	public Query getQuery(Element e) throws ParserException;
-
-}
+package org.apache.lucene.xmlparser;
+
+import org.apache.lucene.search.Query;
+import org.w3c.dom.Element;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Implemented by objects that produce Lucene Query objects from XML streams. Implementations are
+ * expected to be thread-safe so that they can be used to simultaneously parse multiple XML documents.
+ */
+public interface QueryBuilder {
+	
+	public Query getQuery(Element e) throws ParserException;
+
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryBuilderFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryBuilderFactory.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryBuilderFactory.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryBuilderFactory.java Mon Nov 10 18:35:46 2008
@@ -1,48 +1,48 @@
-/*
- * Created on 25-Jan-2006
- */
-package org.apache.lucene.xmlparser;
-
-import java.util.HashMap;
-
-import org.apache.lucene.search.Query;
-import org.w3c.dom.Element;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class QueryBuilderFactory implements QueryBuilder {
-
-	HashMap builders=new HashMap();
-	
-	public Query getQuery(Element n) throws ParserException {
-		QueryBuilder builder=(QueryBuilder) builders.get(n.getNodeName());
-		if(builder==null)
-		{
-			throw new ParserException("No QueryObjectBuilder defined for node "+n.getNodeName()); 
-		}
-		return builder.getQuery(n); 
-	}
-	public void addBuilder(String nodeName,QueryBuilder builder)
-	{
-		builders.put(nodeName,builder);
-	}
-	public QueryBuilder getQueryBuilder(String nodeName)
-	{
-		return (QueryBuilder) builders.get(nodeName);		
-	}
-	
-}
+/*
+ * Created on 25-Jan-2006
+ */
+package org.apache.lucene.xmlparser;
+
+import java.util.HashMap;
+
+import org.apache.lucene.search.Query;
+import org.w3c.dom.Element;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class QueryBuilderFactory implements QueryBuilder {
+
+	HashMap builders=new HashMap();
+	
+	public Query getQuery(Element n) throws ParserException {
+		QueryBuilder builder=(QueryBuilder) builders.get(n.getNodeName());
+		if(builder==null)
+		{
+			throw new ParserException("No QueryObjectBuilder defined for node "+n.getNodeName()); 
+		}
+		return builder.getQuery(n); 
+	}
+	public void addBuilder(String nodeName,QueryBuilder builder)
+	{
+		builders.put(nodeName,builder);
+	}
+	public QueryBuilder getQueryBuilder(String nodeName)
+	{
+		return (QueryBuilder) builders.get(nodeName);		
+	}
+	
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryBuilderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryTemplateManager.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryTemplateManager.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryTemplateManager.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryTemplateManager.java Mon Nov 10 18:35:46 2008
@@ -1,211 +1,211 @@
-package org.apache.lucene.xmlparser;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Properties;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * Provides utilities for turning query form input (such as from a web page or Swing gui) into 
- * Lucene XML queries by using XSL templates.  This approach offers a convenient way of externalizing 
- * and changing how user input is turned into Lucene queries. 
- * Database applications often adopt similar practices by externalizing SQL in template files that can
- * be easily changed/optimized by a DBA.  
- * The static methods can be used on their own or by creating an instance of this class you can store and 
- * re-use compiled stylesheets for fast use (e.g. in a server environment)
- */
-public class QueryTemplateManager
-{
-	static DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
-	static TransformerFactory tFactory = TransformerFactory.newInstance();
-
-	HashMap compiledTemplatesCache=new HashMap();
-	Templates defaultCompiledTemplates=null;
-
-	
-	public QueryTemplateManager()
-	{
-		
-	}
-	public QueryTemplateManager(InputStream xslIs) throws TransformerConfigurationException, ParserConfigurationException, SAXException, IOException
-	{
-		addDefaultQueryTemplate(xslIs);
-	}
-	public void addDefaultQueryTemplate(InputStream xslIs) throws TransformerConfigurationException, ParserConfigurationException, SAXException, IOException
-	{
-		defaultCompiledTemplates=getTemplates(xslIs);
-	}
-	public void addQueryTemplate(String name, InputStream xslIs) throws TransformerConfigurationException, ParserConfigurationException, SAXException, IOException
-	{
-		compiledTemplatesCache.put(name,getTemplates(xslIs));
-	}
-	public String getQueryAsXmlString(Properties formProperties,String queryTemplateName) throws SAXException, IOException, ParserConfigurationException, TransformerException
-	{
-		Templates ts=(Templates) compiledTemplatesCache.get(queryTemplateName);
-		return getQueryAsXmlString(formProperties, ts);
-	}
-	
-	public Document getQueryAsDOM(Properties formProperties,String queryTemplateName) throws SAXException, IOException, ParserConfigurationException, TransformerException
-	{
-		Templates ts=(Templates) compiledTemplatesCache.get(queryTemplateName);
-		return getQueryAsDOM(formProperties, ts);
-	}
-	public String getQueryAsXmlString(Properties formProperties) throws SAXException, IOException, ParserConfigurationException, TransformerException
-	{
-		return getQueryAsXmlString(formProperties, defaultCompiledTemplates);
-	}
-	
-	public Document getQueryAsDOM(Properties formProperties) throws SAXException, IOException, ParserConfigurationException, TransformerException
-	{
-		return getQueryAsDOM(formProperties, defaultCompiledTemplates);
-	}
-	
-	
-	/**
-	 * Fast means of constructing query using a precompiled stylesheet  
-	 */		
-	public static String getQueryAsXmlString(Properties formProperties, Templates template) throws SAXException, IOException, ParserConfigurationException, TransformerException 
-	{
-  		ByteArrayOutputStream baos=new ByteArrayOutputStream();
-  		StreamResult result=new StreamResult(baos);
-  		transformCriteria(formProperties,template,result);
-  		return baos.toString();  		
-	}
-	
-	/**
-	 * Slow means of constructing query parsing a stylesheet from an input stream  
-	 */		
-	public static String getQueryAsXmlString(Properties formProperties, InputStream xslIs) throws SAXException, IOException, ParserConfigurationException, TransformerException 
-	{
-  		ByteArrayOutputStream baos=new ByteArrayOutputStream();
-  		StreamResult result=new StreamResult(baos);
-  		transformCriteria(formProperties,xslIs,result);
-  		return baos.toString();  		
-	}
-			
-
-	/**
-	 * Fast means of constructing query using a cached,precompiled stylesheet  
-	 */	
-	public static Document getQueryAsDOM(Properties formProperties, Templates template) throws SAXException, IOException, ParserConfigurationException, TransformerException
-	{
-  		DOMResult result=new DOMResult();
-  		transformCriteria(formProperties,template,result);
-  		return (Document)result.getNode();
-	}
-
-	
-	/**
-	 * Slow means of constructing query - parses stylesheet from input stream 
-	 */
-	public static Document getQueryAsDOM(Properties formProperties, InputStream xslIs) throws SAXException, IOException, ParserConfigurationException, TransformerException
-	{
-  		DOMResult result=new DOMResult();
-  		transformCriteria(formProperties,xslIs,result);
-  		return (Document)result.getNode();
-	}
-	
-	
-	
-	
-	/**
-	 * Slower transformation using an uncompiled stylesheet (suitable for development environment)
-	 */
-	public static void transformCriteria(Properties formProperties, InputStream xslIs, Result result) throws SAXException, IOException, ParserConfigurationException, TransformerException
-	{
-        dbf.setNamespaceAware(true);	    
-		DocumentBuilder builder = dbf.newDocumentBuilder();
-		org.w3c.dom.Document xslDoc = builder.parse(xslIs);
-		DOMSource ds = new DOMSource(xslDoc);
-		
-		Transformer transformer =null;
-		synchronized (tFactory)
-		{
-			transformer = tFactory.newTransformer(ds);			
-		}
-		transformCriteria(formProperties,transformer,result);
-	}
-	
-	/**
-	 * Fast transformation using a pre-compiled stylesheet (suitable for production environments)
-	 */
-	public static void transformCriteria(Properties formProperties, Templates template, Result result) throws SAXException, IOException, ParserConfigurationException, TransformerException
-	{
-		transformCriteria(formProperties,template.newTransformer(),result);
-	}
-	
-	
-	
-	public static void transformCriteria(Properties formProperties, Transformer transformer, Result result) throws SAXException, IOException, ParserConfigurationException, TransformerException
-	{
-        dbf.setNamespaceAware(true);
-        
-	    //Create an XML document representing the search index document.
-		DocumentBuilder db = dbf.newDocumentBuilder ();
-		org.w3c.dom.Document doc = db.newDocument ();
-		Element root = doc.createElement ("Document");
-		doc.appendChild (root);
-		
-		Enumeration keysEnum = formProperties.keys();
-		while(keysEnum.hasMoreElements())
-		{
-		    String propName=(String) keysEnum.nextElement();
-		    String value=formProperties.getProperty(propName);
-    		if((value!=null)&&(value.length()>0))
-    		{
-    		    DOMUtils.insertChild(root,propName,value);    			
-    		}
-		}		
-		//Use XSLT to to transform into an XML query string using the  queryTemplate
-		DOMSource xml=new DOMSource(doc);
-		transformer.transform(xml,result);		
-	}
-	
-	/**
-	 * Parses a query stylesheet for repeated use
-	 */
-	public static Templates getTemplates(InputStream xslIs) throws ParserConfigurationException, SAXException, IOException, TransformerConfigurationException  
-	{
-        dbf.setNamespaceAware(true);	    
-		DocumentBuilder builder = dbf.newDocumentBuilder();
-		org.w3c.dom.Document xslDoc = builder.parse(xslIs);
-		DOMSource ds = new DOMSource(xslDoc);
-		return tFactory.newTemplates(ds);
-	}
-}
+package org.apache.lucene.xmlparser;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Provides utilities for turning query form input (such as from a web page or Swing gui) into 
+ * Lucene XML queries by using XSL templates.  This approach offers a convenient way of externalizing 
+ * and changing how user input is turned into Lucene queries. 
+ * Database applications often adopt similar practices by externalizing SQL in template files that can
+ * be easily changed/optimized by a DBA.  
+ * The static methods can be used on their own or by creating an instance of this class you can store and 
+ * re-use compiled stylesheets for fast use (e.g. in a server environment)
+ */
+public class QueryTemplateManager
+{
+	static DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+	static TransformerFactory tFactory = TransformerFactory.newInstance();
+
+	HashMap compiledTemplatesCache=new HashMap();
+	Templates defaultCompiledTemplates=null;
+
+	
+	public QueryTemplateManager()
+	{
+		
+	}
+	public QueryTemplateManager(InputStream xslIs) throws TransformerConfigurationException, ParserConfigurationException, SAXException, IOException
+	{
+		addDefaultQueryTemplate(xslIs);
+	}
+	public void addDefaultQueryTemplate(InputStream xslIs) throws TransformerConfigurationException, ParserConfigurationException, SAXException, IOException
+	{
+		defaultCompiledTemplates=getTemplates(xslIs);
+	}
+	public void addQueryTemplate(String name, InputStream xslIs) throws TransformerConfigurationException, ParserConfigurationException, SAXException, IOException
+	{
+		compiledTemplatesCache.put(name,getTemplates(xslIs));
+	}
+	public String getQueryAsXmlString(Properties formProperties,String queryTemplateName) throws SAXException, IOException, ParserConfigurationException, TransformerException
+	{
+		Templates ts=(Templates) compiledTemplatesCache.get(queryTemplateName);
+		return getQueryAsXmlString(formProperties, ts);
+	}
+	
+	public Document getQueryAsDOM(Properties formProperties,String queryTemplateName) throws SAXException, IOException, ParserConfigurationException, TransformerException
+	{
+		Templates ts=(Templates) compiledTemplatesCache.get(queryTemplateName);
+		return getQueryAsDOM(formProperties, ts);
+	}
+	public String getQueryAsXmlString(Properties formProperties) throws SAXException, IOException, ParserConfigurationException, TransformerException
+	{
+		return getQueryAsXmlString(formProperties, defaultCompiledTemplates);
+	}
+	
+	public Document getQueryAsDOM(Properties formProperties) throws SAXException, IOException, ParserConfigurationException, TransformerException
+	{
+		return getQueryAsDOM(formProperties, defaultCompiledTemplates);
+	}
+	
+	
+	/**
+	 * Fast means of constructing query using a precompiled stylesheet  
+	 */		
+	public static String getQueryAsXmlString(Properties formProperties, Templates template) throws SAXException, IOException, ParserConfigurationException, TransformerException 
+	{
+  		ByteArrayOutputStream baos=new ByteArrayOutputStream();
+  		StreamResult result=new StreamResult(baos);
+  		transformCriteria(formProperties,template,result);
+  		return baos.toString();  		
+	}
+	
+	/**
+	 * Slow means of constructing query parsing a stylesheet from an input stream  
+	 */		
+	public static String getQueryAsXmlString(Properties formProperties, InputStream xslIs) throws SAXException, IOException, ParserConfigurationException, TransformerException 
+	{
+  		ByteArrayOutputStream baos=new ByteArrayOutputStream();
+  		StreamResult result=new StreamResult(baos);
+  		transformCriteria(formProperties,xslIs,result);
+  		return baos.toString();  		
+	}
+			
+
+	/**
+	 * Fast means of constructing query using a cached,precompiled stylesheet  
+	 */	
+	public static Document getQueryAsDOM(Properties formProperties, Templates template) throws SAXException, IOException, ParserConfigurationException, TransformerException
+	{
+  		DOMResult result=new DOMResult();
+  		transformCriteria(formProperties,template,result);
+  		return (Document)result.getNode();
+	}
+
+	
+	/**
+	 * Slow means of constructing query - parses stylesheet from input stream 
+	 */
+	public static Document getQueryAsDOM(Properties formProperties, InputStream xslIs) throws SAXException, IOException, ParserConfigurationException, TransformerException
+	{
+  		DOMResult result=new DOMResult();
+  		transformCriteria(formProperties,xslIs,result);
+  		return (Document)result.getNode();
+	}
+	
+	
+	
+	
+	/**
+	 * Slower transformation using an uncompiled stylesheet (suitable for development environment)
+	 */
+	public static void transformCriteria(Properties formProperties, InputStream xslIs, Result result) throws SAXException, IOException, ParserConfigurationException, TransformerException
+	{
+        dbf.setNamespaceAware(true);	    
+		DocumentBuilder builder = dbf.newDocumentBuilder();
+		org.w3c.dom.Document xslDoc = builder.parse(xslIs);
+		DOMSource ds = new DOMSource(xslDoc);
+		
+		Transformer transformer =null;
+		synchronized (tFactory)
+		{
+			transformer = tFactory.newTransformer(ds);			
+		}
+		transformCriteria(formProperties,transformer,result);
+	}
+	
+	/**
+	 * Fast transformation using a pre-compiled stylesheet (suitable for production environments)
+	 */
+	public static void transformCriteria(Properties formProperties, Templates template, Result result) throws SAXException, IOException, ParserConfigurationException, TransformerException
+	{
+		transformCriteria(formProperties,template.newTransformer(),result);
+	}
+	
+	
+	
+	public static void transformCriteria(Properties formProperties, Transformer transformer, Result result) throws SAXException, IOException, ParserConfigurationException, TransformerException
+	{
+        dbf.setNamespaceAware(true);
+        
+	    //Create an XML document representing the search index document.
+		DocumentBuilder db = dbf.newDocumentBuilder ();
+		org.w3c.dom.Document doc = db.newDocument ();
+		Element root = doc.createElement ("Document");
+		doc.appendChild (root);
+		
+		Enumeration keysEnum = formProperties.keys();
+		while(keysEnum.hasMoreElements())
+		{
+		    String propName=(String) keysEnum.nextElement();
+		    String value=formProperties.getProperty(propName);
+    		if((value!=null)&&(value.length()>0))
+    		{
+    		    DOMUtils.insertChild(root,propName,value);    			
+    		}
+		}		
+		//Use XSLT to to transform into an XML query string using the  queryTemplate
+		DOMSource xml=new DOMSource(doc);
+		transformer.transform(xml,result);		
+	}
+	
+	/**
+	 * Parses a query stylesheet for repeated use
+	 */
+	public static Templates getTemplates(InputStream xslIs) throws ParserConfigurationException, SAXException, IOException, TransformerConfigurationException  
+	{
+        dbf.setNamespaceAware(true);	    
+		DocumentBuilder builder = dbf.newDocumentBuilder();
+		org.w3c.dom.Document xslDoc = builder.parse(xslIs);
+		DOMSource ds = new DOMSource(xslDoc);
+		return tFactory.newTemplates(ds);
+	}
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/QueryTemplateManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanFilterBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanFilterBuilder.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanFilterBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanFilterBuilder.java Mon Nov 10 18:35:46 2008
@@ -1,64 +1,64 @@
-/*
- * Created on 25-Jan-2006
- */
-package org.apache.lucene.xmlparser.builders;
-
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanFilter;
-import org.apache.lucene.search.Filter;
-import org.apache.lucene.search.FilterClause;
-import org.apache.lucene.xmlparser.DOMUtils;
-import org.apache.lucene.xmlparser.FilterBuilder;
-import org.apache.lucene.xmlparser.ParserException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class BooleanFilterBuilder implements FilterBuilder {
-	
-	private FilterBuilder factory;
-
-	public BooleanFilterBuilder(FilterBuilder factory)
-	{
-		this.factory=factory;
-	}
-
-	public Filter getFilter(Element e) throws ParserException {
-		BooleanFilter bf=new BooleanFilter();
-		NodeList nl = e.getChildNodes();
-		
-		for(int i=0;i<nl.getLength();i++)
-		{
-			Node node = nl.item(i);
-			if(node.getNodeName().equals("Clause"))
-			{
-				Element clauseElem=(Element) node;
-				BooleanClause.Occur occurs=BooleanQueryBuilder.getOccursValue(clauseElem);
-			
-	 			Element clauseFilter=DOMUtils.getFirstChildOrFail(clauseElem);
-	 			Filter f=factory.getFilter(clauseFilter);
-	 			bf.add(new FilterClause(f,occurs));
-			}
-		}
-		
-		return bf;
-	}
-
-}
+/*
+ * Created on 25-Jan-2006
+ */
+package org.apache.lucene.xmlparser.builders;
+
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanFilter;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.FilterClause;
+import org.apache.lucene.xmlparser.DOMUtils;
+import org.apache.lucene.xmlparser.FilterBuilder;
+import org.apache.lucene.xmlparser.ParserException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class BooleanFilterBuilder implements FilterBuilder {
+	
+	private FilterBuilder factory;
+
+	public BooleanFilterBuilder(FilterBuilder factory)
+	{
+		this.factory=factory;
+	}
+
+	public Filter getFilter(Element e) throws ParserException {
+		BooleanFilter bf=new BooleanFilter();
+		NodeList nl = e.getChildNodes();
+		
+		for(int i=0;i<nl.getLength();i++)
+		{
+			Node node = nl.item(i);
+			if(node.getNodeName().equals("Clause"))
+			{
+				Element clauseElem=(Element) node;
+				BooleanClause.Occur occurs=BooleanQueryBuilder.getOccursValue(clauseElem);
+			
+	 			Element clauseFilter=DOMUtils.getFirstChildOrFail(clauseElem);
+	 			Filter f=factory.getFilter(clauseFilter);
+	 			bf.add(new FilterClause(f,occurs));
+			}
+		}
+		
+		return bf;
+	}
+
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanFilterBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanQueryBuilder.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanQueryBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanQueryBuilder.java Mon Nov 10 18:35:46 2008
@@ -1,100 +1,100 @@
-/*
- * Created on 25-Jan-2006
- */
-package org.apache.lucene.xmlparser.builders;
-
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.xmlparser.DOMUtils;
-import org.apache.lucene.xmlparser.ParserException;
-import org.apache.lucene.xmlparser.QueryBuilder;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-public class BooleanQueryBuilder implements QueryBuilder {
-	
-	private QueryBuilder factory;
-
-	public BooleanQueryBuilder(QueryBuilder factory)
-	{
-		this.factory=factory;
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.lucene.xmlparser.QueryObjectBuilder#process(org.w3c.dom.Element)
-	 */
-	public Query getQuery(Element e) throws ParserException {
-		BooleanQuery bq=new BooleanQuery(DOMUtils.getAttribute(e,"disableCoord",false));
-		bq.setMinimumNumberShouldMatch(DOMUtils.getAttribute(e,"minimumNumberShouldMatch",0));
-		bq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
-		
-		NodeList nl = e.getChildNodes();
-		for(int i=0;i<nl.getLength();i++)
-		{
-			Node node = nl.item(i);
-			if(node.getNodeName().equals("Clause"))
-			{
-				Element clauseElem=(Element) node;
-				BooleanClause.Occur occurs=getOccursValue(clauseElem);
-				
-	 			Element clauseQuery=DOMUtils.getFirstChildOrFail(clauseElem);
-	 			Query q=factory.getQuery(clauseQuery);
-	 			bq.add(new BooleanClause(q,occurs));
-			}
-		}
-		
-		return bq;
-	}
-	static BooleanClause.Occur getOccursValue(Element clauseElem) throws ParserException
-	{
-		String occs=clauseElem.getAttribute("occurs");
-		BooleanClause.Occur occurs=BooleanClause.Occur.SHOULD;
-		if("must".equalsIgnoreCase(occs))
-		{
-			occurs=BooleanClause.Occur.MUST;
-		}
-		else
-		{
-			if("mustNot".equalsIgnoreCase(occs))
-			{
-				occurs=BooleanClause.Occur.MUST_NOT;
-			}			
-			else
-			{
-				if(("should".equalsIgnoreCase(occs))||("".equals(occs)))
-				{
-					occurs=BooleanClause.Occur.SHOULD;
-				}			
-				else				
-				{
-					if(occs!=null)
-					{
-						throw new ParserException("Invalid value for \"occurs\" attribute of clause:"+occs);
-					}
-				}
-			}
-		}
-		return occurs;
-		
-	}
-
-}
+/*
+ * Created on 25-Jan-2006
+ */
+package org.apache.lucene.xmlparser.builders;
+
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.xmlparser.DOMUtils;
+import org.apache.lucene.xmlparser.ParserException;
+import org.apache.lucene.xmlparser.QueryBuilder;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+public class BooleanQueryBuilder implements QueryBuilder {
+	
+	private QueryBuilder factory;
+
+	public BooleanQueryBuilder(QueryBuilder factory)
+	{
+		this.factory=factory;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.lucene.xmlparser.QueryObjectBuilder#process(org.w3c.dom.Element)
+	 */
+	public Query getQuery(Element e) throws ParserException {
+		BooleanQuery bq=new BooleanQuery(DOMUtils.getAttribute(e,"disableCoord",false));
+		bq.setMinimumNumberShouldMatch(DOMUtils.getAttribute(e,"minimumNumberShouldMatch",0));
+		bq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
+		
+		NodeList nl = e.getChildNodes();
+		for(int i=0;i<nl.getLength();i++)
+		{
+			Node node = nl.item(i);
+			if(node.getNodeName().equals("Clause"))
+			{
+				Element clauseElem=(Element) node;
+				BooleanClause.Occur occurs=getOccursValue(clauseElem);
+				
+	 			Element clauseQuery=DOMUtils.getFirstChildOrFail(clauseElem);
+	 			Query q=factory.getQuery(clauseQuery);
+	 			bq.add(new BooleanClause(q,occurs));
+			}
+		}
+		
+		return bq;
+	}
+	static BooleanClause.Occur getOccursValue(Element clauseElem) throws ParserException
+	{
+		String occs=clauseElem.getAttribute("occurs");
+		BooleanClause.Occur occurs=BooleanClause.Occur.SHOULD;
+		if("must".equalsIgnoreCase(occs))
+		{
+			occurs=BooleanClause.Occur.MUST;
+		}
+		else
+		{
+			if("mustNot".equalsIgnoreCase(occs))
+			{
+				occurs=BooleanClause.Occur.MUST_NOT;
+			}			
+			else
+			{
+				if(("should".equalsIgnoreCase(occs))||("".equals(occs)))
+				{
+					occurs=BooleanClause.Occur.SHOULD;
+				}			
+				else				
+				{
+					if(occs!=null)
+					{
+						throw new ParserException("Invalid value for \"occurs\" attribute of clause:"+occs);
+					}
+				}
+			}
+		}
+		return occurs;
+		
+	}
+
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanQueryBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingQueryBuilder.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingQueryBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingQueryBuilder.java Mon Nov 10 18:35:46 2008
@@ -1,57 +1,57 @@
-package org.apache.lucene.xmlparser.builders;
-
-import org.apache.lucene.search.BoostingQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.xmlparser.DOMUtils;
-import org.apache.lucene.xmlparser.ParserException;
-import org.apache.lucene.xmlparser.QueryBuilder;
-import org.w3c.dom.Element;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class BoostingQueryBuilder implements QueryBuilder
-{
-	
-	private QueryBuilder factory;
-	float defaultBoost=0.01f;
-
-	public BoostingQueryBuilder (QueryBuilder factory)
-	{
-		this.factory=factory;
-	}
-
-	public Query getQuery(Element e) throws ParserException
-	{
-		
-        Element mainQueryElem=DOMUtils.getChildByTagOrFail(e,"Query");
- 		mainQueryElem=DOMUtils.getFirstChildOrFail(mainQueryElem);
-  		Query mainQuery=factory.getQuery(mainQueryElem);
-
- 		Element boostQueryElem=DOMUtils.getChildByTagOrFail(e,"BoostQuery");
-  		float boost=DOMUtils.getAttribute(boostQueryElem,"boost",defaultBoost);
- 		boostQueryElem=DOMUtils.getFirstChildOrFail(boostQueryElem);
-  		Query boostQuery=factory.getQuery(boostQueryElem);
-  		
-  		BoostingQuery bq = new BoostingQuery(mainQuery,boostQuery,boost);
-
-  		bq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
-		return bq;
-
-	}
-
-
-}
+package org.apache.lucene.xmlparser.builders;
+
+import org.apache.lucene.search.BoostingQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.xmlparser.DOMUtils;
+import org.apache.lucene.xmlparser.ParserException;
+import org.apache.lucene.xmlparser.QueryBuilder;
+import org.w3c.dom.Element;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class BoostingQueryBuilder implements QueryBuilder
+{
+	
+	private QueryBuilder factory;
+	float defaultBoost=0.01f;
+
+	public BoostingQueryBuilder (QueryBuilder factory)
+	{
+		this.factory=factory;
+	}
+
+	public Query getQuery(Element e) throws ParserException
+	{
+		
+        Element mainQueryElem=DOMUtils.getChildByTagOrFail(e,"Query");
+ 		mainQueryElem=DOMUtils.getFirstChildOrFail(mainQueryElem);
+  		Query mainQuery=factory.getQuery(mainQueryElem);
+
+ 		Element boostQueryElem=DOMUtils.getChildByTagOrFail(e,"BoostQuery");
+  		float boost=DOMUtils.getAttribute(boostQueryElem,"boost",defaultBoost);
+ 		boostQueryElem=DOMUtils.getFirstChildOrFail(boostQueryElem);
+  		Query boostQuery=factory.getQuery(boostQueryElem);
+  		
+  		BoostingQuery bq = new BoostingQuery(mainQuery,boostQuery,boost);
+
+  		bq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
+		return bq;
+
+	}
+
+
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingQueryBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/CachedFilterBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/CachedFilterBuilder.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/CachedFilterBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/CachedFilterBuilder.java Mon Nov 10 18:35:46 2008
@@ -1,129 +1,129 @@
-/*
- * Created on 25-Jan-2006
- */
-package org.apache.lucene.xmlparser.builders;
-
-import java.util.Map.Entry;
-
-import org.apache.lucene.search.CachingWrapperFilter;
-import org.apache.lucene.search.Filter;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.QueryWrapperFilter;
-import org.apache.lucene.xmlparser.DOMUtils;
-import org.apache.lucene.xmlparser.FilterBuilder;
-import org.apache.lucene.xmlparser.FilterBuilderFactory;
-import org.apache.lucene.xmlparser.ParserException;
-import org.apache.lucene.xmlparser.QueryBuilder;
-import org.apache.lucene.xmlparser.QueryBuilderFactory;
-import org.w3c.dom.Element;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * Filters are cached in an LRU Cache keyed on the contained query or filter object. Using this will 
- * speed up overall performance for repeated uses of the same expensive query/filter. The sorts of 
- * queries/filters likely to benefit from caching need not necessarily be complex - e.g. simple 
- * TermQuerys with a large DF (document frequency) can be expensive	on large indexes. 
- * A good example of this might be a term query on a field with only 2 possible	values - 
- * "true" or "false". In a large index, querying or filtering on this field requires reading 
- * millions	of document ids from disk which can more usefully be cached as a filter bitset.
- * 
- * For Queries/Filters to be cached and reused the object must implement hashcode and
- * equals methods correctly so that duplicate queries/filters can be detected in the cache.
- * 
- * The CoreParser.maxNumCachedFilters property can be used to control the size of the LRU 
- * Cache established during the construction of CoreParser instances.
- *
- */
-public class CachedFilterBuilder implements FilterBuilder {
-
-	private QueryBuilderFactory queryFactory;
-	private FilterBuilderFactory filterFactory;
-	
-    private  LRUCache filterCache = null;
-
-	private int cacheSize;
-
-	public CachedFilterBuilder(QueryBuilderFactory queryFactory, 
-			FilterBuilderFactory filterFactory,int cacheSize)
-	{
-		this.queryFactory=queryFactory;
-		this.filterFactory=filterFactory;
-		this.cacheSize=cacheSize;
-	}
-
-	public synchronized Filter getFilter(Element e) throws ParserException
-	{
-
-		Element childElement = DOMUtils.getFirstChildOrFail(e);
-
-		if (filterCache == null)
-		{
-			filterCache = new LRUCache(cacheSize);
-		}
-
-		// Test to see if child Element is a query or filter that needs to be
-		// cached
-		QueryBuilder qb = queryFactory.getQueryBuilder(childElement.getNodeName());
-		Object cacheKey = null;
-		Query q = null;
-		Filter f = null;
-		if (qb != null)
-		{
-			q = qb.getQuery(childElement);
-			cacheKey = q;
-		} else
-		{
-			f = filterFactory.getFilter(childElement);
-			cacheKey = f;
-		}
-		Filter cachedFilter = (Filter) filterCache.get(cacheKey);
-		if (cachedFilter != null)
-		{
-			return cachedFilter; // cache hit
-		}
-		
-		//cache miss
-		if (qb != null)
-		{
-			cachedFilter = new QueryWrapperFilter(q);
-		} else
-		{
-			cachedFilter = new CachingWrapperFilter(f);
-		}
-
-		filterCache.put(cacheKey, cachedFilter);
-		return cachedFilter;
-	}
-	
-	static class LRUCache extends java.util.LinkedHashMap
-	{
-	    public LRUCache(int maxsize)
-	    {
-	        super(maxsize * 4 / 3 + 1, 0.75f, true);
-	        this.maxsize = maxsize;
-	    }
-
-	    protected int maxsize;
-
-	    protected boolean removeEldestEntry(Entry eldest)
-	    {
-	        return size() > maxsize;
-	    }
-
-	}
-
-}
+/*
+ * Created on 25-Jan-2006
+ */
+package org.apache.lucene.xmlparser.builders;
+
+import java.util.Map.Entry;
+
+import org.apache.lucene.search.CachingWrapperFilter;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.QueryWrapperFilter;
+import org.apache.lucene.xmlparser.DOMUtils;
+import org.apache.lucene.xmlparser.FilterBuilder;
+import org.apache.lucene.xmlparser.FilterBuilderFactory;
+import org.apache.lucene.xmlparser.ParserException;
+import org.apache.lucene.xmlparser.QueryBuilder;
+import org.apache.lucene.xmlparser.QueryBuilderFactory;
+import org.w3c.dom.Element;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Filters are cached in an LRU Cache keyed on the contained query or filter object. Using this will 
+ * speed up overall performance for repeated uses of the same expensive query/filter. The sorts of 
+ * queries/filters likely to benefit from caching need not necessarily be complex - e.g. simple 
+ * TermQuerys with a large DF (document frequency) can be expensive	on large indexes. 
+ * A good example of this might be a term query on a field with only 2 possible	values - 
+ * "true" or "false". In a large index, querying or filtering on this field requires reading 
+ * millions	of document ids from disk which can more usefully be cached as a filter bitset.
+ * 
+ * For Queries/Filters to be cached and reused the object must implement hashcode and
+ * equals methods correctly so that duplicate queries/filters can be detected in the cache.
+ * 
+ * The CoreParser.maxNumCachedFilters property can be used to control the size of the LRU 
+ * Cache established during the construction of CoreParser instances.
+ *
+ */
+public class CachedFilterBuilder implements FilterBuilder {
+
+	private QueryBuilderFactory queryFactory;
+	private FilterBuilderFactory filterFactory;
+	
+    private  LRUCache filterCache = null;
+
+	private int cacheSize;
+
+	public CachedFilterBuilder(QueryBuilderFactory queryFactory, 
+			FilterBuilderFactory filterFactory,int cacheSize)
+	{
+		this.queryFactory=queryFactory;
+		this.filterFactory=filterFactory;
+		this.cacheSize=cacheSize;
+	}
+
+	public synchronized Filter getFilter(Element e) throws ParserException
+	{
+
+		Element childElement = DOMUtils.getFirstChildOrFail(e);
+
+		if (filterCache == null)
+		{
+			filterCache = new LRUCache(cacheSize);
+		}
+
+		// Test to see if child Element is a query or filter that needs to be
+		// cached
+		QueryBuilder qb = queryFactory.getQueryBuilder(childElement.getNodeName());
+		Object cacheKey = null;
+		Query q = null;
+		Filter f = null;
+		if (qb != null)
+		{
+			q = qb.getQuery(childElement);
+			cacheKey = q;
+		} else
+		{
+			f = filterFactory.getFilter(childElement);
+			cacheKey = f;
+		}
+		Filter cachedFilter = (Filter) filterCache.get(cacheKey);
+		if (cachedFilter != null)
+		{
+			return cachedFilter; // cache hit
+		}
+		
+		//cache miss
+		if (qb != null)
+		{
+			cachedFilter = new QueryWrapperFilter(q);
+		} else
+		{
+			cachedFilter = new CachingWrapperFilter(f);
+		}
+
+		filterCache.put(cacheKey, cachedFilter);
+		return cachedFilter;
+	}
+	
+	static class LRUCache extends java.util.LinkedHashMap
+	{
+	    public LRUCache(int maxsize)
+	    {
+	        super(maxsize * 4 / 3 + 1, 0.75f, true);
+	        this.maxsize = maxsize;
+	    }
+
+	    protected int maxsize;
+
+	    protected boolean removeEldestEntry(Entry eldest)
+	    {
+	        return size() > maxsize;
+	    }
+
+	}
+
+}

Propchange: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/CachedFilterBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/ConstantScoreQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/ConstantScoreQueryBuilder.java?rev=712922&r1=712921&r2=712922&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/ConstantScoreQueryBuilder.java (original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/ConstantScoreQueryBuilder.java Mon Nov 10 18:35:46 2008
@@ -1,46 +1,46 @@
-package org.apache.lucene.xmlparser.builders;
-
-import org.apache.lucene.search.ConstantScoreQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.xmlparser.DOMUtils;
-import org.apache.lucene.xmlparser.FilterBuilderFactory;
-import org.apache.lucene.xmlparser.ParserException;
-import org.apache.lucene.xmlparser.QueryBuilder;
-import org.w3c.dom.Element;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-public class ConstantScoreQueryBuilder implements QueryBuilder
-{
-	private FilterBuilderFactory filterFactory;
-
-	public ConstantScoreQueryBuilder(FilterBuilderFactory filterFactory)
-	{
-		this.filterFactory=filterFactory;
-	}
-
-	public Query getQuery(Element e) throws ParserException
-	{
- 		Element filterElem=DOMUtils.getFirstChildOrFail(e);
-  		Query q=new ConstantScoreQuery(filterFactory.getFilter(filterElem));
-
-  		q.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
-
-  		return q;
-		
-	}
-
-}
+package org.apache.lucene.xmlparser.builders;
+
+import org.apache.lucene.search.ConstantScoreQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.xmlparser.DOMUtils;
+import org.apache.lucene.xmlparser.FilterBuilderFactory;
+import org.apache.lucene.xmlparser.ParserException;
+import org.apache.lucene.xmlparser.QueryBuilder;
+import org.w3c.dom.Element;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+public class ConstantScoreQueryBuilder implements QueryBuilder
+{
+	private FilterBuilderFactory filterFactory;
+
+	public ConstantScoreQueryBuilder(FilterBuilderFactory filterFactory)
+	{
+		this.filterFactory=filterFactory;
+	}
+
+	public Query getQuery(Element e) throws ParserException
+	{
+ 		Element filterElem=DOMUtils.getFirstChildOrFail(e);
+  		Query q=new ConstantScoreQuery(filterFactory.getFilter(filterElem));
+
+  		q.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
+
+  		return q;
+		
+	}
+
+}



Mime
View raw message