/*
////////////////////////////////////////////////
NamespaceContext implementation
////////////////////////////////////////////////
492978
@Override
    public final String getNamespaceURI(String prefix)
    {
        if (prefix.length() == 0) { //default NS
            return mDefaultNsURI;
        }
        if (mNsMapping != null) {
            String uri = mNsMapping.findUriByPrefix(prefix);
            if (uri != null) {
                return uri;
            }
        }
        return (mRootNsContext != null) ?
            mRootNsContext.getNamespaceURI(prefix) : null;
    }
199142
public Collection<? extends NameClassPair> listInstances(NamingConstants.JavaColonNamespace namespace, String contextName) throws NamingException {
        if (namespace == NamingConstants.JavaColonNamespace.COMP) {
            return listInstances(compLock, compBindings, contextName);
        }
        if (namespace == NamingConstants.JavaColonNamespace.COMP_ENV) {
            return listInstances(compLock, compEnvBindings, contextName);
        }
        if (namespace == this.namespace) {
            return listInstances(nonCompEnvLock, nonCompBindings, contextName);
        }
        return Collections.emptyList();
    }
150973
@SuppressWarnings("unchecked")
    void initThreadContext(WSContextService contextSvc, Map<String, String> execProps) {
        threadContext = contextSvc.captureThreadContext(execProps);
    }
518373
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            isEnum = classContext.getJavaClass().isEnum();
            stack = new OpcodeStack();
            uninitializedRegs = new BitSet();
            arrayAliases = new HashMap<>();
            storedUVs = new HashMap<>();
            super.visitClassContext(classContext);
        } finally {
            stack = null;
            uninitializedRegs = null;
            arrayAliases = null;
            storedUVs = null;
        }
    }
1340785
public T namespaces(Map<String, String> namespaceMappings) {
        getXpathVariableExtractor().getNamespaces().putAll(namespaceMappings);

        xmlMessageValidationContext.getNamespaces().putAll(namespaceMappings);
        return self;
    }
839618
protected Context createContext() throws NamingException
   {
      Properties properties = new Properties();
      properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
      properties.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      properties.setProperty(Context.PROVIDER_URL, jndiProtocol + "://" + jndiHost + ":" + jndiPort);
      return new InitialContext(properties);
   }
1103196
public void setContext(Context context) {
        log = Log.instance(context);
        options = Options.instance(context);
        classLoaderClass = options.get("procloader");
        locations.update(log, options, Lint.instance(context), FSInfo.instance(context));
    }
86341
public static NamespaceContext createNamespaceContext() {
    return new NamespaceContext() {
      private HashMap<String, String> namespaces = new HashMap<String, String>(1);

      {
        namespaces.put(DEFAULT_NAMESPACE_PREFIX, DEFAULT_NAMESPACE_URI);
      }

      public String getNamespaceURI(String prefix) {
        if (namespaces.isEmpty() || StringUtil.isNullOrEmpty(prefix) || !namespaces.containsKey(prefix))
          return StringUtil.empty;
        return namespaces.get(prefix);
      }

      public Iterator getPrefixes(String namespaceURI) {
        return namespaces.values().iterator();
      }

      public String getPrefix(String namespaceURI) {
        if (StringUtil.isNullOrEmpty(namespaceURI))
          return StringUtil.empty;

        for(Entry<String, String> entry : namespaces.entrySet())
          if (namespaceURI.equals(entry.getValue()))
            return entry.getKey();

        return StringUtil.empty;
      }
    };
  }
1187808
@Override
    public void outputNamespaceDeclarations(XMLStreamWriter w) throws XMLStreamException
    {
        for (int i = 0, len = mNamespaces.size(); i < len; ++i) {
            Namespace ns = mNamespaces.get(i);
            if (ns.isDefaultNamespaceDeclaration()) {
                w.writeDefaultNamespace(ns.getNamespaceURI());
            } else {
                w.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
            }
        }
    }
1090520
private static void parseNamespacesForElement(
      XmlPullParser parser, XmlNamespaceDictionary namespaceDictionary)
      throws XmlPullParserException {
    int eventType = parser.getEventType();
    Preconditions.checkState(
        eventType == XmlPullParser.START_TAG,
        "expected start of XML element, but got something else (event type %s)",
        eventType);
    int depth = parser.getDepth();
    int nsStart = parser.getNamespaceCount(depth - 1);
    int nsEnd = parser.getNamespaceCount(depth);
    for (int i = nsStart; i < nsEnd; i++) {
      String namespace = parser.getNamespaceUri(i);
      // if namespace isn't already in our dictionary, add it now
      if (namespaceDictionary.getAliasForUri(namespace) == null) {
        String prefix = parser.getNamespacePrefix(i);
        String originalAlias = prefix == null ? "" : prefix;
        // find an available alias
        String alias = originalAlias;
        int suffix = 1;
        while (namespaceDictionary.getUriForAlias(alias) != null) {
          suffix++;
          alias = originalAlias + suffix;
        }
        namespaceDictionary.set(alias, namespace);
      }
    }
  }
23469
public void addNamespaces(Map<String, String> namespaceMap) throws RepositoryException
   {
      if (!started)
      {
         log.warn("Unable save namespaces in to the storage. Storage not initialized");
         return;
      }

      PlainChangesLog changesLog = new PlainChangesLogImpl();
      for (Map.Entry<String, String> entry : namespaceMap.entrySet())
      {
         String prefix = entry.getKey();
         String uri = entry.getValue();

         if (prefix != null)
         {
            if (log.isDebugEnabled())
               log.debug("Namespace " + uri + ":" + prefix);
            internallAdd(changesLog, prefix, uri);
         }
      }
      dataManager.save(new TransactionChangesLog(changesLog));

   }
841899
def undeclared_namespace_bindings(ns_stack, ns_explicit)
      Hash[ns_explicit.map do |prefix,uri|
             [prefix, uri] if !find_namespace_uri(ns_stack, prefix, uri)
           end.compact]
    end
675286
@Override
  protected void initParser() throws MtasConfigException {
    super.initParser();
    if (config != null) {
      // find namespaceURI
      for (int i = 0; i < config.children.size(); i++) {
        MtasConfiguration current = config.children.get(i);
        if (current.name.equals("namespaceURI")) {
          namespaceURI = current.attributes.get("value");
        }
      }
      // loop again
      for (int i = 0; i < config.children.size(); i++) {
        MtasConfiguration current = config.children.get(i);
        if (current.name.equals(XML_VARIABLES)) {
          for (int j = 0; j < current.children.size(); j++) {
            if (current.children.get(j).name.equals(XML_VARIABLE)) {
              MtasConfiguration variable = current.children.get(j);
              String nameVariable = variable.attributes.get(XML_VARIABLE_NAME);
              String valueVariable = variable.attributes
                  .get(XML_VARIABLE_VALUE);
              if ((nameVariable != null) && (valueVariable != null)) {
                MtasParserVariable v = new MtasParserVariable(nameVariable,
                    valueVariable);
                v.processConfig(variable);
                QName qn = getQName(nameVariable);
                if (variableTypes.containsKey(qn)) {
                  variableTypes.get(qn).addItem(v);
                } else {
                  MtasParserType<MtasParserVariable> t = new MtasParserType<>(
                      nameVariable, valueVariable, false);
                  t.addItem(v);
                  variableTypes.put(qn, t);
                }
              }
            }
          }
        } else if (current.name.equals(XML_REFERENCES)) {
          for (int j = 0; j < current.children.size(); j++) {
            if (current.children.get(j).name.equals(XML_REFERENCE)) {
              MtasConfiguration reference = current.children.get(j);
              String name = reference.attributes.get(XML_REFERENCE_NAME);
              String ref = reference.attributes.get(XML_REFERENCE_REF);
              if ((name != null) && (ref != null)) {
                MtasParserType<MtasParserMapping<?>> t = new MtasParserType<>(
                    MAPPING_TYPE_REF, name, false, ref);
                refTypes.put(getQName(t.getName()), t);
              }
            }
          }
        } else if (current.name.equals(XML_MAPPINGS)) {
          for (int j = 0; j < current.children.size(); j++) {
            if (current.children.get(j).name.equals(XML_MAPPING)) {
              MtasConfiguration mapping = current.children.get(j);
              String typeMapping = mapping.attributes.get(XML_MAPPING_TYPE);
              String nameMapping = mapping.attributes.get(XML_MAPPING_NAME);
              if ((typeMapping != null) && (nameMapping != null)) {
                if (typeMapping.equals(MAPPING_TYPE_RELATION)) {
                  MtasXMLParserMappingRelation m = new MtasXMLParserMappingRelation();
                  m.processConfig(mapping);
                  QName qn = getQName(nameMapping);
                  if (relationTypes.containsKey(qn)) {
                    relationTypes.get(qn).addItem(m);
                  } else {
                    MtasParserType<MtasParserMapping<?>> t = new MtasParserType<>(
                        typeMapping, nameMapping, false);
                    t.addItem(m);
                    relationTypes.put(qn, t);
                  }
                } else if (typeMapping
                    .equals(MAPPING_TYPE_RELATION_ANNOTATION)) {
                  MtasXMLParserMappingRelationAnnotation m = new MtasXMLParserMappingRelationAnnotation();
                  m.processConfig(mapping);
                  QName qn = getQName(nameMapping);
                  if (relationAnnotationTypes.containsKey(qn)) {
                    relationAnnotationTypes.get(qn).addItem(m);
                  } else {
                    MtasParserType<MtasParserMapping<?>> t = new MtasParserType<>(
                        typeMapping, nameMapping, false);
                    t.addItem(m);
                    relationAnnotationTypes.put(qn, t);
                  }
                } else if (typeMapping.equals(MAPPING_TYPE_WORD)) {
                  MtasXMLParserMappingWord m = new MtasXMLParserMappingWord();
                  m.processConfig(mapping);
                  QName qn = getQName(nameMapping);
                  if (wordTypes.containsKey(qn)) {
                    wordTypes.get(qn).addItem(m);
                  } else {
                    MtasParserType<MtasParserMapping<?>> t = new MtasParserType<>(
                        typeMapping, nameMapping, false);
                    t.addItem(m);
                    wordTypes.put(qn, t);
                  }
                } else if (typeMapping.equals(MAPPING_TYPE_WORD_ANNOTATION)) {
                  MtasXMLParserMappingWordAnnotation m = new MtasXMLParserMappingWordAnnotation();
                  m.processConfig(mapping);
                  QName qn = getQName(nameMapping);
                  if (wordAnnotationTypes.containsKey(qn)) {
                    wordAnnotationTypes.get(qn).addItem(m);
                  } else {
                    MtasParserType<MtasParserMapping<?>> t = new MtasParserType<>(
                        typeMapping, nameMapping, false);
                    t.addItem(m);
                    wordAnnotationTypes.put(qn, t);
                  }
                } else if (typeMapping.equals(MAPPING_TYPE_GROUP)) {
                  MtasXMLParserMappingGroup m = new MtasXMLParserMappingGroup();
                  m.processConfig(mapping);
                  QName qn = getQName(nameMapping);
                  if (groupTypes.containsKey(qn)) {
                    groupTypes.get(qn).addItem(m);
                  } else {
                    MtasParserType<MtasParserMapping<?>> t = new MtasParserType<>(
                        typeMapping, nameMapping, false);
                    t.addItem(m);
                    groupTypes.put(qn, t);
                  }
                } else if (typeMapping.equals(MAPPING_TYPE_GROUP_ANNOTATION)) {
                  MtasXMLParserMappingGroupAnnotation m = new MtasXMLParserMappingGroupAnnotation();
                  m.processConfig(mapping);
                  QName qn = getQName(nameMapping);
                  if (groupAnnotationTypes.containsKey(qn)) {
                    groupAnnotationTypes.get(qn).addItem(m);
                  } else {
                    MtasParserType<MtasParserMapping<?>> t = new MtasParserType<>(
                        typeMapping, nameMapping, false);
                    t.addItem(m);
                    groupAnnotationTypes.put(qn, t);
                  }
                } else {
                  throw new MtasConfigException(
                      "unknown mapping type " + typeMapping);
                }
              }
            }
          }
        }
      }
    }
  }
819171
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            bloatableCandidates = new HashMap<>();
            bloatableFields = new HashMap<>();
            threadLocalNonStaticFields = new HashSet<>();
            userValues = new HashMap<>();
            jaxbContextRegs = new HashMap<>();
            parseFields(classContext);

            stack = new OpcodeStack();
            super.visitClassContext(classContext);

            reportMemoryBloatBugs();
            reportThreadLocalBugs();

        } finally {
            stack = null;
            bloatableCandidates = null;
            bloatableFields = null;
            userValues = null;
            threadLocalNonStaticFields = null;
            jaxbContextRegs = null;
        }
    }
300585
public void setContext(Context context) {
        context.put(JavacElements.class, this);
        javaCompiler = JavaCompiler.instance(context);
        syms = Symtab.instance(context);
        names = Names.instance(context);
        types = Types.instance(context);
        enter = Enter.instance(context);
    }
660960
public void xmlns(Map<String, String> definition) {
        Assert.notNull(namespaceHandlerResolver, "You cannot define a Spring namespace without a [namespaceHandlerResolver] set");
        if (definition.isEmpty()) {
            return;
        }

        for (Map.Entry<String, String> entry : definition.entrySet()) {
            String namespace = entry.getKey();
            String uri = entry.getValue() == null ? null : entry.getValue();

            Assert.notNull(uri, "Namespace definition cannot supply a null URI");

            final NamespaceHandler namespaceHandler = namespaceHandlerResolver.resolve(uri);
            if (namespaceHandler == null) {
                throw new BeanDefinitionParsingException(
                      new Problem("No namespace handler found for URI: " + uri,
                            new Location(readerContext.getResource())));
            }
            namespaceHandlers.put(namespace, namespaceHandler);
            namespaces.put(namespace, uri);
        }
    }
1319588
@Override
    public void initializeParsers(ExtensionParsingContext context) {
        for (InfinispanSchema namespace: InfinispanSchema.SCHEMAS) {
            context.setSubsystemXmlMapping(SUBSYSTEM_NAME, namespace.getNamespaceUri(), () -> new InfinispanSubsystemXMLReader(namespace));
        }
    }