parse the configuration file

@param currentNode current analysed node
17180
private final void parseDocument(Node currentNode) {
	    	try {
	    		mutex.acquire();
	        String nodeName = currentNode.getNodeName();
	
	        if ((currentNode.getNodeType() == Node.ELEMENT_NODE)
	                && (nodeName.equals("type"))
	        ) {
	            String typeName = ((Element) currentNode).getAttribute("name");
	            mapFilter.put(
	                typeName + ".filter",
	                new ArrayList()
	            );
	            mapFilter.put(
	                typeName + ".tag",
	                new ArrayList()
	            );
	            mapFilter.put(
	                typeName + ".merge",
	                new ArrayList()
	            );
	        }
	
	        if ((currentNode.getNodeType() == Node.ELEMENT_NODE)
	                && (currentNode.getParentNode() != null)
	        ) {
	            if (nodeName.equals("filter")) {
	                String typeName =
	                    ((Element) currentNode.getParentNode()
	                                          .getParentNode()).getAttribute(
	                        "name"
	                    );
	                ArrayList vMapFilter =
	                    (ArrayList) mapFilter.get(typeName + ".filter");
	                ArrayList vFilter = new ArrayList();
	                int iOrder =
	                    ((Element) currentNode).getAttribute("order")
	                     .equals("")
	                    ? vMapFilter.size()
	                    : Integer.parseInt(
	                        ((Element) currentNode).getAttribute("order")
	                    );
	                String replacement = "";
	                NodeList nl = currentNode.getChildNodes();
	
	                for (int i = 0; i < nl.getLength(); i++) {
	                    Node childNode = nl.item(i);
	
	                    if (childNode.getNodeName()
	                                     .equals("replacement")) {
	                        NodeList nl2 = childNode.getChildNodes();
	
	                        for (int j = 0; j < nl2.getLength(); j++) {
	                            Node child = nl2.item(j);
	
	                            if (child.getNodeType() == Node.TEXT_NODE) {
	                                replacement =
	                                    replacement + child.getNodeValue();
	                            }
	                        }
	                    } else if (childNode.getNodeName()
	                                            .equals("match")) {
	                        String match = "";
	                        NodeList nl2 = childNode.getChildNodes();
	
	                        for (int j = 0; j < nl2.getLength(); j++) {
	                            Node child = nl2.item(j);
	
	                            if (child.getNodeType() == Node.TEXT_NODE) {
	                                match = match + child.getNodeValue();
	                            }
	                        }
	
	                        Pattern p = null;
	
	                        try {
	                            p = Pattern.compile(
	                                    match,
	                                    Pattern.MULTILINE | Pattern.DOTALL
	                                );
	                            vFilter.add(p);
	                        } catch (Exception ignore) {
	                        }
	                    }
	                }
	
	                vMapFilter.add(
	                    iOrder,
	                    new Object[] {
	                        replacement,
	                        vFilter
	                    }
	                );
	            } else if ((nodeName.equals("tag"))
	                    && (
	                        currentNode.getParentNode().getNodeName().equals(
	                            "tags"
	                        )
	                    )
	            ) {
	                String typeName =
	                    ((Element) currentNode.getParentNode()
	                                          .getParentNode()
	                                          .getParentNode()).getAttribute(
	                        "name"
	                    );
	                String tagName = ((Element) currentNode).getAttribute("name");
	                ArrayList vMapTags =
	                    (ArrayList) mapFilter.get(typeName + ".tag");
	                ArrayList vAttributes = new ArrayList();
	                NodeList nl = currentNode.getChildNodes();
	
	                for (int i = 0; i < nl.getLength(); i++) {
	                    Node childNode = nl.item(i);
	
	                    if (childNode.getNodeName()
	                                     .equals("attribute")) {
	                        vAttributes.add(
	                            (String) ((Element) childNode).getAttribute("name")
	                        );
	                    }
	                }
	
	                vMapTags.add(new Object[] {
	                        tagName,
	                        vAttributes
	                    }
	                );
	            } else if (nodeName.equals("source_attribute")) {
	                String typeName =
	                    ((Element) currentNode.getParentNode()
	                                          .getParentNode()
	                                          .getParentNode()
	                                          .getParentNode()).getAttribute(
	                        "name"
	                    );
	                String tagName =
	                    ((Element) currentNode.getParentNode()).getAttribute(
	                        "name"
	                    );
	                String attribName =
	                    ((Element) currentNode).getAttribute("name");
	                String srcAttribNameInDest =
	                    ((Element) currentNode).getAttribute("name_in_destination");
	                ArrayList vMapMerge =
	                    (ArrayList) mapFilter.get(typeName + ".merge");
	                String separator = null;
	                String destAttribName = null;
	                ArrayList match = new ArrayList();
	                ArrayList value = new ArrayList();
	                NodeList nl = currentNode.getChildNodes();
	
	                for (int i = 0; i < nl.getLength(); i++) {
	                    Node childNode = nl.item(i);
	
	                    if (childNode.getNodeName()
	                                     .equals("destination_attribute")) {
	                        destAttribName =
	                            ((Element) childNode).getAttribute("name");
	                    } else if (childNode.getNodeName()
	                                            .equals("separator")) {
	                        separator = ((Element) childNode).getAttribute("value");
	                    } else if (childNode.getNodeName()
	                                            .equals("replace")) {
	                        match.add(((Element) childNode).getAttribute("match"));
	                        value.add(((Element) childNode).getAttribute("value"));
	                    }
	                }
	
	                vMapMerge.add(
	                    new Object[] {
	                        tagName,
	                        attribName,
	                        srcAttribNameInDest,
	                        destAttribName,
	                        separator,
	                        match,
	                        value
	                    }
	                );
	            }
	        }
	
	        NodeList nl = currentNode.getChildNodes();
	
	        for (int i = 0; i < nl.getLength(); i++) {
	            parseDocument(nl.item(i));
	        }
	    	}
	    	finally {
	    		try{mutex.release();}catch(Throwable ignore){}
	    	}
    }
660462
private static HashMap<String, HashMap<String, String>> readConfigurations(
      ResourceLoader resourceLoader, String configFile, String className)
      throws IOException {
    HashMap<String, HashMap<String, String>> configs = null;
    InputStream reader = resourceLoader.openResource(configFile);
    // parse xml
    XMLInputFactory factory = XMLInputFactory.newInstance();
    try {
      XMLStreamReader streamReader = factory.createXMLStreamReader(reader);
      String currentElement = null;
      ArrayList<String> currentElements = new ArrayList<String>();
      QName qname;
      boolean skipCurrentConfigurations = false;
      try {
        int event = streamReader.getEventType();
        while (true) {
          switch (event) {
          case XMLStreamConstants.START_DOCUMENT:
            if (!streamReader.getCharacterEncodingScheme().equals("UTF-8")) {
              throw new IOException("XML not UTF-8 encoded");
            }
            break;
          case XMLStreamConstants.END_DOCUMENT:
            break;
          case XMLStreamConstants.SPACE:
            break;
          case XMLStreamConstants.START_ELEMENT:
            // get data
            qname = streamReader.getName();
            if (configs == null) {
              if (qname.getLocalPart().equals(CONFIGURATIONS_MTAS)) {
                configs = new HashMap<String, HashMap<String, String>>();
              } else {
                throw new IOException("no Mtas Configurations File");
              }
            } else if (currentElement != null
                && currentElement.equals(CONFIGURATIONS_MTAS)) {
              if (qname.getLocalPart().equals(CONFIGURATIONS_CONFIGURATIONS)) {
                skipCurrentConfigurations = true;
                if (className != null) {
                  for (int i = 0; i < streamReader.getAttributeCount(); i++) {
                    if (streamReader.getAttributeLocalName(i).equals("type")) {
                      if (streamReader.getAttributeValue(i).equals(className)) {
                        skipCurrentConfigurations = false;
                      }
                    }
                  }
                }
              } else {
                throw new IOException("unexpected " + qname.getLocalPart());
              }
            } else if (currentElement != null
                && currentElement.equals(CONFIGURATIONS_CONFIGURATIONS)
                && !skipCurrentConfigurations) {
              if (qname.getLocalPart().equals(CONFIGURATIONS_CONFIGURATION)) {
                String configurationName = null;
                HashMap<String, String> configurationValues = new HashMap<String, String>();
                for (int i = 0; i < streamReader.getAttributeCount(); i++) {
                  if (streamReader.getAttributeLocalName(i)
                      .equals(CONFIGURATIONS_CONFIGURATION_NAME)) {
                    configurationName = streamReader.getAttributeValue(i);
                  } else {
                    configurationValues.put(
                        streamReader.getAttributeLocalName(i),
                        streamReader.getAttributeValue(i));
                  }
                }
                if (configurationName != null) {
                  configs.put(configurationName, configurationValues);
                } else {
                  throw new IOException("configuration without "
                      + CONFIGURATIONS_CONFIGURATION_NAME);
                }
              } else {
                throw new IOException("unexpected tag " + qname.getLocalPart());
              }
            }
            currentElement = qname.getLocalPart();
            currentElements.add(currentElement);
            break;
          case XMLStreamConstants.END_ELEMENT:
            if (currentElement != null
                && currentElement.equals(CONFIGURATIONS_CONFIGURATIONS)) {
              skipCurrentConfigurations = false;
            }
            int i = currentElements.size();
            currentElements.remove((i - 1));
            if (i > 1) {
              currentElement = currentElements.get(i - 2);
            } else {
              currentElement = null;
            }
            break;
          case XMLStreamConstants.CHARACTERS:
            break;
          }
          if (!streamReader.hasNext()) {
            break;
          }
          event = streamReader.next();
        }
      } finally {
        streamReader.close();
      }
    } catch (XMLStreamException e) {
      log.debug(e);
    }
    return configs;
  }
937303
private void parseDebugConfig(final Node node, final ConfigSettings config)
	{

		String name;
		Boolean value;
		Node nnode;
		NodeList list = node.getChildNodes();

		int length = list.getLength();
		for (int i = 0; i < length; i++) {
			nnode = list.item(i);

			name = nnode.getNodeName().toUpperCase();
			if (name.equals(KEY_VERIFICATION_DIFF)) {

				value = Boolean.parseBoolean(nnode.getChildNodes().item(0)
						.getNodeValue());
				config.setConfigParameter(ConfigurationKeys.VERIFICATION_DIFF,
						value);

			}
			else if (name.equals(KEY_VERIFICATION_ENCODING)) {

				value = Boolean.parseBoolean(nnode.getChildNodes().item(0)
						.getNodeValue());

				config.setConfigParameter(
						ConfigurationKeys.VERIFICATION_ENCODING, value);

			}
			else if (name.equals(KEY_STATISTICAL_OUTPUT)) {

				value = Boolean.parseBoolean(nnode.getChildNodes().item(0)
						.getNodeValue());
				config.setConfigParameter(
						ConfigurationKeys.MODE_STATISTICAL_OUTPUT, value);

			}
			else if (name.equals(SUBSECTION_DEBUG_OUTPUT)) {

				parseDebugOutputConfig(nnode, config);
			}
		}
	}
1065400
private void parseCacheConfig(final Node node, final ConfigSettings config)
	{

		String name;
		Long lValue;
		Node nnode;
		NodeList list = node.getChildNodes();

		int length = list.getLength();
		for (int i = 0; i < length; i++) {
			nnode = list.item(i);

			name = nnode.getNodeName().toUpperCase();
			if (name.equals(KEY_LIMIT_TASK_SIZE_REVISIONS)) {

				lValue = Long.parseLong(nnode.getChildNodes().item(0)
						.getNodeValue());
				config.setConfigParameter(
						ConfigurationKeys.LIMIT_TASK_SIZE_REVISIONS, lValue);

			}
			else if (name.equals(KEY_LIMIT_TASK_SIZE_DIFFS)) {

				lValue = Long.parseLong(nnode.getChildNodes().item(0)
						.getNodeValue());
				config.setConfigParameter(
						ConfigurationKeys.LIMIT_TASK_SIZE_DIFFS, lValue);

			}
			else if (name.equals(KEY_LIMIT_SQLSERVER_MAX_ALLOWED_PACKET)) {

				lValue = Long.parseLong(nnode.getChildNodes().item(0)
						.getNodeValue());
				config.setConfigParameter(
						ConfigurationKeys.LIMIT_SQLSERVER_MAX_ALLOWED_PACKET,
						lValue);

			}
		}
	}
501160
public GatewayConfigDocument parse(final File configFile) throws Exception {
        long time = 0;
        if (LOGGER.isDebugEnabled()) {
            time = System.currentTimeMillis();
        }

        // For errors and logging (KG-1379) we need to report the real config file name,
        // which is not always 'gateway-config.xml'.
        String configFileName = configFile.getName();

        // Validate the gateway-config
        GatewayConfigDocument config = null;
        XmlOptions parseOptions = new XmlOptions();
        parseOptions.setLoadLineNumbers();
        parseOptions.setLoadLineNumbers(XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT);
        parseOptions.setLoadStripWhitespace();
        parseOptions.setLoadStripComments();

        File translatedConfigFile;
        try {
            translatedConfigFile = getTranslatedConfigFile(configFile);
        } catch (Exception e) {
            Throwable rootCause = getRootCause(e);
            if (rootCause == null) {
                rootCause = e;
            }

            if (LOGGER.isDebugEnabled()) {
                LOGGER.error("Error upgrading XML: " + rootCause, rootCause);

            } else {
                LOGGER.error("Error upgrading XML: " + rootCause);
            }

            // If it's not an IllegalArgumentException, wrap it in a
            // GatewayConfigParserException
            if (e instanceof IllegalArgumentException) {
                throw e;

            } else {
                throw new GatewayConfigParserException(e.getMessage());
            }
        }

        List<String> xmlParseErrors = new ArrayList<>();
        try {
            config = GatewayConfigDocument.Factory.parse(new FileInputStream(translatedConfigFile), parseOptions);

        } catch (Exception e) {
            // track the parse error so that we don't make the 2nd pass through the file
            xmlParseErrors.add("Invalid XML: " + getRootCause(e).getMessage());
        }

        if (xmlParseErrors.isEmpty()) {
            // The properties used in parameter substitution are now proper XMLBeans
            // and should be injected after an initial parse
            GatewayConfigDocument.GatewayConfig gatewayConfig = config.getGatewayConfig();
            PropertiesType properties = gatewayConfig.getProperties();
            Map<String, String> propertiesMap = new HashMap<>();
            if (properties != null) {
                for (PropertyType propertyType : properties.getPropertyArray()) {
                    propertiesMap.put(propertyType.getName(), propertyType.getValue());
                }
            }

            // make a second pass through the file now, injecting the properties and performing XSL translations
            InputStream xmlInjectedIn = new PipedInputStream();
            OutputStream xmlInjectedOut = new PipedOutputStream((PipedInputStream) xmlInjectedIn);
            ExecutorService xmlInjectedExecutor = Executors.newSingleThreadExecutor();
            Future<Boolean> xmlInjectedFuture = xmlInjectedExecutor.submit(new XMLParameterInjector(new FileInputStream(
                    translatedConfigFile), xmlInjectedOut, propertiesMap, configuration, xmlParseErrors));

            // trace injected xml
            if (LOGGER.isTraceEnabled()) {
                xmlInjectedIn = bufferToTraceLog(xmlInjectedIn,
                        "Gateway config file '" + configFileName + "' post parameter injection", LOGGER);
            }

            // Pass gateway-config through the pre-parse transformer
            InputStream xmlTransformedIn = new PipedInputStream();
            OutputStream xmlTransformedOut = new PipedOutputStream((PipedInputStream) xmlTransformedIn);
            ExecutorService xmlTransformedExecutor = Executors.newSingleThreadExecutor();
            Future<Boolean> xmlTransformedFuture = xmlTransformedExecutor.submit(
                    new XSLTransformer(xmlInjectedIn, xmlTransformedOut, GATEWAY_CONFIG_ANNOTATE_TYPES_XSL));

            // trace transformed xml
            if (LOGGER.isTraceEnabled()) {
                xmlTransformedIn = bufferToTraceLog(xmlTransformedIn,
                        "Gateway config file '" + configFileName + "' post XSL transformation", LOGGER);
            }

            try {
                config = GatewayConfigDocument.Factory.parse(xmlTransformedIn, parseOptions);
            } catch (Exception e) {
                // If parsing with previous namespace was also unsuccessful,
                // process errors top down, failing fast, for user level errors
               try {
                    if (xmlInjectedFuture.get()) {
                        if (xmlTransformedFuture.get()) {
                            throw e;
                        }
                    }
                } catch (Exception n) {
                    xmlParseErrors.add("Invalid XML: " + getRootCause(n).getMessage());
                }
            } finally {
                xmlInjectedFuture.cancel(true);
                xmlInjectedExecutor.shutdownNow();
                xmlTransformedFuture.cancel(true);
                xmlTransformedExecutor.shutdownNow();
            }
        }

        validateGatewayConfig(config, xmlParseErrors);

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("parsed " + " gateway config file '" + configFileName + "' in [" + (System.currentTimeMillis() - time) +
                    " ms]");
        }

        return config;
    }
31470
protected void parseConfigurationGroup(I_CmsXmlContentLocation location) {

        List<I_CmsXmlContentValueLocation> locations = location.getSubValues(N_CONFIGURATION);
        m_currentConfigurationGroup = new HashMap<String, CmsContainerConfiguration>();
        m_results.put(m_currentLocale, m_currentConfigurationGroup);
        for (I_CmsXmlContentValueLocation configLocation : locations) {
            parseSingleConfiguration(configLocation);
        }
    }
388396
public NodeConfig parser(InputStreamReader xml) throws UnmarshalException {

		NodeConfig config = new NodeConfig();
		SAXBuilder builder = new SAXBuilder(false);
		Document doc = null;

		try {
			doc = builder.build(xml);
			config = parserNode(doc.getRootElement());

			xml.close();
			return config;
		} catch (JDOMException e) {
			throw new UnmarshalException(e);
		} catch (IOException e) {
			throw new UnmarshalException(e);
		}
	}
145346
@SuppressWarnings("rawtypes")
	public NodeConfig parse(String nodeName, List list) throws MarshalException {
		NodeConfig nodeConfig = new NodeConfig();
		List<NodeConfig> nodeConfigList = new ArrayList<NodeConfig>();

		if (list != null) {
			for (Object item : list) {
				nodeConfigList.add(super.parse(nodeName, item));
			}
		}
		nodeConfig.setName(nodeName);
		nodeConfig.setChildrenNodes(nodeConfigList);
		return nodeConfig;
	}
291541
def parse_structure(self, node):
        

        self.current_structure = self.current_component_type.structure
        self.process_nested_tags(node)
        self.current_structure = None
937585
def _parse_nodes_section(f, current_section, nodes):
    
    section = {}
    dimensions = None

    if current_section == 'NODE_COORD_SECTION':
        dimensions = 3 # i: (i, j)
    elif current_section == 'DEMAND_SECTION':
        dimensions = 2 # i: q
    else:
        raise ParseException('Invalid section {}'.format(current_section))

    n = 0
    for line in f:
        line = strip(line)

        # Check dimensions
        definitions = re.split(r'\s*', line)
        if len(definitions) != dimensions:
            raise ParseException('Invalid dimensions from section {}. Expected: {}'.format(current_section, dimensions))

        node = int(definitions[0])
        values = [int(v) for v in definitions[1:]]

        if len(values) == 1:
            values = values[0]

        section[node] = values

        n = n + 1
        if n == nodes:
            break

    # Assert all nodes were read
    if n != nodes:
        raise ParseException('Missing {} nodes definition from section {}'.format(nodes - n, current_section))

    return section
229874
public synchronized Node parse(InputStream in) throws IOException, SAXException {
        //_dtd=null;
        Handler handler = new Handler();
        XMLReader reader = _parser.getXMLReader();
        reader.setContentHandler(handler);
        reader.setErrorHandler(handler);
        reader.setEntityResolver(handler);
        _parser.parse(new InputSource(in), handler);
        if (handler.error != null)
            throw handler.error;
        Node root = (Node)handler.root;
        handler.reset();
        return root;
    }
1068757
public static Config parse(InputStream in) throws XmlPullParserException, IOException {
        try {
            XmlPullParser parser = Xml.newPullParser();
            parser.setInput(in, null);
            parser.nextTag();
            return readFamilies(parser);
        } finally {
            in.close();
        }
    }
582169
private function mergeConfigurationOption(&$currentNode, $name, $value)
    {
        if (empty($currentNode) || empty($name)) {
            return;
        }

        //We're going to be building our own objects here
        if (is_object($value)) {
            $value = (array)$value;
        }

        if (is_array($value)) {
            if ($this->isAssociative($value)) {
                //An associative array can contain non-leaves, recursively merge them in

                $childNode = null;

                if (!empty($currentNode->$name)) {
                    $childNode = $currentNode->$name;
                } else {
                    $childNode = new Parameter($currentNode, $name);
                    $currentNode->$name = $childNode;
                }

                foreach ($value as $subName => $subValue) {
                    $this->mergeConfigurationOption($childNode, $subName, $subValue);
                }
            } else {
                //Simply an array of values, just add them to the node and assume they're leaves

                if (empty($currentNode->$name)) {
                    $currentNode->$name = array();
                }

                if (!is_array($currentNode->$name)) {
                    $currentNode->$name = array();
                }

                foreach ($value as $subValue) {
                    $currentNode->{$name}[] = $subValue;
                }
            }
        } else {
            //Yay, a scalar value
            $currentNode->$name = $value;
        }
    }
547607
private void configure(Object obj, XmlParser.Node cfg, int i) throws ClassNotFoundException,
            NoSuchMethodException, InvocationTargetException, IllegalAccessException
    {
        XmlParser.Node node = null;
        try
        {
            for (; i < cfg.size(); i++)
            {
                Object o = cfg.get(i);
                if (o instanceof String) continue;
                node = (XmlParser.Node) o;

                String tag = node.getTag();
                if ("Set".equals(tag))
                    set(obj, node);
                else if ("Put".equals(tag))
                    put(obj, node);
                else if ("Call".equals(tag))
                    call(obj, node);
                else if ("Get".equals(tag))
                    get(obj, node);
                else if ("New".equals(tag))
                    newObj(obj, node);
                else if ("Ref".equals(tag))
                    refObj(obj, node);
                else
                    throw new IllegalStateException("Unknown tag: " + tag);
            }
        }
        catch(InvocationTargetException e)
        {
            log.warn("Exception at "+node.toString(),e.getTargetException());
            throw e;
        }
        catch (Error e)
        {
            log.debug(node);
            throw e;
        }
        catch (Exception e)
        {
            log.debug(node);
            if (e instanceof NoSuchMethodException) throw (NoSuchMethodException) e;
            if (e instanceof InvocationTargetException) throw (InvocationTargetException) e;
            if (e instanceof IllegalAccessException) throw (IllegalAccessException) e;
            if (e instanceof RuntimeException) throw (RuntimeException) e;
        }
    }
1219141
public void readConfiguration(InputStream inputStream) throws TracerFactory.Exception {
    if (this.traceConfigSchema == null)
      System.err.println("CAUTION: Unable to validate the given configuration against a schema.");

    DocumentBuilderFactory builderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
    builderFactory.setNamespaceAware(true);
    builderFactory.setXIncludeAware(false);

    try {
      DocumentBuilder parser = builderFactory.newDocumentBuilder();
      Document tracerConfigDoc = parser.parse(inputStream);

      if (this.traceConfigSchema != null) {
        DOMSource domSource = new DOMSource(tracerConfigDoc);
        Validator traceConfigValidator = this.traceConfigSchema.newValidator();
        TracerFactory.ErrorHandler errorHandler = new TracerFactory.ErrorHandler();
        traceConfigValidator.setErrorHandler(errorHandler);
        traceConfigValidator.validate(domSource);
      }
      
      this.poolWriteLock.lock();
      try {
        NodeList tracerNodes = (NodeList) this.xpath.evaluate("/dns:TraceConfig/dns:Pool/dns:TraceLogger", tracerConfigDoc.getDocumentElement(), XPathConstants.NODESET);
        System.out.println();
        System.out.println("Configured Pool Tracers = " + tracerNodes.getLength());
        for (int i = 0; i < tracerNodes.getLength(); i++) {
          System.out.println();
          System.out.println("(+) " + (i + 1) + ". TraceLogger");
          Element tracerElement = (Element) tracerNodes.item(i);
          if (!tracerElement.hasAttribute("name"))
            throw new TracerFactory.Exception("Missing 'name' attribut.");
          String name = tracerElement.getAttribute("name");
          String className = tracerElement.getAttribute("class");
          System.out.println("name = " + name);
          System.out.println("className = " + className);
          Class<?> tracerClass = Class.forName(className);
          if (!AbstractTracer.class.isAssignableFrom(tracerClass))
            throw new TracerFactory.Exception("Illegal tracer class!");
          AbstractTracer tracer = createTracer((Class<? extends AbstractTracer>) tracerClass, name);
          tracer.readConfiguration(this.xpath, tracerElement);

  //        synchronized (this.mapGuardObj) {
  //          this.tracerPool.put(name, tracer);
  //        }
          this.tracerPool.put(name, tracer);
        }

        NodeList threadNodes = (NodeList) this.xpath.evaluate("/dns:TraceConfig/dns:Map/dns:Threads/dns:Thread", tracerConfigDoc.getDocumentElement(), XPathConstants.NODESET);
        System.out.println();
        System.out.println("Configured Tracermappings = " + threadNodes.getLength());
        for (int i = 0; i < threadNodes.getLength(); i++) {
          System.out.println();
          System.out.println("(+) " + (i + 1) + ". Mapping");
          Element threadElement = (Element) threadNodes.item(i);
          String threadName = threadElement.getAttribute("name");
          String referencedTracerName = (String) this.xpath.evaluate("./dns:TraceLogger/@ref", threadElement, XPathConstants.STRING);
          System.out.println(threadName + " => " + referencedTracerName);
          this.threadName2Element.put(threadName, threadElement);
        }

        Node defaultTracerNode = (Node) this.xpath.evaluate("/dns:TraceConfig/dns:DefaultTracer", tracerConfigDoc.getDocumentElement(), XPathConstants.NODE);
        if (defaultTracerNode != null) {
          String className = ((Element) defaultTracerNode).getAttribute("class");
          Class<?> tracerClass = Class.forName(className);
          if (!NullTracer.class.isAssignableFrom(tracerClass))
            throw new TracerFactory.Exception("Requiring a NullTracer as default tracer!");
          this.defaultTracer = createTracer((Class<? extends NullTracer>) tracerClass);
        }
        else {
          this.defaultTracer = TracerFactory.NULLTRACER;
        }
      }
      finally {
        this.poolWriteLock.unlock();
      }
      
      this.queueWriteLock.lock();
      try {
        Node queueNode = (Node) this.xpath.evaluate("/dns:TraceConfig/dns:Queue", tracerConfigDoc.getDocumentElement(), XPathConstants.NODE);
        if (queueNode != null) {
          this.queueConfig = new Queue(queueNode);
        }
        else {
          this.queueConfig = new Queue();
        }
      }
      finally {
        this.queueWriteLock.unlock();
      }
    }
    catch (IOException | ParserConfigurationException | SAXException | XPathExpressionException | ClassNotFoundException | AbstractTracer.Exception ex) {
      throw new TracerFactory.Exception(ex);
    }
  }
711574
function parse_files(files, options, callback) {
  var nodes = {
    // root section node
    '': {
      id: '',
      type: 'section',
      children: [],
      description: '',
      short_description: '',
      href: '#',
      root: true,
      file: '',
      line: 0
    }
  };

  var reportObject = { };
  
  async.forEachSeries(files, function (file, next_file) {
    var fn = parsers[path.extname(file)];

    if (!fn) {
      next_file();
      return;
    }

    console.info('Parsing file: ' + file);
    fn(file, options, function (err, file_nodes, file_report) {
      // TODO:  fail on name clash here as well -- as we might get name clash
      //        from different parsers, or even different files
      _.extend(nodes, file_nodes);
      _.extend(reportObject, file_report);
      next_file(err);
    });
  }, function (err) {
    callback(err, nodes, reportObject);
  });
}
13377
public void parse() throws NodeFileParserException {
        final ResourceXMLParser resourceXMLParser;
        if(null!=file){
            resourceXMLParser=new ResourceXMLParser(file);
        }else{
            resourceXMLParser = new ResourceXMLParser(input);
        }
        //parse both node and settings
        resourceXMLParser.setReceiver(this);
//        long start = System.currentTimeMillis();
        try {
            resourceXMLParser.parse();
        } catch (ResourceXMLParserException e) {
            throw new NodeFileParserException(e);
        } catch (IOException e) {
            throw new NodeFileParserException(e);
        }
//        System.err.println("parse: " + (System.currentTimeMillis() - start));
    }