{@inheritDoc}

@see org.jboss.shrinkwrap.descriptor.spi.node.NodeImporter#importAsNode(java.io.InputStream, boolean)
186356
@Override
    public Node importAsNode(final InputStream stream, final boolean close) throws DescriptorImportException {
        try {
            // Empty contents? If so, no root Node
            if (stream.available() == 0) {
                return null;
            }

            final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            final DocumentBuilder builder = factory.newDocumentBuilder();
            final Document doc = builder.parse(stream);

            final Element element = doc.getDocumentElement();

            final Node root = new Node(element.getNodeName());

            readRecursive(root, element);
            return root;

        } catch (final Exception e) {
            throw new DescriptorImportException("Could not import XML from stream", e);
        } finally {
            if (close) {
                try {
                    stream.close();
                } catch (final IOException ioe) {
                    try {
                        stream.close();
                    } catch (final IOException i) {
                        log.log(Level.WARNING, "Unclosable stream specified to be closed: {0}", stream);
                    }
                }
            }
        }
    }
1291633
@Override
    public I importFrom(final File file, Filter<ArchivePath> filter) throws ArchiveImportException {
        Validate.notNull(file, "File must be specified");
        if (!file.exists()) {
            throw new IllegalArgumentException("Specified file for import does not exist: " + file);
        }
        if (file.isDirectory()) {
            throw new IllegalArgumentException("Specified file for import is a directory: " + file);
        }

        final S archive;
        try {
            archive = this.getInputStreamForFile(file);
        } catch (final IOException e) {
            throw new ArchiveImportException("Could not read archive file " + file, e);
        }

        return this.importFrom(archive, filter);

    }
694408
@Override
   public void writeImport(Definition def, Writer out) throws IOException
   {
      out.write("package " + def.getRaPackage() + ";");

      writeEol(out);
      writeEol(out);
      importLogging(def, out);
      out.write("import javax.naming.NamingException;\n");
      out.write("import javax.naming.Reference;\n\n");
      out.write("import javax.resource.ResourceException;\n");
      out.write("import javax.resource.spi.ConnectionManager;\n\n");
   }
445882
protected void importXMLBuilderImpl(BaseXMLBuilder builder) {
        assertElementContainsNoOrWhitespaceOnlyTextNodes(this.xmlNode);
        Node importedNode = getDocument().importNode(
            builder.getDocument().getDocumentElement(), true);
        this.xmlNode.appendChild(importedNode);
    }
1096299
function xmlImportNode(doc, node) {
  if (node.nodeType == DOM_TEXT_NODE) {
    return domCreateTextNode(doc, node.nodeValue);

  } else if (node.nodeType == DOM_CDATA_SECTION_NODE) {
    return domCreateCDATASection(doc, node.nodeValue);

  } else if (node.nodeType == DOM_ELEMENT_NODE) {
    var newNode = domCreateElement(doc, node.nodeName);
    for (var i = 0; i < node.attributes.length; ++i) {
      var an = node.attributes[i];
      var name = an.nodeName;
      var value = an.nodeValue;
      domSetAttribute(newNode, name, value);
    }

    for (var c = node.firstChild; c; c = c.nextSibling) {
      var cn = arguments.callee(doc, c);
      domAppendChild(newNode, cn);
    }

    return newNode;

  } else {
    return domCreateComment(doc, node.nodeName);
  }
}
236722
@Override
	public boolean add(int o) {
		// Shortcut for empty
		int mySize=size();
		if(mySize==0) {
			super.add(o);
		} else {
			// Shortcut for adding to end (makes imports of already-sorted data operate at constant-time instead of logarithmic complexity)
			if(o>=elementData[mySize-1]) {
				super.add(o);
			} else {
				int index=binarySearch(o);
				if(index<0) {
					// Not found in list
					super.add(-(index+1), o);
				} else {
					// Add after existing
					super.add(index+1, o);
				}
			}
		}

		return true;
	}
406386
@Override
  public boolean visit(final ClassNode<?> node) {

    this.graphStr
        .append("  ")
        .append(node.getName())
        .append(" [label=\"")
        .append(node.getName())
        .append("\", shape=box")
//            .append(config.isSingleton(node) ? ", style=filled" : "")
        .append("];\n");

    final ClassNode<?> boundImplNode = config.getBoundImplementation(node);
    if (boundImplNode != null) {
      this.graphStr
          .append("  ")
          .append(node.getName())
          .append(" -> ")
          .append(boundImplNode.getName())
          .append(" [style=solid, dir=back, arrowtail=normal];\n");
    }

    for (final Object implNodeObj : node.getKnownImplementations()) {
      final ClassNode<?> implNode = (ClassNode<?>) implNodeObj;
      if (implNode != boundImplNode && implNode != node
          && (implNode.isExternalConstructor() || this.showImpl)) {
        this.graphStr
            .append("  ")
            .append(node.getName())
            .append(" -> ")
            .append(implNode.getName())
            .append(" [style=\"dashed")
            .append(implNode.isExternalConstructor() ? ",bold" : "")
            .append("\", dir=back, arrowtail=empty];\n");
      }
    }

    return true;
  }
342003
@Override
   public void startElement(String namespaceURI, String localName, String name, Map<String, String> atts)
      throws RepositoryException
   {
      InternalQName elementName = locationFactory.parseJCRName(name).getInternalName();

      if (Constants.SV_NODE_NAME.equals(elementName))
      {
         // sv:node element

         // node name (value of sv:name attribute)
         String svName = getAttribute(atts, Constants.SV_NAME_NAME);
         if (svName == null)
         {
            throw new RepositoryException("Missing mandatory sv:name attribute of element sv:node");
         }
         String svId = getAttribute(atts, Constants.EXO_ID_NAME);
         if (svId == null)
         {
            throw new RepositoryException("Missing mandatory exo:id attribute of element sv:node");
         }

         ImportNodeData newNodeData;
         InternalQName currentNodeName;
         int nodeIndex = 1;
         NodeData parentData = getParent();
         if (!isFirstElementChecked)
         {
            if (!ROOT_NODE_NAME.equals(svName))
            {
               throw new RepositoryException("The first element must be root. But found '" + svName + "'");
            }

            isFirstElementChecked = true;
         }

         if (ROOT_NODE_NAME.equals(svName))
         {
            // remove the wrong root from the stack
            tree.pop();

            newNodeData = addChangesForRootNodeInitialization(parentData);
         }
         else
         {
            currentNodeName = locationFactory.parseJCRName(svName).getInternalName();
            nodeIndex = getNodeIndex(parentData, currentNodeName, null);
            newNodeData = new ImportNodeData(parentData, currentNodeName, nodeIndex);
            newNodeData.setOrderNumber(getNextChildOrderNum(parentData));
            newNodeData.setIdentifier(svId);
            changesLog.add(new ItemState(newNodeData, ItemState.ADDED, true, parentData.getQPath()));
         }
         tree.push(newNodeData);

         mapNodePropertiesInfo.put(newNodeData.getIdentifier(), new NodePropertiesInfo(newNodeData));
      }
      else
      {
         super.startElement(namespaceURI, localName, name, atts);
         if (Constants.SV_PROPERTY_NAME.equals(elementName))
         {
            String svId = getAttribute(atts, Constants.EXO_ID_NAME);
            if (svId == null)
            {
               throw new RepositoryException("Missing mandatory exo:id attribute of element sv:property");
            }
            propertyInfo.setIndentifer(svId);
         }
      }
   }
114577
@Override
    public I importFrom(final File file) throws ArchiveImportException {
        return importFrom(file, Filters.includeAll());
    }
71023
public static <T extends Descriptor> DescriptorImporter<T> importAs(final Class<T> type)
        throws IllegalArgumentException {
        return importAs(type, null);
    }
415096
private void init(InputStream inputStream) {
        this.inputStream = inputStream;
        currentPath = new LinkedList<Node>();
        nodeQueue = new LinkedList<XmlNode>();
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty("javax.xml.stream.isCoalescing", true);
        factory.setProperty("javax.xml.stream.isReplacingEntityReferences", true);
        try {
            reader = factory.createXMLStreamReader(inputStream);
        } catch (XMLStreamException e) {
            throw new XmlReaderException(e);
        }
    }
27001
protected AstNode add(boolean required) throws ScanException, ParseException {
		AstNode v = mul(required);
		if (v == null) {
			return null;
		}
		while (true) {
			switch (token.getSymbol()) {
				case PLUS:
					consumeToken();
					v = createAstBinary(v, mul(true), AstBinary.ADD);
					break;
				case MINUS:
					consumeToken();
					v = createAstBinary(v, mul(true), AstBinary.SUB);
					break;
				case EXTENSION:
					if (getExtensionHandler(token).getExtensionPoint() == ExtensionPoint.ADD) {
						v = getExtensionHandler(consumeToken()).createAstNode(v, mul(true));
						break;
					}
				default:
					return v;
			}
		}
	}
1266266
@Override
    public void to(final NodeDescriptor descriptor, final OutputStream output) throws DescriptorExportException,
        IllegalArgumentException {
        // Precondition checks
        if (descriptor == null) {
            throw new IllegalArgumentException("descriptor must be specified");
        }
        if (output == null) {
            throw new IllegalArgumentException("stream must be specified");
        }

        // Get the root node
        final Node root = descriptor.getRootNode();

        // Delegate
        this.to(root, output);
    }
1348513
function (path, currentFileInfo, importOptions, callback) {
            var parserImports = this;
            this.queue.push(path);

            var fileParsedFunc = function (e, root, fullPath) {
                parserImports.queue.splice(parserImports.queue.indexOf(path), 1); // Remove the path from the queue

                var importedPreviously = fullPath in parserImports.files || fullPath === rootFilename;

                parserImports.files[fullPath] = root;                        // Store the root

                if (e && !parserImports.error) { parserImports.error = e; }

                callback(e, root, importedPreviously, fullPath);
            };

            if (less.Parser.importer) {
                less.Parser.importer(path, currentFileInfo, fileParsedFunc, env);
            } else {
                less.Parser.fileLoader(path, currentFileInfo, function(e, contents, fullPath, newFileInfo) {
                    if (e) {fileParsedFunc(e); return;}

                    var newEnv = new tree.parseEnv(env);

                    newEnv.currentFileInfo = newFileInfo;
                    newEnv.processImports = false;
                    newEnv.contents[fullPath] = contents;

                    if (currentFileInfo.reference || importOptions.reference) {
                        newFileInfo.reference = true;
                    }

                    if (importOptions.inline) {
                        fileParsedFunc(null, contents, fullPath);
                    } else {
                        new(less.Parser)(newEnv).parse(contents, function (e, root) {
                            fileParsedFunc(e, root, fullPath);
                        });
                    }
                }, env);
            }
        }
328048
function(nodePath) {
            const node = nodePath.value;
            imports[node.source.value] = true;
            return false;
        }
125658
public static boolean convertDOMtoMap(Node nodeXML, Map<String,Object> map, boolean bProcessChildren)
    {
        NodeList nodeList = nodeXML.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++)
        {
            Node node = nodeList.item(i);
            String strKey = node.getNodeName();
            short sNodeType = node.getNodeType();
            if (sNodeType == Node.ELEMENT_NODE)
            {
                String strValue = Constant.BLANK;
                if (node.getChildNodes() == null)
                    strValue = null;
                else if (node.getChildNodes().getLength() == 0)
                    strValue = null;
                else if ((node.getChildNodes().getLength() == 1) && (node.getChildNodes().item(0).getNodeType() == Node.TEXT_NODE))
                    strValue =  node.getChildNodes().item(0).getNodeValue();
                else if (bProcessChildren)
                	MapMessage.convertDOMtoMap(node, map, bProcessChildren);
                if ((strValue != Constant.BLANK) && (strValue != null))
                    map.put(strKey, strValue);
                //?else
                //?    Util.getLogger().warning("--------Error - Create Non-text map node? ------");
            }
            else // if (sNodeType == Node.TEXT_NODE)
            {
                // ???
            }
        }
        return true;    // Success
    }
735671
public final void importDeclaration() throws RecognitionException {
		int importDeclaration_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 3) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:281:5: ( 'import' ( 'static' )? Identifier ( '.' Identifier )* ( '.' '*' )? ';' )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:281:7: 'import' ( 'static' )? Identifier ( '.' Identifier )* ( '.' '*' )? ';'
			{
			match(input,89,FOLLOW_89_in_importDeclaration153); if (state.failed) return;
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:281:16: ( 'static' )?
			int alt5=2;
			int LA5_0 = input.LA(1);
			if ( (LA5_0==106) ) {
				alt5=1;
			}
			switch (alt5) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:281:16: 'static'
					{
					match(input,106,FOLLOW_106_in_importDeclaration155); if (state.failed) return;
					}
					break;

			}

			match(input,Identifier,FOLLOW_Identifier_in_importDeclaration158); if (state.failed) return;
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:281:37: ( '.' Identifier )*
			loop6:
			while (true) {
				int alt6=2;
				int LA6_0 = input.LA(1);
				if ( (LA6_0==47) ) {
					int LA6_1 = input.LA(2);
					if ( (LA6_1==Identifier) ) {
						alt6=1;
					}

				}

				switch (alt6) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:281:38: '.' Identifier
					{
					match(input,47,FOLLOW_47_in_importDeclaration161); if (state.failed) return;
					match(input,Identifier,FOLLOW_Identifier_in_importDeclaration163); if (state.failed) return;
					}
					break;

				default :
					break loop6;
				}
			}

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:281:55: ( '.' '*' )?
			int alt7=2;
			int LA7_0 = input.LA(1);
			if ( (LA7_0==47) ) {
				alt7=1;
			}
			switch (alt7) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:281:56: '.' '*'
					{
					match(input,47,FOLLOW_47_in_importDeclaration168); if (state.failed) return;
					match(input,38,FOLLOW_38_in_importDeclaration170); if (state.failed) return;
					}
					break;

			}

			match(input,52,FOLLOW_52_in_importDeclaration174); if (state.failed) return;
			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 3, importDeclaration_StartIndex); }

		}
	}