public ModuleAnalyzer(InputStream in) throws IOException { NodeImporter importer = new XmlDomNodeImporterImpl(); Node node = importer.importAsNode(in, true); String rootName = node.getName(); if (rootName.equals("module")) { this.module = new ModuleDescriptorImpl(null, node); } in.close(); }
public ModuleAnalyzer(InputStream in) throws IOException { NodeImporter importer = new XmlDomNodeImporterImpl(); Node node = importer.importAsNode(in, true); String rootName = node.getName(); if (rootName.equals("module")) { this.module = new ModuleDescriptorImpl(null, node); } in.close(); }
/** * Returns a multiline {@link String} format of this {@link Node} and all children * * @param verbose * @return */ public String toString(final boolean verbose) { if (!verbose) { return this.toString(); } final StringBuilder sb = new StringBuilder(); sb.append("Listing of "); sb.append(Node.class.getSimpleName()); sb.append(" starting at: "); sb.append(this.getName()); sb.append('\n'); this.appendNodeInfo(sb, 0, this); return sb.toString(); }
/** * Returns a multiline {@link String} format of this {@link Node} and all children * * @param verbose * @return */ public String toString(final boolean verbose) { if (!verbose) { return this.toString(); } final StringBuilder sb = new StringBuilder(); sb.append("Listing of "); sb.append(Node.class.getSimpleName()); sb.append(" starting at: "); sb.append(this.getName()); sb.append('\n'); this.appendNodeInfo(sb, 0, this); return sb.toString(); }
private void appendNodeInfo(final StringBuilder builder, final int level, final Node node) { final StringBuilder indent = new StringBuilder(); for (int i = 0; i < level; i++) { indent.append('-'); } builder.append(indent); builder.append('+'); builder.append(SPACE); builder.append(node.getName()); builder.append('('); builder.append(node.attributes); builder.append(')'); final String nodeText = node.getText(); if (nodeText != null) { builder.append(SPACE); builder.append(node.getText()); } builder.append('\n'); for (final Node child : node.children) { this.appendNodeInfo(builder, level + 1, child); } }
private void appendNodeInfo(final StringBuilder builder, final int level, final Node node) { final StringBuilder indent = new StringBuilder(); for (int i = 0; i < level; i++) { indent.append('-'); } builder.append(indent); builder.append('+'); builder.append(SPACE); builder.append(node.getName()); builder.append('('); builder.append(node.attributes); builder.append(')'); final String nodeText = node.getText(); if (nodeText != null) { builder.append(SPACE); builder.append(node.getText()); } builder.append('\n'); for (final Node child : node.children) { this.appendNodeInfo(builder, level + 1, child); } }
/** * Returns a deep copy of this {@link Node} * * @return */ public Node deepCopy() { // Create new Node final Node newRoot = new Node(this.getName()); // Set attributes this.deepCopy(newRoot); // Return return newRoot; }
public ModuleAnalyzer(InputStream in) throws IOException { NodeImporter importer = new XmlDomNodeImporterImpl(); Node node = importer.importAsNode(in, true); String rootName = node.getName(); if (rootName.equals("module")) { this.module = new ModuleDescriptorImpl(null, node); } in.close(); }
/** * Returns a deep copy of this {@link Node} * * @return */ public Node deepCopy() { // Create new Node final Node newRoot = new Node(this.getName()); // Set attributes this.deepCopy(newRoot); // Return return newRoot; }
if (!name.equals(node.getName())) { return false;
if (!name.equals(node.getName())) { return false;
/** * Copies <code>this</code> reference to the specified {@link Node} * @param copyTarget * @return */ private Node deepCopy(final Node copyTarget){ // Precondition checks assert copyTarget != null : "Node to copy information into must be specified"; // Set attributes final Map<String, String> attributes = this.getAttributes(); final Set<String> attributeKeys = attributes.keySet(); for (final String key : attributeKeys) { final String value = attributes.get(key); copyTarget.attribute(key, value); } // Set text copyTarget.text(this.getText()); // Set children final List<Node> children = this.getChildren(); for (final Node child : children) { final Node newChild = copyTarget.createChild(child.getName()); // Recurse in child.deepCopy(newChild); } // Return return this; }
/** * Copies <code>this</code> reference to the specified {@link Node} * @param copyTarget * @return */ private Node deepCopy(final Node copyTarget){ // Precondition checks assert copyTarget != null : "Node to copy information into must be specified"; // Set attributes final Map<String, String> attributes = this.getAttributes(); final Set<String> attributeKeys = attributes.keySet(); for (final String key : attributeKeys) { final String value = attributes.get(key); copyTarget.attribute(key, value); } // Set text copyTarget.text(this.getText()); // Set children final List<Node> children = this.getChildren(); for (final Node child : children) { final Node newChild = copyTarget.createChild(child.getName()); // Recurse in child.deepCopy(newChild); } // Return return this; }