@@ -0,0 +1,1880 @@
+package cx2x.xcodeml.xnode;%0A%0Aimport org.w3c.dom.Element;%0Aimport org.w3c.dom.Node;%0Aimport org.w3c.dom.NodeList;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * XcodeML AST node.%0A *%0A * @author clementval%0A */%0Apublic class Xnode %7B%0A%0A  private final Element _baseElement;%0A%0A  public Xnode(Element element)%7B%0A    _baseElement = element;%0A  %7D%0A%0A  /**%0A   * Get the element opcode.%0A   * @return Opcode.%0A   */%0A  public Xcode Opcode()%7B%0A    return Xcode.valueOf(_baseElement.getTagName());%0A  %7D%0A%0A  /**%0A   * Check whether the element has the corresponding attribute.%0A   * @param attrCode Attribute code.%0A   * @return True if the element has the corresponding attribute.%0A   */%0A  public boolean hasAttribute(Xattr attrCode)%7B%0A    return _baseElement != null%0A        && _baseElement.hasAttribute(attrCode.toString());%0A  %7D%0A%0A  /**%0A   * Get the attribute's value.%0A   * @param attrCode Attribute code.%0A   * @return Attribute's value.%0A   */%0A  public String getAttribute(Xattr attrCode)%7B%0A    return _baseElement.getAttribute(attrCode.toString());%0A  %7D%0A%0A  /**%0A   * Get the element's value.%0A   * @return Element value.%0A   */%0A  public String getValue()%7B%0A    return _baseElement.getTextContent();%0A  %7D%0A%0A  /**%0A   * Set attribute value.%0A   * @param attrCode Attribute code.%0A   * @param value Value of the attribute.%0A   */%0A  public void setAttribute(Xattr attrCode, String value)%7B%0A    _baseElement.setAttribute(attrCode.toString(), value);%0A  %7D%0A%0A  /**%0A   * Get the list of child elements.%0A   * @return List of children of the current element.%0A   */%0A  public List%3CXnode%3E getChildren()%7B%0A    List%3CXnode%3E nodes = new ArrayList%3C%3E();%0A    NodeList children = _baseElement.getChildNodes();%0A    for(int i = 0; i %3C children.getLength(); ++i)%7B%0A      Node child = children.item(i);%0A      if(child.getNodeType() == Node.ELEMENT_NODE)%7B%0A        nodes.add(new Xnode((Element)child));%0A      %7D%0A    %7D%0A    return nodes;%0A  %7D%0A%0A%7D%0A

Add Xnode