提交 3881b560 authored 作者: Thomas Mueller's avatar Thomas Mueller

Enable warning for 'Local variable declaration hides another field or variable'.

上级 f076058c
...@@ -46,8 +46,6 @@ public class TestRecover { ...@@ -46,8 +46,6 @@ public class TestRecover {
private static final String URL = System.getProperty("test.url", "jdbc:h2:" + TEST_DIRECTORY + "/test;PAGE_STORE=TRUE"); private static final String URL = System.getProperty("test.url", "jdbc:h2:" + TEST_DIRECTORY + "/test;PAGE_STORE=TRUE");
private static final String DRIVER = System.getProperty("test.driver", "org.h2.Driver"); private static final String DRIVER = System.getProperty("test.driver", "org.h2.Driver");
private Random random;
// private static final String DIR = // private static final String DIR =
// System.getProperty("test.dir", "/temp/derby"); // System.getProperty("test.dir", "/temp/derby");
// private static final String URL = // private static final String URL =
...@@ -176,7 +174,7 @@ public class TestRecover { ...@@ -176,7 +174,7 @@ public class TestRecover {
} }
private void testLoop() throws Exception { private void testLoop() throws Exception {
random = new SecureRandom(); Random random = new SecureRandom();
while (true) { while (true) {
runOneTest(random.nextInt()); runOneTest(random.nextInt());
} }
......
...@@ -48,7 +48,7 @@ public class TestSynth extends TestBase { ...@@ -48,7 +48,7 @@ public class TestSynth extends TestBase {
static final int POSTGRESQL = 4; static final int POSTGRESQL = 4;
private static final String DIR = "synth"; private static final String DIR = "synth";
private DbState db = new DbState(this); private DbState dbState = new DbState(this);
private ArrayList<DbInterface> databases; private ArrayList<DbInterface> databases;
private ArrayList<Command> commands; private ArrayList<Command> commands;
private RandomGen random = new RandomGen(); private RandomGen random = new RandomGen();
...@@ -97,7 +97,7 @@ public class TestSynth extends TestBase { ...@@ -97,7 +97,7 @@ public class TestSynth extends TestBase {
} }
private void add(Command command) throws Exception { private void add(Command command) throws Exception {
command.run(db); command.run(dbState);
commands.add(command); commands.add(command);
} }
...@@ -248,7 +248,7 @@ public class TestSynth extends TestBase { ...@@ -248,7 +248,7 @@ public class TestSynth extends TestBase {
* @return the table * @return the table
*/ */
Table randomTable() { Table randomTable() {
return db.randomTable(); return dbState.randomTable();
} }
/** /**
......
...@@ -82,17 +82,17 @@ public class TestMultiNews extends TestMultiThread { ...@@ -82,17 +82,17 @@ public class TestMultiNews extends TestMultiThread {
} }
void first() throws SQLException { void first() throws SQLException {
Connection conn = base.getConnection(); Connection c = base.getConnection();
Statement stat = conn.createStatement(); Statement stat = c.createStatement();
stat.execute("CREATE TABLE TEST (ID IDENTITY, NAME VARCHAR)"); stat.execute("CREATE TABLE TEST (ID IDENTITY, NAME VARCHAR)");
stat.execute("CREATE TABLE NEWS (FID NUMERIC(19) PRIMARY KEY, COMMENTS LONGVARCHAR, " stat.execute("CREATE TABLE NEWS (FID NUMERIC(19) PRIMARY KEY, COMMENTS LONGVARCHAR, "
+ "LINK VARCHAR(255), STATE INTEGER, VALUE VARCHAR(255))"); + "LINK VARCHAR(255), STATE INTEGER, VALUE VARCHAR(255))");
stat.execute("CREATE INDEX IF NOT EXISTS NEWS_GUID_VALUE_INDEX ON NEWS(VALUE)"); stat.execute("CREATE INDEX IF NOT EXISTS NEWS_GUID_VALUE_INDEX ON NEWS(VALUE)");
stat.execute("CREATE INDEX IF NOT EXISTS NEWS_LINK_INDEX ON NEWS(LINK)"); stat.execute("CREATE INDEX IF NOT EXISTS NEWS_LINK_INDEX ON NEWS(LINK)");
stat.execute("CREATE INDEX IF NOT EXISTS NEWS_STATE_INDEX ON NEWS(STATE)"); stat.execute("CREATE INDEX IF NOT EXISTS NEWS_STATE_INDEX ON NEWS(STATE)");
PreparedStatement prep = conn.prepareStatement("INSERT INTO NEWS (FID, COMMENTS, LINK, STATE, VALUE) VALUES " PreparedStatement prep = c.prepareStatement("INSERT INTO NEWS (FID, COMMENTS, LINK, STATE, VALUE) VALUES "
+ "(?, ?, ?, ?, ?) "); + "(?, ?, ?, ?, ?) ");
PreparedStatement prep2 = conn.prepareStatement("INSERT INTO TEST (NAME) VALUES (?)"); PreparedStatement prep2 = c.prepareStatement("INSERT INTO TEST (NAME) VALUES (?)");
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
int x = random.nextInt(10) * 128; int x = random.nextInt(10) * 128;
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
......
...@@ -31,14 +31,14 @@ public class TestMultiNewsSimple extends TestMultiThread { ...@@ -31,14 +31,14 @@ public class TestMultiNewsSimple extends TestMultiThread {
} }
void first() throws SQLException { void first() throws SQLException {
Connection conn = base.getConnection(); Connection c = base.getConnection();
conn.createStatement().execute("create table news(id identity, state int default 0, text varchar default '')"); c.createStatement().execute("create table news(id identity, state int default 0, text varchar default '')");
PreparedStatement prep = conn.prepareStatement("insert into news() values()"); PreparedStatement prep = c.prepareStatement("insert into news() values()");
for (int i = 0; i < newsCount; i++) { for (int i = 0; i < newsCount; i++) {
prep.executeUpdate(); prep.executeUpdate();
} }
conn.createStatement().execute("update news set text = 'Text' || id"); c.createStatement().execute("update news set text = 'Text' || id");
conn.close(); c.close();
} }
void begin() { void begin() {
......
...@@ -118,18 +118,14 @@ public class TestMultiOrder extends TestMultiThread { ...@@ -118,18 +118,14 @@ public class TestMultiOrder extends TestMultiThread {
} }
void first() throws SQLException { void first() throws SQLException {
Connection conn = base.getConnection(); Connection c = base.getConnection();
conn.createStatement().execute("drop table customer if exists"); c.createStatement().execute("drop table customer if exists");
conn.createStatement().execute("drop table orders if exists"); c.createStatement().execute("drop table orders if exists");
conn.createStatement().execute("drop table orderLine if exists"); c.createStatement().execute("drop table orderLine if exists");
conn.createStatement().execute("create table customer(id int primary key, name varchar, account decimal)"); c.createStatement().execute("create table customer(id int primary key, name varchar, account decimal)");
conn.createStatement().execute( c.createStatement().execute("create table orders(id int identity primary key, customer_id int, total decimal)");
"create table orders(id int identity primary key, customer_id int, total decimal)"); c.createStatement().execute("create table orderLine(order_id int, line_id int, text varchar, amount decimal, primary key(order_id, line_id))");
conn c.close();
.createStatement()
.execute(
"create table orderLine(order_id int, line_id int, text varchar, amount decimal, primary key(order_id, line_id))");
conn.close();
} }
void finalTest() throws SQLException { void finalTest() throws SQLException {
......
...@@ -68,17 +68,17 @@ class Arg { ...@@ -68,17 +68,17 @@ class Arg {
return obj; return obj;
} }
private String quote(Class< ? > clazz, Object value) { private String quote(Class< ? > valueClass, Object value) {
if (value == null) { if (value == null) {
return null; return null;
} else if (clazz == String.class) { } else if (valueClass == String.class) {
return StringUtils.quoteJavaString(value.toString()); return StringUtils.quoteJavaString(value.toString());
} else if (clazz == BigDecimal.class) { } else if (valueClass == BigDecimal.class) {
return "new BigDecimal(\"" + value.toString() + "\")"; return "new BigDecimal(\"" + value.toString() + "\")";
} else if (clazz.isArray()) { } else if (valueClass.isArray()) {
if (clazz == String[].class) { if (valueClass == String[].class) {
return StringUtils.quoteJavaStringArray((String[]) value); return StringUtils.quoteJavaStringArray((String[]) value);
} else if (clazz == int[].class) { } else if (valueClass == int[].class) {
return StringUtils.quoteJavaIntArray((int[]) value); return StringUtils.quoteJavaIntArray((int[]) value);
} }
} }
......
...@@ -71,12 +71,12 @@ public class Player { ...@@ -71,12 +71,12 @@ public class Player {
* Execute a trace file. * Execute a trace file.
* *
* @param fileName the file name * @param fileName the file name
* @param log print debug information * @param trace print debug information
* @param checkResult if the result of each method should be compared
* against the result in the file
*/ */
public static void execute(String fileName, boolean log, boolean checkResult) throws IOException { public static void execute(String fileName, boolean trace) throws IOException {
new Player().runFile(fileName, log); Player player = new Player();
player.trace = trace;
player.runFile(fileName);
} }
private void run(String... args) throws IOException { private void run(String... args) throws IOException {
...@@ -96,11 +96,10 @@ public class Player { ...@@ -96,11 +96,10 @@ public class Player {
+ " [-trace] <fileName>"); + " [-trace] <fileName>");
return; return;
} }
runFile(fileName, trace); runFile(fileName);
} }
private void runFile(String fileName, boolean trace) throws IOException { private void runFile(String fileName) throws IOException {
this.trace = trace;
LineNumberReader reader = new LineNumberReader(new BufferedReader( LineNumberReader reader = new LineNumberReader(new BufferedReader(
new FileReader(fileName))); new FileReader(fileName)));
while (true) { while (true) {
......
...@@ -51,8 +51,8 @@ public class FileObjectDatabase implements FileObject { ...@@ -51,8 +51,8 @@ public class FileObjectDatabase implements FileObject {
pos += len; pos += len;
} }
public void seek(long pos) { public void seek(long newPos) {
this.pos = (int) pos; this.pos = (int) newPos;
} }
public void setFileLength(long newLength) { public void setFileLength(long newLength) {
......
...@@ -165,11 +165,11 @@ public class OutputCatcher { ...@@ -165,11 +165,11 @@ public class OutputCatcher {
/** /**
* Write a character. * Write a character.
* *
* @param error if the character comes from the error stream * @param errorStream if the character comes from the error stream
* @param b the character * @param b the character
*/ */
void write(boolean error, int b) throws IOException { void write(boolean errorStream, int b) throws IOException {
setError(error); setError(errorStream);
switch (b) { switch (b) {
case '\n': case '\n':
super.write(BR); super.write(BR);
......
...@@ -149,7 +149,7 @@ public class BuildBase { ...@@ -149,7 +149,7 @@ public class BuildBase {
/** /**
* The output stream (System.out). * The output stream (System.out).
*/ */
protected PrintStream out = System.out; protected PrintStream sysOut = System.out;
/** /**
* If output should be disabled. * If output should be disabled.
...@@ -185,7 +185,7 @@ public class BuildBase { ...@@ -185,7 +185,7 @@ public class BuildBase {
try { try {
m = getClass().getMethod(a); m = getClass().getMethod(a);
} catch (Exception e) { } catch (Exception e) {
out.println("Unknown target: " + a); sysOut.println("Unknown target: " + a);
projectHelp(); projectHelp();
break; break;
} }
...@@ -226,8 +226,8 @@ public class BuildBase { ...@@ -226,8 +226,8 @@ public class BuildBase {
* Emit a beep. * Emit a beep.
*/ */
protected void beep() { protected void beep() {
out.print("\007"); sysOut.print("\007");
out.flush(); sysOut.flush();
} }
/** /**
...@@ -241,14 +241,14 @@ public class BuildBase { ...@@ -241,14 +241,14 @@ public class BuildBase {
return a.getName().compareTo(b.getName()); return a.getName().compareTo(b.getName());
} }
}); });
out.println("Targets:"); sysOut.println("Targets:");
for (Method m : methods) { for (Method m : methods) {
int mod = m.getModifiers(); int mod = m.getModifiers();
if (!Modifier.isStatic(mod) && Modifier.isPublic(mod) && m.getParameterTypes().length == 0) { if (!Modifier.isStatic(mod) && Modifier.isPublic(mod) && m.getParameterTypes().length == 0) {
out.println(m.getName()); sysOut.println(m.getName());
} }
} }
out.println(); sysOut.println();
} }
private boolean isWindows() { private boolean isWindows() {
...@@ -290,8 +290,8 @@ public class BuildBase { ...@@ -290,8 +290,8 @@ public class BuildBase {
} }
println(""); println("");
Process p = Runtime.getRuntime().exec(cmd.array()); Process p = Runtime.getRuntime().exec(cmd.array());
copyInThread(p.getInputStream(), quiet ? null : out); copyInThread(p.getInputStream(), quiet ? null : sysOut);
copyInThread(p.getErrorStream(), quiet ? null : out); copyInThread(p.getErrorStream(), quiet ? null : sysOut);
p.waitFor(); p.waitFor();
return p.exitValue(); return p.exitValue();
} catch (Exception e) { } catch (Exception e) {
...@@ -851,7 +851,7 @@ public class BuildBase { ...@@ -851,7 +851,7 @@ public class BuildBase {
*/ */
protected void println(String s) { protected void println(String s) {
if (!quiet) { if (!quiet) {
out.println(s); sysOut.println(s);
} }
} }
...@@ -862,7 +862,7 @@ public class BuildBase { ...@@ -862,7 +862,7 @@ public class BuildBase {
*/ */
protected void print(String s) { protected void print(String s) {
if (!quiet) { if (!quiet) {
out.print(s); sysOut.print(s);
} }
} }
......
...@@ -40,11 +40,11 @@ public class RailroadImages { ...@@ -40,11 +40,11 @@ public class RailroadImages {
/** /**
* Create the images. * Create the images.
* *
* @param outDir the target directory * @param out the target directory
*/ */
void run(String outDir) { void run(String out) {
this.outDir = outDir; this.outDir = out;
new File(outDir).mkdirs(); new File(out).mkdirs();
BufferedImage img; BufferedImage img;
Graphics2D g; Graphics2D g;
img = new BufferedImage(SIZE, SIZE, BufferedImage.TYPE_INT_ARGB); img = new BufferedImage(SIZE, SIZE, BufferedImage.TYPE_INT_ARGB);
......
...@@ -51,8 +51,8 @@ public class SpellChecker { ...@@ -51,8 +51,8 @@ public class SpellChecker {
new SpellChecker().run("tools/org/h2/build/doc/dictionary.txt", dir); new SpellChecker().run("tools/org/h2/build/doc/dictionary.txt", dir);
} }
private void run(String dictionary, String dir) throws IOException { private void run(String dictionaryFileName, String dir) throws IOException {
process(new File(dir + "/" + dictionary)); process(new File(dir + "/" + dictionaryFileName));
process(new File(dir)); process(new File(dir));
if (printDictionary) { if (printDictionary) {
System.out.println("USED WORDS"); System.out.println("USED WORDS");
......
...@@ -62,13 +62,8 @@ public class XMLParser { ...@@ -62,13 +62,8 @@ public class XMLParser {
*/ */
public static final int DTD = 11; public static final int DTD = 11;
// public static final int CDATA = 12;
// public static final int NAMESPACE = 13;
// public static final int NOTATION_DECLARATION = 14;
// public static final int ENTITY_DECLARATION = 15;
private String xml; private String xml;
private int index; private int pos;
private int eventType; private int eventType;
private String currentText; private String currentText;
private String currentToken; private String currentToken;
...@@ -98,14 +93,14 @@ public class XMLParser { ...@@ -98,14 +93,14 @@ public class XMLParser {
this.html = html; this.html = html;
} }
private void addAttributeName(String prefix, String localName) { private void addAttributeName(String pre, String name) {
if (attributeValues.length <= currentAttribute) { if (attributeValues.length <= currentAttribute) {
String[] temp = new String[attributeValues.length * 2]; String[] temp = new String[attributeValues.length * 2];
System.arraycopy(attributeValues, 0, temp, 0, attributeValues.length); System.arraycopy(attributeValues, 0, temp, 0, attributeValues.length);
attributeValues = temp; attributeValues = temp;
} }
attributeValues[currentAttribute++] = prefix; attributeValues[currentAttribute++] = pre;
attributeValues[currentAttribute++] = localName; attributeValues[currentAttribute++] = name;
} }
private void addAttributeValue(String v) { private void addAttributeValue(String v) {
...@@ -113,18 +108,18 @@ public class XMLParser { ...@@ -113,18 +108,18 @@ public class XMLParser {
} }
private int readChar() { private int readChar() {
if (index >= xml.length()) { if (pos >= xml.length()) {
return -1; return -1;
} }
return xml.charAt(index++); return xml.charAt(pos++);
} }
private void back() { private void back() {
index--; pos--;
} }
private void error(String expected) { private void error(String expected) {
throw new RuntimeException("Expected: " + expected + " got: " + xml.substring(index, Math.min(index + 1000, xml.length()))); throw new RuntimeException("Expected: " + expected + " got: " + xml.substring(pos, Math.min(pos + 1000, xml.length())));
} }
private void read(String chars) { private void read(String chars) {
...@@ -136,26 +131,26 @@ public class XMLParser { ...@@ -136,26 +131,26 @@ public class XMLParser {
} }
private void skipSpaces() { private void skipSpaces() {
while (index < xml.length() && xml.charAt(index) <= ' ') { while (pos < xml.length() && xml.charAt(pos) <= ' ') {
index++; pos++;
} }
} }
private void read() { private void read() {
currentText = null; currentText = null;
currentAttribute = 0; currentAttribute = 0;
int tokenStart = index, currentStart = index; int tokenStart = pos, currentStart = pos;
int ch = readChar(); int ch = readChar();
if (ch < 0) { if (ch < 0) {
eventType = END_DOCUMENT; eventType = END_DOCUMENT;
} else if (ch == '<') { } else if (ch == '<') {
currentStart = index; currentStart = pos;
ch = readChar(); ch = readChar();
if (ch < 0) { if (ch < 0) {
eventType = ERROR; eventType = ERROR;
} else if (ch == '?') { } else if (ch == '?') {
eventType = PROCESSING_INSTRUCTION; eventType = PROCESSING_INSTRUCTION;
currentStart = index; currentStart = pos;
while (true) { while (true) {
ch = readChar(); ch = readChar();
if (ch < 0) { if (ch < 0) {
...@@ -170,7 +165,7 @@ public class XMLParser { ...@@ -170,7 +165,7 @@ public class XMLParser {
read(); read();
tokenStart = back; tokenStart = back;
} else { } else {
currentText = xml.substring(currentStart, index - 1); currentText = xml.substring(currentStart, pos - 1);
} }
} else if (ch == '!') { } else if (ch == '!') {
ch = readChar(); ch = readChar();
...@@ -179,7 +174,7 @@ public class XMLParser { ...@@ -179,7 +174,7 @@ public class XMLParser {
if (readChar() != '-') { if (readChar() != '-') {
error("-"); error("-");
} }
currentStart = index; currentStart = pos;
while (true) { while (true) {
ch = readChar(); ch = readChar();
if (ch < 0) { if (ch < 0) {
...@@ -190,7 +185,7 @@ public class XMLParser { ...@@ -190,7 +185,7 @@ public class XMLParser {
break; break;
} }
} }
currentText = xml.substring(currentStart, index - 1); currentText = xml.substring(currentStart, pos - 1);
} else if (ch == 'D') { } else if (ch == 'D') {
read("OCTYPE"); read("OCTYPE");
eventType = DTD; eventType = DTD;
...@@ -205,7 +200,7 @@ public class XMLParser { ...@@ -205,7 +200,7 @@ public class XMLParser {
} }
} else if (ch == '[') { } else if (ch == '[') {
read("CDATA["); read("CDATA[");
currentStart = index; currentStart = pos;
eventType = CHARACTERS; eventType = CHARACTERS;
while (true) { while (true) {
ch = readChar(); ch = readChar();
...@@ -225,14 +220,14 @@ public class XMLParser { ...@@ -225,14 +220,14 @@ public class XMLParser {
} }
} while (ch == ']'); } while (ch == ']');
if (ch == '>') { if (ch == '>') {
currentText = xml.substring(currentStart, index - 3); currentText = xml.substring(currentStart, pos - 3);
break; break;
} }
} }
} }
} }
} else if (ch == '/') { } else if (ch == '/') {
currentStart = index; currentStart = pos;
prefix = null; prefix = null;
eventType = END_ELEMENT; eventType = END_ELEMENT;
while (true) { while (true) {
...@@ -240,13 +235,13 @@ public class XMLParser { ...@@ -240,13 +235,13 @@ public class XMLParser {
if (ch < 0) { if (ch < 0) {
error(">"); error(">");
} else if (ch == ':') { } else if (ch == ':') {
prefix = xml.substring(currentStart, index - 1); prefix = xml.substring(currentStart, pos - 1);
currentStart = index + 1; currentStart = pos + 1;
} else if (ch == '>') { } else if (ch == '>') {
localName = xml.substring(currentStart, index - 1); localName = xml.substring(currentStart, pos - 1);
break; break;
} else if (ch <= ' ') { } else if (ch <= ' ') {
localName = xml.substring(currentStart, index - 1); localName = xml.substring(currentStart, pos - 1);
skipSpaces(); skipSpaces();
read(">"); read(">");
break; break;
...@@ -261,23 +256,23 @@ public class XMLParser { ...@@ -261,23 +256,23 @@ public class XMLParser {
if (ch < 0) { if (ch < 0) {
error(">"); error(">");
} else if (ch == ':') { } else if (ch == ':') {
prefix = xml.substring(currentStart, index - 1); prefix = xml.substring(currentStart, pos - 1);
currentStart = index + 1; currentStart = pos + 1;
} else if (ch <= ' ') { } else if (ch <= ' ') {
localName = xml.substring(currentStart, index - 1); localName = xml.substring(currentStart, pos - 1);
readAttributeValues(); readAttributeValues();
ch = readChar(); ch = readChar();
} }
if (ch == '/') { if (ch == '/') {
if (localName == null) { if (localName == null) {
localName = xml.substring(currentStart, index - 1); localName = xml.substring(currentStart, pos - 1);
} }
read(">"); read(">");
endElement = true; endElement = true;
break; break;
} else if (ch == '>') { } else if (ch == '>') {
if (localName == null) { if (localName == null) {
localName = xml.substring(currentStart, index - 1); localName = xml.substring(currentStart, pos - 1);
} }
break; break;
} }
...@@ -295,14 +290,14 @@ public class XMLParser { ...@@ -295,14 +290,14 @@ public class XMLParser {
break; break;
} }
} }
currentText = xml.substring(currentStart, index); currentText = xml.substring(currentStart, pos);
} }
currentToken = xml.substring(tokenStart, index); currentToken = xml.substring(tokenStart, pos);
} }
private void readAttributeValues() { private void readAttributeValues() {
while (true) { while (true) {
int start = index; int start = pos;
int ch = readChar(); int ch = readChar();
if (ch < 0) { if (ch < 0) {
error(">"); error(">");
...@@ -316,7 +311,7 @@ public class XMLParser { ...@@ -316,7 +311,7 @@ public class XMLParser {
int localNameStart = start; int localNameStart = start;
boolean noValue = false; boolean noValue = false;
while (true) { while (true) {
end = index; end = pos;
ch = readChar(); ch = readChar();
if (ch < 0) { if (ch < 0) {
error("="); error("=");
...@@ -335,7 +330,7 @@ public class XMLParser { ...@@ -335,7 +330,7 @@ public class XMLParser {
} else if (ch == '=') { } else if (ch == '=') {
break; break;
} else if (ch == ':') { } else if (ch == ':') {
localNameStart = index; localNameStart = pos;
} else if (ch == '/' || ch == '>') { } else if (ch == '/' || ch == '>') {
if (html) { if (html) {
back(); back();
...@@ -358,9 +353,9 @@ public class XMLParser { ...@@ -358,9 +353,9 @@ public class XMLParser {
if (ch != '\"') { if (ch != '\"') {
error("\""); error("\"");
} }
start = index; start = pos;
while (true) { while (true) {
end = index; end = pos;
ch = readChar(); ch = readChar();
if (ch < 0) { if (ch < 0) {
error("\""); error("\"");
...@@ -379,7 +374,7 @@ public class XMLParser { ...@@ -379,7 +374,7 @@ public class XMLParser {
* @return true if there are more tags * @return true if there are more tags
*/ */
public boolean hasNext() { public boolean hasNext() {
return index < xml.length(); return pos < xml.length();
} }
/** /**
...@@ -477,9 +472,9 @@ public class XMLParser { ...@@ -477,9 +472,9 @@ public class XMLParser {
* @return the full name * @return the full name
*/ */
public String getAttributeName(int index) { public String getAttributeName(int index) {
String prefix = getAttributePrefix(index); String pre = getAttributePrefix(index);
String localName = getAttributeLocalName(index); String name = getAttributeLocalName(index);
return prefix == null || prefix.length() == 0 ? localName : prefix + ":" + localName; return pre == null || pre.length() == 0 ? name : pre + ":" + name;
} }
/** /**
...@@ -496,13 +491,13 @@ public class XMLParser { ...@@ -496,13 +491,13 @@ public class XMLParser {
* Get the value of this attribute. * Get the value of this attribute.
* *
* @param namespaceURI the namespace URI (currently ignored) * @param namespaceURI the namespace URI (currently ignored)
* @param localName the attribute name * @param name the local name of the attribute
* @return the value or null * @return the value or null
*/ */
public String getAttributeValue(String namespaceURI, String localName) { public String getAttributeValue(String namespaceURI, String name) {
int len = getAttributeCount(); int len = getAttributeCount();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if (getAttributeLocalName(i).equals(localName)) { if (getAttributeLocalName(i).equals(name)) {
return getAttributeValue(i); return getAttributeValue(i);
} }
} }
...@@ -554,16 +549,16 @@ public class XMLParser { ...@@ -554,16 +549,16 @@ public class XMLParser {
* @return the remaining XML * @return the remaining XML
*/ */
public String getRemaining() { public String getRemaining() {
return xml.substring(index); return xml.substring(pos);
} }
/** /**
* Get the index of the current position. * Get the current character position in the XML document.
* *
* @return the position * @return the position
*/ */
public int getPos() { public int getPos() {
return index; return pos;
} }
} }
...@@ -627,4 +627,5 @@ checklists serves gbif biodiversity wakes taxon ratio ended ipt auckland ...@@ -627,4 +627,5 @@ checklists serves gbif biodiversity wakes taxon ratio ended ipt auckland
galapagos pacific pastebin mystic posting mysticpaste reject prof tick freeing galapagos pacific pastebin mystic posting mysticpaste reject prof tick freeing
sweden abbreviated xmx trede googlecode gustav standing hashes sweden abbreviated xmx trede googlecode gustav standing hashes
decompressed expansion ziv abbreviated augments omitted gain decompressed expansion ziv abbreviated augments omitted gain
subtracted maxed logical lempel increases subtracted maxed logical lempel increases sibling impersonate proper remembers
moon
...@@ -166,14 +166,13 @@ public class Indexer { ...@@ -166,14 +166,13 @@ public class Indexer {
} }
}); });
for (int i = 0; i < pages.size(); i++) { for (int i = 0; i < pages.size(); i++) {
Page page = pages.get(i); pages.get(i).id = i;
page.id = i;
} }
} }
private void listPages() { private void listPages() {
for (Page page : pages) { for (Page p : pages) {
output.println("pages[" + page.id + "]=new Page('" + convertUTF(page.title) + "', '" + page.fileName output.println("pages[" + p.id + "]=new Page('" + convertUTF(p.title) + "', '" + p.fileName
+ "');"); + "');");
} }
} }
...@@ -226,7 +225,7 @@ public class Indexer { ...@@ -226,7 +225,7 @@ public class Indexer {
totalRelations += weights.size(); totalRelations += weights.size();
for (int j = 0; j < weights.size(); j++) { for (int j = 0; j < weights.size(); j++) {
Weight weight = weights.get(j); Weight weight = weights.get(j);
Page page = weight.page; Page p = weight.page;
if (j > 0) { if (j > 0) {
buff.append(","); buff.append(",");
} }
...@@ -242,7 +241,7 @@ public class Indexer { ...@@ -242,7 +241,7 @@ public class Indexer {
weightString = ws; weightString = ws;
buff.append(ws); buff.append(ws);
} }
buff.append(page.id); buff.append(p.id);
} }
} }
output.println("ref['" + convertUTF(first) + "']='" + buff.toString() + "';"); output.println("ref['" + convertUTF(first) + "']='" + buff.toString() + "';");
......
...@@ -45,9 +45,8 @@ class CacheTQ implements Cache { ...@@ -45,9 +45,8 @@ class CacheTQ implements Cache {
private CacheObject[] values; private CacheObject[] values;
CacheTQ(CacheWriter writer, int maxKb) { CacheTQ(CacheWriter writer, int maxKb) {
int maxSize = maxKb * 1024 / 4;
this.writer = writer; this.writer = writer;
this.maxSize = maxSize; this.maxSize = maxKb * 1024 / 4;
this.len = MathUtils.nextPowerOf2(maxSize / 64); this.len = MathUtils.nextPowerOf2(maxSize / 64);
this.mask = len - 1; this.mask = len - 1;
MathUtils.checkPowerOf2(len); MathUtils.checkPowerOf2(len);
...@@ -56,9 +55,9 @@ class CacheTQ implements Cache { ...@@ -56,9 +55,9 @@ class CacheTQ implements Cache {
} }
public void clear() { public void clear() {
headMain.next = headMain.previous = headMain; headMain.cacheNext = headMain.cachePrevious = headMain;
headIn.next = headIn.previous = headIn; headIn.cacheNext = headIn.cachePrevious = headIn;
headOut.next = headOut.previous = headOut; headOut.cacheNext = headOut.cachePrevious = headOut;
// first set to null - avoiding out of memory // first set to null - avoiding out of memory
values = null; values = null;
values = new CacheObject[len]; values = new CacheObject[len];
...@@ -77,26 +76,26 @@ class CacheTQ implements Cache { ...@@ -77,26 +76,26 @@ class CacheTQ implements Cache {
if (rec == head) { if (rec == head) {
Message.throwInternalError("try to move head"); Message.throwInternalError("try to move head");
} }
if (rec.next != null || rec.previous != null) { if (rec.cacheNext != null || rec.cachePrevious != null) {
Message.throwInternalError("already linked"); Message.throwInternalError("already linked");
} }
} }
rec.next = head; rec.cacheNext = head;
rec.previous = head.previous; rec.cachePrevious = head.cachePrevious;
rec.previous.next = rec; rec.cachePrevious.cacheNext = rec;
head.previous = rec; head.cachePrevious = rec;
} }
private void removeFromList(CacheObject rec) { private void removeFromList(CacheObject rec) {
if (SysProperties.CHECK && (rec instanceof CacheHead && rec.cacheQueue != OUT)) { if (SysProperties.CHECK && (rec instanceof CacheHead && rec.cacheQueue != OUT)) {
Message.throwInternalError(); Message.throwInternalError();
} }
rec.previous.next = rec.next; rec.cachePrevious.cacheNext = rec.cacheNext;
rec.next.previous = rec.previous; rec.cacheNext.cachePrevious = rec.cachePrevious;
// TODO cache: mystery: why is this required? needs more memory if we // TODO cache: mystery: why is this required? needs more memory if we
// don't do this // don't do this
rec.next = null; rec.cacheNext = null;
rec.previous = null; rec.cachePrevious = null;
} }
public CacheObject get(int pos) { public CacheObject get(int pos) {
...@@ -122,7 +121,7 @@ class CacheTQ implements Cache { ...@@ -122,7 +121,7 @@ class CacheTQ implements Cache {
private CacheObject findCacheObject(int pos) { private CacheObject findCacheObject(int pos) {
CacheObject rec = values[pos & mask]; CacheObject rec = values[pos & mask];
while (rec != null && rec.getPos() != pos) { while (rec != null && rec.getPos() != pos) {
rec = rec.chained; rec = rec.cacheChained;
} }
return rec; return rec;
} }
...@@ -134,23 +133,23 @@ class CacheTQ implements Cache { ...@@ -134,23 +133,23 @@ class CacheTQ implements Cache {
return null; return null;
} }
if (rec.getPos() == pos) { if (rec.getPos() == pos) {
values[index] = rec.chained; values[index] = rec.cacheChained;
} else { } else {
CacheObject last; CacheObject last;
do { do {
last = rec; last = rec;
rec = rec.chained; rec = rec.cacheChained;
if (rec == null) { if (rec == null) {
return null; return null;
} }
} while (rec.getPos() != pos); } while (rec.getPos() != pos);
last.chained = rec.chained; last.cacheChained = rec.cacheChained;
} }
if (!(rec instanceof CacheHead)) { if (!(rec instanceof CacheHead)) {
recordCount--; recordCount--;
} }
if (SysProperties.CHECK) { if (SysProperties.CHECK) {
rec.chained = null; rec.cacheChained = null;
} }
return rec; return rec;
} }
...@@ -178,7 +177,7 @@ class CacheTQ implements Cache { ...@@ -178,7 +177,7 @@ class CacheTQ implements Cache {
int i = 0; int i = 0;
ObjectArray<CacheObject> changed = ObjectArray.newInstance(); ObjectArray<CacheObject> changed = ObjectArray.newInstance();
int si = sizeIn, sm = sizeMain, rc = recordCount; int si = sizeIn, sm = sizeMain, rc = recordCount;
CacheObject inNext = headIn.next, mainNext = headMain.next; CacheObject inNext = headIn.cacheNext, mainNext = headMain.cacheNext;
while (((si * 4 > maxIn * 3) || (sm * 4 > maxMain * 3)) while (((si * 4 > maxIn * 3) || (sm * 4 > maxMain * 3))
&& rc > Constants.CACHE_MIN_RECORDS) { && rc > Constants.CACHE_MIN_RECORDS) {
i++; i++;
...@@ -194,7 +193,7 @@ class CacheTQ implements Cache { ...@@ -194,7 +193,7 @@ class CacheTQ implements Cache {
} }
if (si > maxIn) { if (si > maxIn) {
CacheObject r = inNext; CacheObject r = inNext;
inNext = r.next; inNext = r.cacheNext;
if (!r.canRemove()) { if (!r.canRemove()) {
if (r != headIn) { if (r != headIn) {
removeFromList(r); removeFromList(r);
...@@ -211,7 +210,7 @@ class CacheTQ implements Cache { ...@@ -211,7 +210,7 @@ class CacheTQ implements Cache {
} }
} else if (sm > 0) { } else if (sm > 0) {
CacheObject r = mainNext; CacheObject r = mainNext;
mainNext = r.next; mainNext = r.cacheNext;
if (!r.canRemove() && !(r instanceof CacheHead)) { if (!r.canRemove() && !(r instanceof CacheHead)) {
removeFromList(r); removeFromList(r);
addToFront(headMain, r); addToFront(headMain, r);
...@@ -265,7 +264,7 @@ class CacheTQ implements Cache { ...@@ -265,7 +264,7 @@ class CacheTQ implements Cache {
addToFront(headOut, r); addToFront(headOut, r);
sizeOut++; sizeOut++;
while (sizeOut >= maxOut) { while (sizeOut >= maxOut) {
r = headOut.next; r = headOut.cacheNext;
sizeOut--; sizeOut--;
removeCacheObject(r.getPos()); removeCacheObject(r.getPos());
removeFromList(r); removeFromList(r);
...@@ -279,12 +278,12 @@ class CacheTQ implements Cache { ...@@ -279,12 +278,12 @@ class CacheTQ implements Cache {
public ObjectArray<CacheObject> getAllChanged() { public ObjectArray<CacheObject> getAllChanged() {
ObjectArray<CacheObject> list = ObjectArray.newInstance(); ObjectArray<CacheObject> list = ObjectArray.newInstance();
for (CacheObject o = headMain.next; o != headMain; o = o.next) { for (CacheObject o = headMain.cacheNext; o != headMain; o = o.cacheNext) {
if (o.isChanged()) { if (o.isChanged()) {
list.add(o); list.add(o);
} }
} }
for (CacheObject o = headIn.next; o != headIn; o = o.next) { for (CacheObject o = headIn.cacheNext; o != headIn; o = o.cacheNext) {
if (o.isChanged()) { if (o.isChanged()) {
list.add(o); list.add(o);
} }
...@@ -311,7 +310,7 @@ class CacheTQ implements Cache { ...@@ -311,7 +310,7 @@ class CacheTQ implements Cache {
} }
} }
int index = rec.getPos() & mask; int index = rec.getPos() & mask;
rec.chained = values[index]; rec.cacheChained = values[index];
values[index] = rec; values[index] = rec;
if (!(rec instanceof CacheHead)) { if (!(rec instanceof CacheHead)) {
recordCount++; recordCount++;
......
...@@ -235,8 +235,8 @@ public class Query<T> { ...@@ -235,8 +235,8 @@ public class Query<T> {
return this; return this;
} }
public Query<T> groupBy(Object... groupByExpressions) { public Query<T> groupBy(Object... groupBy) {
this.groupByExpressions = groupByExpressions; this.groupByExpressions = groupBy;
return this; return this;
} }
......
...@@ -61,7 +61,7 @@ class SelectTable <T> { ...@@ -61,7 +61,7 @@ class SelectTable <T> {
} }
} }
void appendSQLAsJoin(SQLStatement stat, Query<T> query) { void appendSQLAsJoin(SQLStatement stat, Query<T> q) {
if (outerJoin) { if (outerJoin) {
stat.appendSQL(" LEFT OUTER JOIN "); stat.appendSQL(" LEFT OUTER JOIN ");
} else { } else {
...@@ -71,7 +71,7 @@ class SelectTable <T> { ...@@ -71,7 +71,7 @@ class SelectTable <T> {
if (!joinConditions.isEmpty()) { if (!joinConditions.isEmpty()) {
stat.appendSQL(" ON "); stat.appendSQL(" ON ");
for (Token token : joinConditions) { for (Token token : joinConditions) {
token.appendSQL(stat, query); token.appendSQL(stat, q);
stat.appendSQL(" "); stat.appendSQL(" ");
} }
} }
......
...@@ -153,22 +153,22 @@ class TableDefinition<T> { ...@@ -153,22 +153,22 @@ class TableDefinition<T> {
} }
private String getDataType(Field field) { private String getDataType(Field field) {
Class< ? > clazz = field.getType(); Class< ? > fieldClass = field.getType();
if (clazz == Integer.class) { if (fieldClass == Integer.class) {
return "INT"; return "INT";
} else if (clazz == String.class) { } else if (fieldClass == String.class) {
return "VARCHAR"; return "VARCHAR";
} else if (clazz == Double.class) { } else if (fieldClass == Double.class) {
return "DOUBLE"; return "DOUBLE";
} else if (clazz == java.math.BigDecimal.class) { } else if (fieldClass == java.math.BigDecimal.class) {
return "DECIMAL"; return "DECIMAL";
} else if (clazz == java.util.Date.class) { } else if (fieldClass == java.util.Date.class) {
return "DATE"; return "DATE";
} else if (clazz == java.sql.Date.class) { } else if (fieldClass == java.sql.Date.class) {
return "DATE"; return "DATE";
} else if (clazz == java.sql.Time.class) { } else if (fieldClass == java.sql.Time.class) {
return "TIME"; return "TIME";
} else if (clazz == java.sql.Timestamp.class) { } else if (fieldClass == java.sql.Timestamp.class) {
return "TIMESTAMP"; return "TIMESTAMP";
} }
return "VARCHAR"; return "VARCHAR";
......
...@@ -33,7 +33,7 @@ public class ClassReader { ...@@ -33,7 +33,7 @@ public class ClassReader {
private Token result; private Token result;
private Stack<Token> stack = new Stack<Token>(); private Stack<Token> stack = new Stack<Token>();
private ArrayList<Token> variables = new ArrayList<Token>(); private ArrayList<Token> variables = new ArrayList<Token>();
private boolean end; private boolean endOfMethod;
private boolean condition; private boolean condition;
private int nextPc; private int nextPc;
private Map<String, Object> fieldMap = new HashMap<String, Object>(); private Map<String, Object> fieldMap = new HashMap<String, Object>();
...@@ -44,9 +44,9 @@ public class ClassReader { ...@@ -44,9 +44,9 @@ public class ClassReader {
} }
} }
public Token decompile(Object instance, Map<String, Object> fieldMap, String methodName) { public Token decompile(Object instance, Map<String, Object> fields, String method) {
this.fieldMap = fieldMap; this.fieldMap = fields;
this.convertMethodName = methodName; this.convertMethodName = method;
Class< ? > clazz = instance.getClass(); Class< ? > clazz = instance.getClass();
String className = clazz.getName(); String className = clazz.getName();
debug("class name " + className); debug("class name " + className);
...@@ -226,7 +226,7 @@ public class ClassReader { ...@@ -226,7 +226,7 @@ public class ClassReader {
private Token getResult() { private Token getResult() {
while (true) { while (true) {
readByteCode(); readByteCode();
if (end) { if (endOfMethod) {
return stack.pop(); return stack.pop();
} }
if (condition) { if (condition) {
...@@ -266,7 +266,7 @@ public class ClassReader { ...@@ -266,7 +266,7 @@ public class ClassReader {
int startPos = pos - startByteCode; int startPos = pos - startByteCode;
int opCode = readByte(); int opCode = readByte();
String op; String op;
end = false; endOfMethod = false;
condition = false; condition = false;
nextPc = 0; nextPc = 0;
switch(opCode) { switch(opCode) {
...@@ -1165,29 +1165,29 @@ public class ClassReader { ...@@ -1165,29 +1165,29 @@ public class ClassReader {
// } // }
case 172: case 172:
op = "ireturn"; op = "ireturn";
end = true; endOfMethod = true;
break; break;
case 173: case 173:
op = "lreturn"; op = "lreturn";
end = true; endOfMethod = true;
break; break;
case 174: case 174:
op = "freturn"; op = "freturn";
end = true; endOfMethod = true;
break; break;
case 175: case 175:
op = "dreturn"; op = "dreturn";
end = true; endOfMethod = true;
break; break;
case 176: case 176:
op = "areturn"; op = "areturn";
end = true; endOfMethod = true;
break; break;
case 177: case 177:
op = "return"; op = "return";
// no value returned // no value returned
stack.push(null); stack.push(null);
end = true; endOfMethod = true;
break; break;
// case 178: // case 178:
// op = "getstatic " + getField(readShort()); // op = "getstatic " + getField(readShort());
...@@ -1224,8 +1224,8 @@ public class ClassReader { ...@@ -1224,8 +1224,8 @@ public class ClassReader {
break; break;
} }
case 183: { case 183: {
String methodName = getMethod(readShort()); String method = getMethod(readShort());
op = "invokespecial " + methodName; op = "invokespecial " + method;
break; break;
} }
case 184: case 184:
...@@ -1414,8 +1414,8 @@ public class ClassReader { ...@@ -1414,8 +1414,8 @@ public class ClassReader {
return new String(chars, 0, j); return new String(chars, 0, j);
} }
private int getAbsolutePos(int pos, int offset) { private int getAbsolutePos(int start, int offset) {
return pos - startByteCode - 1 + (short) offset; return start - startByteCode - 1 + (short) offset;
} }
private int readByte() { private int readByte() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论