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 2013/02/16 23:26:32 UTC
svn commit: r1446966 - in /tomcat/trunk/java/org/apache/jasper/xmlparser:
ASCIIReader.java ParserUtils.java SymbolTable.java TreeNode.java
UCSReader.java UTF8Reader.java XMLChar.java
Author: markt
Date: Sat Feb 16 22:26:32 2013
New Revision: 1446966
URL: http://svn.apache.org/r1446966
Log:
UCDetector
- use final
- reduce visibility
- remove unused code
Modified:
tomcat/trunk/java/org/apache/jasper/xmlparser/ASCIIReader.java
tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java
tomcat/trunk/java/org/apache/jasper/xmlparser/SymbolTable.java
tomcat/trunk/java/org/apache/jasper/xmlparser/TreeNode.java
tomcat/trunk/java/org/apache/jasper/xmlparser/UCSReader.java
tomcat/trunk/java/org/apache/jasper/xmlparser/UTF8Reader.java
tomcat/trunk/java/org/apache/jasper/xmlparser/XMLChar.java
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/ASCIIReader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/ASCIIReader.java?rev=1446966&r1=1446965&r2=1446966&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/ASCIIReader.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/ASCIIReader.java Sat Feb 16 22:26:32 2013
@@ -38,10 +38,10 @@ public class ASCIIReader extends Reader
//
/** Input stream. */
- protected InputStream fInputStream;
+ private final InputStream fInputStream;
/** Byte buffer. */
- protected byte[] fBuffer;
+ private final byte[] fBuffer;
//
// Constructors
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java?rev=1446966&r1=1446965&r2=1446966&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java Sat Feb 16 22:26:32 2013
@@ -56,12 +56,12 @@ public class ParserUtils {
/**
* An error handler for use when parsing XML documents.
*/
- static ErrorHandler errorHandler = new MyErrorHandler();
+ private static final ErrorHandler errorHandler = new MyErrorHandler();
/**
* An entity resolver for use when parsing XML documents.
*/
- static EntityResolver entityResolver = new MyEntityResolver();
+ private static EntityResolver entityResolver = new MyEntityResolver();
// Turn off for JSP 2.0 until switch over to using xschema.
public static boolean validating = false;
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/SymbolTable.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/SymbolTable.java?rev=1446966&r1=1446965&r2=1446966&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/SymbolTable.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/SymbolTable.java Sat Feb 16 22:26:32 2013
@@ -58,17 +58,17 @@ public class SymbolTable {
//
/** Default table size. */
- protected static final int TABLE_SIZE = 101;
+ private static final int TABLE_SIZE = 101;
//
// Data
//
/** Buckets. */
- protected Entry[] fBuckets = null;
+ private final Entry[] fBuckets;
// actual table size
- protected int fTableSize;
+ private final int fTableSize;
//
// Constructors
@@ -95,37 +95,6 @@ public class SymbolTable {
* the previous symbol reference is returned instead, in order
* guarantee that symbol references remain unique.
*
- * @param symbol The new symbol.
- */
- public String addSymbol(String symbol) {
-
- // search for identical symbol
- int bucket = hash(symbol) % fTableSize;
- int length = symbol.length();
- OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
- if (length == entry.characters.length) {
- for (int i = 0; i < length; i++) {
- if (symbol.charAt(i) != entry.characters[i]) {
- continue OUTER;
- }
- }
- return entry.symbol;
- }
- }
-
- // create new entry
- Entry entry = new Entry(symbol, fBuckets[bucket]);
- fBuckets[bucket] = entry;
- return entry.symbol;
-
- } // addSymbol(String):String
-
- /**
- * Adds the specified symbol to the symbol table and returns a
- * reference to the unique symbol. If the symbol already exists,
- * the previous symbol reference is returned instead, in order
- * guarantee that symbol references remain unique.
- *
* @param buffer The buffer containing the new symbol.
* @param offset The offset into the buffer of the new symbol.
* @param length The length of the new symbol in the buffer.
@@ -153,25 +122,6 @@ public class SymbolTable {
} // addSymbol(char[],int,int):String
/**
- * Returns a hashcode value for the specified symbol. The value
- * returned by this method must be identical to the value returned
- * by the <code>hash(char[],int,int)</code> method when called
- * with the character array that comprises the symbol string.
- *
- * @param symbol The symbol to hash.
- */
- public int hash(String symbol) {
-
- int code = 0;
- int length = symbol.length();
- for (int i = 0; i < length; i++) {
- code = code * 37 + symbol.charAt(i);
- }
- return code & 0x7FFFFFF;
-
- } // hash(String):int
-
- /**
* Returns a hashcode value for the specified symbol information.
* The value returned by this method must be identical to the value
* returned by the <code>hash(String)</code> method when called
@@ -192,59 +142,6 @@ public class SymbolTable {
} // hash(char[],int,int):int
- /**
- * Returns true if the symbol table already contains the specified
- * symbol.
- *
- * @param symbol The symbol to look for.
- */
- public boolean containsSymbol(String symbol) {
-
- // search for identical symbol
- int bucket = hash(symbol) % fTableSize;
- int length = symbol.length();
- OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
- if (length == entry.characters.length) {
- for (int i = 0; i < length; i++) {
- if (symbol.charAt(i) != entry.characters[i]) {
- continue OUTER;
- }
- }
- return true;
- }
- }
-
- return false;
-
- } // containsSymbol(String):boolean
-
- /**
- * Returns true if the symbol table already contains the specified
- * symbol.
- *
- * @param buffer The buffer containing the symbol to look for.
- * @param offset The offset into the buffer.
- * @param length The length of the symbol in the buffer.
- */
- public boolean containsSymbol(char[] buffer, int offset, int length) {
-
- // search for identical symbol
- int bucket = hash(buffer, offset, length) % fTableSize;
- OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
- if (length == entry.characters.length) {
- for (int i = 0; i < length; i++) {
- if (buffer[offset + i] != entry.characters[i]) {
- continue OUTER;
- }
- }
- return true;
- }
- }
-
- return false;
-
- } // containsSymbol(char[],int,int):boolean
-
//
// Classes
//
@@ -253,40 +150,29 @@ public class SymbolTable {
* This class is a symbol table entry. Each entry acts as a node
* in a linked list.
*/
- protected static final class Entry {
+ private static final class Entry {
//
// Data
//
/** Symbol. */
- public String symbol;
+ private final String symbol;
/**
* Symbol characters. This information is duplicated here for
* comparison performance.
*/
- public char[] characters;
+ private final char[] characters;
/** The next entry. */
- public Entry next;
+ private final Entry next;
//
// Constructors
//
/**
- * Constructs a new entry from the specified symbol and next entry
- * reference.
- */
- public Entry(String symbol, Entry next) {
- this.symbol = symbol.intern();
- characters = new char[symbol.length()];
- symbol.getChars(0, characters.length, characters, 0);
- this.next = next;
- }
-
- /**
* Constructs a new entry from the specified symbol information and
* next entry reference.
*/
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/TreeNode.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/TreeNode.java?rev=1446966&r1=1446965&r2=1446966&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/TreeNode.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/TreeNode.java Sat Feb 16 22:26:32 2013
@@ -68,31 +68,31 @@ public class TreeNode {
* The attributes of this node, keyed by attribute name,
* Instantiated only if required.
*/
- protected HashMap<String,String> attributes = null;
+ private HashMap<String,String> attributes = null;
/**
* The body text associated with this node (if any).
*/
- protected String body = null;
+ private String body = null;
/**
* The children of this node, instantiated only if required.
*/
- protected ArrayList<TreeNode> children = null;
+ private ArrayList<TreeNode> children = null;
/**
* The name of this node.
*/
- protected String name = null;
+ private final String name;
/**
* The parent node of this node.
*/
- protected TreeNode parent = null;
+ private final TreeNode parent;
// --------------------------------------------------------- Public Methods
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/UCSReader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/UCSReader.java?rev=1446966&r1=1446965&r2=1446966&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/UCSReader.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/UCSReader.java Sat Feb 16 22:26:32 2013
@@ -42,7 +42,7 @@ public class UCSReader extends Reader {
* since it's reasonable to surmise that the average UCS-4-encoded
* file should be 4 times as large as the average ASCII-encoded file).
*/
- public static final int DEFAULT_BUFFER_SIZE = 8192;
+ private static final int DEFAULT_BUFFER_SIZE = 8192;
public static final short UCS2LE = 1;
public static final short UCS2BE = 2;
@@ -54,13 +54,13 @@ public class UCSReader extends Reader {
//
/** Input stream. */
- protected InputStream fInputStream;
+ private final InputStream fInputStream;
/** Byte buffer. */
- protected byte[] fBuffer;
+ private final byte[] fBuffer;
// what kind of data we're dealing with
- protected short fEncoding;
+ private final short fEncoding;
//
// Constructors
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/UTF8Reader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/UTF8Reader.java?rev=1446966&r1=1446965&r2=1446966&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/UTF8Reader.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/UTF8Reader.java Sat Feb 16 22:26:32 2013
@@ -45,13 +45,13 @@ public class UTF8Reader
//
/** Input stream. */
- protected InputStream fInputStream;
+ private final InputStream fInputStream;
/** Byte buffer. */
- protected byte[] fBuffer;
+ private final byte[] fBuffer;
/** Offset into buffer. */
- protected int fOffset;
+ private int fOffset;
/** Surrogate character. */
private int fSurrogate = -1;
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/XMLChar.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/XMLChar.java?rev=1446966&r1=1446965&r2=1446966&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/XMLChar.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/XMLChar.java Sat Feb 16 22:26:32 2013
@@ -61,19 +61,16 @@ public class XMLChar {
private static final byte[] CHARS = new byte[1 << 16];
/** Valid character mask. */
- public static final int MASK_VALID = 0x01;
+ private static final int MASK_VALID = 0x01;
/** Space character mask. */
- public static final int MASK_SPACE = 0x02;
+ private static final int MASK_SPACE = 0x02;
/** Name start character mask. */
- public static final int MASK_NAME_START = 0x04;
+ private static final int MASK_NAME_START = 0x04;
/** Name character mask. */
- public static final int MASK_NAME = 0x08;
-
- /** Pubid character mask. */
- public static final int MASK_PUBID = 0x10;
+ private static final int MASK_NAME = 0x08;
/**
* Content character mask. Special characters are those that can
@@ -83,13 +80,7 @@ public class XMLChar {
* <p>
* This is an optimization for the inner loop of character scanning.
*/
- public static final int MASK_CONTENT = 0x20;
-
- /** NCName start character mask. */
- public static final int MASK_NCNAME_START = 0x40;
-
- /** NCName character mask. */
- public static final int MASK_NCNAME = 0x80;
+ private static final int MASK_CONTENT = 0x20;
//
// Static initialization
@@ -727,15 +718,6 @@ public class XMLChar {
//
/**
- * Returns true if the specified character is a supplemental character.
- *
- * @param c The character to check.
- */
- public static boolean isSupplemental(int c) {
- return (c >= 0x10000 && c <= 0x10FFFF);
- }
-
- /**
* Returns true the supplemental character corresponding to the given
* surrogates.
*
@@ -747,24 +729,6 @@ public class XMLChar {
}
/**
- * Returns the high surrogate of a supplemental character
- *
- * @param c The supplemental character to "split".
- */
- public static char highSurrogate(int c) {
- return (char) (((c - 0x00010000) >> 10) + 0xD800);
- }
-
- /**
- * Returns the low surrogate of a supplemental character
- *
- * @param c The supplemental character to "split".
- */
- public static char lowSurrogate(int c) {
- return (char) (((c - 0x00010000) & 0x3FF) + 0xDC00);
- }
-
- /**
* Returns whether the given character is a high surrogate
*
* @param c The character to check.
@@ -818,16 +782,6 @@ public class XMLChar {
} // isContent(int):boolean
/**
- * Returns true if the specified character can be considered markup.
- * Markup characters include '<', '&', and '%'.
- *
- * @param c The character to check.
- */
- public static boolean isMarkup(int c) {
- return c == '<' || c == '&' || c == '%';
- } // isMarkup(int):boolean
-
- /**
* Returns true if the specified character is a space character
* as defined by production [3] in the XML 1.0 specification.
*
@@ -859,114 +813,6 @@ public class XMLChar {
return c < 0x10000 && (CHARS[c] & MASK_NAME) != 0;
} // isName(int):boolean
- /**
- * Returns true if the specified character is a valid NCName start
- * character as defined by production [4] in Namespaces in XML
- * recommendation.
- *
- * @param c The character to check.
- */
- public static boolean isNCNameStart(int c) {
- return c < 0x10000 && (CHARS[c] & MASK_NCNAME_START) != 0;
- } // isNCNameStart(int):boolean
-
- /**
- * Returns true if the specified character is a valid NCName
- * character as defined by production [5] in Namespaces in XML
- * recommendation.
- *
- * @param c The character to check.
- */
- public static boolean isNCName(int c) {
- return c < 0x10000 && (CHARS[c] & MASK_NCNAME) != 0;
- } // isNCName(int):boolean
-
- /**
- * Returns true if the specified character is a valid Pubid
- * character as defined by production [13] in the XML 1.0
- * specification.
- *
- * @param c The character to check.
- */
- public static boolean isPubid(int c) {
- return c < 0x10000 && (CHARS[c] & MASK_PUBID) != 0;
- } // isPubid(int):boolean
-
- /*
- * [5] Name ::= (Letter | '_' | ':') (NameChar)*
- */
- /**
- * Check to see if a string is a valid Name according to [5]
- * in the XML 1.0 Recommendation
- *
- * @param name string to check
- * @return true if name is a valid Name
- */
- public static boolean isValidName(String name) {
- if (name.length() == 0)
- return false;
- char ch = name.charAt(0);
- if( isNameStart(ch) == false)
- return false;
- for (int i = 1; i < name.length(); i++ ) {
- ch = name.charAt(i);
- if( isName( ch ) == false ){
- return false;
- }
- }
- return true;
- } // isValidName(String):boolean
-
-
- /*
- * from the namespace rec
- * [4] NCName ::= (Letter | '_') (NCNameChar)*
- */
- /**
- * Check to see if a string is a valid NCName according to [4]
- * from the XML Namespaces 1.0 Recommendation
- *
- * @param ncName string to check
- * @return true if name is a valid NCName
- */
- public static boolean isValidNCName(String ncName) {
- if (ncName.length() == 0)
- return false;
- char ch = ncName.charAt(0);
- if( isNCNameStart(ch) == false)
- return false;
- for (int i = 1; i < ncName.length(); i++ ) {
- ch = ncName.charAt(i);
- if( isNCName( ch ) == false ){
- return false;
- }
- }
- return true;
- } // isValidNCName(String):boolean
-
- /*
- * [7] Nmtoken ::= (NameChar)+
- */
- /**
- * Check to see if a string is a valid Nmtoken according to [7]
- * in the XML 1.0 Recommendation
- *
- * @param nmtoken string to check
- * @return true if nmtoken is a valid Nmtoken
- */
- public static boolean isValidNmtoken(String nmtoken) {
- if (nmtoken.length() == 0)
- return false;
- for (int i = 0; i < nmtoken.length(); i++ ) {
- char ch = nmtoken.charAt(i);
- if( ! isName( ch ) ){
- return false;
- }
- }
- return true;
- } // isValidName(String):boolean
-
-
// encodings
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org