Class NaiveSequenceSlicer
The slice does modify the original sequences.
Note: Using this class may lead to problems in the execution of the Diff-X algorithm and incorrect results, because it could potentially take off some parts that helps the Diff-X algorithm ensuring that the XML is well-formed.
- Version:
- 6 December 2008
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) EventSequenceThe common end between the two sequences.(package private) final EventSequenceThe first sequence of events to test.(package private) final EventSequenceThe second sequence of events to test.(package private) EventSequenceThe common start between the two sequences. -
Constructor Summary
ConstructorsConstructorDescriptionNaiveSequenceSlicer(EventSequence seq0, EventSequence seq1) Creates a new sequence slicer. -
Method Summary
Modifier and TypeMethodDescriptionvoidformatEnd(DiffXFormatter formatter) Formats the end subsequence that has been buffered by this class.voidformatStart(DiffXFormatter formatter) Formats the start subsequence that has been buffered by this class.getEnd()Returns the current end sequence buffer.getStart()Returns the current start sequence buffer.intsliceEnd()Slices the end of both sequences.intsliceEnd(DiffXFormatter formatter) Slices the end of both sequences and formats the start subsequence with the specified formatter.intSlices the start of both sequences.intsliceStart(DiffXFormatter formatter) Slices the start of both sequences and formats the start subsequence with the specified formatter.
-
Field Details
-
sequence1
The first sequence of events to test. -
sequence2
The second sequence of events to test. -
start
EventSequence startThe common start between the two sequences. -
end
EventSequence endThe common end between the two sequences.
-
-
Constructor Details
-
NaiveSequenceSlicer
Creates a new sequence slicer.- Parameters:
seq0- The first sequence to slice.seq1- The second sequence to slice.
-
-
Method Details
-
sliceStart
Slices the start of both sequences.The common start sequence will be stroed in the class until the next
formatStart(DiffXFormatter)is called.- Returns:
- The number of common elements at the start of the sequences.
- Throws:
IllegalStateException- If the start buffer is not empty.
-
sliceEnd
Slices the end of both sequences.The common end sequence will be stored in the class until the next
formatEnd(DiffXFormatter)is called.- Returns:
- The number of common elements at the end of the sequences.
- Throws:
IllegalStateException- If the end buffer is not empty.
-
sliceStart
public int sliceStart(DiffXFormatter formatter) throws IllegalStateException, NullPointerException, IOException Slices the start of both sequences and formats the start subsequence with the specified formatter.Implementation note: although this is functionally equivalent to call successively the methods
sliceStart()andformatStart(DiffXFormatter), this method is optimised and passes the event directly to the formatter without using a buffer.- Parameters:
formatter- The formatter that will handle the output.- Returns:
- The number of common elements at the start of the sequences.
- Throws:
IllegalStateException- If the start buffer is not empty.NullPointerException- If the specified formatter isnull.IOException- If an error occurs whilst writing with the formatter.
-
sliceEnd
public int sliceEnd(DiffXFormatter formatter) throws IllegalStateException, NullPointerException, IOException Slices the end of both sequences and formats the start subsequence with the specified formatter.Implementation note: although this is exactly equivalent to successive calls to the methods
sliceEnd()andformatEnd(DiffXFormatter).- Parameters:
formatter- The formatter that will handle the output.- Returns:
- The number of common elements at the end of the sequences.
- Throws:
IllegalStateException- If the end buffer is not empty.NullPointerException- If the specified formatter isnull.IOException- If an error occurs whilst writing with the formatter.
-
formatStart
Formats the start subsequence that has been buffered by this class.This method will clear the buffer, but will do nothing if the start buffer is
null.- Parameters:
formatter- The formatter that will handle the output.- Throws:
NullPointerException- If the specified formatter isnull.IOException- If an error occurs whilst writing with the formatter.
-
formatEnd
Formats the end subsequence that has been buffered by this class.This method will clear the buffer, but will do nothing if the end buffer is
null.- Parameters:
formatter- The formatter that will handle the output.- Throws:
NullPointerException- If the specified formatter isnull.IOException- If an error occurs whilst writing with the formatter.
-
getStart
Returns the current start sequence buffer.- Returns:
- The current start sequence buffer or
nullif none.
-
getEnd
Returns the current end sequence buffer.- Returns:
- The current end sequence buffer or
nullif none.
-