Package com.google.gwt.xml.client

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


  public Element getRootElement() throws XmlException {

    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;
      }
    }
View Full Code Here


   * {@inheritDoc }
   */
  @Override
  public Element getOptionalElement(String nodeName) {
    try {
      Node n = this.document.getElementsByTagName(nodeName).item(0);
      return (Element) n;
    } catch (Exception ex) {
      return null;
    }
  }
View Full Code Here

    for(String jid:disco.keySet())
    {
      Element el = disco.get(jid);
      if(el == null)
        continue;
      Node item = el.getElementsByTagName("identity").item(0);
      if(item == null)
        continue;
      Element elItem = (Element)item;
      if(elItem.getAttribute("category").equals("gateway"))
      {
View Full Code Here

    for(String jid:disco.keySet())
    {
      Element el = disco.get(jid);
      if(el == null)
        continue;
      Node item = el.getElementsByTagName("identity").item(0);
      if(item == null)
        continue;
      Element elItem = (Element)item;
      if(elItem.getAttribute("category").equals("conference")&&elItem.getAttribute("type").equals("text"))
      {
View Full Code Here

      return false;
   
    NodeList childs = vcardElement.getChildNodes();
    for(int index = 0;index<childs.getLength();index++)
    {
      Node child = childs.item(index);
      String tagName = child.getNodeName().toUpperCase();
      String value = XMLHelper.getTagContent((Element) child);
      if(tagName.equals("VERSION"))
        version = value.trim();
      else if(tagName.equals("FN"))
        fullName = value.trim();
      else if(tagName.equals("NICKNAME"))
        nickName = value.trim();   
      else if(tagName.equals("PHOTO"))
        photo = XMLHelper.subTagText((Element) child, "BINVAL");
      else if(tagName.equals("BDAY"))
        bday = value.trim();
      else if(tagName.equals("ADR"))
      {
        Address a = new Address();
       
        a.home = XMLHelper.hasSubTag((Element) child, "HOME");
        a.work = XMLHelper.hasSubTag((Element) child, "WORK");
        a.postal = XMLHelper.hasSubTag((Element) child, "POSTAL");
        a.parcel = XMLHelper.hasSubTag((Element) child, "PARCEL");
        a.dom    = XMLHelper.hasSubTag((Element) child, "DOM");
        a.intl   = XMLHelper.hasSubTag((Element) child, "INTL");
        a.pref   = XMLHelper.hasSubTag((Element) child,"PREF");
       
        a.pobox    = XMLHelper.subTagText((Element) child, "POBOX");
        a.extaddr  = XMLHelper.subTagText((Element) child, "EXTADR");
        a.street   = XMLHelper.subTagText((Element) child, "STREET");
        a.locality = XMLHelper.subTagText((Element) child, "LOCALITY");
        a.region   = XMLHelper.subTagText((Element) child, "REGION");
        a.pcode    = XMLHelper.subTagText((Element) child, "PCODE");
        a.country  = XMLHelper.subTagText((Element) child, "CTRY");
       
        if(a.country.isEmpty())
        {
          if(XMLHelper.hasSubTag((Element) child, "COUNTRY"))
            a.country = XMLHelper.subTagText((Element) child, "COUNTRY");
        }
       
        if(a.extaddr.isEmpty())
        {
          if(XMLHelper.hasSubTag((Element) child, "EXTADD"))
            a.extaddr = XMLHelper.subTagText((Element) child, "EXTADD");
        }
       
        addressList.add(a);
      }
      else if(tagName.equals("LABEL"))
      {
        Label l = new Label();
        l.home   = XMLHelper.hasSubTag((Element) child, "HOME");
        l.work   = XMLHelper.hasSubTag((Element) child, "WORK");
        l.postal = XMLHelper.hasSubTag((Element) child, "POSTAL");
        l.parcel = XMLHelper.hasSubTag((Element) child, "PARCEL");
        l.dom    = XMLHelper.hasSubTag((Element) child, "DOM");
        l.intl   = XMLHelper.hasSubTag((Element) child, "INTL");
        l.pref   = XMLHelper.hasSubTag((Element) child, "PREF");
       
        NodeList lines = child.getChildNodes();
        for(int i = 0;i<lines.getLength();i++)
        {
          Element line = (Element) lines.item(i);
          if(line.getTagName().toUpperCase().equals("LINE"))
          {
            if(!XMLHelper.getTagContent(line).isEmpty())
              l.lines.add(XMLHelper.getTagContent(line));
          }
        }
        labelList.add(l);
      }
      else if(tagName.equals("TEL"))
      {
        Phone p = new Phone();
       
        p.home  = XMLHelper.hasSubTag((Element) child, "HOME");
        p.work  = XMLHelper.hasSubTag((Element) child, "WORK");
        p.voice = XMLHelper.hasSubTag((Element) child, "VOICE");
        p.fax   = XMLHelper.hasSubTag((Element) child, "FAX");
        p.pager = XMLHelper.hasSubTag((Element) child, "PAGER");
        p.msg   = XMLHelper.hasSubTag((Element) child, "MSG");
        p.cell  = XMLHelper.hasSubTag((Element) child, "CELL");
        p.video = XMLHelper.hasSubTag((Element) child, "VIDEO");
        p.bbs   = XMLHelper.hasSubTag((Element) child, "BBS");
        p.modem = XMLHelper.hasSubTag((Element) child, "MODEM");
        p.isdn  = XMLHelper.hasSubTag((Element) child, "ISDN");
        p.pcs   = XMLHelper.hasSubTag((Element) child, "PCS");
        p.pref  = XMLHelper.hasSubTag((Element) child, "PREF");
       
        p.number = XMLHelper.subTagText((Element) child, "NUMBER");
        if(p.number.isEmpty())
        {
          if(XMLHelper.hasSubTag((Element) child, "VOICE"))
            p.number = XMLHelper.subTagText((Element) child, "VOICE");
        }
        phoneList.add(p);
      }
      else if(tagName.equals("EMAIL"))
      {
        Email m = new Email();

        m.home = XMLHelper.hasSubTag((Element) child, "HOME");
        m.work = XMLHelper.hasSubTag((Element) child, "WORK");
        m.internet = XMLHelper.hasSubTag((Element) child, "INTERNET");
        m.x400 = XMLHelper.hasSubTag((Element) child, "X400");

        m.userid = XMLHelper.subTagText((Element) child, "USERID");

        if (m.userid.isEmpty())
        {
          if(!XMLHelper.getTagContent((Element)child).isEmpty())
          {
            m.userid = XMLHelper.getTagContent((Element)child);
          }
        }
        emailList.add(m);
      }
      else if(tagName.equals("JABBERID"))
        jid = value.trim();
      else if(tagName.equals("MAILER"))
        mailer = value.trim();
      else if(tagName.equals("TZ"))
        timezone = value.trim();
      else if(tagName.equals("GEO"))
      {
        geo.lat = XMLHelper.subTagText((Element) child, "LAT");
        geo.lon = XMLHelper.subTagText((Element) child, "LON");
      }
      else if(tagName.equals("TITLE"))
        title = value.trim();
      else if(tagName.equals("ROLE"))
        role = value.trim();
      else if(tagName.equals("LOGO"))
      {
        logo = XMLHelper.subTagText((Element)child, "BINVAL");
        logoURI = XMLHelper.subTagText((Element)child, "EXTVAL");
      }
      else if(tagName.equals("AGENT"))
      {
       
      }
      else if(tagName.equals("ORG"))
      {
        org.name = XMLHelper.subTagText((Element)child, "ORGNAME");
        NodeList units = child.getChildNodes();
        for(int iunit = 0;iunit<units.getLength();iunit++)
        {
          Element unit = (Element) units.item(iunit);
          if(!XMLHelper.getTagContent(unit).isEmpty())
            org.unit.add(XMLHelper.getTagContent(unit));
View Full Code Here

  return packet.toString();
    }

    public static IPacket toXML(final String xml) {
  final Document parsed = XMLParser.parse(xml);
  final Node body = parsed.getChildNodes().item(0);
  return new GWTPacket((Element) body);
    }
View Full Code Here

    public HashMap<String, String> getAttributes() {
  final HashMap<String, String> map = new HashMap<String, String>();
  final NamedNodeMap attributes = element.getAttributes();
  for (int index = 0; index < attributes.getLength(); index++) {
      final Node attrib = attributes.item(index);
      map.put(attrib.getNodeName(), attrib.getNodeValue());
  }
  return map;
    }
View Full Code Here

    public Map<String, String> getAttributtes() {
  final HashMap<String, String> attributes = new HashMap<String, String>();
  final NamedNodeMap original = element.getAttributes();
  for (int index = 0; index < original.getLength(); index++) {
      final Node node = original.item(index);
      attributes.put(node.getNodeName(), node.getNodeValue());
  }
  return attributes;
    }
View Full Code Here

    public IPacket getParent() {
  return new GWTPacket((Element) element.getParentNode());
    }

    public String getText() {
  Node item;
  final NodeList childs = element.getChildNodes();
  for (int index = 0; index < childs.getLength(); index++) {
      item = childs.item(index);
      if (item.getNodeType() == Node.TEXT_NODE) {
    return TextUtils.unescape(item.getNodeValue());
      }
  }
  return null;
    }
View Full Code Here

    public void setText(final String text) {
  final String escaped = TextUtils.escape(text);
  final NodeList nodes = element.getChildNodes();
  for (int index = 0; index < nodes.getLength(); index++) {
      final Node child = nodes.item(index);
      if (child.getNodeType() == Node.TEXT_NODE) {
    element.removeChild(child);
      }
  }
  element.appendChild(element.getOwnerDocument().createTextNode(escaped));
    }
View Full Code Here

TOP

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

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.