Example usage for org.eclipse.jdt.internal.compiler.util GenericXMLWriter printTag

List of usage examples for org.eclipse.jdt.internal.compiler.util GenericXMLWriter printTag

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.util GenericXMLWriter printTag.

Prototype

public void printTag(String name, HashMap parameters, boolean insertTab, boolean insertNewLine,
            boolean closeTag) 

Source Link

Usage

From source file:io.sarl.eclipse.util.JavaClasspathParser.java

License:Apache License

@SuppressWarnings({ "checkstyle:innerassignment", "checkstyle:illegaltype" })
private static void decodeUnknownNode(Node node, GenericXMLWriter xmlWriter, boolean insertNewLine) {
    switch (node.getNodeType()) {
    case Node.ELEMENT_NODE:
        final NamedNodeMap attributes;
        HashMap<String, String> parameters = null;
        if ((attributes = node.getAttributes()) != null) {
            final int length = attributes.getLength();
            if (length > 0) {
                parameters = new HashMap<>();
                for (int i = 0; i < length; i++) {
                    final Node attribute = attributes.item(i);
                    parameters.put(attribute.getNodeName(), attribute.getNodeValue());
                }//from   www.ja  v a  2  s  . c  om
            }
        }
        final NodeList children = node.getChildNodes();
        final int childrenLength = children.getLength();
        final String nodeName = node.getNodeName();
        xmlWriter.printTag(nodeName, parameters, false/* don't insert tab */, false/* don't insert new line */,
                childrenLength == 0/* close tag if no children */);
        if (childrenLength > 0) {
            for (int i = 0; i < childrenLength; i++) {
                decodeUnknownNode(children.item(i), xmlWriter, false/* don't insert new line */);
            }
            xmlWriter.endTag(nodeName, false/* don't insert tab */, insertNewLine);
        }
        break;
    case Node.TEXT_NODE:
        final String data = ((Text) node).getData();
        xmlWriter.printString(data, false/* don't insert tab */, false/* don't insert new line */);
        break;
    default:
        break;
    }
}