aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2018-11-27 02:59:03 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2018-11-27 02:59:03 +0000
commitf6315def9c252d7b3866eb580d4c0c5de003a86e (patch)
tree928b5a3075b3081437039123c9d10173c223f884
parent985b8674968ca118a4845280174aa69924242145 (diff)
downloadjackcess-f6315def9c252d7b3866eb580d4c0c5de003a86e.tar.gz
jackcess-f6315def9c252d7b3866eb580d4c0c5de003a86e.zip
switch to commons lang3
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jdk8@1230 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r--pom.xml10
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/expr/Identifier.java9
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/CompoundOleUtil.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java20
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java4
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/IndexData.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/IndexImpl.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/IndexPageCache.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/OleUtil.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/RowIdImpl.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java12
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/expr/StringValue.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/query/QueryFormat.java15
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/util/RowFilter.java32
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/util/SimpleColumnMatcher.java8
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java57
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/util/ExportTest.java11
21 files changed, 98 insertions, 102 deletions
diff --git a/pom.xml b/pom.xml
index 41af67c..a876000 100644
--- a/pom.xml
+++ b/pom.xml
@@ -194,9 +194,9 @@
</build>
<dependencies>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.8.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
@@ -254,10 +254,10 @@
<minmemory>128m</minmemory>
<maxmemory>512</maxmemory>
<links>
- <list>http://docs.oracle.com/javase/1.5.0/docs/api/</list>
+ <list>https://docs.oracle.com/javase/8/docs/api/</list>
<list>http://docs.oracle.com/javaee/5/api/</list>
</links>
- <source>1.5</source>
+ <source>1.8</source>
<show>public</show>
<stylesheetfile>${basedir}/src/site/javadoc/stylesheet.css</stylesheetfile>
<tags>
diff --git a/src/main/java/com/healthmarketscience/jackcess/expr/Identifier.java b/src/main/java/com/healthmarketscience/jackcess/expr/Identifier.java
index 45db1ad..709a7cd 100644
--- a/src/main/java/com/healthmarketscience/jackcess/expr/Identifier.java
+++ b/src/main/java/com/healthmarketscience/jackcess/expr/Identifier.java
@@ -16,7 +16,8 @@ limitations under the License.
package com.healthmarketscience.jackcess.expr;
-import org.apache.commons.lang.ObjectUtils;
+import java.util.Objects;
+
/**
* identifies a database entity (e.g. the name of a database field). An
@@ -71,9 +72,9 @@ public class Identifier
Identifier oi = (Identifier)o;
- return (ObjectUtils.equals(_objectName, oi._objectName) &&
- ObjectUtils.equals(_collectionName, oi._collectionName) &&
- ObjectUtils.equals(_propertyName, oi._propertyName));
+ return (Objects.equals(_objectName, oi._objectName) &&
+ Objects.equals(_collectionName, oi._collectionName) &&
+ Objects.equals(_propertyName, oi._propertyName));
}
@Override
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
index be2bf1c..8fa1906 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
@@ -54,7 +54,7 @@ import com.healthmarketscience.jackcess.expr.Identifier;
import com.healthmarketscience.jackcess.impl.complex.ComplexValueForeignKeyImpl;
import com.healthmarketscience.jackcess.util.ColumnValidator;
import com.healthmarketscience.jackcess.util.SimpleColumnValidator;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/CompoundOleUtil.java b/src/main/java/com/healthmarketscience/jackcess/impl/CompoundOleUtil.java
index 8440f81..18811c3 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/CompoundOleUtil.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/CompoundOleUtil.java
@@ -32,7 +32,7 @@ import com.healthmarketscience.jackcess.RuntimeIOException;
import static com.healthmarketscience.jackcess.impl.OleUtil.*;
import com.healthmarketscience.jackcess.util.MemFileChannel;
import static com.healthmarketscience.jackcess.util.OleBlob.*;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.DocumentInputStream;
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java b/src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java
index 707e163..89ef061 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java
@@ -21,9 +21,8 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
-import org.apache.commons.lang.SystemUtils;
-import org.apache.commons.lang.builder.StandardToStringStyle;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.StandardToStringStyle;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* Custom ToStringStyle for use with ToStringBuilder.
@@ -34,7 +33,7 @@ public class CustomToStringStyle extends StandardToStringStyle
{
private static final long serialVersionUID = 0L;
- private static final String ML_FIELD_SEP = SystemUtils.LINE_SEPARATOR + " ";
+ private static final String ML_FIELD_SEP = System.lineSeparator() + " ";
private static final String IMPL_SUFFIX = "Impl";
private static final int MAX_BYTE_DETAIL_LEN = 20;
private static final Object IGNORE_ME = new Object();
@@ -47,7 +46,7 @@ public class CustomToStringStyle extends StandardToStringStyle
setFieldSeparatorAtStart(true);
setFieldNameValueSeparator(": ");
setArraySeparator("," + ML_FIELD_SEP);
- setContentEnd(SystemUtils.LINE_SEPARATOR + "]");
+ setContentEnd(System.lineSeparator() + "]");
setUseShortClassName(true);
}
};
@@ -91,7 +90,7 @@ public class CustomToStringStyle extends StandardToStringStyle
}
@Override
- protected String getShortClassName(Class clss) {
+ protected String getShortClassName(Class<?> clss) {
String shortName = super.getShortClassName(clss);
if(shortName.endsWith(IMPL_SUFFIX)) {
shortName = shortName.substring(0,
@@ -116,7 +115,7 @@ public class CustomToStringStyle extends StandardToStringStyle
@Override
protected void appendDetail(StringBuffer buffer, String fieldName,
- Collection value) {
+ Collection<?> value) {
buffer.append("[");
// gather contents of list in a new StringBuffer
@@ -145,13 +144,12 @@ public class CustomToStringStyle extends StandardToStringStyle
@Override
protected void appendDetail(StringBuffer buffer, String fieldName,
- Map value) {
+ Map<?,?> value) {
buffer.append("{");
// gather contents of map in a new StringBuffer
StringBuffer sb = new StringBuffer();
- @SuppressWarnings("unchecked")
- Iterator<Map.Entry<?,?>> iter = value.entrySet().iterator();
+ Iterator<? extends Map.Entry<?,?>> iter = value.entrySet().iterator();
if(iter.hasNext()) {
if(isFieldSeparatorAtStart()) {
appendFieldSeparator(sb);
@@ -203,7 +201,7 @@ public class CustomToStringStyle extends StandardToStringStyle
private static String indent(Object obj) {
return ((obj != null) ? obj.toString().replaceAll(
- SystemUtils.LINE_SEPARATOR, ML_FIELD_SEP) : null);
+ System.lineSeparator(), ML_FIELD_SEP) : null);
}
public static Object ignoreNull(Object obj) {
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
index 6831e99..220d5b0 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
@@ -73,8 +73,8 @@ import com.healthmarketscience.jackcess.util.LinkResolver;
import com.healthmarketscience.jackcess.util.ReadOnlyFileChannel;
import com.healthmarketscience.jackcess.util.SimpleColumnValidatorFactory;
import com.healthmarketscience.jackcess.util.TableIterableBuilder;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/IndexData.java b/src/main/java/com/healthmarketscience/jackcess/impl/IndexData.java
index e2b2dd5..341859d 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/IndexData.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/IndexData.java
@@ -33,7 +33,7 @@ import com.healthmarketscience.jackcess.IndexBuilder;
import com.healthmarketscience.jackcess.RuntimeIOException;
import static com.healthmarketscience.jackcess.impl.ByteUtil.ByteStream;
import static com.healthmarketscience.jackcess.impl.IndexCodes.*;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/IndexImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/IndexImpl.java
index 0fbd231..5332432 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/IndexImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/IndexImpl.java
@@ -25,7 +25,7 @@ import java.util.Map;
import com.healthmarketscience.jackcess.CursorBuilder;
import com.healthmarketscience.jackcess.Index;
import com.healthmarketscience.jackcess.IndexBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/IndexPageCache.java b/src/main/java/com/healthmarketscience/jackcess/impl/IndexPageCache.java
index 4ee1882..d594c1c 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/IndexPageCache.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/IndexPageCache.java
@@ -29,7 +29,7 @@ import java.util.Map;
import java.util.RandomAccess;
import static com.healthmarketscience.jackcess.impl.IndexData.*;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* Manager of the index pages for a IndexData.
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/OleUtil.java b/src/main/java/com/healthmarketscience/jackcess/impl/OleUtil.java
index d8a2336..466b6a4 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/OleUtil.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/OleUtil.java
@@ -35,7 +35,7 @@ import java.util.regex.Pattern;
import com.healthmarketscience.jackcess.DataType;
import com.healthmarketscience.jackcess.util.OleBlob;
import static com.healthmarketscience.jackcess.util.OleBlob.*;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* Utility code for working with OLE data.
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/RowIdImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/RowIdImpl.java
index 7bfab4a..5ce8214 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/RowIdImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/RowIdImpl.java
@@ -19,7 +19,7 @@ package com.healthmarketscience.jackcess.impl;
import java.io.Serializable;
import com.healthmarketscience.jackcess.RowId;
-import org.apache.commons.lang.builder.CompareToBuilder;
+import org.apache.commons.lang3.builder.CompareToBuilder;
/**
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java
index 15a0c8c..e065f05 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java
@@ -52,7 +52,7 @@ import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.expr.Identifier;
import com.healthmarketscience.jackcess.util.ErrorHandler;
import com.healthmarketscience.jackcess.util.ExportUtil;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java
index 5643766..fcc9cb5 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java
@@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
-
package com.healthmarketscience.jackcess.impl.expr;
import java.math.BigDecimal;
@@ -23,7 +22,6 @@ import com.healthmarketscience.jackcess.expr.EvalException;
import com.healthmarketscience.jackcess.expr.Function;
import com.healthmarketscience.jackcess.expr.LocaleContext;
import com.healthmarketscience.jackcess.expr.Value;
-import org.apache.commons.lang.WordUtils;
import static com.healthmarketscience.jackcess.impl.expr.DefaultFunctions.*;
import static com.healthmarketscience.jackcess.impl.expr.FunctionSupport.*;
@@ -360,6 +358,7 @@ public class DefaultTextFunctions
}
});
+ @SuppressWarnings("deprecation")
public static final Function STRCONV = registerStringFunc(new FuncVar("StrConv", 2, 3) {
@Override
protected Value evalVar(EvalContext ctx, Value[] params) {
@@ -387,7 +386,8 @@ public class DefaultTextFunctions
break;
case 3:
// vbProperCase
- str = WordUtils.capitalize(str.toLowerCase());
+ str = org.apache.commons.lang3.text.WordUtils.capitalize(
+ str.toLowerCase());
break;
default:
// do nothing
@@ -441,11 +441,11 @@ public class DefaultTextFunctions
String fmtStr = params[1].getAsString(ctx);
int firstDay = DefaultDateFunctions.getFirstDayParam(ctx, params, 2);
int firstWeekType = DefaultDateFunctions.getFirstWeekTypeParam(ctx, params, 3);
-
+
return FormatUtil.format(ctx, expr, fmtStr, firstDay, firstWeekType);
}
});
-
+
private static String nchars(int num, char c) {
StringBuilder sb = new StringBuilder(num);
nchars(sb, num, c);
@@ -457,7 +457,7 @@ public class DefaultTextFunctions
sb.append(c);
}
}
-
+
private static String trim(String str, boolean doLeft, boolean doRight) {
int start = 0;
int end = str.length();
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java
index d2bb847..bee27ca 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java
@@ -47,7 +47,7 @@ import com.healthmarketscience.jackcess.expr.TemporalConfig;
import com.healthmarketscience.jackcess.expr.Value;
import com.healthmarketscience.jackcess.impl.expr.ExpressionTokenizer.Token;
import com.healthmarketscience.jackcess.impl.expr.ExpressionTokenizer.TokenType;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
/**
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/StringValue.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/StringValue.java
index 19b22eb..197d8b5 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/StringValue.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/StringValue.java
@@ -23,7 +23,7 @@ import java.text.DecimalFormatSymbols;
import com.healthmarketscience.jackcess.expr.EvalException;
import com.healthmarketscience.jackcess.expr.LocaleContext;
import com.healthmarketscience.jackcess.expr.Value;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
/**
*
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryFormat.java b/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryFormat.java
index f9513d4..f0272f3 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryFormat.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryFormat.java
@@ -22,14 +22,13 @@ import java.util.regex.Pattern;
import com.healthmarketscience.jackcess.DataType;
import com.healthmarketscience.jackcess.query.Query;
-import org.apache.commons.lang.SystemUtils;
/**
* Constants used by the query data parsing.
- *
+ *
* @author James Ahlborn
*/
-public class QueryFormat
+public class QueryFormat
{
private QueryFormat() {}
@@ -90,7 +89,7 @@ public class QueryFormat
public static final short APPEND_VALUE_FLAG = (short)0x8000;
public static final short CROSSTAB_PIVOT_FLAG = 0x01;
- public static final short CROSSTAB_NORMAL_FLAG = 0x02;
+ public static final short CROSSTAB_NORMAL_FLAG = 0x02;
public static final String UNION_PART1 = "X7YZ_____1";
public static final String UNION_PART2 = "X7YZ_____2";
@@ -102,10 +101,10 @@ public class QueryFormat
public static final Pattern IDENTIFIER_SEP_PAT = Pattern.compile("\\.");
public static final char IDENTIFIER_SEP_CHAR = '.';
- public static final String NEWLINE = SystemUtils.LINE_SEPARATOR;
+ public static final String NEWLINE = System.lineSeparator();
- public static final Map<Short,String> PARAM_TYPE_MAP =
+ public static final Map<Short,String> PARAM_TYPE_MAP =
new HashMap<Short,String>();
static {
PARAM_TYPE_MAP.put((short)0, "Value");
@@ -123,7 +122,7 @@ public class QueryFormat
PARAM_TYPE_MAP.put((short)DataType.GUID.getValue(), "Guid");
}
- public static final Map<Short,String> JOIN_TYPE_MAP =
+ public static final Map<Short,String> JOIN_TYPE_MAP =
new HashMap<Short,String>();
static {
JOIN_TYPE_MAP.put((short)1, " INNER JOIN ");
@@ -131,7 +130,7 @@ public class QueryFormat
JOIN_TYPE_MAP.put((short)3, " RIGHT JOIN ");
}
- public static final Map<Short,Query.Type> TYPE_MAP =
+ public static final Map<Short,Query.Type> TYPE_MAP =
new HashMap<Short,Query.Type>();
static {
for(Query.Type type : Query.Type.values()) {
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java
index 6b51236..389ca90 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java
@@ -27,7 +27,7 @@ import com.healthmarketscience.jackcess.impl.RowIdImpl;
import com.healthmarketscience.jackcess.impl.RowImpl;
import static com.healthmarketscience.jackcess.impl.query.QueryFormat.*;
import com.healthmarketscience.jackcess.query.Query;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/src/main/java/com/healthmarketscience/jackcess/util/RowFilter.java b/src/main/java/com/healthmarketscience/jackcess/util/RowFilter.java
index 440d9dd..607bf9a 100644
--- a/src/main/java/com/healthmarketscience/jackcess/util/RowFilter.java
+++ b/src/main/java/com/healthmarketscience/jackcess/util/RowFilter.java
@@ -19,17 +19,17 @@ package com.healthmarketscience.jackcess.util;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
+import java.util.Objects;
import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.Row;
-import org.apache.commons.lang.ObjectUtils;
/**
* The RowFilter class encapsulates a filter test for a table row. This can
* be used by the {@link #apply(Iterable)} method to create an Iterable over a
* table which returns only rows matching some criteria.
- *
+ *
* @author Patricia Donaldson, Xerox Corporation
* @usage _general_class_
*/
@@ -59,22 +59,22 @@ public abstract class RowFilter
/**
* Creates a filter based on a row pattern.
- *
+ *
* @param rowPattern Map from column names to the values to be matched.
* A table row will match the target if
- * {@code ObjectUtils.equals(rowPattern.get(s), row.get(s))}
+ * {@code Objects.equals(rowPattern.get(s), row.get(s))}
* for all column names in the pattern map.
* @return a filter which matches table rows which match the values in the
* row pattern
*/
- public static RowFilter matchPattern(final Map<String,?> rowPattern)
+ public static RowFilter matchPattern(final Map<String,?> rowPattern)
{
return new RowFilter() {
@Override
- public boolean matches(Row row)
+ public boolean matches(Row row)
{
for(Map.Entry<String,?> e : rowPattern.entrySet()) {
- if(!ObjectUtils.equals(e.getValue(), row.get(e.getKey()))) {
+ if(!Objects.equals(e.getValue(), row.get(e.getKey()))) {
return false;
}
}
@@ -89,18 +89,18 @@ public abstract class RowFilter
* @param columnPattern column to be matched
* @param valuePattern value to be matched.
* A table row will match the target if
- * {@code ObjectUtils.equals(valuePattern, row.get(columnPattern.getName()))}.
+ * {@code Objects.equals(valuePattern, row.get(columnPattern.getName()))}.
* @return a filter which matches table rows which match the value in the
* row pattern
*/
- public static RowFilter matchPattern(final Column columnPattern,
- final Object valuePattern)
+ public static RowFilter matchPattern(final Column columnPattern,
+ final Object valuePattern)
{
return new RowFilter() {
@Override
- public boolean matches(Row row)
+ public boolean matches(Row row)
{
- return ObjectUtils.equals(valuePattern, columnPattern.getRowValue(row));
+ return Objects.equals(valuePattern, columnPattern.getRowValue(row));
}
};
}
@@ -118,7 +118,7 @@ public abstract class RowFilter
{
return new RowFilter() {
@Override
- public boolean matches(Row row)
+ public boolean matches(Row row)
{
return !filter.matches(row);
}
@@ -140,7 +140,7 @@ public abstract class RowFilter
public static Iterable<Row> apply(RowFilter rowFilter,
Iterable<? extends Row> iterable)
{
- return((rowFilter != null) ? rowFilter.apply(iterable) :
+ return((rowFilter != null) ? rowFilter.apply(iterable) :
(Iterable<Row>)iterable);
}
@@ -152,7 +152,7 @@ public abstract class RowFilter
{
private final Iterable<? extends Row> _iterable;
- private FilterIterable(Iterable<? extends Row> iterable)
+ private FilterIterable(Iterable<? extends Row> iterable)
{
_iterable = iterable;
}
@@ -163,7 +163,7 @@ public abstract class RowFilter
* iterable, returning only rows for which the {@link RowFilter#matches}
* method returns {@code true}
*/
- public Iterator<Row> iterator()
+ public Iterator<Row> iterator()
{
return new Iterator<Row>() {
private final Iterator<? extends Row> _iter = _iterable.iterator();
diff --git a/src/main/java/com/healthmarketscience/jackcess/util/SimpleColumnMatcher.java b/src/main/java/com/healthmarketscience/jackcess/util/SimpleColumnMatcher.java
index a564834..b814e93 100644
--- a/src/main/java/com/healthmarketscience/jackcess/util/SimpleColumnMatcher.java
+++ b/src/main/java/com/healthmarketscience/jackcess/util/SimpleColumnMatcher.java
@@ -19,12 +19,12 @@ package com.healthmarketscience.jackcess.util;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Objects;
import com.healthmarketscience.jackcess.DataType;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.impl.ColumnImpl;
import com.healthmarketscience.jackcess.impl.DatabaseImpl;
-import org.apache.commons.lang.ObjectUtils;
/**
* Simple concrete implementation of ColumnMatcher which tests for equality.
@@ -48,7 +48,7 @@ public class SimpleColumnMatcher implements ColumnMatcher {
return true;
}
- if((value1 != null) && (value2 != null) &&
+ if((value1 != null) && (value2 != null) &&
(value1.getClass() != value2.getClass())) {
// the values aren't the same type, try coercing them to "internal"
@@ -58,7 +58,7 @@ public class SimpleColumnMatcher implements ColumnMatcher {
DatabaseImpl db = (DatabaseImpl)table.getDatabase();
Object internalV1 = ColumnImpl.toInternalValue(dataType, value1, db);
Object internalV2 = ColumnImpl.toInternalValue(dataType, value2, db);
-
+
return equals(internalV1, internalV2);
} catch(IOException e) {
// ignored, just go with the original result
@@ -73,7 +73,7 @@ public class SimpleColumnMatcher implements ColumnMatcher {
*/
private static boolean equals(Object o1, Object o2)
{
- return (ObjectUtils.equals(o1, o2) ||
+ return (Objects.equals(o1, o2) ||
((o1 instanceof byte[]) && (o2 instanceof byte[]) &&
Arrays.equals((byte[])o1, (byte[])o2)));
}
diff --git a/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java b/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java
index f7e48f4..f2fe675 100644
--- a/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java
@@ -29,9 +29,8 @@ import com.healthmarketscience.jackcess.TestUtil;
import com.healthmarketscience.jackcess.impl.query.QueryImpl;
import com.healthmarketscience.jackcess.impl.query.QueryImpl.Row;
import junit.framework.TestCase;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
-import static org.apache.commons.lang.SystemUtils.LINE_SEPARATOR;
import static com.healthmarketscience.jackcess.impl.query.QueryFormat.*;
import static com.healthmarketscience.jackcess.impl.JetFormatTest.*;
@@ -53,22 +52,22 @@ public class QueryTest extends TestCase
String expr2 = "Select * from Table2";
UnionQuery query = (UnionQuery)newQuery(
- Query.Type.UNION,
+ Query.Type.UNION,
newRow(TABLE_ATTRIBUTE, expr1, null, UNION_PART1),
newRow(TABLE_ATTRIBUTE, expr2, null, UNION_PART2));
setFlag(query, 3);
assertEquals(multiline("Select * from Table1",
- "UNION Select * from Table2;"),
+ "UNION Select * from Table2;"),
query.toSQLString());
setFlag(query, 1);
assertEquals(multiline("Select * from Table1",
- "UNION ALL Select * from Table2;"),
+ "UNION ALL Select * from Table2;"),
query.toSQLString());
- addRows(query, newRow(ORDERBY_ATTRIBUTE, "Table1.id",
+ addRows(query, newRow(ORDERBY_ATTRIBUTE, "Table1.id",
null, null));
assertEquals(multiline("Select * from Table1",
@@ -112,7 +111,7 @@ public class QueryTest extends TestCase
public void testUpdateQuery() throws Exception
{
UpdateQuery query = (UpdateQuery)newQuery(
- Query.Type.UPDATE,
+ Query.Type.UPDATE,
newRow(TABLE_ATTRIBUTE, null, "Table1", null),
newRow(COLUMN_ATTRIBUTE, "\"some string\"", null, "Table1.id"),
newRow(COLUMN_ATTRIBUTE, "42", null, "Table1.col1"));
@@ -122,7 +121,7 @@ public class QueryTest extends TestCase
"SET Table1.id = \"some string\", Table1.col1 = 42;"),
query.toSQLString());
- addRows(query, newRow(WHERE_ATTRIBUTE, "(Table1.col2 < 13)",
+ addRows(query, newRow(WHERE_ATTRIBUTE, "(Table1.col2 < 13)",
null, null));
assertEquals(
@@ -135,14 +134,14 @@ public class QueryTest extends TestCase
public void testSelectQuery() throws Exception
{
SelectQuery query = (SelectQuery)newQuery(
- Query.Type.SELECT,
+ Query.Type.SELECT,
newRow(TABLE_ATTRIBUTE, null, "Table1", null));
setFlag(query, 1);
assertEquals(multiline("SELECT *",
"FROM Table1;"),
query.toSQLString());
-
+
doTestColumns(query);
doTestSelectFlags(query);
doTestParameters(query);
@@ -168,7 +167,7 @@ public class QueryTest extends TestCase
}
addRows(query, newRow(TYPE_ATTRIBUTE, null, -1, null, null));
-
+
try {
query.getTypeRow();
fail("IllegalStateException should have been thrown");
@@ -265,7 +264,7 @@ public class QueryTest extends TestCase
newRow(COLUMN_ATTRIBUTE, "54", APPEND_VALUE_FLAG, null, null),
newRow(COLUMN_ATTRIBUTE, "'hello'", APPEND_VALUE_FLAG, null, null));
- assertEquals(multiline("INSERT INTO Table2",
+ assertEquals(multiline("INSERT INTO Table2",
"VALUES (54, 'hello');"), query.toSQLString());
query = (AppendQuery)newQuery(
@@ -274,7 +273,7 @@ public class QueryTest extends TestCase
newRow(COLUMN_ATTRIBUTE, "54", APPEND_VALUE_FLAG, null, "ID"),
newRow(COLUMN_ATTRIBUTE, "'hello'", APPEND_VALUE_FLAG, null, "Field 3"));
- assertEquals(multiline("INSERT INTO Table2 (ID, [Field 3])",
+ assertEquals(multiline("INSERT INTO Table2 (ID, [Field 3])",
"VALUES (54, 'hello');"), query.toSQLString());
}
@@ -291,27 +290,27 @@ public class QueryTest extends TestCase
private void doTestSelectFlags(SelectQuery query) throws Exception
{
setFlag(query, 3);
-
+
assertEquals(multiline("SELECT DISTINCT Table1.id, Table1.col AS [Some.Alias], *",
"FROM Table1;"),
query.toSQLString());
setFlag(query, 9);
-
+
assertEquals(multiline("SELECT DISTINCTROW Table1.id, Table1.col AS [Some.Alias], *",
"FROM Table1;"),
query.toSQLString());
setFlag(query, 7);
-
+
assertEquals(multiline("SELECT DISTINCT Table1.id, Table1.col AS [Some.Alias], *",
"FROM Table1",
"WITH OWNERACCESS OPTION;"),
query.toSQLString());
- replaceRows(query,
+ replaceRows(query,
newRow(FLAG_ATTRIBUTE, null, 49, null, "5", null));
-
+
assertEquals(multiline("SELECT TOP 5 PERCENT Table1.id, Table1.col AS [Some.Alias], *",
"FROM Table1;"),
query.toSQLString());
@@ -354,7 +353,7 @@ public class QueryTest extends TestCase
assertEquals(multiline("SELECT Table1.id, Table1.col AS [Some.Alias]",
"FROM Table1, Table2 AS [Another Table], [Select val from Table3].val AS Table3Val;"),
- query.toSQLString());
+ query.toSQLString());
}
private void doTestRemoteDb(SelectQuery query) throws Exception
@@ -387,7 +386,7 @@ public class QueryTest extends TestCase
assertEquals(multiline("SELECT Table1.id, Table1.col AS [Some.Alias]",
"FROM [Select val from Table3].val AS Table3Val, Table1 INNER JOIN Table2 AS [Another Table] ON (Table1.id = [Another Table].id);"),
query.toSQLString());
-
+
addRows(query, newRow(JOIN_ATTRIBUTE, "(Table1.id = Table3Val.id)", 2, "Table1", "Table3Val"));
assertEquals(multiline("SELECT Table1.id, Table1.col AS [Some.Alias]",
@@ -417,13 +416,13 @@ public class QueryTest extends TestCase
private void doTestWhereExpression(SelectQuery query) throws Exception
{
- addRows(query, newRow(WHERE_ATTRIBUTE, "(Table1.col2 < 13)",
+ addRows(query, newRow(WHERE_ATTRIBUTE, "(Table1.col2 < 13)",
null, null));
assertEquals(multiline("SELECT Table1.id, Table1.col AS [Some.Alias]",
"FROM Table1, Table2 AS [Another Table], [Select val from Table3].val AS Table3Val",
"WHERE (Table1.col2 < 13);"),
- query.toSQLString());
+ query.toSQLString());
}
private void doTestGroupings(SelectQuery query) throws Exception
@@ -435,7 +434,7 @@ public class QueryTest extends TestCase
"FROM Table1, Table2 AS [Another Table], [Select val from Table3].val AS Table3Val",
"WHERE (Table1.col2 < 13)",
"GROUP BY Table1.id, SUM(Table1.val);"),
- query.toSQLString());
+ query.toSQLString());
}
private void doTestHavingExpression(SelectQuery query) throws Exception
@@ -447,7 +446,7 @@ public class QueryTest extends TestCase
"WHERE (Table1.col2 < 13)",
"GROUP BY Table1.id, SUM(Table1.val)",
"HAVING (SUM(Table1.val) = 500);"),
- query.toSQLString());
+ query.toSQLString());
}
private void doTestOrderings(SelectQuery query) throws Exception
@@ -461,7 +460,7 @@ public class QueryTest extends TestCase
"GROUP BY Table1.id, SUM(Table1.val)",
"HAVING (SUM(Table1.val) = 500)",
"ORDER BY Table1.id, Table2.val DESC;"),
- query.toSQLString());
+ query.toSQLString());
}
public void testComplexJoins() throws Exception
@@ -484,7 +483,7 @@ public class QueryTest extends TestCase
addJoinRows(query, 1, 2, 1,
2, 1, 1);
-
+
assertEquals(multiline("SELECT *",
"FROM Table3, Table4, Table5, Table6, Table7, Table8, Table9, Table10, Table1 INNER JOIN Table2 ON (Table2.f3 = Table1.f3) AND (Table1.f0 = Table2.f0);"),
query.toSQLString());
@@ -498,7 +497,7 @@ public class QueryTest extends TestCase
} catch(IllegalStateException e) {
// success
}
-
+
addJoinRows(query, 1, 2, 1,
3, 4, 1,
5, 6, 1,
@@ -613,7 +612,7 @@ public class QueryTest extends TestCase
private static void setFlag(Query query, Number newFlagNum)
{
- replaceRows(query,
+ replaceRows(query,
newRow(FLAG_ATTRIBUTE, null, newFlagNum, null, null, null));
}
@@ -646,7 +645,7 @@ public class QueryTest extends TestCase
private static String multiline(String... strs)
{
- return StringUtils.join(strs, LINE_SEPARATOR);
+ return StringUtils.join(strs, System.lineSeparator());
}
}
diff --git a/src/test/java/com/healthmarketscience/jackcess/util/ExportTest.java b/src/test/java/com/healthmarketscience/jackcess/util/ExportTest.java
index 754be06..5ffdbd9 100644
--- a/src/test/java/com/healthmarketscience/jackcess/util/ExportTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/util/ExportTest.java
@@ -30,7 +30,6 @@ import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.TableBuilder;
import com.healthmarketscience.jackcess.impl.JetFormatTest;
import junit.framework.TestCase;
-import org.apache.commons.lang.SystemUtils;
import static com.healthmarketscience.jackcess.TestUtil.*;
/**
@@ -39,7 +38,7 @@ import static com.healthmarketscience.jackcess.TestUtil.*;
*/
public class ExportTest extends TestCase
{
- private static final String NL = SystemUtils.LINE_SEPARATOR;
+ private static final String NL = System.lineSeparator();
public ExportTest(String name) {
@@ -78,7 +77,7 @@ public class ExportTest extends TestCase
new ExportUtil.Builder(db, "test")
.exportWriter(new BufferedWriter(out));
- String expected =
+ String expected =
"some text||some more,13,13.25,\"61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78\n79 7A 61 62 63 64\",true," + testDate + NL +
"\"crazy'data\"\"here\",-345,-3.45E-4,61 62 63 64 65 66 67,true," + NL +
"C:\\temp\\some_file.txt,25,0.0,,false," + NL;
@@ -86,14 +85,14 @@ public class ExportTest extends TestCase
assertEquals(expected, out.toString());
out = new StringWriter();
-
+
new ExportUtil.Builder(db, "test")
.setHeader(true)
.setDelimiter("||")
.setQuote('\'')
.exportWriter(new BufferedWriter(out));
- expected =
+ expected =
"col1||col2||col3||col4||col5||col6" + NL +
"'some text||some more'||13||13.25||'61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78\n79 7A 61 62 63 64'||true||" + testDate + NL +
"'crazy''data\"here'||-345||-3.45E-4||61 62 63 64 65 66 67||true||" + NL +
@@ -117,7 +116,7 @@ public class ExportTest extends TestCase
.setFilter(oddFilter)
.exportWriter(new BufferedWriter(out));
- expected =
+ expected =
"some text||some more,13,13.25,\"61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78\n79 7A 61 62 63 64\",true," + testDate + NL +
"C:\\temp\\some_file.txt,25,0.0,,false," + NL;