src/share/jaxws_classes/com/sun/xml/internal/rngom/parse/compact/JavaCharStream.java
Print this page
@@ -20,46 +20,21 @@
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-/*
- * Copyright (C) 2004-2011
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 5.0 */
-/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
+/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 3.0 */
package com.sun.xml.internal.rngom.parse.compact;
/**
* An implementation of interface CharStream, where the stream is assumed to
* contain only ASCII characters (with java-like unicode escape processing).
*/
-public
-class JavaCharStream
+public class JavaCharStream
{
- /** Whether parser is static. */
public static final boolean staticFlag = false;
-
static final int hexval(char c) throws java.io.IOException {
switch(c)
{
case '0' :
return 0;
@@ -103,11 +78,10 @@
}
throw new java.io.IOException(); // Should never come here
}
-/** Position in buffer. */
public int bufpos = -1;
int bufsize;
int available;
int tokenBegin;
protected int bufline[];
@@ -124,14 +98,10 @@
protected char[] nextCharBuf;
protected char[] buffer;
protected int maxNextCharInd = 0;
protected int nextCharInd = -1;
protected int inBuf = 0;
- protected int tabSize = 8;
-
- protected void setTabSize(int i) { tabSize = i; }
- protected int getTabSize(int i) { return tabSize; }
protected void ExpandBuff(boolean wrapAround)
{
char[] newbuffer = new char[bufsize + 2048];
int newbufline[] = new int[bufsize + 2048];
@@ -140,11 +110,12 @@
try
{
if (wrapAround)
{
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
- System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
bufline = newbufline;
@@ -216,11 +187,10 @@
FillBuff();
return nextCharBuf[nextCharInd];
}
-/** @return starting character for token. */
public char BeginToken() throws java.io.IOException
{
if (inBuf > 0)
{
--inBuf;
@@ -286,21 +256,20 @@
case '\n' :
prevCharIsLF = true;
break;
case '\t' :
column--;
- column += (tabSize - (column % tabSize));
+ column += (8 - (column & 07));
break;
default :
break;
}
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
-/** Read a character. */
public char readChar() throws java.io.IOException
{
if (inBuf > 0)
{
--inBuf;
@@ -345,13 +314,12 @@
return '\\';
}
}
catch(java.io.IOException e)
{
- // We are returning one backslash so we should only backup (count-1)
if (backSlashCnt > 1)
- backup(backSlashCnt-1);
+ backup(backSlashCnt);
return '\\';
}
UpdateLineColumn(c);
@@ -386,61 +354,55 @@
}
}
else
{
UpdateLineColumn(c);
- return c;
+ return (c);
}
}
- @Deprecated
/**
* @deprecated
* @see #getEndColumn
*/
+
public int getColumn() {
return bufcolumn[bufpos];
}
- @Deprecated
/**
* @deprecated
* @see #getEndLine
*/
+
public int getLine() {
return bufline[bufpos];
}
-/** Get end column. */
public int getEndColumn() {
return bufcolumn[bufpos];
}
-/** Get end line. */
public int getEndLine() {
return bufline[bufpos];
}
-/** @return column of token start */
public int getBeginColumn() {
return bufcolumn[tokenBegin];
}
-/** @return line number of token start */
public int getBeginLine() {
return bufline[tokenBegin];
}
-/** Retreat. */
public void backup(int amount) {
inBuf += amount;
if ((bufpos -= amount) < 0)
bufpos += bufsize;
}
-/** Constructor. */
public JavaCharStream(java.io.Reader dstream,
int startline, int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
@@ -451,23 +413,20 @@
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
nextCharBuf = new char[4096];
}
-/** Constructor. */
public JavaCharStream(java.io.Reader dstream,
int startline, int startcolumn)
{
this(dstream, startline, startcolumn, 4096);
}
-/** Constructor. */
public JavaCharStream(java.io.Reader dstream)
{
this(dstream, 1, 1, 4096);
}
-/** Reinitialise. */
public void ReInit(java.io.Reader dstream,
int startline, int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
@@ -484,110 +443,61 @@
prevCharIsLF = prevCharIsCR = false;
tokenBegin = inBuf = maxNextCharInd = 0;
nextCharInd = bufpos = -1;
}
-/** Reinitialise. */
public void ReInit(java.io.Reader dstream,
int startline, int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
-/** Reinitialise. */
public void 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);
}
-/** Constructor. */
- public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
- {
- this(dstream, encoding, 1, 1, 4096);
- }
-
-/** Constructor. */
public JavaCharStream(java.io.InputStream dstream)
{
this(dstream, 1, 1, 4096);
}
-/** Reinitialise. */
- public void ReInit(java.io.InputStream dstream, String encoding, int startline,
- int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
- {
- ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
- }
-
-/** Reinitialise. */
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
- ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
- }
-/** Reinitialise. */
- public void ReInit(java.io.InputStream dstream, String encoding, int startline,
- int startcolumn) throws java.io.UnsupportedEncodingException
- {
- ReInit(dstream, encoding, startline, startcolumn, 4096);
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
-/** Reinitialise. */
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
-/** Reinitialise. */
- public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
- {
- ReInit(dstream, encoding, 1, 1, 4096);
- }
-
-/** Reinitialise. */
public void ReInit(java.io.InputStream dstream)
{
ReInit(dstream, 1, 1, 4096);
}
- /** @return token image as String */
public String GetImage()
{
if (bufpos >= tokenBegin)
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
else
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
new String(buffer, 0, bufpos + 1);
}
- /** @return suffix */
public char[] GetSuffix(int len)
{
char[] ret = new char[len];
if ((bufpos + 1) >= len)
@@ -600,11 +510,10 @@
}
return ret;
}
- /** Set buffers back to null when finished. */
public void Done()
{
nextCharBuf = null;
buffer = null;
bufline = null;
@@ -629,11 +538,12 @@
}
int i = 0, j = 0, k = 0;
int nextColDiff = 0, columnDiff = 0;
- while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
{
bufline[j] = newLine;
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j] = newCol + columnDiff;
columnDiff = nextColDiff;
@@ -657,6 +567,5 @@
line = bufline[j];
column = bufcolumn[j];
}
}
-/* JavaCC - OriginalChecksum=d4510307ecc248a96e4d3455ebf92ff3 (do not edit this line) */