public AbstractXPathCompiled()

in sources/java-incremental-compilation/jvm-inc-builder/src/com/intellij/tools/build/bazel/org/jdom/xpath/util/AbstractXPathCompiled.java [116:189]


  public AbstractXPathCompiled(final String query, final Filter<T> filter,
                               final Map<String, Object> variables, final Namespace[] namespaces) {
    if (query == null) {
      throw new NullPointerException("Null query");
    }
    if (filter == null) {
      throw new NullPointerException("Null filter");
    }
    xnamespaces.put(Namespace.NO_NAMESPACE.getPrefix(),
                    Namespace.NO_NAMESPACE);
    if (namespaces != null) {
      for (Namespace ns : namespaces) {
        if (ns == null) {
          throw new NullPointerException("Null namespace");
        }
        final Namespace oldns = xnamespaces.put(ns.getPrefix(), ns);
        if (oldns != null && oldns != ns) {
          if (oldns == Namespace.NO_NAMESPACE) {
            throw new IllegalArgumentException(
              "The default (no prefix) Namespace URI for XPath queries is always" +
              " '' and it cannot be redefined to '" + ns.getURI() + "'.");
          }
          throw new IllegalArgumentException(
            "A Namespace with the prefix '" + ns.getPrefix()
            + "' has already been declared.");
        }
      }
    }

    if (variables != null) {
      for (Map.Entry<String, Object> me : variables.entrySet()) {
        final String qname = me.getKey();
        if (qname == null) {
          throw new NullPointerException("Variable with a null name");
        }
        final int p = qname.indexOf(':');
        final String pfx = p < 0 ? "" : qname.substring(0, p);
        final String lname = p < 0 ? qname : qname.substring(p + 1);

        final String vpfxmsg = Verifier.checkNamespacePrefix(pfx);
        if (vpfxmsg != null) {
          throw new IllegalArgumentException("Prefix '" + pfx
                                             + "' for variable " + qname + " is illegal: "
                                             + vpfxmsg);
        }
        final String vnamemsg = Verifier.checkXMLName(lname);
        if (vnamemsg != null) {
          throw new IllegalArgumentException("Variable name '"
                                             + lname + "' for variable " + qname
                                             + " is illegal: " + vnamemsg);
        }

        final Namespace ns = xnamespaces.get(pfx);
        if (ns == null) {
          throw new IllegalArgumentException("Prefix '" + pfx
                                             + "' for variable " + qname
                                             + " has not been assigned a Namespace.");
        }

        Map<String, Object> vmap = xvariables.get(ns.getURI());
        if (vmap == null) {
          vmap = new HashMap<>();
          xvariables.put(ns.getURI(), vmap);
        }

        if (vmap.put(lname, me.getValue()) != null) {
          throw new IllegalArgumentException("Variable with name "
                                             + me.getKey() + "' has already been defined.");
        }
      }
    }
    xquery = query;
    xfilter = filter;
  }