This is an automated email from the ASF dual-hosted git repository.
doebele pushed a commit to branch version3
in repository https://gitbox.apache.org/repos/asf/empire-db.git
The following commit(s) were added to refs/heads/version3 by this push:
new aaa23d6 EMPIREDB-365
aaa23d6 is described below
commit aaa23d6444a703a313bcd78700a5bbbbb451355b
Author: Rainer Döbele <[email protected]>
AuthorDate: Sat Jan 22 12:53:41 2022 +0100
EMPIREDB-365
---
.../org/apache/empire/jsf2/app/WebDBContext.java | 6 +
.../java/org/apache/empire/commons/DateUtils.java | 119 ++++++++++++++++++
.../org/apache/empire/commons/ObjectUtils.java | 134 ++++++++++++++++++---
.../org/apache/empire/db/DBDatabaseDriver.java | 10 ++
.../java/org/apache/empire/db/DBRecordData.java | 50 ++++++++
.../main/java/org/apache/empire/db/DBRowSet.java | 15 ++-
.../java/org/apache/empire/db/DBTableColumn.java | 34 ++----
.../empire/exceptions/InvalidValueException.java | 43 +++++++
pom.xml | 4 +-
9 files changed, 369 insertions(+), 46 deletions(-)
diff --git
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebDBContext.java
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebDBContext.java
index 8f8b8a5..2cecdd9 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebDBContext.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebDBContext.java
@@ -4,6 +4,7 @@ import java.sql.Connection;
import javax.faces.context.FacesContext;
+import org.apache.empire.db.DBCommand;
import org.apache.empire.db.DBDatabase;
import org.apache.empire.db.DBDatabaseDriver;
import org.apache.empire.db.context.DBContextBase;
@@ -43,6 +44,11 @@ public class WebDBContext<DB extends DBDatabase> extends
DBContextBase
return database;
}
+ public DBCommand createCommand()
+ {
+ return super.createCommand(database);
+ }
+
@Override
public DBDatabaseDriver getDriver()
{
diff --git a/empire-db/src/main/java/org/apache/empire/commons/DateUtils.java
b/empire-db/src/main/java/org/apache/empire/commons/DateUtils.java
index 913cfcf..17c754e 100644
--- a/empire-db/src/main/java/org/apache/empire/commons/DateUtils.java
+++ b/empire-db/src/main/java/org/apache/empire/commons/DateUtils.java
@@ -21,6 +21,11 @@ package org.apache.empire.commons;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.format.FormatStyle;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
@@ -119,6 +124,28 @@ public class DateUtils
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
+
+ public static Date getDateTime(int year, int month, int day, int hours,
int minutes, int seconds, int millis)
+ {
+ Calendar calendar = Calendar.getInstance();
+ if (year>0)
+ calendar.set(Calendar.YEAR, year);
+ if (month>0)
+ calendar.set(Calendar.MONTH, month-1);
+ if (day>0)
+ calendar.set(Calendar.DAY_OF_MONTH, day);
+ // No Time
+ calendar.set(Calendar.HOUR_OF_DAY, hours);
+ calendar.set(Calendar.MINUTE, minutes);
+ calendar.set(Calendar.SECOND, seconds);
+ calendar.set(Calendar.MILLISECOND, millis);
+ return calendar.getTime();
+ }
+
+ public static Date getDateTime(int year, int month, int day, int hours,
int minutes, int seconds)
+ {
+ return getDateTime(year, month, day, hours, minutes, seconds, 0);
+ }
public static Date setTime(Date date, int hours, int minutes, int seconds,
int millis)
{
@@ -234,4 +261,96 @@ public class DateUtils
c.setTime(d);
return sdf.format(d);
}
+
+ /*
+ * LocalDate
+ */
+
+ public static LocalDate toLocalDate(java.sql.Date date)
+ {
+ return date.toLocalDate();
+ }
+
+ public static LocalDate toLocalDate(java.sql.Timestamp timestamp)
+ {
+ return timestamp.toLocalDateTime().toLocalDate();
+ }
+
+ public static LocalDateTime toLocalDateTime(java.sql.Date date)
+ {
+ return date.toLocalDate().atStartOfDay();
+ }
+
+ public static LocalDateTime toLocalDateTime(java.sql.Timestamp timestamp)
+ {
+ return timestamp.toLocalDateTime();
+ }
+
+ public static LocalDate toLocalDate(Date date)
+ { // return
Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
+ return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+ }
+
+ public static LocalDateTime toLocalDateTime(Date date) {
+ // return
Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
+ return
date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+ }
+
+ public static Date toDate(LocalDate localDate) {
+ // return
java.util.Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
+ return java.sql.Date.valueOf(localDate);
+ }
+
+ public static Date toDate(LocalDateTime localDateTime) {
+ // return
java.util.Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
+ return java.sql.Timestamp.valueOf(localDateTime);
+ }
+
+ public static LocalDate parseLocalDate(String date) {
+ // DateTimeFormatter ISO_LOCAL_DATE
+ return LocalDate.parse(date);
+ }
+
+ public static LocalDate parseLocalDate(String date, DateTimeFormatter
formatter) {
+ return LocalDate.parse(date, formatter);
+ }
+
+ public static LocalDateTime parseLocalDateTime(String date) {
+ // DateTimeFormatter.ISO_LOCAL_DATE_TIME
+ return LocalDateTime.parse(date);
+ }
+
+ public static LocalDateTime parseLocalDateTime(String date,
DateTimeFormatter formatter) {
+ return LocalDateTime.parse(date, formatter);
+ }
+
+ /*
+ * Local Date formatting
+ */
+
+ public static DateTimeFormatter getLocalDateFormatter(Locale locale)
+ {
+ return
DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(getSafeLocale(locale));
+ }
+
+ public static DateTimeFormatter getLocalDateTimeFormatter(Locale locale,
boolean withSeconds)
+ {
+ return DateTimeFormatter.ofLocalizedDateTime((withSeconds ?
FormatStyle.MEDIUM : FormatStyle.SHORT)).withLocale(getSafeLocale(locale));
+ }
+
+ public static String formatDate(LocalDate localDate, Locale locale)
+ {
+ return getLocalDateFormatter(locale).format(localDate);
+ }
+
+ public static String formatDate(LocalDateTime localDateTime, Locale locale)
+ {
+ return
getLocalDateFormatter(locale).format(localDateTime.toLocalDate());
+ }
+
+ public static String formatDateTime(LocalDateTime localDateTime, Locale
locale, boolean withSeconds)
+ {
+ return getLocalDateTimeFormatter(locale,
withSeconds).format(localDateTime);
+ }
+
}
diff --git a/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
b/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
index b077ec2..ef23459 100644
--- a/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
+++ b/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
@@ -24,7 +24,12 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeParseException;
+import java.time.temporal.Temporal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@@ -35,6 +40,7 @@ import org.apache.commons.beanutils.MethodUtils;
import org.apache.empire.exceptions.EmpireException;
import org.apache.empire.exceptions.InternalException;
import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.InvalidValueException;
import org.apache.empire.exceptions.ItemNotFoundException;
import org.apache.empire.exceptions.NotSupportedException;
import org.slf4j.Logger;
@@ -110,8 +116,10 @@ public final class ObjectUtils
*/
public static boolean isEmpty(Object o)
{
- if (o==null || o==ObjectUtils.NO_VALUE)
+ if (o==null)
return true;
+ if (o==NO_VALUE)
+ throw new InvalidValueException(o);
if ((o instanceof String) && ((String)o).length()==0)
return true;
// not empty
@@ -167,7 +175,7 @@ public final class ObjectUtils
*/
public static int lengthOf(Object o)
{
- if (o==null || o==ObjectUtils.NO_VALUE)
+ if (o==null || o==NO_VALUE)
return 0;
if ((o instanceof String))
return ((String)o).length();
@@ -213,6 +221,15 @@ public final class ObjectUtils
double d2 = ((Number)o2).doubleValue();
return (d1==d2);
}
+ // Compare Date with LocalDate / LocalDateTime
+ if (o1 instanceof Temporal && o2 instanceof Date)
+ { // swap
+ Object tmp = o2; o2 = o1; o1 = tmp;
+ }
+ if (o1 instanceof Date && o2 instanceof LocalDate)
+ return o1.equals(DateUtils.toDate((LocalDate)o2));
+ if (o1 instanceof Date && o2 instanceof LocalDateTime)
+ return o1.equals(DateUtils.toDate((LocalDateTime)o2));
// Enum
if (o1 instanceof Enum<?>)
{ // Special enum handling
@@ -302,8 +319,7 @@ public final class ObjectUtils
try
{ // Try to convert
return toInteger(v);
- } catch (Exception e)
- {
+ } catch (NumberFormatException e) {
log.warn(String.format("Cannot convert value [%s] to int!", v));
return defValue;
}
@@ -354,8 +370,7 @@ public final class ObjectUtils
try
{ // Try to convert
return toLong(v);
- } catch (Exception e)
- {
+ } catch (NumberFormatException e) {
log.warn(String.format("Cannot convert value [%s] to long!",
v));
return defValue;
}
@@ -406,8 +421,7 @@ public final class ObjectUtils
try
{ // Try to convert
return toDouble(v);
- } catch (Exception e)
- {
+ } catch (NumberFormatException e) {
log.warn(String.format("Cannot convert value [%s] to double!", v));
return defValue;
}
@@ -470,8 +484,7 @@ public final class ObjectUtils
try
{ // Try to convert
return toDecimal(v);
- } catch (Exception e)
- { // Error
+ } catch (NumberFormatException e) {
log.warn(String.format("Cannot convert value [%s] to BigDecimal!",
v));
return defValue;
}
@@ -619,9 +632,9 @@ public final class ObjectUtils
return null;
if (value instanceof String)
return (String)value;
- // convert
if (value==NO_VALUE)
- throw new NotSupportedException(value, "getString");
+ throw new InvalidValueException(value);
+ // convert
if (value instanceof Enum<?>)
return getString((Enum<?>)value);
if (value instanceof Date)
@@ -633,6 +646,28 @@ public final class ObjectUtils
/**
* Converts an object value to a Date.
* <P>
+ * @param v the object to convert
+ * @return the Date value of o or null
+ */
+ public static Date toDate(Object v)
+ throws ParseException
+ {
+ // Get DateTime value
+ if (ObjectUtils.isEmpty(v))
+ return null;
+ if (v instanceof java.util.Date)
+ return ((java.util.Date)v);
+ // Convert from String
+ String str = v.toString();
+ if (str.length() > 10)
+ return dateTimeFormatter.get().parse(str);
+ else
+ return dateOnlyFormatter.get().parse(str);
+ }
+
+ /**
+ * Converts an object value to a Date.
+ * <P>
* If the object value supplied is null or if conversion is not possible
then null is returned.
* @param v the object to convert
* @param locale the locale used for conversion
@@ -681,15 +716,78 @@ public final class ObjectUtils
if (v instanceof java.util.Date)
return ((java.util.Date)v);
// Convert from String
+ String str = v.toString();
try
- { String str = v.toString();
- if (str.length() > 10)
+ { if (str.length() > 10)
return dateTimeFormatter.get().parse(str);
else
return dateOnlyFormatter.get().parse(str);
- } catch (Exception e)
- {
- log.error("Cannot convert value to date!", e);
+ } catch (ParseException e) {
+ log.error("Cannot convert \""+str+"\" to Date!", e);
+ return null;
+ }
+ }
+
+ /**
+ * Converts an object value to a Date.
+ * <P>
+ * @param v the object to convert
+ * @return the Date value of o or null
+ */
+ public static LocalDate getLocalDate(Object v)
+ {
+ // Get DateTime value
+ if (ObjectUtils.isEmpty(v))
+ return null;
+ if (v instanceof java.time.LocalDate)
+ return (LocalDate)v;
+ if (v instanceof java.time.LocalDateTime)
+ return ((LocalDateTime)v).toLocalDate();
+ if (v instanceof java.sql.Timestamp)
+ return ((java.sql.Timestamp)v).toLocalDateTime().toLocalDate();
+ if (v instanceof java.sql.Date)
+ return ((java.sql.Date)v).toLocalDate();
+ if (v instanceof java.util.Date)
+ return DateUtils.toLocalDate((Date)v);
+ // Convert from String
+ try
+ { // DateTimeFormatter ISO_LOCAL_DATE
+ String str = v.toString();
+ return LocalDate.parse(str);
+ } catch (DateTimeParseException e) {
+ log.error("Cannot convert value to LocalDate!", e);
+ return null;
+ }
+ }
+
+ /**
+ * Converts an object value to a Date.
+ * <P>
+ * @param v the object to convert
+ * @return the Date value of o or null
+ */
+ public static LocalDateTime getLocalDateTime(Object v)
+ {
+ // Get DateTime value
+ if (ObjectUtils.isEmpty(v))
+ return null;
+ if (v instanceof java.time.LocalDate)
+ return ((LocalDate)v).atStartOfDay();
+ if (v instanceof java.time.LocalDateTime)
+ return (LocalDateTime)v;
+ if (v instanceof java.sql.Timestamp)
+ return ((java.sql.Timestamp)v).toLocalDateTime();
+ if (v instanceof java.sql.Date)
+ return ((java.sql.Date)v).toLocalDate().atStartOfDay();
+ if (v instanceof java.util.Date)
+ return DateUtils.toLocalDateTime((Date)v);
+ // Convert from String
+ try
+ { // DateTimeFormatter.ISO_LOCAL_DATE_TIME
+ String str = v.toString();
+ return LocalDateTime.parse(str);
+ } catch (DateTimeParseException e) {
+ log.error("Cannot convert value to LocalDateTime!", e);
return null;
}
}
@@ -728,6 +826,8 @@ public final class ObjectUtils
{
if (v==null || c.isInstance(v))
return (T)v;
+ if (v==NO_VALUE)
+ throw new InvalidValueException(v);
// Get Class form Primitive Type
if (c.isPrimitive())
{ // Get's the Java Class representing the primitive type
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
b/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
index 60764fb..d899cc0 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
@@ -26,6 +26,8 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
@@ -899,6 +901,14 @@ public abstract class DBDatabaseDriver implements
Serializable
{ // Convert Date to Timestamp
ts = new Timestamp(((Date)value).getTime());
}
+ else if ((value instanceof LocalDate))
+ { // Convert LocalDate to Timestamp
+ ts = java.sql.Timestamp.valueOf(((LocalDate)value).atStartOfDay());
+ }
+ else if ((value instanceof LocalDateTime))
+ { // Convert LocalDateTime to Timestamp
+ ts = java.sql.Timestamp.valueOf((LocalDateTime)value);
+ }
else
{ // "Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]"
String dtValue = value.toString().trim();
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
b/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
index 4380ed5..9965933 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
@@ -20,6 +20,8 @@ package org.apache.empire.db;
// XML
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Date;
@@ -310,6 +312,54 @@ public abstract class DBRecordData extends DBObject
}
/**
+ * Returns a data value identified by the column index.
+ * The data value is converted to a Date if necessary.
+ *
+ * @param index index of the column
+ * @return the value
+ */
+ public final LocalDate getLocalDate(int index)
+ {
+ return ObjectUtils.getLocalDate(getValue(index));
+ }
+
+ /**
+ * Returns a data value for the desired column.
+ * The data value is converted to a Date if necessary.
+ *
+ * @param column identifying the column
+ * @return the value
+ */
+ public final LocalDate getLocalDate(ColumnExpr column)
+ {
+ return getLocalDate(getFieldIndex(column));
+ }
+
+ /**
+ * Returns a data value identified by the column index.
+ * The data value is converted to a Date if necessary.
+ *
+ * @param index index of the column
+ * @return the value
+ */
+ public final LocalDateTime getLocalDateTime(int index)
+ {
+ return ObjectUtils.getLocalDateTime(getValue(index));
+ }
+
+ /**
+ * Returns a data value for the desired column.
+ * The data value is converted to a Date if necessary.
+ *
+ * @param column identifying the column
+ * @return the value
+ */
+ public final LocalDateTime getLocalDateTime(ColumnExpr column)
+ {
+ return getLocalDateTime(getFieldIndex(column));
+ }
+
+ /**
* Returns the value of a field as an enum
* For numeric columns the value is assumed to be an ordinal of the
enumeration item
* For non numeric columns the value is assumed to be the name of the
enumeration item
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
b/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
index 9d3fa1a..545a22e 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
@@ -864,7 +864,7 @@ public abstract class DBRowSet extends DBExpr
cmd.set(col.to(timestamp));
continue;
}
- boolean empty = ObjectUtils.isEmpty(value);
+ boolean empty = (value==ObjectUtils.NO_VALUE ||
ObjectUtils.isEmpty(value));
if (empty && col.isAutoGenerated())
{ // Check for AutoInc data type
if (col.getDataType()==DataType.AUTOINC &&
@@ -907,6 +907,14 @@ public abstract class DBRowSet extends DBExpr
for (int i = 0; i < columns.size(); i++)
{ // search for the column
Object value = fields[i];
+ // check for NO_VALUE
+ if (value==ObjectUtils.NO_VALUE)
+ { // Timestamp?
+ if (timestampColumn == columns.get(i))
+ log.info("Record has no value for timestamp column.
Concurrent changes will not be detected.");
+ // next
+ continue;
+ }
boolean modified = rec.wasModified(i);
boolean empty = ObjectUtils.isEmpty(value);
DBTableColumn col = (DBTableColumn) columns.get(i);
@@ -929,14 +937,11 @@ public abstract class DBRowSet extends DBExpr
value = cmd.addParam(col, value);
cmd.where(col.is(value));
}
- else if (value!=ObjectUtils.NO_VALUE) {
- log.warn("updateRecord has no value for
timestamp column. Concurrent changes will not be detected.");
- }
// set new timestamp
if (timestamp!=null)
cmd.set(col.to(timestamp));
}
- else if (modified && value!=ObjectUtils.NO_VALUE)
+ else if (modified)
{ // Update a field
if (col.isReadOnly())
log.warn("updateRecord: Read-only column '" +
col.getName() + " has been modified!");
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
b/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
index 3ab157a..c5f1f8c 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
@@ -22,14 +22,14 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Connection;
import java.text.ParseException;
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.util.Date;
import org.apache.empire.commons.Attributes;
import org.apache.empire.commons.ObjectUtils;
import org.apache.empire.commons.OptionEntry;
import org.apache.empire.commons.Options;
-import org.apache.empire.commons.StringUtils;
import org.apache.empire.data.Column;
import org.apache.empire.data.DataType;
import org.apache.empire.db.exceptions.FieldIllegalValueException;
@@ -394,27 +394,18 @@ public class DBTableColumn extends DBColumn
switch (type)
{
case DATE:
+ // Check for LocalDate
+ if (value instanceof LocalDate)
+ break;
case DATETIME:
case TIMESTAMP:
// Check whether value is a valid date/time value!
- if (!(value instanceof Date) &&
!DBDatabase.SYSDATE.equals(value))
- { // Parse String
- String dateValue = value.toString();
- if (dateValue.length()==0)
- return null;
- // Convert through SimpleDateFormat
- String datePattern =
StringUtils.coalesce(StringUtils.toString(getAttribute(Column.COLATTR_DATETIMEPATTERN)),
"yyyy-MM-dd HH:mm:ss");
- if ((type==DataType.DATE || dateValue.length()<=12) &&
datePattern.indexOf(' ')>0)
- datePattern = datePattern.substring(0,
datePattern.indexOf(' ')); // Strip off time
- try
- { // Parse date time value
- SimpleDateFormat sdFormat = new
SimpleDateFormat(datePattern);
- sdFormat.setLenient(true);
- value = sdFormat.parse(dateValue);
- // OK
- } catch (ParseException e)
- { // Error
- log.info("Parsing '{}' to Date ("+datePattern+")
failed for column {}. Message is "+e.toString(), value, getName());
+ if (!(value instanceof LocalDateTime) && !(value instanceof
Date) && !DBDatabase.SYSDATE.equals(value))
+ { // Parse Date
+ try {
+ value = ObjectUtils.toDate(value);
+ } catch(ParseException e) {
+ log.info("Parsing '{}' to Date failed for column {}.
Message is "+e.toString(), value, getName());
throw new FieldIllegalValueException(this,
String.valueOf(value), e);
}
}
@@ -432,8 +423,7 @@ public class DBTableColumn extends DBColumn
{ // Convert to String and check
value = ObjectUtils.toDecimal(value);
// throws NumberFormatException if not a number!
- } catch (NumberFormatException e)
- {
+ } catch (NumberFormatException e) {
log.info("Parsing '{}' to Decimal failed for column
{}. Message is "+e.toString(), value, getName());
throw new FieldIllegalValueException(this,
String.valueOf(value), e);
}
diff --git
a/empire-db/src/main/java/org/apache/empire/exceptions/InvalidValueException.java
b/empire-db/src/main/java/org/apache/empire/exceptions/InvalidValueException.java
new file mode 100644
index 0000000..0c40cb6
--- /dev/null
+++
b/empire-db/src/main/java/org/apache/empire/exceptions/InvalidValueException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, 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 org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+import org.apache.empire.commons.StringUtils;
+
+public class InvalidValueException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new
ErrorType("error.invalidValue", "The value {0} is invalid.");
+
+ public InvalidValueException(Object value)
+ {
+ super(errorType, new String[] { StringUtils.valueOf(value) } );
+ }
+
+ public InvalidValueException(Object[] value)
+ {
+ super(errorType, new String[] { StringUtils.valueOf(value) } );
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index c00e912..5562c3f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,8 +43,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <maven.compile.source>1.6</maven.compile.source>
- <maven.compile.target>1.6</maven.compile.target>
+ <maven.compile.source>1.8</maven.compile.source>
+ <maven.compile.target>1.8</maven.compile.target>
<disclaimer.dir>{project.basedir}</disclaimer.dir>
</properties>