/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 7.0 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/ package org.apache.tomcat.util.json;
/** * An implementation of interface CharStream, where the stream is assumed to * contain only ASCII characters (with java-like unicode escape processing).
*/
@SuppressWarnings("all") // Ignore warnings in generated code public class JavaCharStream
{ /** Whether parser is static. */ publicstaticfinalboolean staticFlag = false;
/** Read a character. */ publicchar readChar() throws java.io.IOException
{ if (inBuf > 0)
{
--inBuf;
if (++bufpos == bufsize) {
bufpos = 0;
}
return buffer[bufpos];
}
char c;
if (++bufpos == available) {
AdjustBuffSize();
}
if ((buffer[bufpos] = c = ReadByte()) == '\\')
{ if (trackLineColumn) { UpdateLineColumn(c); }
int backSlashCnt = 1;
for (;;) // Read all the backslashes
{ if (++bufpos == available) {
AdjustBuffSize();
}
try
{ if ((buffer[bufpos] = c = ReadByte()) != '\\')
{ if (trackLineColumn) { UpdateLineColumn(c); } // found a non-backslash char. if ((c == 'u') && ((backSlashCnt & 1) == 1))
{ if (--bufpos < 0) {
bufpos = bufsize - 1;
}
break;
}
backup(backSlashCnt); return'\\';
}
} catch(java.io.IOException e)
{ // We are returning one backslash so we should only backup (count-1) if (backSlashCnt > 1) {
backup(backSlashCnt-1);
}
return'\\';
}
if (trackLineColumn) { UpdateLineColumn(c); }
backSlashCnt++;
}
// Here, we have seen an odd number of backslash's followed by a 'u' try
{ while ((c = ReadByte()) == 'u') {
++column;
}
/** Constructor. */ public JavaCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
column = startcolumn - 1;
/** Reinitialise. */ publicvoid ReInit(java.io.Reader dstream, int startline, int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
/** Reinitialise. */ publicvoid ReInit(java.io.Reader dstream)
{
ReInit(dstream, 1, 1, 4096);
} /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
{ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
}
/** Constructor. */ public JavaCharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize)
{ this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
/** Constructor. */ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException
{ this(dstream, encoding, startline, startcolumn, 4096);
}
/** Constructor. */ public JavaCharStream(java.io.InputStream dstream, int startline, int startcolumn)
{ this(dstream, startline, startcolumn, 4096);
}
/** Set buffers back to null when finished. */ publicvoid Done()
{
nextCharBuf = null;
buffer = null;
bufline = null;
bufcolumn = null;
}
/** * Method to adjust line and column numbers for the start of a token.
*/ publicvoid adjustBeginLineColumn(int newLine, int newCol)
{ int start = tokenBegin; int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
} else {
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0; int nextColDiff = 0, columnDiff = 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.