46 *
47 * <ul>
48 *
49 * <li><p> The {@link #matches matches} method attempts to match the entire
50 * input sequence against the pattern. </p></li>
51 *
52 * <li><p> The {@link #lookingAt lookingAt} method attempts to match the
53 * input sequence, starting at the beginning, against the pattern. </p></li>
54 *
55 * <li><p> The {@link #find find} method scans the input sequence looking for
56 * the next subsequence that matches the pattern. </p></li>
57 *
58 * </ul>
59 *
60 * <p> Each of these methods returns a boolean indicating success or failure.
61 * More information about a successful match can be obtained by querying the
62 * state of the matcher.
63 *
64 * <p> A matcher finds matches in a subset of its input called the
65 * <i>region</i>. By default, the region contains all of the matcher's input.
66 * The region can be modified via the{@link #region region} method and queried
67 * via the {@link #regionStart regionStart} and {@link #regionEnd regionEnd}
68 * methods. The way that the region boundaries interact with some pattern
69 * constructs can be changed. See {@link #useAnchoringBounds
70 * useAnchoringBounds} and {@link #useTransparentBounds useTransparentBounds}
71 * for more details.
72 *
73 * <p> This class also defines methods for replacing matched subsequences with
74 * new strings whose contents can, if desired, be computed from the match
75 * result. The {@link #appendReplacement appendReplacement} and {@link
76 * #appendTail appendTail} methods can be used in tandem in order to collect
77 * the result into an existing string buffer or string builder. Alternatively,
78 * the more convenient {@link #replaceAll replaceAll} method can be used to
79 * create a string in which every matching subsequence in the input sequence
80 * is replaced.
81 *
82 * <p> The explicit state of a matcher includes the start and end indices of
83 * the most recent successful match. It also includes the start and end
84 * indices of the input subsequence captured by each <a
85 * href="Pattern.html#cg">capturing group</a> in the pattern as well as a total
86 * count of such subsequences. As a convenience, methods are also provided for
1622 * @param b a boolean indicating whether or not to use anchoring bounds.
1623 * @return this matcher
1624 * @see java.util.regex.Matcher#hasAnchoringBounds
1625 * @since 1.5
1626 */
1627 public Matcher useAnchoringBounds(boolean b) {
1628 anchoringBounds = b;
1629 return this;
1630 }
1631
1632 /**
1633 * <p>Returns the string representation of this matcher. The
1634 * string representation of a <code>Matcher</code> contains information
1635 * that may be useful for debugging. The exact format is unspecified.
1636 *
1637 * @return The string representation of this matcher
1638 * @since 1.5
1639 */
1640 public String toString() {
1641 StringBuilder sb = new StringBuilder();
1642 sb.append("java.util.regex.Matcher");
1643 sb.append("[pattern=" + pattern());
1644 sb.append(" region=");
1645 sb.append(regionStart() + "," + regionEnd());
1646 sb.append(" lastmatch=");
1647 if ((first >= 0) && (group() != null)) {
1648 sb.append(group());
1649 }
1650 sb.append("]");
1651 return sb.toString();
1652 }
1653
1654 /**
1655 * <p>Returns true if the end of input was hit by the search engine in
1656 * the last match operation performed by this matcher.
1657 *
1658 * <p>When this method returns true, then it is possible that more input
1659 * would have changed the result of the last search.
1660 *
1661 * @return true iff the end of input was hit in the last match; false
1662 * otherwise
1663 * @since 1.5
1664 */
1665 public boolean hitEnd() {
1666 return hitEnd;
1667 }
1668
1669 /**
1670 * <p>Returns true if more input could change a positive match into a
|
46 *
47 * <ul>
48 *
49 * <li><p> The {@link #matches matches} method attempts to match the entire
50 * input sequence against the pattern. </p></li>
51 *
52 * <li><p> The {@link #lookingAt lookingAt} method attempts to match the
53 * input sequence, starting at the beginning, against the pattern. </p></li>
54 *
55 * <li><p> The {@link #find find} method scans the input sequence looking for
56 * the next subsequence that matches the pattern. </p></li>
57 *
58 * </ul>
59 *
60 * <p> Each of these methods returns a boolean indicating success or failure.
61 * More information about a successful match can be obtained by querying the
62 * state of the matcher.
63 *
64 * <p> A matcher finds matches in a subset of its input called the
65 * <i>region</i>. By default, the region contains all of the matcher's input.
66 * The region can be modified via the {@link #region region} method and queried
67 * via the {@link #regionStart regionStart} and {@link #regionEnd regionEnd}
68 * methods. The way that the region boundaries interact with some pattern
69 * constructs can be changed. See {@link #useAnchoringBounds
70 * useAnchoringBounds} and {@link #useTransparentBounds useTransparentBounds}
71 * for more details.
72 *
73 * <p> This class also defines methods for replacing matched subsequences with
74 * new strings whose contents can, if desired, be computed from the match
75 * result. The {@link #appendReplacement appendReplacement} and {@link
76 * #appendTail appendTail} methods can be used in tandem in order to collect
77 * the result into an existing string buffer or string builder. Alternatively,
78 * the more convenient {@link #replaceAll replaceAll} method can be used to
79 * create a string in which every matching subsequence in the input sequence
80 * is replaced.
81 *
82 * <p> The explicit state of a matcher includes the start and end indices of
83 * the most recent successful match. It also includes the start and end
84 * indices of the input subsequence captured by each <a
85 * href="Pattern.html#cg">capturing group</a> in the pattern as well as a total
86 * count of such subsequences. As a convenience, methods are also provided for
1622 * @param b a boolean indicating whether or not to use anchoring bounds.
1623 * @return this matcher
1624 * @see java.util.regex.Matcher#hasAnchoringBounds
1625 * @since 1.5
1626 */
1627 public Matcher useAnchoringBounds(boolean b) {
1628 anchoringBounds = b;
1629 return this;
1630 }
1631
1632 /**
1633 * <p>Returns the string representation of this matcher. The
1634 * string representation of a <code>Matcher</code> contains information
1635 * that may be useful for debugging. The exact format is unspecified.
1636 *
1637 * @return The string representation of this matcher
1638 * @since 1.5
1639 */
1640 public String toString() {
1641 StringBuilder sb = new StringBuilder();
1642 sb.append("java.util.regex.Matcher")
1643 .append("[pattern=").append(pattern())
1644 .append(" region=")
1645 .append(regionStart()).append(',').append(regionEnd())
1646 .append(" lastmatch=");
1647 if ((first >= 0) && (group() != null)) {
1648 sb.append(group());
1649 }
1650 sb.append(']');
1651 return sb.toString();
1652 }
1653
1654 /**
1655 * <p>Returns true if the end of input was hit by the search engine in
1656 * the last match operation performed by this matcher.
1657 *
1658 * <p>When this method returns true, then it is possible that more input
1659 * would have changed the result of the last search.
1660 *
1661 * @return true iff the end of input was hit in the last match; false
1662 * otherwise
1663 * @since 1.5
1664 */
1665 public boolean hitEnd() {
1666 return hitEnd;
1667 }
1668
1669 /**
1670 * <p>Returns true if more input could change a positive match into a
|