Package com.google.gwt.dom.client

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


  public void insert(HtmlObject child, int beforeIndex) {
    if (beforeIndex >= getChildCount()) {
      add(child);
      return;
    }
    Node beforeNode = getElement().getChild(beforeIndex);
    getElement().insertBefore(child.getElement(), beforeNode);
    child.setParent(this);

    List<HtmlObject> newChildList = new ArrayList<HtmlObject>();
    for (int i = 0; i < children.size(); i++) {
View Full Code Here


     *
     * @param context the XPath evaluation context
     */

    public void apply(XPathContext context) throws XPathException {
        Node parent = targetNode.getParentElement();
        if (parent != null) {
            parent.removeChild(targetNode);
        }
    }
View Full Code Here

                    targetNode.appendChild(content.getFirstChild());
                }
                break;
            }
            case BEFORE: {
                Node refNode = targetNode.getChild(position);
                NodeList list = content.getChildNodes();
                int count = list.getLength();
                for (int i=0; i < count; i++) {
                    targetNode.insertBefore(list.getItem(i), refNode);
                }
                break;
            }
            case AFTER: {
                Node refNode = targetNode.getChild(position);
                NodeList list = content.getChildNodes();
                int count = list.getLength();
                for (int i=count-1; i>=0; i--) {
                    targetNode.insertAfter(list.getItem(i), refNode);
                }
View Full Code Here

     *         is no such element. This relies on the getElementById() method in the
     *         underlying DOM.
     */

    public NodeInfo selectID(String id) {
      Node el;
      // IE does not support getElementById for XML documents
      // but it does support it for XHTML if its the host page
      Document doc = ((Document)node);

      if (!isHttpRequested) {
          el = (doc).getElementById(id);
          if (el == null) {
              return null;
          }
          return wrap(el);
      } else {
            if (idIndex != null) {
                return idIndex.get(id);
            } else {
                idIndex = new HashMap();
                AxisIterator iter = iterateAxis(Axis.DESCENDANT, NodeKindTest.ELEMENT);
                boolean useNS = isNSok(node);
                while (true) {
                    NodeInfo node = (NodeInfo)iter.next();
                    if (node == null) {
                        break;
                    }
                    Node testNode = (Node)((HTMLNodeWrapper)node).getUnderlyingNode();
                    String xmlId = (useNS)? getXmlIdNS(testNode) : getXmlId(testNode);
                    //String xmlId = ((Element)((HTMLNodeWrapper)node).getUnderlyingNode()).getAttribute("xml:id");
                    if (xmlId != null && !xmlId.isEmpty()) {
                        idIndex.put(xmlId, (HTMLNodeWrapper)node);
                    }
View Full Code Here

            element = (Element)document.getFirstChild();
          } else {
            element = (Element)document.getElementsByTagName(localName.toUpperCase()).getItem(0);
            NodeList<Node> nodes = element.getChildNodes();
            for (int n = 0; n < nodes.getLength(); n++) {
              Node node = nodes.getItem(n);
              node.removeFromParent();
            }
          }
          currentNode = element;
          level++;
          return;
View Full Code Here

            case Type.TEXT:
                if (span == 1) {
                    return emptyIfNull(getValue(node));
                } else {
                    FastStringBuffer fsb = new FastStringBuffer(FastStringBuffer.SMALL);
                    Node textNode = node;
                    for (int i=0; i<span; i++) {
                        fsb.append(emptyIfNull(getValue(textNode)));
                        textNode = textNode.getNextSibling();
                    }
                    return fsb.condense();
                }

            case Type.COMMENT:
View Full Code Here

    }

    private static void expandStringValue(NodeList list, StringBuffer sb) {
        final int len = list.getLength();
        for (int i = 0; i < len; i++) {
            Node child = list.getItem(i);
            switch (child.getNodeType()) {
                case Node.ELEMENT_NODE:
                    expandStringValue(child.getChildNodes(), sb);                   
                    break;
                case Type.COMMENT:
                case Type.PROCESSING_INSTRUCTION:
                    break;
                default:
View Full Code Here

        if (parent==null) {
            switch (getNodeKind()) {
            case Type.ATTRIBUTE:
                throw new IllegalStateException("parent of attribute node is unknown");
            default:
                Node p = node.getParentNode();
                if (p==null) {
                    return null;
                } else {
                    parent = makeWrapper(p, docWrapper);
                }
View Full Code Here

                case Type.ELEMENT:
                case Type.TEXT:
                case Type.COMMENT:
                case Type.PROCESSING_INSTRUCTION:
                    int ix = 0;
                    Node start = node;
                    while (true) {
                        start = start.getPreviousSibling();
                        if (start == null) {
                            index = ix;
                            return ix;
                        }
                        ix++;
View Full Code Here

        ArrayList<HTMLAttributeNode> nodeAtts = new ArrayList<HTMLAttributeNode>();
        namespaceBindings = new ArrayList<NamespaceBinding>();
        // assume attributes within HTML doc have no namespace - unless they have a prefix
        boolean getNamespaces = (docWrapper.getDocType() != DocType.HTML);
        for (int i=0; i<len; i++) {
          Node attNode = attributes.get(i);
          String name = attNode.getNodeName();
          String val = "";
          try {
          val = getValue(attNode); // changed for compatibility
          } catch(Exception e){
            String rp = getTypeOfNodeValue(attNode);
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.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.