Skip to content

Commit

Permalink
[bugfix] rbrennan sidefragment - subsequence fixes to date.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Spencer committed Sep 7, 2012
1 parent ed47f0c commit d182024
Show file tree
Hide file tree
Showing 2 changed files with 389 additions and 102 deletions.
Expand Up @@ -116,6 +116,7 @@ public class SideFragment extends SimpleElement {
private int myPosition;
private int myMinOffset;
private int myMaxOffset;
private int originalMinOffset;
private SequenceMatcher matcher;
private boolean isInvalidFragment;

Expand All @@ -137,13 +138,14 @@ public final void setPosition(final int thePosition) {
* A minimum offset is the amount of bytes to skip before
* looking for this fragment.
*
* @param theMinOffset The minimum offset to begin looking for this fragment.
* @param offset The minimum offset to begin looking for this fragment.
*/
public final void setMinOffset(final int theMinOffset) {
this.myMinOffset = theMinOffset;
// ensure the maximum is never less than then minimum.
public final void setMinOffset(final int offset) {
this.myMinOffset = offset;
this.originalMinOffset = offset;
// ensure the maximum is never less than the minimum.
if (this.myMaxOffset < this.myMinOffset) {
this.myMaxOffset = theMinOffset;
this.myMaxOffset = offset;
}
}

Expand All @@ -153,16 +155,40 @@ public final void setMinOffset(final int theMinOffset) {
* than the minimum offset, then a range of bytes will be
* searched for this fragment.
*
* @param theMaxOffset The maximum offset to begin lookiing for this fragment.
* @param offset The maximum offset to begin looking for this fragment.
*/
public final void setMaxOffset(final int theMaxOffset) {
this.myMaxOffset = theMaxOffset;
public final void setMaxOffset(final int offset) {
this.myMaxOffset = offset;
// ensure the minimum is never greater than the maximum.
if (this.originalMinOffset > this.myMaxOffset) {
this.originalMinOffset = offset;
}
// ensure the minimum is never greater than the maximum.
if (this.myMinOffset > this.myMaxOffset) {
this.myMinOffset = theMaxOffset;
this.myMinOffset = offset;
}
}

/**
* The next offset is the new amount of bytes to skip before looking for
* this fragment after a previous match which failed on a subsequent fragment.
*
* @param offset The next minimum offset to begin looking for this fragment.
*/
public final void changeMinOffset(final int offset) {
if (offset >= this.originalMinOffset && offset <= this.myMaxOffset) {
this.myMinOffset = offset;
}
}

/**
* Reset the minimum offset to the original amount of bytes to skip
* before looking for this fragment.
*/
public final void resetMinOffset() {
this.myMinOffset = this.originalMinOffset;
}

/**
*
* @param expression The regular expression defining the fragment.
Expand Down Expand Up @@ -220,6 +246,16 @@ public final int getMinOffset() {
return myMinOffset;
}

/**
* A next offset is the new amount of bytes to skip before looking for
* this fragment after a previous match failed on a subsequent fragment.
*
* @return The next minimum offset to begin looking for this fragment.
*/
public final int getOriginalMinOffset() {
return originalMinOffset;
}

/**
* A maximum offset is the largest amount of bytes to look
* in for this fragment. If the maximum offset is greater
Expand Down

0 comments on commit d182024

Please sign in to comment.