summaryrefslogtreecommitdiff
path: root/java/util/regex/Matcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/util/regex/Matcher.java')
-rw-r--r--java/util/regex/Matcher.java118
1 files changed, 59 insertions, 59 deletions
diff --git a/java/util/regex/Matcher.java b/java/util/regex/Matcher.java
index 50cb065f2..c27a70bf9 100644
--- a/java/util/regex/Matcher.java
+++ b/java/util/regex/Matcher.java
@@ -70,9 +70,9 @@ public final class Matcher implements MatchResult
* The end of the region of the input on which to match.
*/
private int regionEnd;
-
+
/**
- * True if the match process should look beyond the
+ * True if the match process should look beyond the
* region marked by regionStart to regionEnd when
* performing lookAhead, lookBehind and boundary
* matching.
@@ -101,7 +101,7 @@ public final class Matcher implements MatchResult
transparentBounds = false;
anchoringBounds = 0;
}
-
+
/**
* @param sb The target string buffer
* @param replacement The replacement string
@@ -116,9 +116,9 @@ public final class Matcher implements MatchResult
{
assertMatchOp();
sb.append(input.subSequence(appendPosition,
- match.getStartIndex()).toString());
+ match.getStartIndex()).toString());
sb.append(RE.getReplacement(replacement, match,
- RE.REG_REPLACE_USE_BACKSLASHESCAPE));
+ RE.REG_REPLACE_USE_BACKSLASHESCAPE));
appendPosition = match.getEndIndex();
return this;
}
@@ -131,7 +131,7 @@ public final class Matcher implements MatchResult
sb.append(input.subSequence(appendPosition, input.length()).toString());
return sb;
}
-
+
/**
* @exception IllegalStateException If no match has yet been attempted,
* or if the previous match operation failed
@@ -142,7 +142,7 @@ public final class Matcher implements MatchResult
assertMatchOp();
return match.getEndIndex();
}
-
+
/**
* @param group The index of a capturing group in this matcher's pattern
*
@@ -157,7 +157,7 @@ public final class Matcher implements MatchResult
assertMatchOp();
return match.getEndIndex(group);
}
-
+
public boolean find ()
{
boolean first = (match == null);
@@ -165,28 +165,28 @@ public final class Matcher implements MatchResult
match = pattern.getRE().getMatch(inputCharIndexed, position, anchoringBounds);
else
match = pattern.getRE().getMatch(input.subSequence(regionStart, regionEnd),
- position, anchoringBounds);
+ position, anchoringBounds);
if (match != null)
{
- int endIndex = match.getEndIndex();
- // Are we stuck at the same position?
- if (!first && endIndex == position)
- {
- match = null;
- // Not at the end of the input yet?
- if (position < input.length() - 1)
- {
- position++;
- return find(position);
- }
- else
- return false;
- }
- position = endIndex;
- return true;
+ int endIndex = match.getEndIndex();
+ // Are we stuck at the same position?
+ if (!first && endIndex == position)
+ {
+ match = null;
+ // Not at the end of the input yet?
+ if (position < input.length() - 1)
+ {
+ position++;
+ return find(position);
+ }
+ else
+ return false;
+ }
+ position = endIndex;
+ return true;
}
return false;
- }
+ }
/**
* @param start The index to start the new pattern matching
@@ -200,15 +200,15 @@ public final class Matcher implements MatchResult
match = pattern.getRE().getMatch(inputCharIndexed, start, anchoringBounds);
else
match = pattern.getRE().getMatch(input.subSequence(regionStart, regionEnd),
- start, anchoringBounds);
+ start, anchoringBounds);
if (match != null)
{
- position = match.getEndIndex();
- return true;
+ position = match.getEndIndex();
+ return true;
}
return false;
}
-
+
/**
* @exception IllegalStateException If no match has yet been attempted,
* or if the previous match operation failed
@@ -218,7 +218,7 @@ public final class Matcher implements MatchResult
assertMatchOp();
return match.toString();
}
-
+
/**
* @param group The index of a capturing group in this matcher's pattern
*
@@ -242,7 +242,7 @@ public final class Matcher implements MatchResult
reset();
// Semantics might not quite match
return pattern.getRE().substitute(input, replacement, position,
- RE.REG_REPLACE_USE_BACKSLASHESCAPE);
+ RE.REG_REPLACE_USE_BACKSLASHESCAPE);
}
/**
@@ -252,36 +252,36 @@ public final class Matcher implements MatchResult
{
reset();
return pattern.getRE().substituteAll(input, replacement, position,
- RE.REG_REPLACE_USE_BACKSLASHESCAPE);
+ RE.REG_REPLACE_USE_BACKSLASHESCAPE);
}
-
+
public int groupCount ()
{
return pattern.getRE().getNumSubs();
}
-
+
public boolean lookingAt ()
{
if (transparentBounds || (regionStart == 0 && regionEnd == input.length()))
match = pattern.getRE().getMatch(inputCharIndexed, regionStart,
- anchoringBounds|RE.REG_FIX_STARTING_POSITION|RE.REG_ANCHORINDEX);
+ anchoringBounds|RE.REG_FIX_STARTING_POSITION|RE.REG_ANCHORINDEX);
else
match = pattern.getRE().getMatch(input.subSequence(regionStart, regionEnd), 0,
- anchoringBounds|RE.REG_FIX_STARTING_POSITION);
+ anchoringBounds|RE.REG_FIX_STARTING_POSITION);
if (match != null)
{
- if (match.getStartIndex() == 0)
- {
- position = match.getEndIndex();
- return true;
- }
- match = null;
+ if (match.getStartIndex() == 0)
+ {
+ position = match.getEndIndex();
+ return true;
+ }
+ match = null;
}
return false;
}
-
+
/**
- * Attempts to match the entire input sequence against the pattern.
+ * Attempts to match the entire input sequence against the pattern.
*
* If the match succeeds then more information can be obtained via the
* start, end, and group methods.
@@ -294,23 +294,23 @@ public final class Matcher implements MatchResult
{
if (transparentBounds || (regionStart == 0 && regionEnd == input.length()))
match = pattern.getRE().getMatch(inputCharIndexed, regionStart,
- anchoringBounds|RE.REG_TRY_ENTIRE_MATCH|RE.REG_FIX_STARTING_POSITION|RE.REG_ANCHORINDEX);
+ anchoringBounds|RE.REG_TRY_ENTIRE_MATCH|RE.REG_FIX_STARTING_POSITION|RE.REG_ANCHORINDEX);
else
match = pattern.getRE().getMatch(input.subSequence(regionStart, regionEnd), 0,
- anchoringBounds|RE.REG_TRY_ENTIRE_MATCH|RE.REG_FIX_STARTING_POSITION);
+ anchoringBounds|RE.REG_TRY_ENTIRE_MATCH|RE.REG_FIX_STARTING_POSITION);
if (match != null)
{
- if (match.getStartIndex() == 0)
- {
- position = match.getEndIndex();
- if (position == input.length())
- return true;
- }
- match = null;
+ if (match.getStartIndex() == 0)
+ {
+ position = match.getEndIndex();
+ if (position == input.length())
+ return true;
+ }
+ match = null;
}
return false;
}
-
+
/**
* Returns the Pattern that is interpreted by this Matcher
*/
@@ -318,7 +318,7 @@ public final class Matcher implements MatchResult
{
return pattern;
}
-
+
/**
* Resets the internal state of the matcher, including
* resetting the region to its default state of encompassing
@@ -340,7 +340,7 @@ public final class Matcher implements MatchResult
appendPosition = 0;
return this;
}
-
+
/**
* Resets the internal state of the matcher, including
* resetting the region to its default state of encompassing
@@ -360,7 +360,7 @@ public final class Matcher implements MatchResult
this.inputCharIndexed = RE.makeCharIndexed(input, 0);
return reset();
}
-
+
/**
* @return the index of a capturing group in this matcher's pattern
*
@@ -493,7 +493,7 @@ public final class Matcher implements MatchResult
{
return regionStart;
}
-
+
/**
* The end of the region on which to perform matches (exclusive).
*