Package com.topologi.diffx.event

Examples of com.topologi.diffx.event.OpenElementEvent


      e = sequence.getEvent(i);
      if (e instanceof OpenElementEvent) {
        open.push(e);
      } else if (e instanceof CloseElementEvent) {
        if (open.empty()) return false;
        OpenElementEvent o = (OpenElementEvent)open.peek();
        String lastOpenElementName = o.getName();
        String closeElementName = ((CloseElementEvent)e).getName();
        if (!closeElementName.equals(lastOpenElementName)) return false;
      }
    }
    return open.empty();
View Full Code Here


    if (this.currentWeight > 0) {
      this.weights.add(Integer.valueOf(this.currentWeight));
    }
    this.currentWeight = 1;
    // namespace handling
    OpenElementEvent open = null;
    // namespace aware configuration
    if (this.config.isNamespaceAware()) {
      String uri = element.getNamespaceURI() == null? "" : element.getNamespaceURI();
      String name = element.getLocalName();
      handlePrefixMapping(uri, element.getPrefix());
      open = this.efactory.makeOpenElement(uri, name);
      // not namespace aware
    } else {
      open = this.efactory.makeOpenElement(null, element.getNodeName());
    }

    this.sequence.addEvent(open);
    NamedNodeMap atts = element.getAttributes();
    // only 1 attribute, just load it
    if (atts.getLength() == 1) {
      load((Attr)atts.item(0));
      // several attributes sort them in alphabetical order
      // TODO: also use URI
    } else if (atts.getLength() > 1) {
      String[] names = new String[atts.getLength()];
      for (int i = 0; i < atts.getLength(); i++) {
        Attr attr = (Attr)atts.item(i);
        names[i] = attr.getName();
      }
      Arrays.sort(names);
      for (String name : names) {
        load((Attr)atts.getNamedItem(name));
      }
    }
    // load all the child nodes
    NodeList list = element.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
      loadNode(list.item(i));
    }
    CloseElementEvent close = this.efactory.makeCloseElement(open);
    this.sequence.addEvent(close);
    // handle the weights
    close.setWeight(this.currentWeight);
    open.setWeight(this.currentWeight);
    this.currentWeight += popWeight();
  }
View Full Code Here

      recordCharacters();
      if (this.currentWeight > 0) {
        this.weights.add(new Integer(this.currentWeight));
      }
      this.currentWeight = 1;
      OpenElementEvent open = this.efactory.makeOpenElement(uri, localName, qName);
      this.openElements.add(open);
      SAXRecorder.this.sequence.addEvent(open);
      handleAttributes(atts);
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public void endElement(String uri, String localName, String qName) {
      recordCharacters();
      OpenElementEvent open = popLastOpenElement();
      open.setWeight(this.currentWeight);
      CloseElementEvent close = this.efactory.makeCloseElement(open);
      close.setWeight(this.currentWeight);
      SAXRecorder.this.sequence.addEvent(close);
      // calculate weights
      this.currentWeight += popWeight();
View Full Code Here

        closeIns();
      }
      if (this.isDeleting) {
        closeDel();
      }
      OpenElementEvent oee = (OpenElementEvent)e;
      this.xml.print('<'+oee.getName());
      if (this.declareNamespace) {
        this.xml.print(" xmlns:dfx=\""+Constants.BASE_NS_URI+"\"");
        this.declareNamespace = false;
      }
      this.isElementNude = true;
View Full Code Here

        denudeElement();
      }
      if (this.isDeleting) {
        closeDel();
      }
      OpenElementEvent oee = (OpenElementEvent)e;
      this.xml.print('<'+oee.getName());
      if (this.declareNamespace) {
        this.xml.print(" xmlns:dfx=\"http://www.allette.com.au/diffex\"");
      }
      this.xml.print(" dfx:insert=\"true\"");
      this.isElementNude = true;
View Full Code Here

      closeIns();
    }

    // delete an element
    if (e instanceof OpenElementEvent) {
      OpenElementEvent oee = (OpenElementEvent)e;
      this.xml.print('<'+oee.getName());
      if (this.declareNamespace) {
        this.xml.print(" xmlns:dfx=\"http://www.allette.com.au/diffex\"");
      }
      this.xml.print(" dfx:delete=\"true\"");
      this.xml.print('>');
View Full Code Here

   * @throws IndexOutOfBoundsException if index is out of range
   *         <code>(index &lt; 0 || index &gt;= size())</code>.
   */
  public OpenElementEvent remove(int index) throws IndexOutOfBoundsException {
    checkRange(index);
    OpenElementEvent oldValue = this.openElements[index];
    int numMoved = this.size - index - 1;
    if (numMoved > 0) {
      System.arraycopy(this.openElements, index+1, this.openElements, index, numMoved);
    }
    this.openElements[--this.size] = null; // Let gc do its work
View Full Code Here

TOP

Related Classes of com.topologi.diffx.event.OpenElementEvent

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.