Package com.google.gwt.xml.client

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


  private void getElementByIdThenParse(Node entryNode, String id, Object parentNode) {   
    if (id.startsWith("#")) {
      id = id.substring(1);
    }   
    if ((entryNode.getNodeType() == ELEMENT_NODE) && (entryNode.hasAttributes())) {     
      Node idNode = entryNode.getAttributes().getNamedItem("id");
      if ((idNode != null) && (idNode.getNodeValue().equals(id))) {         
        parseFoundNode(entryNode, parentNode);
        return;
      }     
    }
    NodeList childNodes = entryNode.getChildNodes();  
View Full Code Here


   * @param isReferenced
   */
  private boolean parseMethodNode(Node methodElement, Object parentNode, boolean isReferenced) {
    if (containsOnlyAllowedChildren(methodElement, WadlXml.methodChildren)) {
      if (containsOnlyAllowedAttributes(methodElement, WadlXml.methodAttributes)) {
        Node hrefNode = methodElement.getAttributes().getNamedItem(WadlXml.method_href);       
        if (hrefNode != null) {
          getElementByIdThenParse(applicationElement, hrefNode.getNodeValue(), parentNode);
        }
        else {
          Node nameNode = methodElement.getAttributes().getNamedItem(WadlXml.method_name);
          if (nameNode != null) {           
            // either create a full node, or just an href node
            MethodNode method;
            if (!isReferenced) {
              method = new MethodNode(nameNode.getNodeValue(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication());
              Node idNode = methodElement.getAttributes().getNamedItem(WadlXml.method_id);
              if (idNode != null) {
                method.setId(idNode.getNodeValue());
              }
                           
              // methodChildren = {requestNode, responseNode, docNode}
              NodeList childNodes = methodElement.getChildNodes();
              for (int i = 0; i < childNodes.getLength(); i++) {          
                if (childNodes.item(i).getNodeName().equals(WadlXml.requestNode)) {       
                  if (!parseRequestNode(childNodes.item(i), method)) {
                    return false;
                  }       
                }
                else if (childNodes.item(i).getNodeName().equals(WadlXml.responseNode)) {       
                  if (!parseResponseNode(childNodes.item(i), method)) {
                    return false;
                  }       
                }
                else if (childNodes.item(i).getNodeName().equals(WadlXml.docNode)) {       
                  if (!parseDocNode(childNodes.item(i), method)) {
                    return false;
                  }       
                }
              }
            }
            else {
              Node idNode = methodElement.getAttributes().getNamedItem(WadlXml.method_id);
              method = new MethodNode(idNode.getNodeValue(), true, (GenericNode) parentNode, ((GenericNode) parentNode).getApplication());             
            }  
            // add to the correct parent node
            if (parentNode instanceof ResourceNode) {
              ((ResourceNode) parentNode).directlyAddMethod(method);
            }
View Full Code Here

   * @param isReferenced
   */
  private boolean parseFaultNode(Node faultElement, Object parentNode, boolean isReferenced) {   
    if (containsOnlyAllowedChildren(faultElement, WadlXml.faultChildren)) {
      if (containsOnlyAllowedAttributes(faultElement, WadlXml.faultAttributes)) {
        Node hrefNode = faultElement.getAttributes().getNamedItem(WadlXml.fault_href);     
        if (hrefNode != null) {       
          getElementByIdThenParse(applicationElement, hrefNode.getNodeValue(), parentNode);       
        }
        else {
          String mediaType = "";
          String element = "";
          String profile = "";
          String status = "";
         
          Node mediaTypeNode = faultElement.getAttributes().getNamedItem(WadlXml.fault_mediaType);
          if (mediaTypeNode != null) {
            mediaType = mediaTypeNode.getNodeValue();
          }
         
          Node elementNode = faultElement.getAttributes().getNamedItem(WadlXml.fault_element);
          if (elementNode != null) {
            element = elementNode.getNodeValue();
          }
         
          Node profileNode = faultElement.getAttributes().getNamedItem(WadlXml.fault_profile);
          if (profileNode != null) {
            profile = profileNode.getNodeValue();
          }
         
          Node statusNode = faultElement.getAttributes().getNamedItem(WadlXml.fault_status);
          if (statusNode != null) {
            status = statusNode.getNodeValue();
          }       
         
          FaultNode fault = null;
          if (!isReferenced) {
            if (parentNode instanceof ResponseNode) {         
              fault = new FaultNode(mediaType, element, profile, status, (ResponseNode) parentNode, ((ResponseNode) parentNode).getApplication());
              ((ResponseNode) parentNode).addFault(fault);
            }
            else if (parentNode instanceof ApplicationNode) {         
              fault = new FaultNode(mediaType, element, profile, status, (ApplicationNode) parentNode, (ApplicationNode) parentNode);
              ((ApplicationNode) parentNode).addFault(fault);
            }
            Node idNode = faultElement.getAttributes().getNamedItem(WadlXml.fault_id);
            if (idNode != null) {
              fault.setId(idNode.getNodeValue());
            }
           
            // faultChildren = {paramNode, docNode}
            NodeList childNodes = faultElement.getChildNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
              if (childNodes.item(i).getNodeName().equals(WadlXml.paramNode)) {
                if (!parseParamNode(childNodes.item(i), fault, false));
              }
              else if (childNodes.item(i).getNodeName().equals(WadlXml.docNode)) {
                if (!parseDocNode(childNodes.item(i), fault));
              }
            }
          }
          else {
            Node idNode = faultElement.getAttributes().getNamedItem(WadlXml.fault_id);           
            if (parentNode instanceof ResponseNode) {         
              fault = new FaultNode(idNode.getNodeValue(), true, (ResponseNode) parentNode, ((ResponseNode) parentNode).getApplication());
              ((ResponseNode) parentNode).addFault(fault);
            }
            else if (parentNode instanceof ApplicationNode) {         
              fault = new FaultNode(idNode.getNodeValue(), true, (ApplicationNode) parentNode, (ApplicationNode) parentNode);
              ((ApplicationNode) parentNode).addFault(fault);
            }
          }         
        }     
      }       
View Full Code Here

   * @param isReferenced
   */
  private boolean parseRepresentationNode(Node representationElement, Object parentNode, boolean isReferenced) {
    if (containsOnlyAllowedChildren(representationElement, WadlXml.representationChildren)) {
      if (containsOnlyAllowedAttributes(representationElement, WadlXml.representationAttributes)) {
        Node hrefNode = representationElement.getAttributes().getNamedItem(WadlXml.representation_href);
        if (hrefNode != null) {
          getElementByIdThenParse(applicationElement, hrefNode.getNodeValue(), parentNode);
        }
        else {
          String mediaType = "";
          String element = "";
          String profile = "";
          String status = "";
         
          Node mediaTypeNode = representationElement.getAttributes().getNamedItem(WadlXml.representation_mediaType);
          if (mediaTypeNode != null) {
            mediaType = mediaTypeNode.getNodeValue();
          }
         
          Node elementNode = representationElement.getAttributes().getNamedItem(WadlXml.representation_element);
          if (elementNode != null) {
            element = elementNode.getNodeValue();
          }
         
          Node profileNode = representationElement.getAttributes().getNamedItem(WadlXml.representation_profile);
          if (profileNode != null) {
            profile = profileNode.getNodeValue();
          }
         
          Node statusNode = representationElement.getAttributes().getNamedItem(WadlXml.representation_status);
          if (statusNode != null) {
            status = statusNode.getNodeValue();
          }
         
          RepresentationNode representation = null;
          if (!isReferenced) {          
            if (parentNode instanceof ResponseNode) {             
              representation = new RepresentationNode(mediaType, element, profile, status, (ResponseNode) parentNode, ((ResponseNode) parentNode).getApplication());
              ((ResponseNode) parentNode).addRepresentation(representation);
            }
            else if (parentNode instanceof RequestNode) {             
              representation = new RepresentationNode(mediaType, element, profile, status, (RequestNode) parentNode, ((RequestNode) parentNode).getApplication());
              ((RequestNode) parentNode).addRepresentation(representation);
            }
            else if (parentNode instanceof ApplicationNode) {             
              representation = new RepresentationNode(mediaType, element, profile, status, (ApplicationNode) parentNode, (ApplicationNode) parentNode);
              ((ApplicationNode) parentNode).addRepresentation(representation);
            }
           
            Node idNode = representationElement.getAttributes().getNamedItem(WadlXml.fault_id);
            if (idNode != null) {
              representation.setId(idNode.getNodeValue());
            }
           
            // representationChildren = {paramNode, docNode}
            NodeList childNodes = representationElement.getChildNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
              if (childNodes.item(i).getNodeName().equals(WadlXml.paramNode)) {
                if (!parseParamNode(childNodes.item(i), representation, false));
              }         
              else if (childNodes.item(i).getNodeName().equals(WadlXml.docNode)) {
                if (!parseDocNode(childNodes.item(i), representation));
              }
            }
          }
          else {           
            Node idNode = representationElement.getAttributes().getNamedItem(WadlXml.representation_id);           
            if (parentNode instanceof ResponseNode) {
              representation = new RepresentationNode(idNode.getNodeValue(), true, (ResponseNode) parentNode, ((ResponseNode) parentNode).getApplication());
              ((ResponseNode) parentNode).addRepresentation(representation);
            }
            else if (parentNode instanceof RequestNode) {             
              representation = new RepresentationNode(idNode.getNodeValue(), true, (RequestNode) parentNode, ((RequestNode) parentNode).getApplication());
              ((RequestNode) parentNode).addRepresentation(representation);
            }
            else if (parentNode instanceof ApplicationNode) {             
              representation = new RepresentationNode(idNode.getNodeValue(), true, (ApplicationNode) parentNode, (ApplicationNode) parentNode);
              ((ApplicationNode) parentNode).addRepresentation(representation);
            }
          }        
        }     
      }
View Full Code Here

   * @param isReferenced 
   */
  private boolean parseParamNode(Node paramElement, Object parentNode, boolean isReferenced) {
    if (containsOnlyAllowedChildren(paramElement, WadlXml.paramChildren)) {
      if (containsOnlyAllowedAttributes(paramElement, WadlXml.paramAttributes)) {
        Node hrefNode = paramElement.getAttributes().getNamedItem(WadlXml.param_href);
        if (hrefNode != null) {
          getElementByIdThenParse(applicationElement, hrefNode.getNodeValue(), parentNode);         
        }
        else {       
          String name = "";
          String style = "";
          String type = "";
          String defaultValue = "";
          String path = "";
          boolean isRequired = false;
          boolean isRepeating = false;
          String fixed = "";
         
          Node nameNode = paramElement.getAttributes().getNamedItem(WadlXml.param_name);
          if (nameNode != null) {
            name = nameNode.getNodeValue();
          }
         
          Node styleNode = paramElement.getAttributes().getNamedItem(WadlXml.param_style);
          if (styleNode != null) {
            style = styleNode.getNodeValue();
          }
         
          Node pathNode = paramElement.getAttributes().getNamedItem(WadlXml.param_path);
          if (pathNode != null) {
            path = pathNode.getNodeValue();
          }
         
          Node typeNode = paramElement.getAttributes().getNamedItem(WadlXml.param_type);
          if (typeNode != null) {
            type = typeNode.getNodeValue();
          }
          // if no type is given use string as the default value
          if (type.equals("")) {
            type = TypeEstimator.typeString;
          }
         
          Node defaultValueNode = paramElement.getAttributes().getNamedItem(WadlXml.param_default);
          if (defaultValueNode != null) {
            defaultValue = defaultValueNode.getNodeValue();
          }
                   
          Node fixedNode = paramElement.getAttributes().getNamedItem(WadlXml.param_fixed);
          if (fixedNode != null) {
            fixed = fixedNode.getNodeValue();
          }
         
          Node isRequiredNode = paramElement.getAttributes().getNamedItem(WadlXml.param_required);
          if (isRequiredNode != null) {
            if (isRequiredNode.getNodeValue().equals("true")) {
              isRequired = true;
            }
          }
         
          Node isRepeatingNode = paramElement.getAttributes().getNamedItem(WadlXml.param_repeating);
          if (isRepeatingNode != null) {
            if (isRepeatingNode.getNodeValue().equals("true")) {
              isRepeating = true;
            }
          }
         
          ParamNode param = null;
          if (!isReferenced) {
            if (parentNode instanceof ResourceNode) {
              param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (ResourceNode) parentNode, ((ResourceNode) parentNode).getApplication());         
              ((ResourceNode) parentNode).addParam(param);
            }
            else if (parentNode instanceof RequestNode) {
              param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (RequestNode) parentNode, ((RequestNode) parentNode).getApplication());
              ((RequestNode) parentNode).addParam(param);
            }
            else if (parentNode instanceof ResponseNode) {
              param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (ResponseNode) parentNode, ((ResponseNode) parentNode).getApplication());
              ((ResponseNode) parentNode).addParam(param);
            }
            else if (parentNode instanceof RepresentationNode) {
              param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (RepresentationNode) parentNode, ((RepresentationNode) parentNode).getApplication());
              ((RepresentationNode) parentNode).addParam(param);
            }
            else if (parentNode instanceof FaultNode) {
              param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (FaultNode) parentNode, ((FaultNode) parentNode).getApplication());
              ((FaultNode) parentNode).addParam(param);
            }
            else if (parentNode instanceof ApplicationNode) {
              param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (ApplicationNode) parentNode, ((ApplicationNode) parentNode));
              ((ApplicationNode) parentNode).addParam(param);
            }
           
            Node idNode = paramElement.getAttributes().getNamedItem(WadlXml.param_id);
            if (idNode != null) {
              param.setId(idNode.getNodeValue());
            }
           
            // paramChildren = {optionNode, linkNode, docNode}
            NodeList childNodes = paramElement.getChildNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
              if (childNodes.item(i).getNodeName().equals(WadlXml.optionNode)) {
                if (!parseOptionNode(childNodes.item(i), param));
              }
              else if (childNodes.item(i).getNodeName().equals(WadlXml.linkNode)) {
                if (!parseLinkNode(childNodes.item(i), param));
              }
              else if (childNodes.item(i).getNodeName().equals(WadlXml.docNode)) {
                if (!parseDocNode(childNodes.item(i), param));
              }
            }
          }
          else {
            Node idNode = paramElement.getAttributes().getNamedItem(WadlXml.param_id);
            if (parentNode instanceof ResourceNode) {
              param = new ParamNode(idNode.getNodeValue(), true, (ResourceNode) parentNode, ((ResourceNode) parentNode).getApplication());         
              ((ResourceNode) parentNode).addParam(param);
            }
            else if (parentNode instanceof RequestNode) {
              param = new ParamNode(idNode.getNodeValue(), true, (RequestNode) parentNode, ((RequestNode) parentNode).getApplication());
              ((RequestNode) parentNode).addParam(param);
            }
            else if (parentNode instanceof ResponseNode) {
              param = new ParamNode(idNode.getNodeValue(), true, (ResponseNode) parentNode, ((ResponseNode) parentNode).getApplication());
              ((ResponseNode) parentNode).addParam(param);
            }
            else if (parentNode instanceof RepresentationNode) {
              param = new ParamNode(idNode.getNodeValue(), true, (RepresentationNode) parentNode, ((RepresentationNode) parentNode).getApplication());
              ((RepresentationNode) parentNode).addParam(param);
            }
            else if (parentNode instanceof FaultNode) {
              param = new ParamNode(idNode.getNodeValue(), true, (FaultNode) parentNode, ((FaultNode) parentNode).getApplication());
              ((FaultNode) parentNode).addParam(param);
            }
            else if (parentNode instanceof ApplicationNode) {
              param = new ParamNode(idNode.getNodeValue(), true, (ApplicationNode) parentNode, (ApplicationNode) parentNode);
              ((ApplicationNode) parentNode).addParam(param);
            }
          }
        } 
      }
View Full Code Here

   * @return
   */
  private boolean parseOptionNode(Node optionElement, ParamNode paramNode) {
    if (containsOnlyAllowedChildren(optionElement, WadlXml.optionChildren)) {
      if (containsOnlyAllowedAttributes(optionElement, WadlXml.optionAttributes)) {
        Node valueNode = optionElement.getAttributes().getNamedItem(WadlXml.option_value);
        if (valueNode != null) {
          paramNode.addOption(valueNode.getNodeValue());
        }
      }
      else {
        alertInvalidWadlAndRetry(GuiFactory.notifications.invalidAttributes(WadlXml.optionNode, allowedAttributes(WadlXml.optionAttributes)));
        return false;
View Full Code Here

   * @param grammars
   */
  private boolean parseIncludeNode(Node includeElement, GrammarsNode grammars) {   
    if (containsOnlyAllowedChildren(includeElement, WadlXml.includeChildren)) {
      if (containsOnlyAllowedAttributes(includeElement, WadlXml.includeAttributes)) {
        Node hrefNode = includeElement.getAttributes().getNamedItem(WadlXml.include_href);
        if (hrefNode != null) {
          grammars.addInclude(hrefNode.getNodeValue());
        }
      }
      else {
        alertInvalidWadlAndRetry(GuiFactory.notifications.invalidAttributes(WadlXml.includeNode, allowedAttributes(WadlXml.includeAttributes)));
        return false;
View Full Code Here

        String other = position.getOther();
        if (other != null) {
            try {
                NodeList nodes = XMLParser.parse(other).getFirstChild().getChildNodes();
                for (int i = 0; i < nodes.getLength(); i++) {
                    Node node = nodes.item(i);
                    state.add(new StateItem(node.getNodeName(), node.getFirstChild().getNodeValue()));
                }
            } catch (Exception error) {
            }
        }
View Full Code Here

        System.out.println("ReadLookupValuesCallback response.getText() = " + response.getText());
        responseDocument = XMLParser.parse(response.getText());
        NodeList entryNodes = responseDocument.getElementsByTagName("entry");

        for(int i=0; i < entryNodes.getLength(); i++){
            Node entryNode = entryNodes.item(i);
            NodeList entryNodeChilds = entryNode.getChildNodes();
            for(int j=0; j < entryNodeChilds.getLength(); j++){
                if (entryNodeChilds.item(j).getNodeName().equals("content")){
                    String lookupValue = entryNodeChilds.item(j).getFirstChild().getNodeValue();
                    System.out.println("lookupValue = " + lookupValue);
                    lookupValuesSet.add(lookupValue);
View Full Code Here

    }

    public static String getTextValue(Element element, String defaultValue) {
        NodeList nodes = element.getChildNodes();
        for (int i=0; i<nodes.getLength(); i++) {
            Node node = nodes.item(i);
            if (node.getNodeType() == Node.TEXT_NODE) {
                return node.getNodeValue();
            }
        }
        return defaultValue;
    }
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.