You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/10/22 23:18:07 UTC
svn commit: r1187803 [6/6] - in /tomcat/trunk/java/org/apache/jasper: ./
compiler/ compiler/tagplugin/ el/ resources/ runtime/ security/ servlet/
tagplugins/jstl/ tagplugins/jstl/core/ util/ xmlparser/
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/XMLEncodingDetector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/XMLEncodingDetector.java?rev=1187803&r1=1187802&r2=1187803&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/XMLEncodingDetector.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/XMLEncodingDetector.java Sat Oct 22 21:18:03 2011
@@ -5,9 +5,9 @@
* 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.
@@ -40,7 +40,7 @@ import org.apache.jasper.compiler.JspUti
import org.apache.jasper.compiler.Localizer;
public class XMLEncodingDetector {
-
+
private InputStream stream;
private String encoding;
private boolean isEncodingSetInProlog;
@@ -48,7 +48,7 @@ public class XMLEncodingDetector {
private int skip;
private Boolean isBigEndian;
private Reader reader;
-
+
// org.apache.xerces.impl.XMLEntityManager fields
public static final int DEFAULT_BUFFER_SIZE = 2048;
public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 64;
@@ -56,7 +56,7 @@ public class XMLEncodingDetector {
private SymbolTable fSymbolTable;
private XMLEncodingDetector fCurrentEntity;
private int fBufferSize = DEFAULT_BUFFER_SIZE;
-
+
// org.apache.xerces.impl.XMLEntityManager.ScannedEntity fields
private int lineNumber = 1;
private int columnNumber = 1;
@@ -65,15 +65,15 @@ public class XMLEncodingDetector {
private int position;
private int count;
private boolean mayReadChunks = false;
-
+
// org.apache.xerces.impl.XMLScanner fields
- private XMLString fString = new XMLString();
+ private XMLString fString = new XMLString();
private XMLStringBuffer fStringBuffer = new XMLStringBuffer();
private XMLStringBuffer fStringBuffer2 = new XMLStringBuffer();
private static final String fVersionSymbol = "version";
private static final String fEncodingSymbol = "encoding";
private static final String fStandaloneSymbol = "standalone";
-
+
// org.apache.xerces.impl.XMLDocumentFragmentScannerImpl fields
private int fMarkupDepth = 0;
private String[] fStrings = new String[3];
@@ -97,7 +97,7 @@ public class XMLEncodingDetector {
*
* @return Two-element array, where the first element (of type
* java.lang.String) contains the name of the (auto)detected encoding, and
- * the second element (of type java.lang.Boolean) specifies whether the
+ * the second element (of type java.lang.Boolean) specifies whether the
* encoding was specified using the 'encoding' attribute of an XML prolog
* (TRUE) or autodetected (FALSE).
*/
@@ -128,11 +128,11 @@ public class XMLEncodingDetector {
Boolean.valueOf(this.isBomPresent),
Integer.valueOf(this.skip) };
}
-
+
// stub method
void endEntity() {
}
-
+
// Adapted from:
// org.apache.xerces.impl.XMLEntityManager.startEntity()
private void createInitialReader() throws IOException, JasperException {
@@ -152,7 +152,7 @@ public class XMLEncodingDetector {
Object [] encodingDesc = getEncodingName(b4, count);
encoding = (String)(encodingDesc[0]);
isBigEndian = (Boolean)(encodingDesc[1]);
-
+
if (encodingDesc.length > 3) {
isBomPresent = ((Boolean)(encodingDesc[2])).booleanValue();
skip = ((Integer)(encodingDesc[3])).intValue();
@@ -388,12 +388,12 @@ public class XMLEncodingDetector {
* @throws EOFException Thrown on end of file.
*/
public int peekChar() throws IOException {
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
load(0, true);
}
-
+
// peek at character
int c = fCurrentEntity.ch[fCurrentEntity.position];
@@ -404,9 +404,9 @@ public class XMLEncodingDetector {
else {
return c;
}
-
+
} // peekChar():int
-
+
// Adapted from:
// org.apache.xerces.impl.XMLEntityManager.EntityScanner.scanChar
/**
@@ -446,7 +446,7 @@ public class XMLEncodingDetector {
// return character that was scanned
fCurrentEntity.columnNumber++;
return c;
-
+
}
// Adapted from:
@@ -468,12 +468,12 @@ public class XMLEncodingDetector {
* @see XMLChar#isNameStart
*/
public String scanName() throws IOException {
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
load(0, true);
}
-
+
// scan name
int offset = fCurrentEntity.position;
if (XMLChar.isNameStart(fCurrentEntity.ch[offset])) {
@@ -517,7 +517,7 @@ public class XMLEncodingDetector {
symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, offset, length);
}
return symbol;
-
+
}
// Adapted from:
@@ -694,9 +694,9 @@ public class XMLEncodingDetector {
char charAt0 = delimiter.charAt(0);
boolean external = fCurrentEntity.isExternal();
do {
-
+
// load more characters, if needed
-
+
if (fCurrentEntity.position == fCurrentEntity.count) {
load(0, true);
}
@@ -705,19 +705,19 @@ public class XMLEncodingDetector {
fCurrentEntity.ch, 0, fCurrentEntity.count - fCurrentEntity.position);
load(fCurrentEntity.count - fCurrentEntity.position, false);
fCurrentEntity.position = 0;
- }
+ }
if (fCurrentEntity.position >= fCurrentEntity.count - delimLen) {
// something must be wrong with the input: e.g., file ends an
// unterminated comment
int length = fCurrentEntity.count - fCurrentEntity.position;
buffer.append (fCurrentEntity.ch, fCurrentEntity.position,
- length);
+ length);
fCurrentEntity.columnNumber += fCurrentEntity.count;
fCurrentEntity.position = fCurrentEntity.count;
load(0,true);
return false;
}
-
+
// normalize newlines
int offset = fCurrentEntity.position;
int c = fCurrentEntity.ch[offset];
@@ -772,7 +772,7 @@ public class XMLEncodingDetector {
return true;
}
}
-
+
// iterate over buffer looking for delimiter
OUTER: while (fCurrentEntity.position < fCurrentEntity.count) {
c = fCurrentEntity.ch[fCurrentEntity.position++];
@@ -803,7 +803,7 @@ public class XMLEncodingDetector {
fCurrentEntity.position--;
int length = fCurrentEntity.position - offset;
fCurrentEntity.columnNumber += length - newlines;
- buffer.append(fCurrentEntity.ch, offset, length);
+ buffer.append(fCurrentEntity.ch, offset, length);
return true;
}
}
@@ -813,7 +813,7 @@ public class XMLEncodingDetector {
length -= delimLen;
}
buffer.append (fCurrentEntity.ch, offset, length);
-
+
// return true if string was skipped
} while (!done);
return !done;
@@ -1243,7 +1243,7 @@ public class XMLEncodingDetector {
}
}
}
-
+
// Adapted from:
// org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanXMLDeclOrTextDecl
/**
@@ -1264,7 +1264,7 @@ public class XMLEncodingDetector {
* be scanned instead of an XML
* declaration.
*/
- private void scanXMLDeclOrTextDecl(boolean scanningTextDecl)
+ private void scanXMLDeclOrTextDecl(boolean scanningTextDecl)
throws IOException, JasperException {
// scan decl
@@ -1308,7 +1308,7 @@ public class XMLEncodingDetector {
* at the time of calling is lost.
*/
private void scanXMLDeclOrTextDecl(boolean scanningTextDecl,
- String[] pseudoAttributeValues)
+ String[] pseudoAttributeValues)
throws IOException, JasperException {
// pseudo-attribute values
@@ -1419,7 +1419,7 @@ public class XMLEncodingDetector {
if (scanningTextDecl && state != STATE_DONE) {
err.jspError("jsp.error.xml.morePseudoAttributes");
}
-
+
// If there is no data in the xml or text decl then we fail to report
// error for version or encoding info above.
if (scanningTextDecl) {
@@ -1440,7 +1440,7 @@ public class XMLEncodingDetector {
err.jspError("jsp.error.xml.xmlDeclUnterminated");
}
-
+
// fill in return array
pseudoAttributeValues[0] = version;
pseudoAttributeValues[1] = encoding;
@@ -1453,10 +1453,10 @@ public class XMLEncodingDetector {
* Scans a pseudo attribute.
*
* @param scanningTextDecl True if scanning this pseudo-attribute for a
- * TextDecl; false if scanning XMLDecl. This
+ * TextDecl; false if scanning XMLDecl. This
* flag is needed to report the correct type of
* error.
- * @param value The string to fill in with the attribute
+ * @param value The string to fill in with the attribute
* value.
*
* @return The name of the attribute
@@ -1464,8 +1464,8 @@ public class XMLEncodingDetector {
* <strong>Note:</strong> This method uses fStringBuffer2, anything in it
* at the time of calling is lost.
*/
- public String scanPseudoAttribute(boolean scanningTextDecl,
- XMLString value)
+ public String scanPseudoAttribute(boolean scanningTextDecl,
+ XMLString value)
throws IOException, JasperException {
String name = scanName();
@@ -1524,12 +1524,12 @@ public class XMLEncodingDetector {
return name;
}
-
+
// Adapted from:
// org.apache.xerces.impl.XMLScanner.scanPIData
/**
* Scans a processing data. This is needed to handle the situation
- * where a document starts with a processing instruction whose
+ * where a document starts with a processing instruction whose
* target name <em>starts with</em> "xml". (e.g. xmlfoo)
*
* <strong>Note:</strong> This method uses fStringBuffer, anything in it
@@ -1538,7 +1538,7 @@ public class XMLEncodingDetector {
* @param target The PI target
* @param data The string to fill in with the data
*/
- private void scanPIData(String target, XMLString data)
+ private void scanPIData(String target, XMLString data)
throws IOException, JasperException {
// check target
@@ -1613,7 +1613,7 @@ public class XMLEncodingDetector {
// supplemental character must be a valid XML character
if (!XMLChar.isValid(c)) {
err.jspError("jsp.error.xml.invalidCharInContent",
- Integer.toString(c, 16));
+ Integer.toString(c, 16));
return false;
}
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java?rev=1187803&r1=1187802&r2=1187803&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java Sat Oct 22 21:18:03 2011
@@ -5,9 +5,9 @@
* 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.
@@ -38,7 +38,7 @@ package org.apache.jasper.xmlparser;
* <p>
* <strong>Note:</strong> Methods that are passed an XMLString structure
* are required to copy the information out of the buffer if it is to be
- * saved for use beyond the scope of the method. The contents of the
+ * saved for use beyond the scope of the method. The contents of the
* structure are volatile and the contents of the character buffer cannot
* be assured once the method that is passed this structure returns.
* Therefore, methods passed this structure should not save any reference
@@ -79,7 +79,7 @@ public class XMLString {
/**
* Initializes the contents of the XMLString structure with the
* specified values.
- *
+ *
* @param ch The character array.
* @param offset The offset into the character array.
* @param length The length of characters from the offset.
@@ -96,7 +96,7 @@ public class XMLString {
* <p>
* <strong>Note:</strong> This does not copy the character array;
* only the reference to the array is copied.
- *
+ *
* @param s
*/
public void setValues(XMLString s) {
@@ -114,7 +114,7 @@ public class XMLString {
/**
* Returns true if the contents of this XMLString structure and
* the specified string are equal.
- *
+ *
* @param s The string to compare.
*/
public boolean equals(String s) {
@@ -125,7 +125,7 @@ public class XMLString {
return false;
}
- // is this faster than call s.toCharArray first and compare the
+ // is this faster than call s.toCharArray first and compare the
// two arrays directly, which will possibly involve creating a
// new char array object.
for (int i=0; i<length; i++) {
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/XMLStringBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/XMLStringBuffer.java?rev=1187803&r1=1187802&r2=1187803&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/XMLStringBuffer.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/XMLStringBuffer.java Sat Oct 22 21:18:03 2011
@@ -5,9 +5,9 @@
* 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.
@@ -32,15 +32,15 @@ package org.apache.jasper.xmlparser;
* expecting an XMLString object. This is a safe operation because
* it is assumed that any callee will <strong>not</strong> modify
* the contents of the XMLString structure.
- * <p>
+ * <p>
* The contents of the string are managed by the string buffer. As
* characters are appended, the string buffer will grow as needed.
* <p>
- * <strong>Note:</strong> Never set the <code>ch</code>,
+ * <strong>Note:</strong> Never set the <code>ch</code>,
* <code>offset</code>, and <code>length</code> fields directly.
* These fields are managed by the string buffer. In order to reset
* the buffer, call <code>clear()</code>.
- *
+ *
* @author Andy Clark, IBM
* @author Eric Ye, IBM
*
@@ -61,16 +61,16 @@ public class XMLStringBuffer
//
/**
- *
+ *
*/
public XMLStringBuffer() {
this(DEFAULT_SIZE);
} // <init>()
/**
- *
- *
- * @param size
+ *
+ *
+ * @param size
*/
public XMLStringBuffer(int size) {
ch = new char[size];
@@ -89,8 +89,8 @@ public class XMLStringBuffer
/**
* append
- *
- * @param c
+ *
+ * @param c
*/
public void append(char c) {
if (this.length + 1 > this.ch.length) {
@@ -107,8 +107,8 @@ public class XMLStringBuffer
/**
* append
- *
- * @param s
+ *
+ * @param s
*/
public void append(String s) {
int length = s.length();
@@ -116,7 +116,7 @@ public class XMLStringBuffer
int newLength = this.ch.length*2;
if (newLength < this.length + length + DEFAULT_SIZE)
newLength = this.ch.length + length + DEFAULT_SIZE;
- char[] newch = new char[newLength];
+ char[] newch = new char[newLength];
System.arraycopy(this.ch, 0, newch, 0, this.length);
this.ch = newch;
}
@@ -126,10 +126,10 @@ public class XMLStringBuffer
/**
* append
- *
- * @param ch
- * @param offset
- * @param length
+ *
+ * @param ch
+ * @param offset
+ * @param length
*/
public void append(char[] ch, int offset, int length) {
if (this.length + length > this.ch.length) {
@@ -143,8 +143,8 @@ public class XMLStringBuffer
/**
* append
- *
- * @param s
+ *
+ * @param s
*/
public void append(XMLString s) {
append(s.ch, s.offset, s.length);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org