Package squidpony
Class ObText.ContentMatcher
java.lang.Object
regexodus.Matcher
squidpony.ObText.ContentMatcher
- All Implemented Interfaces:
Serializable
,regexodus.between.MatchResult
,regexodus.MatchResult
- Enclosing class:
- ObText
public static class ObText.ContentMatcher extends regexodus.Matcher
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ContentMatcher()
Constructs a ContentMatcher that will need to have its target set withsetTarget(CharSequence)
or one of its overloads.ContentMatcher(CharSequence text)
Constructs a ContentMatcher that already has its target set totext
. -
Method Summary
Modifier and Type Method Description String
getMatch()
Returns the contents of the latest String successfully found withMatcher.find()
, without quotation.boolean
hasMatch()
Returns true ifMatcher.find()
has returned true and the found text is a usable String (not some syntax).void
setTarget(char[] text, int start, int len)
Supplies a text to search in/match with, as a part of char array.void
setTarget(CharSequence text)
Supplies a text to search in/match with.void
setTarget(CharSequence text, int start, int len)
Supplies a text to search in/match with, as a part of String.Methods inherited from class regexodus.Matcher
charAt, charAt, copy, dataEnd, dataStart, end, end, end, equals, find, find, findAll, findAll, flush, foundStrings, getGroup, getGroup, getGroup, getGroup, getGroup, getGroup, getGroup, getGroup, getString, group, group, group, groupCount, groups, groupv, hashCode, isCaptured, isCaptured, isCaptured, isStart, length, length, matches, matches, matchesPrefix, pattern, prefix, proceed, proceed, replaceAll, replaceAll, replaceAmount, replaceAmount, replaceFirst, replaceFirst, search, setAll, setPattern, setPosition, setTarget, setTarget, setTarget, skip, start, start, start, suffix, target, targetChars, targetEnd, targetStart, toString
-
Constructor Details
-
ContentMatcher
public ContentMatcher()Constructs a ContentMatcher that will need to have its target set withsetTarget(CharSequence)
or one of its overloads. The target should contain multiple substrings that may have quotation around them; this class is meant to skip the quotation in ObText's style. -
ContentMatcher
Constructs a ContentMatcher that already has its target set totext
.- Parameters:
text
- the CharSequence, such as a String, to find possibly-quoted Strings in.
-
-
Method Details
-
setTarget
Supplies a text to search in/match with. Resets current search position to zero.- Overrides:
setTarget
in classregexodus.Matcher
- Parameters:
text
- - a data- See Also:
Matcher.setTarget(Matcher, int)
,Matcher.setTarget(CharSequence, int, int)
,Matcher.setTarget(char[], int, int)
,Matcher.setTarget(Reader, int)
-
setTarget
Supplies a text to search in/match with, as a part of String. Resets current search position to zero.- Overrides:
setTarget
in classregexodus.Matcher
- Parameters:
text
- - a data sourcestart
- - where the target startslen
- - how long is the target- See Also:
Matcher.setTarget(Matcher, int)
,Matcher.setTarget(CharSequence)
,Matcher.setTarget(char[], int, int)
,Matcher.setTarget(Reader, int)
-
setTarget
Supplies a text to search in/match with, as a part of char array. Resets current search position to zero.- Overrides:
setTarget
in classregexodus.Matcher
- Parameters:
text
- - a data sourcestart
- - where the target startslen
- - how long is the target- See Also:
Matcher.setTarget(Matcher, int)
,Matcher.setTarget(CharSequence)
,Matcher.setTarget(CharSequence, int, int)
,Matcher.setTarget(Reader, int)
-
hasMatch
Returns true ifMatcher.find()
has returned true and the found text is a usable String (not some syntax). If this returns true, you can reasonably get a (possibly empty) String usinggetMatch()
.- Returns:
- true if there is a usable String found that can be obtained with
getMatch()
-
getMatch
Returns the contents of the latest String successfully found withMatcher.find()
, without quotation. You should typically callhasMatch()
even if find() has returned true, to ensure there is a valid String that can be acquired (this will return an empty String if hasMatch() returns false, but an empty String is also potentially a valid result in a successful match, so it should be distinguished).- Returns:
- the contents of the latest String successfully found with
Matcher.find()
-