~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanOrBuilder.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.xmlparser.builders;
2
 
 
3
 
import java.util.ArrayList;
4
 
 
5
 
import org.apache.lucene.search.spans.SpanOrQuery;
6
 
import org.apache.lucene.search.spans.SpanQuery;
7
 
import org.apache.lucene.xmlparser.DOMUtils;
8
 
import org.apache.lucene.xmlparser.ParserException;
9
 
import org.w3c.dom.Element;
10
 
import org.w3c.dom.Node;
11
 
/**
12
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
13
 
 * contributor license agreements.  See the NOTICE file distributed with
14
 
 * this work for additional information regarding copyright ownership.
15
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
16
 
 * (the "License"); you may not use this file except in compliance with
17
 
 * the License.  You may obtain a copy of the License at
18
 
 *
19
 
 *     http://www.apache.org/licenses/LICENSE-2.0
20
 
 *
21
 
 * Unless required by applicable law or agreed to in writing, software
22
 
 * distributed under the License is distributed on an "AS IS" BASIS,
23
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
 
 * See the License for the specific language governing permissions and
25
 
 * limitations under the License.
26
 
 */
27
 
 
28
 
/**
29
 
 * 
30
 
 */
31
 
public class SpanOrBuilder extends SpanBuilderBase
32
 
{
33
 
    
34
 
    SpanQueryBuilder factory;
35
 
    
36
 
    public SpanOrBuilder(SpanQueryBuilder factory)
37
 
    {
38
 
        super();
39
 
        this.factory = factory;
40
 
    }
41
 
    
42
 
        public SpanQuery getSpanQuery(Element e) throws ParserException
43
 
        {
44
 
            ArrayList<SpanQuery> clausesList=new ArrayList<SpanQuery>();
45
 
                for (Node kid = e.getFirstChild(); kid != null; kid = kid.getNextSibling())
46
 
                {
47
 
                        if (kid.getNodeType() == Node.ELEMENT_NODE) 
48
 
                        {
49
 
                                SpanQuery clause=factory.getSpanQuery((Element) kid);
50
 
                                clausesList.add(clause);                                
51
 
                        }
52
 
                }           
53
 
                SpanQuery[] clauses= clausesList.toArray(new SpanQuery[clausesList.size()]);
54
 
                SpanOrQuery soq = new SpanOrQuery(clauses);             
55
 
                soq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
56
 
                return soq;
57
 
        }
58
 
 
59
 
}