aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/search/SchemaDefinitionXMLHandler.java
blob: 06a5929a4301cace59417b0d52b48f655a87a881 (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
33
34
35
36
// Copyright Yahoo. 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.schema.Schema;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;

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

/**
 * Represents a single schema file.
 *
 * @author arnej27959
 */
public class SchemaDefinitionXMLHandler implements Serializable {

    private String schemaName;

    public SchemaDefinitionXMLHandler(ModelElement elem) {
        schemaName = elem.stringAttribute("name");
        if (schemaName == null) {
            schemaName = elem.stringAttribute("type");
        }
    }

    public String getName() { return schemaName; }

    public Schema findResponsibleSchema(List<Schema> schemas) {
        for (Schema candidate : schemas) {
            if (candidate.getName().equals(schemaName) )
                return candidate;
        }
        return null;
    }

}