Class TransliteratorParser.RuleHalf

java.lang.Object
com.ibm.icu.text.TransliteratorParser.RuleHalf
Enclosing class:
TransliteratorParser

private static class TransliteratorParser.RuleHalf extends Object
A class representing one side of a rule. This class knows how to parse half of a rule. It is tightly coupled to the method TransliteratorParser.parseRule().
  • Field Details

    • text

      public String text
    • cursor

      public int cursor
    • ante

      public int ante
    • post

      public int post
    • cursorOffset

      public int cursorOffset
    • cursorOffsetPos

      private int cursorOffsetPos
    • anchorStart

      public boolean anchorStart
    • anchorEnd

      public boolean anchorEnd
    • nextSegmentNumber

      private int nextSegmentNumber
      The segment number from 1..n of the next '(' we see during parsing; 1-based.
  • Constructor Details

    • RuleHalf

      private RuleHalf()
  • Method Details

    • parse

      public int parse(String rule, int pos, int limit, TransliteratorParser parser)
      Parse one side of a rule, stopping at either the limit, the END_OF_RULE character, or an operator.
      Returns:
      the index after the terminating character, or if limit was reached, limit
    • parseSection

      private int parseSection(String rule, int pos, int limit, TransliteratorParser parser, StringBuffer buf, UnicodeSet illegal, boolean isSegment)
      Parse a section of one side of a rule, stopping at either the limit, the END_OF_RULE character, an operator, or a segment close character. This method parses both a top-level rule half and a segment within such a rule half. It calls itself recursively to parse segments and nested segments.
      Parameters:
      buf - buffer into which to accumulate the rule pattern characters, either literal characters from the rule or standins for UnicodeMatcher objects including segments.
      illegal - the set of special characters that is illegal during this parse.
      isSegment - if true, then we've already seen a '(' and pos on entry points right after it. Accumulate everything up to the closing ')', put it in a segment matcher object, generate a standin for it, and add the standin to buf. As a side effect, update the segments vector with a reference to the segment matcher. This works recursively for nested segments. If isSegment is false, just accumulate characters into buf.
      Returns:
      the index after the terminating character, or if limit was reached, limit
    • removeContext

      void removeContext()
      Remove context.
    • isValidOutput

      public boolean isValidOutput(TransliteratorParser parser)
      Return true if this half looks like valid output, that is, does not contain quantifiers or other special input-only elements.
    • isValidInput

      public boolean isValidInput(TransliteratorParser parser)
      Return true if this half looks like valid input, that is, does not contain functions or other special output-only elements.