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

    Fields inherited from class regexodus.Matcher

    ACCEPT_INCOMPLETE, ANCHOR_END, ANCHOR_LASTMATCH, ANCHOR_START

    Fields inherited from interface regexodus.MatchResult

    MATCH, PREFIX, SUFFIX, TARGET
  • Constructor Summary

    Constructors 
    Constructor Description
    ContentMatcher()
    Constructs a ContentMatcher that will need to have its target set with setTarget(CharSequence) or one of its overloads.
    ContentMatcher​(CharSequence text)
    Constructs a ContentMatcher that already has its target set to text.
  • Method Summary

    Modifier and Type Method Description
    String getMatch()
    Returns the contents of the latest String successfully found with Matcher.find(), without quotation.
    boolean hasMatch()
    Returns true if Matcher.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

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ContentMatcher

      public ContentMatcher()
      Constructs a ContentMatcher that will need to have its target set with setTarget(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

      public ContentMatcher​(CharSequence text)
      Constructs a ContentMatcher that already has its target set to text.
      Parameters:
      text - the CharSequence, such as a String, to find possibly-quoted Strings in.
  • Method Details

    • setTarget

      public void setTarget​(CharSequence text)
      Supplies a text to search in/match with. Resets current search position to zero.
      Overrides:
      setTarget in class regexodus.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

      public void setTarget​(CharSequence text, int start, int len)
      Supplies a text to search in/match with, as a part of String. Resets current search position to zero.
      Overrides:
      setTarget in class regexodus.Matcher
      Parameters:
      text - - a data source
      start - - where the target starts
      len - - how long is the target
      See Also:
      Matcher.setTarget(Matcher, int), Matcher.setTarget(CharSequence), Matcher.setTarget(char[], int, int), Matcher.setTarget(Reader, int)
    • setTarget

      public void setTarget​(char[] text, int start, int len)
      Supplies a text to search in/match with, as a part of char array. Resets current search position to zero.
      Overrides:
      setTarget in class regexodus.Matcher
      Parameters:
      text - - a data source
      start - - where the target starts
      len - - how long is the target
      See Also:
      Matcher.setTarget(Matcher, int), Matcher.setTarget(CharSequence), Matcher.setTarget(CharSequence, int, int), Matcher.setTarget(Reader, int)
    • hasMatch

      public boolean hasMatch()
      Returns true if Matcher.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 using getMatch().
      Returns:
      true if there is a usable String found that can be obtained with getMatch()
    • getMatch

      public String getMatch()
      Returns the contents of the latest String successfully found with Matcher.find(), without quotation. You should typically call hasMatch() 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()