public final class ElementState extends Object
This class has two purposes, firstly to provide an object that is more specialised than the generic lists and stack for use by the DiffX algorithms. Second, to delegate some of the complexity of algorithm.
This class has several methods that are similar to List
interface
but does not implement it.
This class is not synchronised and is not meant to be serializable.
Constructor and Description |
---|
ElementState()
Constructs an empty stack with an initial capacity of 12.
|
ElementState(int initialCapacity)
Constructs an stack of elements with the specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the elements from this list.
|
boolean |
contains(OpenElementEvent element)
Returns
true if this list contains the specified element. |
OpenElementEvent |
current()
Returns the current open element.
|
char |
currentChange()
Returns the change of the current open element.
|
void |
delete(DiffXEvent e)
Updates the state from the deleted event.
|
void |
ensureCapacity(int minCapacity)
Increases the capacity of this class instance, if necessary, to ensure
that it can hold at least the number of elements specified by the
minimum capacity argument.
|
void |
format(DiffXEvent e)
Updates the state from the formatted event.
|
OpenElementEvent |
get(int index)
Returns the open element at the specified position in this list.
|
boolean |
hasPriorityOver(DiffXEvent e1,
DiffXEvent e2)
Indicates whether the first specified event has priority over the second element.
|
int |
indexOf(OpenElementEvent element)
Searches for the first occurrence of the given argument, testing
for equality using the
equals method. |
void |
insert(DiffXEvent e)
Updates the state from the inserted event.
|
boolean |
isEmpty()
Tests if this list has no elements.
|
int |
lastIndexOf(OpenElementEvent element)
Returns the index of the last occurrence of the specified object in
this list.
|
boolean |
matchCurrent(DiffXEvent e)
Indicates whether the specified event is a close element that
matches the name and URI of the current open element.
|
boolean |
okDelete(DiffXEvent e)
Indicates whether the specified event is a close element that
matches the name and URI of the current open element.
|
boolean |
okFormat(DiffXEvent e)
Indicates whether the specified event is a close element that
matches the name and URI of the current open element.
|
boolean |
okInsert(DiffXEvent e)
Indicates whether the specified event is a close element that
matches the name and URI of the current open element.
|
OpenElementEvent |
pop()
Removes the last element from the top of the stack.
|
OpenElementEvent |
remove(int index)
Removes the element at the specified position in this list.
|
int |
size()
Returns the number of elements in this stack.
|
public ElementState(int initialCapacity) throws IllegalArgumentException
initialCapacity
- The initial capacity of the list.IllegalArgumentException
- if the specified initial capacity is negative.public ElementState()
public void ensureCapacity(int minCapacity)
minCapacity
- The desired minimum capacity.public int size()
public boolean isEmpty()
true
if this list has no elements;
false
otherwise.public boolean contains(OpenElementEvent element)
true
if this list contains the specified element.element
- Element whose presence is to be tested.true
if the specified element is present;
false
otherwise.public int indexOf(OpenElementEvent element)
equals
method.element
- The open elemnt to find.-1
DiffXEvent.equals(DiffXEvent)
public int lastIndexOf(OpenElementEvent element)
element
- The desired element.public OpenElementEvent current()
null
if none.public char currentChange()
public boolean matchCurrent(DiffXEvent e)
e
- The event to check.true
if it matches the current element;
false
otherwise.public void insert(DiffXEvent e)
e
- The inserted event.public void format(DiffXEvent e)
e
- The formatted event.public void delete(DiffXEvent e)
e
- The deleted event.public boolean okFormat(DiffXEvent e)
e
- The event to check.true
if it matches the current element;
false
otherwise.public boolean okInsert(DiffXEvent e)
e
- The event to check.true
if it matches the current element;
false
otherwise.public boolean okDelete(DiffXEvent e)
e
- The event to check.true
if it matches the current element;
false
otherwise.public boolean hasPriorityOver(DiffXEvent e1, DiffXEvent e2)
e1
- The element assumed to have priority.e2
- The other element.true
if first specified event has priority over the second element;
false
otherwise.public OpenElementEvent pop()
public OpenElementEvent get(int index) throws IndexOutOfBoundsException
index
- index of element to return.IndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= size())
.public OpenElementEvent remove(int index) throws IndexOutOfBoundsException
index
- The index of the element to removed.IndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= size())
.public void clear()
Copyright © 2007-2014. All Rights Reserved.