com.topologi.diffx.sequence
Class EventSequence

java.lang.Object
  extended bycom.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.

Version:
14 April 2005
Author:
Christophe Lauret

Nested Class Summary
 class EventSequence.EventIterator
          An iterator over the event elements in the sequences.
 
Constructor Summary
EventSequence()
          Creates a new event sequence.
EventSequence(int size)
          Creates a new event sequence of the specified size.
 
Method Summary
 void addEvent(DiffXEvent e)
          Adds an event to this sequence.
 void addEvent(int i, DiffXEvent e)
          Inserts an event to this sequence at the specified position.
 void addSequence(EventSequence seq)
          Adds a sequence of events to this sequence.
 boolean equals(EventSequence seq)
          Returns true if the specified event sequence is the same as this one.
 boolean equals(Object o)
          Returns true if the specified event sequence is the same as this one.
 EventSequence.EventIterator eventIterator()
          Returns a event iterator for this list.
 void export(PrintWriter w)
          Export the sequence.
 DiffXEvent getEvent(int i)
          Returns the event at position i.
 PrefixMapping getPrefixMapping()
          Returns the prefix mapping for the namespace URIs in this sequence.
 int hashCode()
           
 void mapPrefix(String uri, String prefix)
          Maps a uri to a prefix.
 DiffXEvent removeEvent(int index)
          Removes an event from this sequence at the specified position.
 DiffXEvent setEvent(int index, DiffXEvent e)
          Replaces an event of this sequence at the specified position.
 int size()
          The size of the sequence.
 String toString()
          Returns the string representation of this sequence.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 Detail

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.

hashCode

public int hashCode()
See Also:
Object.hashCode()

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 methdo will redirect to the equals(EventSequence) method if the specified object is an instance of EventSequence.

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.

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 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:
PrefixMapping.add(String, String)

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.