예제 #1
0
        public override bool IncrementToken()
        {
            if (savedTerms.Count > 0)
            {
                RestoreState(current);

                SavedTerm savedTerm = savedTerms[0];
                savedTerms.RemoveAt(0);
                termAtt.SetTermBuffer(savedTerm.Term);
                posIncrAtt.PositionIncrement = 0;
                termOff.SetOffset(savedTerm.StartOffset, savedTerm.EndOffset);

                return(true);
            }

            do
            {
                if (!input.IncrementToken())
                {
                    return(false);
                }
            }while (IsNonWhiteSpaceChar(termAtt.Term));

            // A-Ha
            string s   = "";
            int    pos = 0;

            foreach (char c in termAtt.Term)
            {
                if (IsNonWhiteSpaceChar(c))
                {
                    if (s.Length > 0)
                    {
                        SavedTerm savedTerm = new SavedTerm();
                        savedTerm.Term        = s;
                        savedTerm.StartOffset = termOff.StartOffset;
                        savedTerm.EndOffset   = termOff.EndOffset;
                        savedTerms.Add(savedTerm);
                        s = "";
                    }
                }
                else
                {
                    s += c;
                }
                pos++;
            }
            if (s.Length > 0 && s != termAtt.Term)
            {
                SavedTerm savedTerm = new SavedTerm();
                savedTerm.Term        = s;
                savedTerm.StartOffset = termOff.StartOffset;
                savedTerm.EndOffset   = termOff.EndOffset;
                savedTerms.Add(savedTerm);
            }

            if (savedTerms.Count > 0)
            {
                current = CaptureState();
            }

            return(true);
        }
예제 #2
0
 private void InitBlock(Lucene.Net.Util.AttributeSource.State initState, AttributeSource enclosingInstance)
 {
     this.initState = initState;
     this.enclosingInstance = enclosingInstance;
     state = initState;
 }