Package com.google.gwt.xml.client

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


    Document doc = XMLParser.parse(xml);
    Element vcardElement = XMLHelper.findSubTag(doc.getDocumentElement(), "vCard");
    if(vcardElement == null)
      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));
        }
      }
      else if(tagName.equals("NOTE"))
View Full Code Here


  return wrap(element.getChildNodes());
    }

    @Override
    public List<IPacket> getChildren(final String name) {
  final NodeList nodes = element.getElementsByTagName(name);
  return wrap(nodes);
    }
View Full Code Here

  return element;
    }

    @Override
    public IPacket getFirstChild(final String childName) {
  final NodeList nodes = element.getElementsByTagName(childName);
  return nodes.getLength() > 0 ? new GWTPacket((Element) nodes.item(0)) : NoPacket.INSTANCE;
    }
View Full Code Here

  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

  @SuppressWarnings({"unchecked", "rawtypes"})
  public D read(Object loadConfig, Object data) {
    Document doc = XMLParser.parse((String) data);

    NodeList list = doc.getElementsByTagName(modelType.getRecordName());
    ArrayList<ModelData> records = new ArrayList<ModelData>();
    for (int i = 0; i < list.getLength(); i++) {
      Node node = list.item(i);
      Element elem = (Element) node;
      ModelData model = newModelInstance();
      for (int j = 0; j < modelType.getFieldCount(); j++) {
        DataField field = modelType.getField(j);
        Class type = field.getType();
View Full Code Here

    defaultNamespace.clear();
    otherNamespaces.clear();
   
    Document response = XMLParser.parse(serviceDataXmlString);
   
    NodeList namespaces = response.getElementsByTagName("namespace");   
    for (int i = 0; i < namespaces.getLength(); i++) {
      Node namespace = namespaces.item(i);
      if (namespace.hasChildNodes()) {
        String namespaceString = namespace.getFirstChild().getNodeValue();
        if ((!otherNamespaces.contains(namespaceString)) &&
            (!namespaceString.equals(WadlXml.xmlns_xsd)) &&
            (!namespaceString.equals(WadlXml.xmlns_xsi))) {
          otherNamespaces.add(namespaceString);
        }
      }
    }
   
    NodeList requests = response.getElementsByTagName("requestData");   
    for (int i = 0; i < requests.getLength(); i++) {
      Node request = requests.item(i);           
      NodeList requestChildren = request.getChildNodes();     
      for (int j = 0; j < requestChildren.getLength(); j++) {
        Node requestChild = requestChildren.item(j);
        if (requestChild.getNodeName().equals("validRequest")) {         
          treatValidRequests(requestChild);
        }
        else if (requestChild.getNodeName().equals("erroneousRequests")) {
          treatErroneousRequests(requestChild);
View Full Code Here

 
  /**
   * @param validRequest
   */
  private static void treatValidRequests(Node validRequest) {   
    NodeList children = validRequest.getChildNodes();
    for(int i = 0; i < children.getLength(); i++) {
      Node node = children.item(i);
      if (node.getNodeType() != Node.ELEMENT_NODE) {
        continue;
      }
      if (node.getNodeName().equals("schemaLocation")) {       
        if (node.hasChildNodes() &&           
View Full Code Here

  /**
   * @param erroneousRequests
   */
  private static void treatErroneousRequests(Node erroneousRequestChildren) {   
    NodeList erroneousRequests = erroneousRequestChildren.getChildNodes();   
    for (int i = 0; i < erroneousRequests.getLength(); i++) {     
      Node erroneousRequest = erroneousRequests.item(i);
      if (erroneousRequest.getNodeType() != Node.ELEMENT_NODE) {
        continue;     
      }
      String status = erroneousRequest.getAttributes().getNamedItem("status").getNodeValue();     
      if (!errorStatuses.contains(status) && (!status.equals("200"))) {       
        errorStatuses.add(status);       
      }   
      NodeList children = erroneousRequest.getChildNodes();
      for(int j = 0; j < children.getLength(); j++) {
        Node node = children.item(j);       
        if (node.getNodeType() != Node.ELEMENT_NODE) {
          continue;
        }
        if (node.getNodeName().equals("schemaLocation")) {         
          if (node.hasChildNodes() &&
View Full Code Here

  /**
   * @param wadl
   */
  private boolean startParsing(Document wadl) {
    // the first node must be an application node with namespace attributes
    NodeList wadlChildren = wadl.getChildNodes();
    for (int i = 0; i < wadlChildren.getLength(); i++) {
      Node wadlChild = wadlChildren.item(i);
      if (wadlChild.getNodeType() == ELEMENT_NODE) {
        applicationElement = wadlChild;
        break;
      }
    }
    if (applicationElement.getNodeName().equals(WadlXml.applicationNode)) {       
      // allowed children are only doc, grammars, resources, resource_type, method, representation, param, fault     
      if (containsOnlyAllowedChildren(applicationElement, WadlXml.applicationChildren)) {
        if ((applicationElement.getAttributes().getNamedItem(WadlXml.application_xmlns) != null) &&
            (applicationElement.getAttributes().getNamedItem(WadlXml.application_xmlns_xsd) != null) &&
            (applicationElement.getAttributes().getNamedItem(WadlXml.application_xmlns_xsi) != null) &&
            (applicationElement.getAttributes().getNamedItem(WadlXml.application_xsi_schemaLocation) != null)) {
          Analyzer analyzer = new Analyzer("");       
          application = new ApplicationNode(analyzer);       
          analyzer.setApplication(application);
         
          NamedNodeMap attributes = applicationElement.getAttributes();
          for (int i = 0; i < attributes.getLength(); i++) {
            Node attribute = attributes.item(i);
            if ((attribute.getNodeName().equals(WadlXml.application_xmlns)) ||
                (attribute.getNodeName().equals(WadlXml.application_xmlns_xsd)) ||
                (attribute.getNodeName().equals(WadlXml.application_xmlns_xsi)) ||
                (attribute.getNodeName().equals(WadlXml.application_xsi_schemaLocation))) {
              continue;
            }
            NamespaceAttribute namespace = new NamespaceAttribute(attribute.getNodeName(), attribute.getNodeValue());
            application.addNamespace(namespace);           
          }
         
          // applicationChildren = {resourcesNode, grammarsNode, resourceTypeNode, methodNode, representationNode, faultNode, docNode}
          NodeList applicationChildren = applicationElement.getChildNodes();
          for (int i = 0; i < applicationChildren.getLength(); i++) {     
            if (applicationChildren.item(i).getNodeName().equals(WadlXml.resourcesNode)) {
              if (!parseResourcesNode(applicationChildren.item(i), application)) {
                return false;       
              }
            }
            else if (applicationChildren.item(i).getNodeName().equals(WadlXml.grammarsNode)) {
              if (!parseGrammarsNode(applicationChildren.item(i), application)) {
                return false;
              }       
            }
            else if (applicationChildren.item(i).getNodeName().equals(WadlXml.resourceTypeNode)) {
              if (!parseResourceTypeNode(applicationChildren.item(i), application)) {
                return false;       
              }
            }
            else if (applicationChildren.item(i).getNodeName().equals(WadlXml.methodNode)) {
              if (!parseMethodNode(applicationChildren.item(i), application, false)) {
                return false;       
              }
            }
            else if (applicationChildren.item(i).getNodeName().equals(WadlXml.representationNode)) {
              if (!parseRepresentationNode(applicationChildren.item(i), application, false)) {
                return false;       
              }
            }
            else if (applicationChildren.item(i).getNodeName().equals(WadlXml.faultNode)) {
              if (!parseFaultNode(applicationChildren.item(i), application, false)) {
                return false;       
              }
            }
            else if (applicationChildren.item(i).getNodeName().equals(WadlXml.paramNode)) {
              if (!parseParamNode(applicationChildren.item(i), application, false)) {
                return false;       
              }
            }
            else if (applicationChildren.item(i).getNodeName().equals(WadlXml.docNode)) {
              if (!parseDocNode(applicationChildren.item(i), application)) {
                return false;       
              }
            }
          }
        }
View Full Code Here

TOP

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

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.