Package com.google.gwt.xml.client

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


  private void removeAllAces( Document fileInfo ) {
    // Window.alert("removeAllAces() called with: \n" + fileInfo.toString());
    NodeList aces = fileInfo.getElementsByTagName( ACES_ELEMENT_NAME );
    while ( aces != null && aces.getLength() > 0 ) {
      for ( int i = 0; i < aces.getLength(); i++ ) {
        Node ace = aces.item( i );
        ace.getParentNode().removeChild( ace );
      }
      aces = fileInfo.getElementsByTagName( ACES_ELEMENT_NAME );
    }
  }
View Full Code Here


  private void replacePermissionsWithAll( Element ace, Document fileInfo ) {
    NodeList perms = ace.getElementsByTagName( PERMISSIONS_ELEMENT_NAME );
    int childCount = perms.getLength();
    for ( int i = 0; i < childCount; i++ ) {
      Node perm = perms.item( i );
      if ( perm != null ) {
        ace.removeChild( perm );
      }
    }
    Element newPerm = fileInfo.createElement( PERMISSIONS_ELEMENT_NAME );
View Full Code Here

    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();
        String name = field.getName();
        String map = field.getMap() != null ? field.getMap() : field.getName();
        String v = getValue(elem, map);
        if (v == null) continue;
        if (type != null) {
          if (type.equals(Boolean.class)) {
            model.set(name, Boolean.parseBoolean(v));
          } else if (type.equals(Integer.class)) {
            model.set(name, Integer.parseInt(v));
          } else if (type.equals(Long.class)) {
            model.set(name, Long.parseLong(v));
          } else if (type.equals(Float.class)) {
            model.set(name, Float.parseFloat(v));
          } else if (type.equals(Double.class)) {
            model.set(name, Double.parseDouble(v));
          } else if (type.equals(Date.class)) {
            if ("timestamp".equals(field.getFormat())) {
              Date d = new Date(Long.parseLong(v) * 1000);
              model.set(name, d);
            } else {
              DateTimeFormat format = DateTimeFormat.getFormat(field.getFormat());
              Date d = format.parse(v);
              model.set(name, d);
            }
          }
        } else {
          model.set(field.getName(), v);
        }

      }
      records.add(model);
    }

    int totalCount = records.size();
    Node root = doc.getElementsByTagName(modelType.getRoot()).item(0);
    if (root != null && modelType.getTotalName() != null) {
      String tot = getValue((Element) root, modelType.getTotalName());
      if (tot != null) {
        totalCount = Integer.parseInt(tot);
      }
View Full Code Here

    NodeList variables = xmlDoc.getElementsByTagName("variable");
    if (variables.getLength() == 0) {
      throw new SparqlEmptyException("Variables missing from xml");
    }
    for (int i = 0; i < variables.getLength(); i++) {
      Node variable = variables.item(i);
      if (variable == null) {
        throw new SparqlParseException("Variable in head parsed as null");
      }
      String varName = ((Element)variable).getAttribute("name");
      if (varName == null) {
View Full Code Here

  private HashMap<String, HashMap<String, String>> getSolutionFromNode(Node node) {
    HashMap<String, HashMap<String, String>> solution = new HashMap<String, HashMap<String, String>>();
   
    NodeList bindings = ((Element) node).getElementsByTagName("binding");
    for (int i = 0; i < bindings.getLength(); i++) {
      Node binding = bindings.item(i);
      solution.put(((Element) binding).getAttribute("name"), getBindingFromNode(binding));
    }
    return solution;
  }
View Full Code Here

      rdfNode = extractValuesFromXmlNode(literals.item(0), new String[]{"xml:lang", "datatype"});
      rdfNode.put("type", "literal");
    }
    NodeList bnodes = ((Element) binding).getElementsByTagName("bnode");
    if (bnodes.getLength() > 0) {
      Node bnode = bnodes.item(0);
      rdfNode.put("type", "bnode");
      rdfNode.put("value", bnode.getFirstChild().getNodeValue());
    }
    NodeList uris = ((Element) binding).getElementsByTagName("uri");
    if (uris.getLength() > 0) {
      Node uri = uris.item(0);
      rdfNode.put("type", "uri");
      rdfNode.put("value", uri.getFirstChild().getNodeValue());
    }
    return rdfNode;
  }
View Full Code Here

    return rdfNode;
  }
 
  private HashMap<String, String> extractValuesFromXmlNode(Node xmlNode, String[] attributes) {
    HashMap<String, String> rdfNode = new HashMap<String, String>();
    Node firstChild = xmlNode.getFirstChild();
    if (firstChild != null) {
      String value = firstChild.getNodeValue();
      if (value != null) {
        rdfNode.put("value", value);
        for (String attribute: attributes) {
          String attributeValue = ((Element)xmlNode).getAttribute(attribute);
          if (attributeValue != null) rdfNode.put(attribute, attributeValue);
View Full Code Here

    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();
        String name = field.getName();
        String map = field.getMap() != null ? field.getMap() : field.getName();
        String v = getValue(elem, map);
        if (v == null) continue;
        if (type != null) {
          if (type.equals(Boolean.class)) {
            model.set(name, Boolean.parseBoolean(v));
          } else if (type.equals(Integer.class)) {
            model.set(name, Integer.parseInt(v));
          } else if (type.equals(Long.class)) {
            model.set(name, Long.parseLong(v));
          } else if (type.equals(Float.class)) {
            model.set(name, Float.parseFloat(v));
          } else if (type.equals(Double.class)) {
            model.set(name, Double.parseDouble(v));
          } else if (type.equals(Date.class)) {
            if ("timestamp".equals(field.getFormat())) {
              Date d = new Date(Long.parseLong(v) * 1000);
              model.set(name, d);
            } else {
              DateTimeFormat format = DateTimeFormat.getFormat(field.getFormat());
              Date d = format.parse(v);
              model.set(name, d);
            }
          }
        } else {
          model.set(field.getName(), v);
        }

      }
      records.add(model);
    }

    int totalCount = records.size();
    Node root = doc.getElementsByTagName(modelType.getRoot()).item(0);
    if (root != null && modelType.getTotalName() != null) {
      String tot = getValue((Element) root, modelType.getTotalName());
      if (tot != null) {
        totalCount = Integer.parseInt(tot);
      }
View Full Code Here

    Document doc = XMLParser.parse((String) data);

    NodeList list = doc.getElementsByTagName(modelType.recordName);
    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);
        String map = field.map != null ? field.map : field.name;
        String v = getValue(elem, map);
        model.set(field.name, v);
      }
      records.add(model);
    }

    int totalCount = records.size();

    Node root = doc.getElementsByTagName(modelType.root).item(0);
    if (root != null && modelType.totalName != null) {
      Node totalNode = root.getAttributes().getNamedItem(modelType.totalName);
      if (totalNode != null) {
        String sTot = totalNode.getNodeValue();
        totalCount = Integer.parseInt(sTot);
      }
    }
    ListLoadResult result = newLoadResult(loadConfig, records);
    if (result instanceof PagingLoadResult) {
View Full Code Here

      NodeList list = doc.getElementsByTagName(tag);
      if (list.getLength() == 0) {
        return null;
      }

      Node node = list.item(0);
      if (node.getNodeType() != Node.ELEMENT_NODE) {
        return null;
      }

      String ret = "";
      NodeList textNodes = node.getChildNodes();
      for (int i = 0; i < textNodes.getLength(); i++) {
        Node n = textNodes.item(i);
        if (n.getNodeType() == Node.TEXT_NODE && n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0) {
          ret += n.getNodeValue();
        } else if (n.getNodeType() == Node.CDATA_SECTION_NODE) {
          ret += n.getNodeValue();
        }
      }
      return ret.length() == 0 ? null : ret.replaceAll("^\\s+", "").replaceAll("\\s+$", "");
    }
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.