aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/search/SearchDefinitionXMLHandler.java
blob: 11758284a31edb4b0119106208440a171a1fb7bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.search;

import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
import org.w3c.dom.Element;

import java.io.Serializable;
import java.util.List;

/**
 * Represents a single searchdefinition file.
 *
 * @author arnej27959
 */
public class SearchDefinitionXMLHandler implements Serializable {

    private String sdName;

    public SearchDefinitionXMLHandler(ModelElement elem) {
        sdName = elem.getStringAttribute("name");
        if (sdName == null) {
            sdName = elem.getStringAttribute("type");
        }
    }

    public String getName() { return sdName; }

    public SearchDefinition getResponsibleSearchDefinition(List<SearchDefinition> searchDefinitions) {
        return SearchDefinition.findByName( getName(), searchDefinitions );
    }

}