Skip to content
Snippets Groups Projects
Commit 6f8ff70a authored by Mark Taylor's avatar Mark Taylor
Browse files

replace references to since-J2SE6 methods in ADQL lib

Replace uses of String.isEmpty and Arrays.copyOf methods
(both introduced in java 6) with equivalent code that makes
use of only methods available in the java 5 runtime.
This allows the ADQL library, if cross-compiled for java 5,
to run without errors on a java 5 runtime.
parent 94b00c57
No related branches found
No related tags found
No related merge requests found
......@@ -215,7 +215,9 @@ public class DBChecker implements QueryChecker {
tmp[cnt++] = udf;
}
// make a copy of the array:
this.allowedUdfs = Arrays.copyOf(tmp, cnt, FunctionDef[].class);
this.allowedUdfs = new FunctionDef[cnt];
System.arraycopy(tmp, 0, this.allowedUdfs, 0, cnt);
tmp = null;
// sort the values:
Arrays.sort(this.allowedUdfs);
......@@ -318,7 +320,8 @@ public class DBChecker implements QueryChecker {
}
// Make an adjusted array copy:
String[] copy = Arrays.copyOf(tmp, cnt);
String[] copy = new String[cnt];
System.arraycopy(tmp, 0, copy, 0, cnt);
// Sort the values:
Arrays.sort(copy);
......
......@@ -66,15 +66,15 @@ public class UnresolvedIdentifiersException extends ParseException implements It
exceptions.add(pe);
if (pe instanceof UnresolvedColumnException){
String colName = ((UnresolvedColumnException)pe).getColumnName();
if (colName != null && !colName.trim().isEmpty())
if (colName != null && colName.trim().length()>0)
addIdentifierName(colName + " " + pe.getPosition());
}else if (pe instanceof UnresolvedTableException){
String tableName = ((UnresolvedTableException)pe).getTableName();
if (tableName != null && !tableName.trim().isEmpty())
if (tableName != null && tableName.trim().length()>0)
addIdentifierName(tableName + " " + pe.getPosition());
}else if (pe instanceof UnresolvedFunctionException){
String fctName = (((UnresolvedFunctionException)pe).getFunction() == null) ? null : ((UnresolvedFunctionException)pe).getFunction().getName() + "(...)";
if (fctName != null && !fctName.trim().isEmpty())
if (fctName != null && fctName.trim().length()>0)
addIdentifierName(fctName /*+ " " + pe.getPosition()*/); // TODO Add the position of the function in the ADQL query!
}else if (pe instanceof UnresolvedIdentifiersException)
addIdentifierName(((UnresolvedIdentifiersException)pe).unresolvedIdentifiers);
......@@ -87,7 +87,7 @@ public class UnresolvedIdentifiersException extends ParseException implements It
* @param name Name (or description) of the identifier to add.
*/
private final void addIdentifierName(final String name){
if (name != null && !name.trim().isEmpty()){
if (name != null && name.trim().length()>0){
if (unresolvedIdentifiers == null)
unresolvedIdentifiers = "";
else
......
......@@ -398,7 +398,7 @@ public class ADQLParser implements ADQLParserConstants {
try{
if (file == null || file.isEmpty())
if (file == null || file.length()==0)
parser = new ADQLParser(System.in);
else if (file.matches(urlRegex))
parser = new ADQLParser((new java.net.URL(file)).openStream());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment