mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
@@ -73,11 +73,7 @@ public class CharsetConvert {
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isEmpty(String s) {
|
||||
if (s == null || "".equals(s)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return s == null || "".equals(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,11 +56,7 @@ public class CobarFailureDetecter extends DefaultDataSourceFailureDetecter {
|
||||
|
||||
String status = rs.getString(1);
|
||||
|
||||
if ("on".equalsIgnoreCase(status)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return "on".equalsIgnoreCase(status);
|
||||
} catch (Exception ex) {
|
||||
LOG.error("check datasource valid errror", ex);
|
||||
return false;
|
||||
|
||||
@@ -48,8 +48,9 @@ public abstract class SQLObjectImpl implements SQLObject, Serializable {
|
||||
protected abstract void accept0(SQLASTVisitor visitor);
|
||||
|
||||
protected final void acceptChild(SQLASTVisitor visitor, List<? extends SQLObject> children) {
|
||||
for (SQLObject child : children)
|
||||
for (SQLObject child : children) {
|
||||
acceptChild(visitor, child);
|
||||
}
|
||||
}
|
||||
|
||||
protected final void acceptChild(SQLASTVisitor visitor, SQLObject child) {
|
||||
|
||||
@@ -941,9 +941,9 @@ public class Lexer {
|
||||
return this.ch;
|
||||
}
|
||||
|
||||
public void reset(int mark, char mark_ch, Token token) {
|
||||
public void reset(int mark, char markChar, Token token) {
|
||||
this.bp = mark;
|
||||
this.ch = mark_ch;
|
||||
this.ch = markChar;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,18 @@ public class SymbolTable {
|
||||
/** Default table size. */
|
||||
public static final int DEFAULT_TABLE_SIZE = 128;
|
||||
|
||||
public static final int MAX_SIZE = 1024;
|
||||
|
||||
/** Buckets. */
|
||||
private final Entry[] buckets;
|
||||
private final String[] symbols;
|
||||
private final char[][] symbols_char;
|
||||
private final char[][] symbolsChar;
|
||||
|
||||
// actual table size
|
||||
private final int indexMask;
|
||||
|
||||
private int size = 0;
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
@@ -49,7 +53,7 @@ public class SymbolTable {
|
||||
this.indexMask = tableSize - 1;
|
||||
this.buckets = new Entry[tableSize];
|
||||
this.symbols = new String[tableSize];
|
||||
this.symbols_char = new char[tableSize][];
|
||||
this.symbolsChar = new char[tableSize][];
|
||||
}
|
||||
|
||||
//
|
||||
@@ -97,7 +101,7 @@ public class SymbolTable {
|
||||
|
||||
if (sym != null) {
|
||||
if (sym.length() == len) {
|
||||
char[] characters = symbols_char[bucket];
|
||||
char[] characters = symbolsChar[bucket];
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (buffer[offset + i] != characters[i]) {
|
||||
@@ -125,14 +129,19 @@ public class SymbolTable {
|
||||
return entry.symbol;
|
||||
}
|
||||
}
|
||||
|
||||
if (size >= MAX_SIZE) {
|
||||
return new String(buffer, offset, len);
|
||||
}
|
||||
|
||||
// add new entry
|
||||
Entry entry = new Entry(buffer, offset, len, hash, buckets[bucket]);
|
||||
buckets[bucket] = entry;
|
||||
if (match) {
|
||||
symbols[bucket] = entry.symbol;
|
||||
symbols_char[bucket] = entry.characters;
|
||||
symbolsChar[bucket] = entry.characters;
|
||||
}
|
||||
size++;
|
||||
return entry.symbol;
|
||||
|
||||
} // addSymbol(char[],int,int):String
|
||||
|
||||
@@ -187,8 +187,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
|
||||
}
|
||||
|
||||
public void printIndent() {
|
||||
for (int i = 0; i < this.indentCount; ++i)
|
||||
for (int i = 0; i < this.indentCount; ++i) {
|
||||
print(this.indent);
|
||||
}
|
||||
}
|
||||
|
||||
public void println() {
|
||||
|
||||
@@ -227,7 +227,7 @@ public class IPAddress implements Cloneable {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
// get the position of the first dot
|
||||
int index = tmp.indexOf(".");
|
||||
int index = tmp.indexOf('.');
|
||||
|
||||
// if there is not a dot then the ip string representation is
|
||||
// not compliant to the decimal-dotted notation.
|
||||
|
||||
@@ -198,7 +198,7 @@ public class IPRange {
|
||||
throw new IllegalArgumentException("Invalid IP range");
|
||||
}
|
||||
|
||||
int index = range.indexOf("/");
|
||||
int index = range.indexOf('/');
|
||||
String subnetStr = null;
|
||||
if (index == -1) {
|
||||
ipAddress = new IPAddress(range);
|
||||
@@ -257,18 +257,19 @@ public class IPRange {
|
||||
}
|
||||
|
||||
public static String toDecimalString(String inBinaryIpAddress) {
|
||||
String decimalip = new String();
|
||||
StringBuilder decimalip = new StringBuilder();
|
||||
String[] binary = new String[4];
|
||||
|
||||
for (int i = 0, c = 0; i < 32; i = i + 8, c++) {
|
||||
binary[c] = inBinaryIpAddress.substring(i, i + 8);
|
||||
int octet = Integer.parseInt(binary[c], 2);
|
||||
decimalip = decimalip + Integer.toString(octet);
|
||||
decimalip.append(octet);
|
||||
if (c < 3) {
|
||||
decimalip = decimalip + ".";
|
||||
|
||||
decimalip.append('.');
|
||||
}
|
||||
}
|
||||
return decimalip;
|
||||
return decimalip.toString();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@@ -82,15 +82,16 @@ public class SpringMethodInfo {
|
||||
public static String getMethodSignature(Method method) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append(method.getName() + "(");
|
||||
sb.append(method.getName());
|
||||
sb.append('(');
|
||||
Class<?>[] params = method.getParameterTypes();
|
||||
for (int j = 0; j < params.length; j++) {
|
||||
sb.append(params[j].getName());
|
||||
if (j < (params.length - 1)) {
|
||||
sb.append(",");
|
||||
sb.append(',');
|
||||
}
|
||||
}
|
||||
sb.append(")");
|
||||
sb.append(')');
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MapComparator<K extends Object, V extends Object> implements Compar
|
||||
String keyStr = (String) key;
|
||||
|
||||
if (keyStr.matches(".+\\[[0-9]+\\]")) {
|
||||
Object value = map.get(keyStr.substring(0, keyStr.indexOf("[")));
|
||||
Object value = map.get(keyStr.substring(0, keyStr.indexOf('[')));
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user