Search in sources :

Example 16 with NamedReader

use of com.yahoo.io.reader.NamedReader in project vespa by vespa-engine.

the class QueryProfileXMLReader method createQueryProfileTypes.

public List<Element> createQueryProfileTypes(List<NamedReader> queryProfileTypeReaders, QueryProfileTypeRegistry registry) {
    List<Element> queryProfileTypeElements = new ArrayList<>(queryProfileTypeReaders.size());
    for (NamedReader reader : queryProfileTypeReaders) {
        Element root = XML.getDocument(reader).getDocumentElement();
        if (!root.getNodeName().equals("query-profile-type")) {
            throw new IllegalArgumentException("Root tag in '" + reader.getName() + "' must be 'query-profile-type', not '" + root.getNodeName() + "'");
        }
        String idString = root.getAttribute("id");
        if (idString == null || idString.equals(""))
            throw new IllegalArgumentException("'" + reader.getName() + "' has no 'id' attribute in the root element");
        ComponentId id = new ComponentId(idString);
        validateFileNameToId(reader.getName(), id, "query profile type");
        QueryProfileType type = new QueryProfileType(id);
        type.setMatchAsPath(XML.getChild(root, "match") != null);
        type.setStrict(XML.getChild(root, "strict") != null);
        registry.register(type);
        queryProfileTypeElements.add(root);
    }
    return queryProfileTypeElements;
}
Also used : Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) NamedReader(com.yahoo.io.reader.NamedReader) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType) ComponentId(com.yahoo.component.ComponentId)

Aggregations

NamedReader (com.yahoo.io.reader.NamedReader)16 ArrayList (java.util.ArrayList)7 Element (org.w3c.dom.Element)4 ComponentId (com.yahoo.component.ComponentId)3 File (java.io.File)3 StringReader (java.io.StringReader)3 ApplicationFile (com.yahoo.config.application.api.ApplicationFile)2 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 JarFile (java.util.jar.JarFile)2 Path (com.yahoo.path.Path)1 PageTemplate (com.yahoo.search.pagetemplates.PageTemplate)1 PageTemplateXMLReader (com.yahoo.search.pagetemplates.config.PageTemplateXMLReader)1 QueryProfile (com.yahoo.search.query.profile.QueryProfile)1 ParseException (com.yahoo.searchdefinition.parser.ParseException)1 PageTemplates (com.yahoo.vespa.model.container.search.PageTemplates)1 NonNull (edu.umd.cs.findbugs.annotations.NonNull)1 Reader (java.io.Reader)1 URISyntaxException (java.net.URISyntaxException)1