Android Open Source - penmanship Android X M L Node






From Project

Back to project page penmanship.

License

The source code is released under:

Apache License

If you think the Android project penmanship listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.mindsnacks.penmanship;
//from w  ww .j a va 2  s .  c o  m
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by Tony Cosentini Date: 1/13/14 Time: 10:51 AM
 */
public class AndroidXMLNode {
  private String name;
  private Map<String, String> attributes;
  private List<AndroidXMLNode> children = new ArrayList<AndroidXMLNode>();

  public AndroidXMLNode(String name, Map<String, String> attributes) {
    this.name = name;
    this.attributes = attributes;
  }

  public void addChild(AndroidXMLNode child) {
    children.add(child);
  }

  public String render() {
    StringBuilder sb = new StringBuilder();

    sb.append(String.format("<%s ", name));

    for (String attributeName : attributes.keySet()) {
      String attributeValue = attributes.get(attributeName);
      sb.append(String.format("%s=\"%s\" ", attributeName, attributeValue));
    }

    if (children.size() == 0) {
      sb.append("/>\n");
    } else {
      sb.append(">\n");

      for (AndroidXMLNode child : children) {
        sb.append(child.render());
      }

      sb.append(String.format("</%s>\n", name));
    }

    return sb.toString();
  }

  public List<AndroidXMLNode> getChildren() {
    return children;
  }

  public String getName() {
    return name;
  }

  public Map<String, String> getAttributes() {
    return attributes;
  }
}




Java Source Code List

com.mindsnacks.penmanship.AndroidMarkdownVisitor.java
com.mindsnacks.penmanship.AndroidXMLConstants.java
com.mindsnacks.penmanship.AndroidXMLNode.java
com.mindsnacks.penmanship.BaseVisitor.java
com.mindsnacks.penmanship.Penmanship.java
com.mindsnacks.penmanship.Penmanship.java
com.mindsnacks.penmanship.group_handlers.BaseHandler.java
com.mindsnacks.penmanship.group_handlers.ImageGroupHandler.java
com.mindsnacks.penmanship.group_handlers.TextNodeGroupHandler.java
com.penmanship.example.MainActivity.java