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;
}
Aggregations