예제 #1
0
 public Node getNamedItem(String name) {
   for (IIOMetadataNode node : list) {
     if (name.equals(node.getNodeName())) {
       return node;
     }
   }
   return null;
 }
예제 #2
0
  public Node cloneNode(boolean deep) {
    IIOMetadataNode cloned = new IIOMetadataNode(nodeName);
    cloned.setUserObject(getUserObject());

    if (deep) { // Clone recursively
      IIOMetadataNode c = firstChild;
      while (c != null) {
        cloned.insertBefore(c.cloneNode(true), null);
        c = c.nextSibling;
      }
    }

    return cloned; // To change body of implemented methods use File | Settings | File Templates.
  }
예제 #3
0
  public Node removeChild(Node oldChild) throws DOMException {
    if (oldChild == null) {
      throw new IllegalArgumentException(Messages.getString("imageio.62"));
    }

    IIOMetadataNode oldIIOChild = (IIOMetadataNode) oldChild;

    // Fix next and previous
    IIOMetadataNode previous = oldIIOChild.previousSibling;
    IIOMetadataNode next = oldIIOChild.nextSibling;

    if (previous != null) {
      previous.nextSibling = next;
    }
    if (next != null) {
      next.previousSibling = previous;
    }

    // Fix this node
    if (lastChild == oldIIOChild) {
      lastChild = previous;
    }
    if (firstChild == oldIIOChild) {
      firstChild = next;
    }
    nChildren--;

    // Fix old child
    oldIIOChild.parent = null;
    oldIIOChild.previousSibling = null;
    oldIIOChild.nextSibling = null;

    return oldIIOChild;
  }
예제 #4
0
  public Node insertBefore(Node newChild, Node refChild) throws DOMException {
    if (newChild == null) {
      throw new IllegalArgumentException(Messages.getString("imageio.61"));
    }

    IIOMetadataNode newIIOChild = (IIOMetadataNode) newChild;
    IIOMetadataNode refIIOChild = (IIOMetadataNode) refChild;

    newIIOChild.parent = this;

    if (refIIOChild == null) {
      newIIOChild.nextSibling = null;
      newIIOChild.previousSibling = lastChild;

      // Fix this node
      lastChild = newIIOChild;
      if (firstChild == null) {
        firstChild = newIIOChild;
      }
    } else {
      newIIOChild.nextSibling = refIIOChild;
      newIIOChild.previousSibling = refIIOChild.previousSibling;

      // Fix this node
      if (firstChild == refIIOChild) {
        firstChild = newIIOChild;
      }

      // Fix next node
      if (refIIOChild != null) {
        refIIOChild.previousSibling = newIIOChild;
      }
    }

    // Fix prev node
    if (newIIOChild.previousSibling != null) {
      newIIOChild.previousSibling.nextSibling = newIIOChild;
    }

    nChildren++;

    return newIIOChild;
  }
예제 #5
0
  public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
    if (newChild == null) {
      throw new IllegalArgumentException(Messages.getString("imageio.61"));
    }

    IIOMetadataNode newIIOChild = (IIOMetadataNode) newChild;
    IIOMetadataNode oldIIOChild = (IIOMetadataNode) oldChild;

    IIOMetadataNode next = oldIIOChild.nextSibling;
    IIOMetadataNode previous = oldIIOChild.previousSibling;

    // Fix new node
    newIIOChild.parent = this;
    newIIOChild.nextSibling = next;
    newIIOChild.previousSibling = previous;

    // Fix this node
    if (lastChild == oldIIOChild) {
      lastChild = newIIOChild;
    }
    if (firstChild == oldIIOChild) {
      firstChild = newIIOChild;
    }

    // Fix siblings
    if (next != null) {
      next.previousSibling = newIIOChild;
    }
    if (previous != null) {
      previous.nextSibling = newIIOChild;
    }

    // Fix old child
    oldIIOChild.parent = null;
    oldIIOChild.nextSibling = next;
    oldIIOChild.previousSibling = previous;

    return oldIIOChild;
  }