예제 #1
0
                public override bool IncrementToken()
                {
                    if (state != null)
                    {
                        RestoreState(state);
                        payloadAtt.SetPayload(null);
                        posIncrAtt.SetPositionIncrement(0);
                        termAtt.SetTermBuffer(new char[] { 'b' }, 0, 1);
                        state = null;
                        return(true);
                    }

                    bool hasNext = input.IncrementToken();

                    if (!hasNext)
                    {
                        return(false);
                    }
                    if (System.Char.IsDigit(termAtt.TermBuffer()[0]))
                    {
                        posIncrAtt.SetPositionIncrement(termAtt.TermBuffer()[0] - '0');
                    }
                    if (first)
                    {
                        // set payload on first position only
                        payloadAtt.SetPayload(new Payload(new byte[] { 100 }));
                        first = false;
                    }

                    // index a "synonym" for every token
                    state = CaptureState();
                    return(true);
                }
예제 #2
0
        public override bool IncrementToken()
        {
            if (input.IncrementToken())
            {
                // capture state lazily - maybe no SinkFilter accepts this state
                AttributeSource.State state = null;
                for (System.Collections.IEnumerator it = sinks.GetEnumerator(); it.MoveNext();)
                {
                    SinkTokenStream sink = (SinkTokenStream)((System.WeakReference)it.Current).Target;
                    if (sink != null)
                    {
                        if (sink.Accept(this))
                        {
                            if (state == null)
                            {
                                state = this.CaptureState();
                            }
                            sink.AddState(state);
                        }
                    }
                }
                return(true);
            }

            return(false);
        }
예제 #3
0
        public override bool IncrementToken()
        {
            if (input.IncrementToken())
            {
                // capture state lazily - maybe no SinkFilter accepts this state
                AttributeSource.State state = null;
                foreach (WeakReference wr in sinks)
                {
                    SinkTokenStream sink = (SinkTokenStream)wr.Target;
                    if (sink != null)
                    {
                        if (sink.Accept(this))
                        {
                            if (state == null)
                            {
                                state = this.CaptureState();
                            }
                            sink.AddState(state);
                        }
                    }
                }
                return(true);
            }

            return(false);
        }
예제 #4
0
 internal /*private*/ void  AddState(AttributeSource.State state)
 {
     if (it != null)
     {
         throw new System.SystemException("The tee must be consumed before sinks are consumed.");
     }
     cachedStates.Add(state);
 }
예제 #5
0
 private void  FillCache()
 {
     while (input.IncrementToken())
     {
         cache.Add(CaptureState());
     }
     // capture final state
     input.End();
     finalState = CaptureState();
 }
예제 #6
0
 public override void  End()
 {
     base.End();
     AttributeSource.State finalState = CaptureState();
     for (System.Collections.IEnumerator it = sinks.GetEnumerator(); it.MoveNext();)
     {
         SinkTokenStream sink = (SinkTokenStream)((System.WeakReference)it.Current).Target;
         if (sink != null)
         {
             sink.SetFinalState(finalState);
         }
     }
 }
예제 #7
0
 public override void  End()
 {
     base.End();
     AttributeSource.State finalState = CaptureState();
     foreach (WeakReference wr in sinks)
     {
         SinkTokenStream sink = (SinkTokenStream)wr.Target;
         if (sink != null)
         {
             sink.SetFinalState(finalState);
         }
     }
 }
예제 #8
0
            public override bool IncrementToken()
            {
                // lazy init the iterator
                if (it == null)
                {
                    it = cachedStates.GetEnumerator();
                }

                if (!it.MoveNext())
                {
                    return(false);
                }

                AttributeSource.State state = (State)it.Current;
                RestoreState(state);
                return(true);
            }
예제 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks></remarks>
 /// <seealso cref=""/>
 /// <param>NA</param>
 /// <returns></returns>
 public override bool IncrementToken()
 {
     if (synonymStack.Count > 0)
     {
         String syn = synonymStack.Pop();
         RestoreState(current);
         termAtt.SetTermBuffer(syn);
         posIncrAtt.PositionIncrement = 0;
         return(true);
     }
     if (!input.IncrementToken())
     {
         return(false);
     }
     if (addAliasesToStack())
     {
         current = CaptureState();
     }
     return(true);
 }
예제 #10
0
				public override bool IncrementToken()
				{
					if (state != null)
					{
						RestoreState(state);
						payloadAtt.SetPayload(null);
						posIncrAtt.SetPositionIncrement(0);
						termAtt.SetTermBuffer(new char[]{'b'}, 0, 1);
						state = null;
						return true;
					}
					
					bool hasNext = input.IncrementToken();
					if (!hasNext)
						return false;
					if (System.Char.IsDigit(termAtt.TermBuffer()[0]))
					{
						posIncrAtt.SetPositionIncrement(termAtt.TermBuffer()[0] - '0');
					}
					if (first)
					{
						// set payload on first position only
						payloadAtt.SetPayload(new Payload(new byte[]{100}));
						first = false;
					}
					
					// index a "synonym" for every token
					state = CaptureState();
					return true;
				}
예제 #11
0
 private void FillCache()
 {
     while (input.IncrementToken())
     {
         Cache.AddLast(CaptureState());
     }
     // capture final state
     input.End();
     FinalState = CaptureState();
 }
예제 #12
0
 internal /*private*/ void  SetFinalState(AttributeSource.State finalState)
 {
     this.finalState = finalState;
 }
 /*private*/
 internal void SetFinalState(AttributeSource.State finalState)
 {
     this.finalState = finalState;
 }
예제 #14
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks></remarks>
 /// <seealso cref=""/>
 /// <param>NA</param>       
 /// <returns></returns>
 public override bool IncrementToken()
 {
     if (synonymStack.Count > 0) {
         String syn = synonymStack.Pop();
         RestoreState(current);
         termAtt.SetTermBuffer(syn);
         posIncrAtt.PositionIncrement=0;
         return true;
     }
     if (!input.IncrementToken())
         return false;
     if (addAliasesToStack()) {
         current = CaptureState();
     }
     return true;
 }
예제 #15
0
 public override sealed void Reset()
 {
     base.Reset();
     first = true;
     state = null;
 }
예제 #16
0
                public override sealed bool IncrementToken()
                {
                    if (state != null)
                    {
                        RestoreState(state);
                        payloadAtt.Payload = null;
                        posIncrAtt.PositionIncrement = 0;
                        termAtt.SetEmpty().Append("b");
                        state = null;
                        return true;
                    }

                    bool hasNext = input.IncrementToken();
                    if (!hasNext)
                    {
                        return false;
                    }
                    if (char.IsDigit(termAtt.Buffer()[0]))
                    {
                        posIncrAtt.PositionIncrement = termAtt.Buffer()[0] - '0';
                    }
                    if (first)
                    {
                        // set payload on first position only
                        payloadAtt.Payload = new BytesRef(new byte[] { 100 });
                        first = false;
                    }

                    // index a "synonym" for every token
                    state = CaptureState();
                    return true;
                }