Skip to content

Package: SimpleCharStream

SimpleCharStream

nameinstructionbranchcomplexitylinemethod
BeginToken()
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
Done()
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
ExpandBuff(boolean)
M: 192 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 28 C: 0
0%
M: 1 C: 0
0%
FillBuff()
M: 114 C: 0
0%
M: 16 C: 0
0%
M: 9 C: 0
0%
M: 24 C: 0
0%
M: 1 C: 0
0%
GetImage()
M: 44 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
GetSuffix(int)
M: 59 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
ReInit(InputStream)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ReInit(InputStream, String)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ReInit(InputStream, String, int, int)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ReInit(InputStream, String, int, int, int)
M: 18 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ReInit(InputStream, int, int)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ReInit(InputStream, int, int, int)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ReInit(Reader)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ReInit(Reader, int, int)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ReInit(Reader, int, int, int)
M: 56 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
SimpleCharStream(InputStream)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
SimpleCharStream(InputStream, String)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
SimpleCharStream(InputStream, String, int, int)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
SimpleCharStream(InputStream, String, int, int, int)
M: 18 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
SimpleCharStream(InputStream, int, int)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
SimpleCharStream(InputStream, int, int, int)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
SimpleCharStream(Reader)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
SimpleCharStream(Reader, int, int)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
SimpleCharStream(Reader, int, int, int)
M: 56 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 17 C: 0
0%
M: 1 C: 0
0%
UpdateLineColumn(char)
M: 89 C: 0
0%
M: 10 C: 0
0%
M: 7 C: 0
0%
M: 20 C: 0
0%
M: 1 C: 0
0%
adjustBeginLineColumn(int, int)
M: 159 C: 0
0%
M: 12 C: 0
0%
M: 7 C: 0
0%
M: 22 C: 0
0%
M: 1 C: 0
0%
backup(int)
M: 22 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getBeginColumn()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getBeginLine()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getColumn()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getEndColumn()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getEndLine()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getLine()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getTabSize(int)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
readChar()
M: 51 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
setTabSize(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: /* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */
18: /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
19: package com.sun.el.parser;
20:
21: /**
22: * An implementation of interface CharStream, where the stream is assumed to
23: * contain only ASCII characters (without unicode processing).
24: */
25:
26: public class SimpleCharStream
27: {
28: /** Whether parser is static. */
29: public static final boolean staticFlag = false;
30: int bufsize;
31: int available;
32: int tokenBegin;
33: /** Position in buffer. */
34: public int bufpos = -1;
35: protected int bufline[];
36: protected int bufcolumn[];
37:
38: protected int column = 0;
39: protected int line = 1;
40:
41: protected boolean prevCharIsCR = false;
42: protected boolean prevCharIsLF = false;
43:
44: protected java.io.Reader inputStream;
45:
46: protected char[] buffer;
47: protected int maxNextCharInd = 0;
48: protected int inBuf = 0;
49: protected int tabSize = 8;
50:
51: protected void setTabSize(int i) { tabSize = i; }
52: protected int getTabSize(int i) { return tabSize; }
53:
54:
55: protected void ExpandBuff(boolean wrapAround)
56: {
57: char[] newbuffer = new char[bufsize + 2048];
58: int newbufline[] = new int[bufsize + 2048];
59: int newbufcolumn[] = new int[bufsize + 2048];
60:
61: try
62: {
63:• if (wrapAround)
64: {
65: System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
66: System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
67: buffer = newbuffer;
68:
69: System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
70: System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
71: bufline = newbufline;
72:
73: System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
74: System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
75: bufcolumn = newbufcolumn;
76:
77: maxNextCharInd = (bufpos += (bufsize - tokenBegin));
78: }
79: else
80: {
81: System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
82: buffer = newbuffer;
83:
84: System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
85: bufline = newbufline;
86:
87: System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
88: bufcolumn = newbufcolumn;
89:
90: maxNextCharInd = (bufpos -= tokenBegin);
91: }
92: }
93: catch (Throwable t)
94: {
95: throw new Error(t.getMessage());
96: }
97:
98:
99: bufsize += 2048;
100: available = bufsize;
101: tokenBegin = 0;
102: }
103:
104: protected void FillBuff() throws java.io.IOException
105: {
106:• if (maxNextCharInd == available)
107: {
108:• if (available == bufsize)
109: {
110:• if (tokenBegin > 2048)
111: {
112: bufpos = maxNextCharInd = 0;
113: available = tokenBegin;
114: }
115:• else if (tokenBegin < 0)
116: bufpos = maxNextCharInd = 0;
117: else
118: ExpandBuff(false);
119: }
120:• else if (available > tokenBegin)
121: available = bufsize;
122:• else if ((tokenBegin - available) < 2048)
123: ExpandBuff(true);
124: else
125: available = tokenBegin;
126: }
127:
128: int i;
129: try {
130:• if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1)
131: {
132: inputStream.close();
133: throw new java.io.IOException();
134: }
135: else
136: maxNextCharInd += i;
137: return;
138: }
139: catch(java.io.IOException e) {
140: --bufpos;
141: backup(0);
142:• if (tokenBegin == -1)
143: tokenBegin = bufpos;
144: throw e;
145: }
146: }
147:
148: /** Start. */
149: public char BeginToken() throws java.io.IOException
150: {
151: tokenBegin = -1;
152: char c = readChar();
153: tokenBegin = bufpos;
154:
155: return c;
156: }
157:
158: protected void UpdateLineColumn(char c)
159: {
160: column++;
161:
162:• if (prevCharIsLF)
163: {
164: prevCharIsLF = false;
165: line += (column = 1);
166: }
167:• else if (prevCharIsCR)
168: {
169: prevCharIsCR = false;
170:• if (c == '\n')
171: {
172: prevCharIsLF = true;
173: }
174: else
175: line += (column = 1);
176: }
177:
178:• switch (c)
179: {
180: case '\r' :
181: prevCharIsCR = true;
182: break;
183: case '\n' :
184: prevCharIsLF = true;
185: break;
186: case '\t' :
187: column--;
188: column += (tabSize - (column % tabSize));
189: break;
190: default :
191: break;
192: }
193:
194: bufline[bufpos] = line;
195: bufcolumn[bufpos] = column;
196: }
197:
198: /** Read a character. */
199: public char readChar() throws java.io.IOException
200: {
201:• if (inBuf > 0)
202: {
203: --inBuf;
204:
205:• if (++bufpos == bufsize)
206: bufpos = 0;
207:
208: return buffer[bufpos];
209: }
210:
211:• if (++bufpos >= maxNextCharInd)
212: FillBuff();
213:
214: char c = buffer[bufpos];
215:
216: UpdateLineColumn(c);
217: return c;
218: }
219:
220: @Deprecated
221: /**
222: * @deprecated
223: * @see #getEndColumn
224: */
225:
226: public int getColumn() {
227: return bufcolumn[bufpos];
228: }
229:
230: @Deprecated
231: /**
232: * @deprecated
233: * @see #getEndLine
234: */
235:
236: public int getLine() {
237: return bufline[bufpos];
238: }
239:
240: /** Get token end column number. */
241: public int getEndColumn() {
242: return bufcolumn[bufpos];
243: }
244:
245: /** Get token end line number. */
246: public int getEndLine() {
247: return bufline[bufpos];
248: }
249:
250: /** Get token beginning column number. */
251: public int getBeginColumn() {
252: return bufcolumn[tokenBegin];
253: }
254:
255: /** Get token beginning line number. */
256: public int getBeginLine() {
257: return bufline[tokenBegin];
258: }
259:
260: /** Backup a number of characters. */
261: public void backup(int amount) {
262:
263: inBuf += amount;
264:• if ((bufpos -= amount) < 0)
265: bufpos += bufsize;
266: }
267:
268: /** Constructor. */
269: public SimpleCharStream(java.io.Reader dstream, int startline,
270: int startcolumn, int buffersize)
271: {
272: inputStream = dstream;
273: line = startline;
274: column = startcolumn - 1;
275:
276: available = bufsize = buffersize;
277: buffer = new char[buffersize];
278: bufline = new int[buffersize];
279: bufcolumn = new int[buffersize];
280: }
281:
282: /** Constructor. */
283: public SimpleCharStream(java.io.Reader dstream, int startline,
284: int startcolumn)
285: {
286: this(dstream, startline, startcolumn, 4096);
287: }
288:
289: /** Constructor. */
290: public SimpleCharStream(java.io.Reader dstream)
291: {
292: this(dstream, 1, 1, 4096);
293: }
294:
295: /** Reinitialise. */
296: public void ReInit(java.io.Reader dstream, int startline,
297: int startcolumn, int buffersize)
298: {
299: inputStream = dstream;
300: line = startline;
301: column = startcolumn - 1;
302:
303:• if (buffer == null || buffersize != buffer.length)
304: {
305: available = bufsize = buffersize;
306: buffer = new char[buffersize];
307: bufline = new int[buffersize];
308: bufcolumn = new int[buffersize];
309: }
310: prevCharIsLF = prevCharIsCR = false;
311: tokenBegin = inBuf = maxNextCharInd = 0;
312: bufpos = -1;
313: }
314:
315: /** Reinitialise. */
316: public void ReInit(java.io.Reader dstream, int startline,
317: int startcolumn)
318: {
319: ReInit(dstream, startline, startcolumn, 4096);
320: }
321:
322: /** Reinitialise. */
323: public void ReInit(java.io.Reader dstream)
324: {
325: ReInit(dstream, 1, 1, 4096);
326: }
327: /** Constructor. */
328: public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
329: int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
330: {
331:• this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
332: }
333:
334: /** Constructor. */
335: public SimpleCharStream(java.io.InputStream dstream, int startline,
336: int startcolumn, int buffersize)
337: {
338: this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
339: }
340:
341: /** Constructor. */
342: public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
343: int startcolumn) throws java.io.UnsupportedEncodingException
344: {
345: this(dstream, encoding, startline, startcolumn, 4096);
346: }
347:
348: /** Constructor. */
349: public SimpleCharStream(java.io.InputStream dstream, int startline,
350: int startcolumn)
351: {
352: this(dstream, startline, startcolumn, 4096);
353: }
354:
355: /** Constructor. */
356: public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
357: {
358: this(dstream, encoding, 1, 1, 4096);
359: }
360:
361: /** Constructor. */
362: public SimpleCharStream(java.io.InputStream dstream)
363: {
364: this(dstream, 1, 1, 4096);
365: }
366:
367: /** Reinitialise. */
368: public void ReInit(java.io.InputStream dstream, String encoding, int startline,
369: int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
370: {
371:• ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
372: }
373:
374: /** Reinitialise. */
375: public void ReInit(java.io.InputStream dstream, int startline,
376: int startcolumn, int buffersize)
377: {
378: ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
379: }
380:
381: /** Reinitialise. */
382: public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
383: {
384: ReInit(dstream, encoding, 1, 1, 4096);
385: }
386:
387: /** Reinitialise. */
388: public void ReInit(java.io.InputStream dstream)
389: {
390: ReInit(dstream, 1, 1, 4096);
391: }
392: /** Reinitialise. */
393: public void ReInit(java.io.InputStream dstream, String encoding, int startline,
394: int startcolumn) throws java.io.UnsupportedEncodingException
395: {
396: ReInit(dstream, encoding, startline, startcolumn, 4096);
397: }
398: /** Reinitialise. */
399: public void ReInit(java.io.InputStream dstream, int startline,
400: int startcolumn)
401: {
402: ReInit(dstream, startline, startcolumn, 4096);
403: }
404: /** Get token literal value. */
405: public String GetImage()
406: {
407:• if (bufpos >= tokenBegin)
408: return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
409: else
410: return new String(buffer, tokenBegin, bufsize - tokenBegin) +
411: new String(buffer, 0, bufpos + 1);
412: }
413:
414: /** Get the suffix. */
415: public char[] GetSuffix(int len)
416: {
417: char[] ret = new char[len];
418:
419:• if ((bufpos + 1) >= len)
420: System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
421: else
422: {
423: System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
424: len - bufpos - 1);
425: System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
426: }
427:
428: return ret;
429: }
430:
431: /** Reset buffer when finished. */
432: public void Done()
433: {
434: buffer = null;
435: bufline = null;
436: bufcolumn = null;
437: }
438:
439: /**
440: * Method to adjust line and column numbers for the start of a token.
441: */
442: public void adjustBeginLineColumn(int newLine, int newCol)
443: {
444: int start = tokenBegin;
445: int len;
446:
447:• if (bufpos >= tokenBegin)
448: {
449: len = bufpos - tokenBegin + inBuf + 1;
450: }
451: else
452: {
453: len = bufsize - tokenBegin + bufpos + 1 + inBuf;
454: }
455:
456: int i = 0, j = 0, k = 0;
457: int nextColDiff = 0, columnDiff = 0;
458:
459:• while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
460: {
461: bufline[j] = newLine;
462: nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
463: bufcolumn[j] = newCol + columnDiff;
464: columnDiff = nextColDiff;
465: i++;
466: }
467:
468:• if (i < len)
469: {
470: bufline[j] = newLine++;
471: bufcolumn[j] = newCol + columnDiff;
472:
473:• while (i++ < len)
474: {
475:• if (bufline[j = start % bufsize] != bufline[++start % bufsize])
476: bufline[j] = newLine++;
477: else
478: bufline[j] = newLine;
479: }
480: }
481:
482: line = bufline[j];
483: column = bufcolumn[j];
484: }
485:
486: }
487: /* JavaCC - OriginalChecksum=7ea14199259e7ce0336b228c8cdb9958 (do not edit this line) */