Example #1
0
 /// <summary>
 /// Returns <c>true</c> if character class contains symbol specified,
 /// <c>false</c> otherwise. Note: #setNegative() method changes the
 /// meaning of contains method;
 /// </summary>
 ///
 /// <param name="ch"></param>
 /// <returns><c>true</c> if character class contains symbol specified;
 /// TODO: currently <c>character class</c> implementation based on
 /// BitSet, but this implementation possibly will be turned to combined
 /// BitSet(for first 256 symbols) and Black/Red tree for the rest of UTF.</returns>
 public override bool Contains(int ch)
 {
     if (nonBitSet == null)
     {
         return(this.alt ^ bits.Get(ch));
     }
     else
     {
         return(alt ^ nonBitSet.Contains(ch));
     }
 }
        /// <summary>
        /// Returns stringIndex+shift, the next position to match
        /// </summary>
        ///
        public override int Matches(int stringIndex, String testString,
                                    MatchResultImpl matchResult)
        {
            int startStr  = matchResult.GetLeftBound();
            int strLength = matchResult.GetRightBound();

            if (stringIndex + 1 > strLength)
            {
                matchResult.hitEnd = true;
                return(-1);
            }

            char ch = testString[stringIndex];

            if (!surrChars.Contains(ch))
            {
                return(-1);
            }

            if (System.Char.IsHighSurrogate(ch))
            {
                if (stringIndex + 1 < strLength)
                {
                    char low = testString[stringIndex + 1];

                    if (System.Char.IsLowSurrogate(low))
                    {
                        return(-1);
                    }
                }
            }
            else if (System.Char.IsLowSurrogate(ch))
            {
                if (stringIndex > startStr)
                {
                    char high = testString[stringIndex - 1];

                    if (System.Char.IsHighSurrogate(high))
                    {
                        return(-1);
                    }
                }
            }

            return(next.Matches(stringIndex + 1, testString, matchResult));
        }
Example #3
0
 public override int Accepts(int strIndex, String testString)
 {
     return((chars.Contains(testString[strIndex])) ? 1 : -1);
 }
Example #4
0
 public virtual bool Contains(int ch)
 {
     return(chars.Contains(ch));
 }
Example #5
0
 public override bool Contains(int ch)
 {
     return((curAlt ^ outer_CharClass.bits.Get(ch)) ||
            ((curAlt ^ outer_CharClass.inverted) ^ cc
             .Contains(ch)));
 }
Example #6
0
 public override bool Contains(int ch)
 {
     return(cc.Contains(ch));
 }
Example #7
0
 public override bool Contains(int ch)
 {
     return((curAlt ^ nb.Contains(ch)) &&
            clazz.Contains(ch));
 }
Example #8
0
 public override bool Contains(int ch)
 {
     return(clazz.Contains(ch) &&
            (curAlt ^ outer_CharClass.bits.Get(ch)));
 }
Example #9
0
 public override bool Contains(int ch)
 {
     return(!clazz.Contains(ch));
 }
Example #10
0
 public override bool Contains(int ch)
 {
     return(curAlt
            ^ (nb.Contains(ch) || cc.Contains(ch)));
 }