Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../img/srcFileCovDistChart8.png 62% of files have more coverage
15   157   13   1.15
0   48   0.87   13
13     1  
1    
 
  MementoTextInput       Line # 27 15 13 71.4% 0.71428573
 
  (99)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.bo.parser;
17   
18    import java.util.Stack;
19   
20    import org.qedeq.base.io.TextInput;
21   
22    /**
23    * Remember TextInput positions.
24    *
25    * @author Michael Meyling
26    */
 
27    public class MementoTextInput {
28   
29    /** For remembering input positions. */
30    private final Stack stack = new Stack();
31   
32    /** Input source to parse. */
33    private final TextInput input;
34   
35    /**
36    * Constructor.
37    *
38    * @param input Input source to parse.
39    */
 
40  99 toggle public MementoTextInput(final TextInput input) {
41  99 this.input = input;
42    }
43   
44    /**
45    * Remember current position.
46    */
 
47  16138 toggle public void markPosition() {
48  16138 stack.push(new Integer(input.getPosition()));
49    }
50   
51    /**
52    * Rewind to previous marked position. Also clears the mark.
53    *
54    * @return Current position before pop.
55    */
 
56  9352 toggle public long rewindPosition() {
57  9352 final long oldPosition = getPosition();
58  9352 input.setPosition(((Integer) stack.pop()).intValue());
59  9352 return oldPosition;
60    }
61   
62    /**
63    * Forget last remembered position.
64    */
 
65  6785 toggle public void clearMark() {
66  6785 stack.pop();
67    }
68   
69    /**
70    * Get byte position.
71    *
72    * @return Position.
73    */
 
74  9359 toggle public long getPosition() {
75  9359 return input.getPosition();
76    }
77   
78    /**
79    * Reads a single character and does not change the reading
80    * position.
81    *
82    * @return character read, if there are no more chars
83    * <code>-1</code> is returned
84    */
 
85  66093 toggle public int getChar() {
86  66093 return input.getChar();
87    }
88   
89    /**
90    * Reads a single character and increments the reading position
91    * by one.
92    *
93    * @return character read, if there are no more chars
94    * <code>-1</code> is returned
95    */
 
96  15347 toggle public int read() {
97  15347 return input.read();
98    }
99   
100    /**
101    * Are there still any characters to read?
102    *
103    * @return Anything left for reading further?
104    */
 
105  22712 toggle public final boolean isEmpty() {
106  22712 return input.isEmpty();
107    }
108   
109    /**
110    * Get rewind stack size.
111    *
112    * @return Rewind stack size.
113    */
 
114  89 toggle public int getRewindStackSize() {
115  89 return stack.size();
116    }
117   
118    /**
119    * Returns the current column number.
120    *
121    * @return Current column number (starting with line 1).
122    */
 
123  0 toggle public int getColumn() {
124  0 return input.getColumn();
125    }
126   
127    /**
128    * Returns the current line number.
129    *
130    * @return Current line number (starting with line 1).
131    */
 
132  0 toggle public int getRow() {
133  0 return input.getRow();
134    }
135   
136    /**
137    * Returns the current line.
138    *
139    * @return Current line.
140    */
 
141  0 toggle public String getLine() {
142  0 return input.getLine();
143    }
144   
145    /**
146    * Decrements the reading position by one and reads a single character.
147    * If no characters are left, <code>-1</code> is returned.
148    * Otherwise a cast to <code>char</code> gives the character read.
149    *
150    * @return Character read, if there are no more chars
151    * <code>-1</code> is returned.
152    */
 
153  0 toggle public int readInverse() {
154  0 return input.readInverse();
155    }
156   
157    }