Package com.google.gwt.xml.client

Examples of com.google.gwt.xml.client.Element


    NodeList nodeList = this.document.getChildNodes();

    for (int i = 0; i < nodeList.getLength(); i++) {
      Node n = nodeList.item(i);
      if (n.getNodeType() == Node.ELEMENT_NODE) {
        Element root = (Element) n;
        return root;
      }
    }

    throw new XmlException("Can't find any Root Element");
View Full Code Here


  /**
   * {@inheritDoc }
   */
  @Override
  public Element getElement(String nodeName) throws XmlException {
    Element elt = getOptionalElement(nodeName);
    if (elt == null) {
      throw new XmlException("Can't find element : " + nodeName);
    } else {
      return elt;
    }
View Full Code Here

   * {@inheritDoc }
   */
  @Override
  public GwtRepresentation add(String nodeName, String nodeValue)
      throws XmlException {
    Element root = this.document.getDocumentElement();
    if (root == null) {
      throw new XmlException("The document has no Root Element");
    }

    Text textValue = this.document.createTextNode(nodeValue);
    Element elt = this.document.createElement(nodeName);
    elt.appendChild(textValue);
    root.appendChild(elt);
    return this;
  }
View Full Code Here

   * {@inheritDoc }
   */
  @Override
  public GwtRepresentation remove(String nodeName) throws XmlException {

    Element elt = this.getElement(nodeName);
    elt.getParentNode().removeChild(elt);
    return this;
  }
View Full Code Here

   * {@inheritDoc }
   */
  @Override
  public String getAttribute(String nodeName, String attribute)
      throws XmlException {
    Element elt = getElement(nodeName);
    return elt.getAttribute(attribute);
  }
View Full Code Here

   * {@inheritDoc }
   */
  @Override
  public XmlDocumentRepresentation setAttribute(String nodeName,
      String attribute, String value) throws XmlException {
    Element elt = getElement(nodeName);
    elt.setAttribute(attribute, value);
    return this;
  }
View Full Code Here

  /**
   * {@inheritDoc }
   */
  @Override
  public GwtRepresentation set(String nodeName, String value) {
    Element elt = getOptionalElement(nodeName);
    if (elt == null) {
      this.add(nodeName, value);
    } else {
      elt.setNodeValue(value);
    }
    return this;
  }
View Full Code Here

  /**
   * {@inheritDoc }
   */
  @Override
  public String getOptionalValue(String nodeName) {
    Element e = getOptionalElement(nodeName);
    if (e == null) {
      return null;
    } else {
      return getValue(e);
    }
View Full Code Here

   * {@inheritDoc }
   */
  @Override
  public Representation addList(String listName, String nodeName,
      List<Object> values) {
    Element root = this.document.getDocumentElement();
    if (root == null) {
      throw new XmlException("The document has no Root Element");
    }

    Element list = this.document.createElement(listName);
    root.appendChild(list);

    for (Object o : values) {
      Element e = this.document.createElement(nodeName);
      list.appendChild(e);
      Text textValue = this.document.createTextNode(o.toString());
      e.appendChild(textValue);     
    }
   
    return this;
  }
View Full Code Here

  @Override
  public Representation addList(ResourceList resources, String prefixIfListIsEmpty) {
    if (resources == null){
      throw new IllegalArgumentException("Resources is null");
    }
    Element root = this.document.getDocumentElement();
    if (root == null) {
      throw new XmlException("The document has no Root Element");
    }
   
    if (resources.isEmpty()){
      Element emptyListElement = this.document.createElement(prefixIfListIsEmpty) ;
      root.appendChild(emptyListElement);
    }else{
      Resource r0 = resources.get(0);
      Element list = this.document.createElement(r0.getListPrefix());
      root.appendChild(list);
      for (Object r :  resources){
       
        Element elt = this.document.createElement(r0.getPrefix());
        list.appendChild(elt);
       
        Element id=this.document.createElement("id");
        elt.appendChild(id);
        id.appendChild(document.createTextNode((((Resource)r).getId().toString())));
               
        Element show = this.document.createElement("show");
        elt.appendChild(show);
        show.appendChild(document.createTextNode(r.toString()));
      }           
    }
    return this;   
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.xml.client.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.