/// <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)); }
public override int Accepts(int strIndex, String testString) { return((chars.Contains(testString[strIndex])) ? 1 : -1); }
public virtual bool Contains(int ch) { return(chars.Contains(ch)); }
public override bool Contains(int ch) { return((curAlt ^ outer_CharClass.bits.Get(ch)) || ((curAlt ^ outer_CharClass.inverted) ^ cc .Contains(ch))); }
public override bool Contains(int ch) { return(cc.Contains(ch)); }
public override bool Contains(int ch) { return((curAlt ^ nb.Contains(ch)) && clazz.Contains(ch)); }
public override bool Contains(int ch) { return(clazz.Contains(ch) && (curAlt ^ outer_CharClass.bits.Get(ch))); }
public override bool Contains(int ch) { return(!clazz.Contains(ch)); }
public override bool Contains(int ch) { return(curAlt ^ (nb.Contains(ch) || cc.Contains(ch))); }