Class EventSequence

java.lang.Object
com.topologi.diffx.sequence.EventSequence

public final class EventSequence extends Object
A sequence of events used for the Diff-X algorithm.

This class wraps a list of DiffXEvents and provide method to access and modify the content of the list using strongly typed methods.

Since:
0.7
Version:
6 December 2008
  • Field Details

    • prefixMapping

      private final PrefixMapping prefixMapping
      The prefix mapping for the elements in this sequence.
    • sequence

      private final List<DiffXEvent> sequence
      The sequence of events.
  • Constructor Details

    • EventSequence

      public EventSequence()
      Creates a new event sequence.
    • EventSequence

      public EventSequence(int size)
      Creates a new event sequence of the specified size.
      Parameters:
      size - The size of the sequence.
  • Method Details

    • addSequence

      public void addSequence(EventSequence seq)
      Adds a sequence of events to this sequence.
      Parameters:
      seq - The sequence of events to be added.
    • addEvent

      public void addEvent(DiffXEvent e)
      Adds an event to this sequence.
      Parameters:
      e - The event to be added.
    • addEvent

      public void addEvent(int i, DiffXEvent e)
      Inserts an event to this sequence at the specified position.
      Parameters:
      i - The position of the event.
      e - The event to be added.
    • getEvent

      public DiffXEvent getEvent(int i)
      Returns the event at position i.
      Parameters:
      i - The position of the event.
      Returns:
      the event at position i.
    • setEvent

      public DiffXEvent setEvent(int index, DiffXEvent e)
      Replaces an event of this sequence at the specified position.
      Parameters:
      index - The 0-based index of the position.
      e - The event to be inserted.
      Returns:
      The event at the previous position.
    • removeEvent

      public DiffXEvent removeEvent(int index)
      Removes an event from this sequence at the specified position.
      Parameters:
      index - The 0-based index of the position.
      Returns:
      The removed event.
    • size

      public int size()
      The size of the sequence.
      Returns:
      The number of events in the sequence.
    • eventIterator

      public EventSequence.EventIterator eventIterator()
      Returns a event iterator for this list.
      Returns:
      The event iterator for this sequence.
    • events

      public List<DiffXEvent> events()
      Returns the sequence of events.
      Returns:
      the sequence of events.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(EventSequence seq)
      Returns true if the specified event sequence is the same as this one.
      Parameters:
      seq - The sequence of events to compare with this one.
      Returns:
      true if the specified event sequence is equal to this one; false otherwise.
    • equals

      public boolean equals(Object o)
      Returns true if the specified event sequence is the same as this one.

      This method will redirect to the equals(EventSequence) method if the specified object is an instance of EventSequence.

      Overrides:
      equals in class Object
      Parameters:
      o - The sequence of events to compare with this one.
      Returns:
      true if the specified event sequence is equal to this one; false otherwise.
    • toString

      public String toString()
      Returns the string representation of this sequence.
      Overrides:
      toString in class Object
      Returns:
      The string representation of this sequence.
    • export

      public void export(PrintWriter w)
      Export the sequence.
      Parameters:
      w - The print writer receiving the SAX events.
    • mapPrefix

      public void mapPrefix(String uri, String prefix) throws NullPointerException
      Maps a namespace URI to a prefix.
      Parameters:
      uri - The namespace URI to map.
      prefix - The prefix to use.
      Throws:
      NullPointerException - if the URI or prefix is null
      See Also:
    • getPrefixMapping

      public PrefixMapping getPrefixMapping()
      Returns the prefix mapping for the namespace URIs in this sequence.
      Returns:
      the prefix mapping for the namespace URIs in this sequence.