View Javadoc
1   package de.fhdw.wtf.common.stream;
2   
3   import de.fhdw.wtf.common.token.Token;
4   
5   /**
6    * Definition of a sequence of Token.
7    */
8   public interface TokenStream {
9   	
10  	/**
11  	 * Adds the {@link Token} <code>t</code> to the end of the stream.
12  	 * 
13  	 * @param t
14  	 *            {@link Token} to be added.
15  	 */
16  	void add(Token t);
17  	
18  	/**
19  	 * Returns the next {@link Token} element from the stream. <br>
20  	 * <br>
21  	 * <code>
22  	 * TokenStream stream = new ...; <br>
23  	 * stream.next() // first element <br>
24  	 * stream.next() // second element <br>
25  	 * </code> and so on. <br>
26  	 * 
27  	 * @return the next {@link Token}.
28  	 */
29  	Token next();
30  	
31  	/**
32  	 * Tests if there is at least one more {@link Token} at the Stream.
33  	 * 
34  	 * @return <code>true</code> if there are {@link Token}s left at the Stream. <br>
35  	 *         <code>false</code> if the Stream is empty.
36  	 */
37  	boolean hasNext();
38  	
39  	/**
40  	 * Removes the first Token in the stream.
41  	 * 
42  	 * @return Returns true if an element is removed, false otherwise.
43  	 */
44  	boolean removeFirst();
45  	
46  	/**
47  	 * Returns the next {@link Token} element without removing it from the stream.
48  	 * 
49  	 * @return the next {@link Token}.
50  	 */
51  	Token peek();
52  	
53  	/**
54  	 * Return a Copy of the {@link TokenStream}.
55  	 * 
56  	 * @return copied Tokenstream
57  	 */
58  	TokenStream copy();
59  	
60  }