diff --git a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/DefaultEnvironment.java b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/DefaultEnvironment.java index 543ddae9e8..48073b4fb1 100644 --- a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/DefaultEnvironment.java +++ b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/DefaultEnvironment.java @@ -7,10 +7,10 @@ public class DefaultEnvironment implements IEnvironment { protected IResourceFactory resourceFactory; protected IDbPlatform dbPlatform; - - public DefaultEnvironment() { + + public DefaultEnvironment() { } - + public DefaultEnvironment(IResourceFactory resourceFactory, IDbPlatform dbPlatform) { this.resourceFactory = resourceFactory; this.dbPlatform = dbPlatform; @@ -23,13 +23,13 @@ public void setDbPlatform(IDbPlatform dbPlatform) { public IDbPlatform getDbPlatform() { return dbPlatform; } - + public void setResourceFactory(IResourceFactory resourceFactory) { this.resourceFactory = resourceFactory; } - + public IResourceFactory getResourceFactory() { return resourceFactory; - } + } } diff --git a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/IEnvironment.java b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/IEnvironment.java index 74880604f0..c271b6fae0 100644 --- a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/IEnvironment.java +++ b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/IEnvironment.java @@ -6,7 +6,7 @@ public interface IEnvironment { public IResourceFactory getResourceFactory(); - + public IDbPlatform getDbPlatform(); - + } diff --git a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/Version.java b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/Version.java index 68bed26b5a..7e867c2d30 100644 --- a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/Version.java +++ b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/Version.java @@ -22,7 +22,6 @@ import org.jumpmind.symmetric.core.common.AbstractVersion; - /** * Follow the Apache versioning scheme documented here. diff --git a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/ArrayUtils.java b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/ArrayUtils.java index c560ee8943..7a93a82913 100644 --- a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/ArrayUtils.java +++ b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/ArrayUtils.java @@ -3,7 +3,7 @@ import java.lang.reflect.Array; public abstract class ArrayUtils { - + /** *
* Adds all the elements of the given arrays into a new array. @@ -45,17 +45,25 @@ public static Object[] addAll(Object[] array1, Object[] array2) { System.arraycopy(array2, 0, joinedArray, array1.length, array2.length); return joinedArray; } - + /** - *
Shallow clones an array returning a typecast result and handling
- * null
.
The objects in the array are not cloned, thus there is no special - * handling for multi-dimensional arrays.
+ *
+ * Shallow clones an array returning a typecast result and handling
+ * null
.
+ *
This method returns null
for a null
input array.
+ * The objects in the array are not cloned, thus there is no special + * handling for multi-dimensional arrays. + *
+ * + *
+ * This method returns null
for a null
input
+ * array.
+ *
null
+ * @param array
+ * the array to shallow clone, may be null
* @return the cloned array, null
if null
input
*/
public static Object[] clone(Object[] array) {
diff --git a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/CollectionUtils.java b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/CollectionUtils.java
index d4b108009d..133018b6ab 100644
--- a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/CollectionUtils.java
+++ b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/CollectionUtils.java
@@ -7,33 +7,42 @@
public abstract class CollectionUtils {
- /**
+ /**
* Adds all elements in the array to the given collection.
*
- * @param collection the collection to add to, may not be null
- * @param elements the array of elements to add, may not be null
- * @throws NullPointerException if the collection or array is null
+ * @param collection
+ * the collection to add to, may not be null
+ * @param elements
+ * the array of elements to add, may not be null
+ * @throws NullPointerException
+ * if the collection or array is null
*/
public static Adds all the elements of the given arrays into a new array.
- *The new array contains all of the element of array1
followed
- * by all of the elements array2
. When an array is returned, it is always
- * a new array.
+ * Adds all the elements of the given arrays into a new array. + *
+ *
+ * The new array contains all of the element of array1
followed
+ * by all of the elements array2
. When an array is returned, it
+ * is always a new array.
+ *
* ArrayUtils.addAll(array1, null) = cloned copy of array1 * ArrayUtils.addAll(null, array2) = cloned copy of array2 * ArrayUtils.addAll([], []) = [] *- * - * @param array1 the first array whose elements are added to the new array. - * @param array2 the second array whose elements are added to the new array. + * + * @param array1 + * the first array whose elements are added to the new array. + * @param array2 + * the second array whose elements are added to the new array. * @return The new int[] array. * @since 2.1 */ @@ -48,14 +57,20 @@ public static int[] addAll(int[] array1, int[] array2) { System.arraycopy(array2, 0, joinedArray, array1.length, array2.length); return joinedArray; } - + /** - *
Clones an array returning a typecast result and handling
- * null
.
This method returns null
for a null
input array.
+ * Clones an array returning a typecast result and handling
+ * null
.
+ *
null
+ *
+ * This method returns null
for a null
input
+ * array.
+ *
null
* @return the cloned array, null
if null
input
*/
public static int[] clone(int[] array) {
@@ -63,15 +78,18 @@ public static int[] clone(int[] array) {
return null;
}
return (int[]) array.clone();
- }
-
-
+ }
+
/**
- * Adds all the elements of the given arrays into a new array.
- *The new array contains all of the element of array1
followed
- * by all of the elements array2
. When an array is returned, it is always
- * a new array.
+ * Adds all the elements of the given arrays into a new array. + *
+ *
+ * The new array contains all of the element of array1
followed
+ * by all of the elements array2
. When an array is returned, it
+ * is always a new array.
+ *
* ArrayUtils.addAll(null, null) = null * ArrayUtils.addAll(array1, null) = cloned copy of array1 @@ -80,11 +98,15 @@ public static int[] clone(int[] array) { * ArrayUtils.addAll([null], [null]) = [null, null] * ArrayUtils.addAll(["a", "b", "c"], ["1", "2", "3"]) = ["a", "b", "c", "1", "2", "3"] *- * - * @param array1 the first array whose elements are added to the new array, may be
null
- * @param array2 the second array whose elements are added to the new array, may be null
- * @return The new array, null
if null
array inputs.
- * The type of the new array is the type of the first array.
+ *
+ * @param array1
+ * the first array whose elements are added to the new array, may
+ * be null
+ * @param array2
+ * the second array whose elements are added to the new array,
+ * may be null
+ * @return The new array, null
if null
array
+ * inputs. The type of the new array is the type of the first array.
* @since 2.1
*/
public static Shallow clones an array returning a typecast result and handling
- * null
.
The objects in the array are not cloned, thus there is no special - * handling for multi-dimensional arrays.
+ *
+ * Shallow clones an array returning a typecast result and handling
+ * null
.
+ *
This method returns null
for a null
input array.
+ * The objects in the array are not cloned, thus there is no special + * handling for multi-dimensional arrays. + *
* - * @param array the array to shallow clone, may benull
+ *
+ * This method returns null
for a null
input
+ * array.
+ *
null
* @return the cloned array, null
if null
input
*/
public static A suite of utilities surrounding the use of the - * {@link java.util.Calendar} and {@link java.util.Date} object.
- * + *+ * A suite of utilities surrounding the use of the {@link java.util.Calendar} + * and {@link java.util.Date} object. + *
+ * * @author Serge Knystautas * @author Stephen Colebourne * @author Janek Bogucki @@ -37,50 +39,51 @@ * @since 2.0 * @version $Id: DateUtils.java 437554 2006-08-28 06:21:41Z bayard $ */ -public abstract class DateUtils { - +public abstract class DateUtils { + /** - * The UTC time zone (often referred to as GMT). + * The UTC time zone (often referred to as GMT). */ public static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("GMT"); /** * Number of milliseconds in a standard second. + * * @since 2.1 */ public static final long MILLIS_PER_SECOND = 1000; /** * Number of milliseconds in a standard minute. + * * @since 2.1 */ public static final long MILLIS_PER_MINUTE = 60 * MILLIS_PER_SECOND; /** * Number of milliseconds in a standard hour. + * * @since 2.1 */ public static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE; /** * Number of milliseconds in a standard day. + * * @since 2.1 */ public static final long MILLIS_PER_DAY = 24 * MILLIS_PER_HOUR; /** - * This is half a month, so this represents whether a date is in the top - * or bottom half of the month. + * This is half a month, so this represents whether a date is in the top or + * bottom half of the month. */ public final static int SEMI_MONTH = 1001; - private static final int[][] fields = { - {Calendar.MILLISECOND}, - {Calendar.SECOND}, - {Calendar.MINUTE}, - {Calendar.HOUR_OF_DAY, Calendar.HOUR}, - {Calendar.DATE, Calendar.DAY_OF_MONTH, Calendar.AM_PM - /* Calendar.DAY_OF_YEAR, Calendar.DAY_OF_WEEK, Calendar.DAY_OF_WEEK_IN_MONTH */ - }, - {Calendar.MONTH, DateUtils.SEMI_MONTH}, - {Calendar.YEAR}, - {Calendar.ERA}}; + private static final int[][] fields = { { Calendar.MILLISECOND }, { Calendar.SECOND }, + { Calendar.MINUTE }, { Calendar.HOUR_OF_DAY, Calendar.HOUR }, + { Calendar.DATE, Calendar.DAY_OF_MONTH, Calendar.AM_PM + /* + * Calendar.DAY_OF_YEAR, Calendar.DAY_OF_WEEK, + * Calendar.DAY_OF_WEEK_IN_MONTH + */ + }, { Calendar.MONTH, DateUtils.SEMI_MONTH }, { Calendar.YEAR }, { Calendar.ERA } }; /** * A week range, starting on Sunday. @@ -113,29 +116,39 @@ public abstract class DateUtils { public final static int RANGE_MONTH_MONDAY = 6; /** - *DateUtils
instances should NOT be constructed in
- * standard programming. Instead, the class should be used as
- * DateUtils.parse(str);
.
This constructor is public to permit tools that require a JavaBean - * instance to operate.
+ *
+ * DateUtils
instances should NOT be constructed in standard
+ * programming. Instead, the class should be used as
+ * DateUtils.parse(str);
.
+ *
+ * This constructor is public to permit tools that require a JavaBean + * instance to operate. + *
*/ public DateUtils() { super(); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - *Checks if two date objects are on the same day ignoring time.
- * - *28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. - * 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false. + *
+ * Checks if two date objects are on the same day ignoring time. *
* - * @param date1 the first date, not altered, not null - * @param date2 the second date, not altered, not null + *+ * 28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. 28 Mar 2002 + * 13:45 and 12 Mar 2002 13:45 would return false. + *
+ * + * @param date1 + * the first date, not altered, not null + * @param date2 + * the second date, not altered, not null * @return true if they represent the same day - * @throws IllegalArgumentException if either date isnull
+ * @throws IllegalArgumentException
+ * if either date is null
* @since 2.1
*/
public static boolean isSameDay(Date date1, Date date2) {
@@ -150,37 +163,50 @@ public static boolean isSameDay(Date date1, Date date2) {
}
/**
- * Checks if two calendar objects are on the same day ignoring time.
- * - *28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. - * 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false. + *
+ * Checks if two calendar objects are on the same day ignoring time. + *
+ * + *+ * 28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. 28 Mar 2002 + * 13:45 and 12 Mar 2002 13:45 would return false. *
* - * @param cal1 the first calendar, not altered, not null - * @param cal2 the second calendar, not altered, not null + * @param cal1 + * the first calendar, not altered, not null + * @param cal2 + * the second calendar, not altered, not null * @return true if they represent the same day - * @throws IllegalArgumentException if either calendar isnull
+ * @throws IllegalArgumentException
+ * if either calendar is null
* @since 2.1
*/
public static boolean isSameDay(Calendar cal1, Calendar cal2) {
if (cal1 == null || cal2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
- return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) &&
- cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
- cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR));
+ return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA)
+ && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1
+ .get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR));
}
- //-----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
/**
- * Checks if two date objects represent the same instant in time.
- * - *This method compares the long millisecond time of the two objects.
+ *+ * Checks if two date objects represent the same instant in time. + *
+ * + *+ * This method compares the long millisecond time of the two objects. + *
* - * @param date1 the first date, not altered, not null - * @param date2 the second date, not altered, not null + * @param date1 + * the first date, not altered, not null + * @param date2 + * the second date, not altered, not null * @return true if they represent the same millisecond instant - * @throws IllegalArgumentException if either date isnull
+ * @throws IllegalArgumentException
+ * if either date is null
* @since 2.1
*/
public static boolean isSameInstant(Date date1, Date date2) {
@@ -191,14 +217,21 @@ public static boolean isSameInstant(Date date1, Date date2) {
}
/**
- * Checks if two calendar objects represent the same instant in time.
- * - *This method compares the long millisecond time of the two objects.
+ *+ * Checks if two calendar objects represent the same instant in time. + *
+ * + *+ * This method compares the long millisecond time of the two objects. + *
* - * @param cal1 the first calendar, not altered, not null - * @param cal2 the second calendar, not altered, not null + * @param cal1 + * the first calendar, not altered, not null + * @param cal2 + * the second calendar, not altered, not null * @return true if they represent the same millisecond instant - * @throws IllegalArgumentException if either date isnull
+ * @throws IllegalArgumentException
+ * if either date is null
* @since 2.1
*/
public static boolean isSameInstant(Calendar cal1, Calendar cal2) {
@@ -208,52 +241,69 @@ public static boolean isSameInstant(Calendar cal1, Calendar cal2) {
return cal1.getTime().getTime() == cal2.getTime().getTime();
}
- //-----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
/**
- * Checks if two calendar objects represent the same local time.
- * - *This method compares the values of the fields of the two objects. - * In addition, both calendars must be the same of the same type.
+ *+ * Checks if two calendar objects represent the same local time. + *
+ * + *+ * This method compares the values of the fields of the two objects. In + * addition, both calendars must be the same of the same type. + *
* - * @param cal1 the first calendar, not altered, not null - * @param cal2 the second calendar, not altered, not null + * @param cal1 + * the first calendar, not altered, not null + * @param cal2 + * the second calendar, not altered, not null * @return true if they represent the same millisecond instant - * @throws IllegalArgumentException if either date isnull
+ * @throws IllegalArgumentException
+ * if either date is null
* @since 2.1
*/
public static boolean isSameLocalTime(Calendar cal1, Calendar cal2) {
if (cal1 == null || cal2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
- return (cal1.get(Calendar.MILLISECOND) == cal2.get(Calendar.MILLISECOND) &&
- cal1.get(Calendar.SECOND) == cal2.get(Calendar.SECOND) &&
- cal1.get(Calendar.MINUTE) == cal2.get(Calendar.MINUTE) &&
- cal1.get(Calendar.HOUR) == cal2.get(Calendar.HOUR) &&
- cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR) &&
- cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
- cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) &&
- cal1.getClass() == cal2.getClass());
+ return (cal1.get(Calendar.MILLISECOND) == cal2.get(Calendar.MILLISECOND)
+ && cal1.get(Calendar.SECOND) == cal2.get(Calendar.SECOND)
+ && cal1.get(Calendar.MINUTE) == cal2.get(Calendar.MINUTE)
+ && cal1.get(Calendar.HOUR) == cal2.get(Calendar.HOUR)
+ && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)
+ && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
+ && cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && cal1.getClass() == cal2
+ .getClass());
}
- //-----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
/**
- * Parses a string representing a date by trying a variety of different parsers.
+ *+ * Parses a string representing a date by trying a variety of different + * parsers. + *
* - *The parse will try each parse pattern in turn. - * A parse is only deemed sucessful if it parses the whole of the input string. - * If no parse patterns match, a ParseException is thrown.
+ *+ * The parse will try each parse pattern in turn. A parse is only deemed + * sucessful if it parses the whole of the input string. If no parse + * patterns match, a ParseException is thrown. + *
* - * @param str the date to parse, not null - * @param parsePatterns the date format patterns to use, see SimpleDateFormat, not null + * @param str + * the date to parse, not null + * @param parsePatterns + * the date format patterns to use, see SimpleDateFormat, not + * null * @return the parsed date - * @throws IllegalArgumentException if the date string or pattern array is null - * @throws ParseException if none of the date patterns were suitable + * @throws IllegalArgumentException + * if the date string or pattern array is null + * @throws ParseException + * if none of the date patterns were suitable */ public static Date parseDate(String str, String[] parsePatterns) throws ParseException { if (str == null || parsePatterns == null) { throw new IllegalArgumentException("Date and Patterns must not be null"); } - + SimpleDateFormat parser = null; ParsePosition pos = new ParsePosition(0); for (int i = 0; i < parsePatterns.length; i++) { @@ -271,128 +321,156 @@ public static Date parseDate(String str, String[] parsePatterns) throws ParseExc throw new ParseException("Unable to parse the date: " + str, -1); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - * Adds a number of years to a date returning a new object. - * The original date object is unchanged. - * - * @param date the date, not null - * @param amount the amount to add, may be negative + * Adds a number of years to a date returning a new object. The original + * date object is unchanged. + * + * @param date + * the date, not null + * @param amount + * the amount to add, may be negative * @return the new date object with the amount added - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException + * if the date is null */ public static Date addYears(Date date, int amount) { return add(date, Calendar.YEAR, amount); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - * Adds a number of months to a date returning a new object. - * The original date object is unchanged. - * - * @param date the date, not null - * @param amount the amount to add, may be negative + * Adds a number of months to a date returning a new object. The original + * date object is unchanged. + * + * @param date + * the date, not null + * @param amount + * the amount to add, may be negative * @return the new date object with the amount added - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException + * if the date is null */ public static Date addMonths(Date date, int amount) { return add(date, Calendar.MONTH, amount); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - * Adds a number of weeks to a date returning a new object. - * The original date object is unchanged. - * - * @param date the date, not null - * @param amount the amount to add, may be negative + * Adds a number of weeks to a date returning a new object. The original + * date object is unchanged. + * + * @param date + * the date, not null + * @param amount + * the amount to add, may be negative * @return the new date object with the amount added - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException + * if the date is null */ public static Date addWeeks(Date date, int amount) { return add(date, Calendar.WEEK_OF_YEAR, amount); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - * Adds a number of days to a date returning a new object. - * The original date object is unchanged. - * - * @param date the date, not null - * @param amount the amount to add, may be negative + * Adds a number of days to a date returning a new object. The original date + * object is unchanged. + * + * @param date + * the date, not null + * @param amount + * the amount to add, may be negative * @return the new date object with the amount added - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException + * if the date is null */ public static Date addDays(Date date, int amount) { return add(date, Calendar.DAY_OF_MONTH, amount); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - * Adds a number of hours to a date returning a new object. - * The original date object is unchanged. - * - * @param date the date, not null - * @param amount the amount to add, may be negative + * Adds a number of hours to a date returning a new object. The original + * date object is unchanged. + * + * @param date + * the date, not null + * @param amount + * the amount to add, may be negative * @return the new date object with the amount added - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException + * if the date is null */ public static Date addHours(Date date, int amount) { return add(date, Calendar.HOUR_OF_DAY, amount); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - * Adds a number of minutes to a date returning a new object. - * The original date object is unchanged. - * - * @param date the date, not null - * @param amount the amount to add, may be negative + * Adds a number of minutes to a date returning a new object. The original + * date object is unchanged. + * + * @param date + * the date, not null + * @param amount + * the amount to add, may be negative * @return the new date object with the amount added - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException + * if the date is null */ public static Date addMinutes(Date date, int amount) { return add(date, Calendar.MINUTE, amount); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - * Adds a number of seconds to a date returning a new object. - * The original date object is unchanged. - * - * @param date the date, not null - * @param amount the amount to add, may be negative + * Adds a number of seconds to a date returning a new object. The original + * date object is unchanged. + * + * @param date + * the date, not null + * @param amount + * the amount to add, may be negative * @return the new date object with the amount added - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException + * if the date is null */ public static Date addSeconds(Date date, int amount) { return add(date, Calendar.SECOND, amount); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - * Adds a number of milliseconds to a date returning a new object. - * The original date object is unchanged. - * - * @param date the date, not null - * @param amount the amount to add, may be negative + * Adds a number of milliseconds to a date returning a new object. The + * original date object is unchanged. + * + * @param date + * the date, not null + * @param amount + * the amount to add, may be negative * @return the new date object with the amount added - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException + * if the date is null */ public static Date addMilliseconds(Date date, int amount) { return add(date, Calendar.MILLISECOND, amount); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - * Adds to a date returning a new object. - * The original date object is unchanged. - * - * @param date the date, not null - * @param calendarField the calendar field to add to - * @param amount the amount to add, may be negative + * Adds to a date returning a new object. The original date object is + * unchanged. + * + * @param date + * the date, not null + * @param calendarField + * the calendar field to add to + * @param amount + * the amount to add, may be negative * @return the new date object with the amount added - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException + * if the date is null */ public static Date add(Date date, int calendarField, int amount) { if (date == null) { @@ -404,20 +482,24 @@ public static Date add(Date date, int calendarField, int amount) { return c.getTime(); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** - *Round this date, leaving the field specified as the most - * significant field.
- * - *For example, if you had the datetime of 28 Mar 2002 - * 13:45:01.231, if this was passed with HOUR, it would return - * 28 Mar 2002 14:00:00.000. If this was passed with MONTH, it - * would return 1 April 2002 0:00:00.000.
+ *+ * Round this date, leaving the field specified as the most significant + * field. + *
* - *For a date in a timezone that handles the change to daylight - * saving time, rounding to Calendar.HOUR_OF_DAY will behave as follows. - * Suppose daylight saving time begins at 02:00 on March 30. Rounding a - * date that crosses this time would produce the following values: + *
+ * For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if this + * was passed with HOUR, it would return 28 Mar 2002 14:00:00.000. If this + * was passed with MONTH, it would return 1 April 2002 0:00:00.000. + *
+ * + *+ * For a date in a timezone that handles the change to daylight saving time, + * rounding to Calendar.HOUR_OF_DAY will behave as follows. Suppose daylight + * saving time begins at 02:00 on March 30. Rounding a date that crosses + * this time would produce the following values: *
Calendar
- * or SEMI_MONTH
+ * @param date
+ * the date to work with
+ * @param field
+ * the field from Calendar
or
+ * SEMI_MONTH
* @return the rounded date
- * @throws IllegalArgumentException if the date is null
- * @throws ArithmeticException if the year is over 280 million
+ * @throws IllegalArgumentException
+ * if the date is null
+ * @throws ArithmeticException
+ * if the year is over 280 million
*/
public static Date round(Date date, int field) {
if (date == null) {
@@ -444,18 +530,22 @@ public static Date round(Date date, int field) {
}
/**
- * Round this date, leaving the field specified as the most - * significant field.
- * - *For example, if you had the datetime of 28 Mar 2002 - * 13:45:01.231, if this was passed with HOUR, it would return - * 28 Mar 2002 14:00:00.000. If this was passed with MONTH, it - * would return 1 April 2002 0:00:00.000.
+ *+ * Round this date, leaving the field specified as the most significant + * field. + *
+ * + *+ * For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if this + * was passed with HOUR, it would return 28 Mar 2002 14:00:00.000. If this + * was passed with MONTH, it would return 1 April 2002 0:00:00.000. + *
* - *For a date in a timezone that handles the change to daylight - * saving time, rounding to Calendar.HOUR_OF_DAY will behave as follows. - * Suppose daylight saving time begins at 02:00 on March 30. Rounding a - * date that crosses this time would produce the following values: + *
+ * For a date in a timezone that handles the change to daylight saving time, + * rounding to Calendar.HOUR_OF_DAY will behave as follows. Suppose daylight + * saving time begins at 02:00 on March 30. Rounding a date that crosses + * this time would produce the following values: *
Calendar
- * or SEMI_MONTH
+ * @param date
+ * the date to work with
+ * @param field
+ * the field from Calendar
or
+ * SEMI_MONTH
* @return the rounded date (a different object)
- * @throws IllegalArgumentException if the date is null
- * @throws ArithmeticException if the year is over 280 million
+ * @throws IllegalArgumentException
+ * if the date is null
+ * @throws ArithmeticException
+ * if the year is over 280 million
*/
public static Calendar round(Calendar date, int field) {
if (date == null) {
@@ -481,18 +575,22 @@ public static Calendar round(Calendar date, int field) {
}
/**
- * Round this date, leaving the field specified as the most - * significant field.
- * - *For example, if you had the datetime of 28 Mar 2002 - * 13:45:01.231, if this was passed with HOUR, it would return - * 28 Mar 2002 14:00:00.000. If this was passed with MONTH, it - * would return 1 April 2002 0:00:00.000.
+ *+ * Round this date, leaving the field specified as the most significant + * field. + *
* - *For a date in a timezone that handles the change to daylight - * saving time, rounding to Calendar.HOUR_OF_DAY will behave as follows. - * Suppose daylight saving time begins at 02:00 on March 30. Rounding a - * date that crosses this time would produce the following values: + *
+ * For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if this + * was passed with HOUR, it would return 28 Mar 2002 14:00:00.000. If this + * was passed with MONTH, it would return 1 April 2002 0:00:00.000. + *
+ * + *+ * For a date in a timezone that handles the change to daylight saving time, + * rounding to Calendar.HOUR_OF_DAY will behave as follows. Suppose daylight + * saving time begins at 02:00 on March 30. Rounding a date that crosses + * this time would produce the following values: *
Calendar
- * or SEMI_MONTH
+ * @param date
+ * the date to work with, either Date or Calendar
+ * @param field
+ * the field from Calendar
or
+ * SEMI_MONTH
* @return the rounded date
- * @throws IllegalArgumentException if the date is null
- * @throws ClassCastException if the object type is not a Date
- * or Calendar
- * @throws ArithmeticException if the year is over 280 million
+ * @throws IllegalArgumentException
+ * if the date is null
+ * @throws ClassCastException
+ * if the object type is not a Date
or
+ * Calendar
+ * @throws ArithmeticException
+ * if the year is over 280 million
*/
public static Date round(Object date, int field) {
if (date == null) {
@@ -523,22 +626,29 @@ public static Date round(Object date, int field) {
}
}
- //-----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
/**
- * Truncate this date, leaving the field specified as the most - * significant field.
- * - *For example, if you had the datetime of 28 Mar 2002 - * 13:45:01.231, if you passed with HOUR, it would return 28 Mar - * 2002 13:00:00.000. If this was passed with MONTH, it would - * return 1 Mar 2002 0:00:00.000.
+ *+ * Truncate this date, leaving the field specified as the most significant + * field. + *
* - * @param date the date to work with - * @param field the field fromCalendar
- * or SEMI_MONTH
+ * + * For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you + * passed with HOUR, it would return 28 Mar 2002 13:00:00.000. If this was + * passed with MONTH, it would return 1 Mar 2002 0:00:00.000. + *
+ * + * @param date + * the date to work with + * @param field + * the field fromCalendar
or
+ * SEMI_MONTH
* @return the rounded date
- * @throws IllegalArgumentException if the date is null
- * @throws ArithmeticException if the year is over 280 million
+ * @throws IllegalArgumentException
+ * if the date is null
+ * @throws ArithmeticException
+ * if the year is over 280 million
*/
public static Date truncate(Date date, int field) {
if (date == null) {
@@ -551,20 +661,27 @@ public static Date truncate(Date date, int field) {
}
/**
- * Truncate this date, leaving the field specified as the most - * significant field.
- * - *For example, if you had the datetime of 28 Mar 2002 - * 13:45:01.231, if you passed with HOUR, it would return 28 Mar - * 2002 13:00:00.000. If this was passed with MONTH, it would - * return 1 Mar 2002 0:00:00.000.
+ *+ * Truncate this date, leaving the field specified as the most significant + * field. + *
* - * @param date the date to work with - * @param field the field fromCalendar
- * or SEMI_MONTH
+ * + * For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you + * passed with HOUR, it would return 28 Mar 2002 13:00:00.000. If this was + * passed with MONTH, it would return 1 Mar 2002 0:00:00.000. + *
+ * + * @param date + * the date to work with + * @param field + * the field fromCalendar
or
+ * SEMI_MONTH
* @return the rounded date (a different object)
- * @throws IllegalArgumentException if the date is null
- * @throws ArithmeticException if the year is over 280 million
+ * @throws IllegalArgumentException
+ * if the date is null
+ * @throws ArithmeticException
+ * if the year is over 280 million
*/
public static Calendar truncate(Calendar date, int field) {
if (date == null) {
@@ -576,24 +693,31 @@ public static Calendar truncate(Calendar date, int field) {
}
/**
- * Truncate this date, leaving the field specified as the most - * significant field.
- * - *For example, if you had the datetime of 28 Mar 2002 - * 13:45:01.231, if you passed with HOUR, it would return 28 Mar - * 2002 13:00:00.000. If this was passed with MONTH, it would - * return 1 Mar 2002 0:00:00.000.
+ *+ * Truncate this date, leaving the field specified as the most significant + * field. + *
* - * @param date the date to work with, eitherDate
- * or Calendar
- * @param field the field from Calendar
- * or SEMI_MONTH
+ * + * For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you + * passed with HOUR, it would return 28 Mar 2002 13:00:00.000. If this was + * passed with MONTH, it would return 1 Mar 2002 0:00:00.000. + *
+ * + * @param date + * the date to work with, eitherDate
or
+ * Calendar
+ * @param field
+ * the field from Calendar
or
+ * SEMI_MONTH
* @return the rounded date
- * @throws IllegalArgumentException if the date
- * is null
- * @throws ClassCastException if the object type is not a
- * Date
or Calendar
- * @throws ArithmeticException if the year is over 280 million
+ * @throws IllegalArgumentException
+ * if the date is null
+ * @throws ClassCastException
+ * if the object type is not a Date
or
+ * Calendar
+ * @throws ArithmeticException
+ * if the year is over 280 million
*/
public static Date truncate(Object date, int field) {
if (date == null) {
@@ -608,28 +732,36 @@ public static Date truncate(Object date, int field) {
}
}
- //-----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
/**
- * Internal calculation method.
+ *+ * Internal calculation method. + *
* - * @param val the calendar - * @param field the field constant - * @param round true to round, false to truncate - * @throws ArithmeticException if the year is over 280 million + * @param val + * the calendar + * @param field + * the field constant + * @param round + * true to round, false to truncate + * @throws ArithmeticException + * if the year is over 280 million */ private static void modify(Calendar val, int field, boolean round) { if (val.get(Calendar.YEAR) > 280000000) { throw new ArithmeticException("Calendar value too large for accurate calculations"); } - + if (field == Calendar.MILLISECOND) { return; } - // ----------------- Fix for LANG-59 ---------------------- START --------------- + // ----------------- Fix for LANG-59 ---------------------- START + // --------------- // see http://issues.apache.org/jira/browse/LANG-59 // - // Manually truncate milliseconds, seconds and minutes, rather than using + // Manually truncate milliseconds, seconds and minutes, rather than + // using // Calendar methods. Date date = val.getTime(); @@ -665,18 +797,19 @@ private static void modify(Calendar val, int field, boolean round) { date.setTime(time); val.setTime(date); } - // ----------------- Fix for LANG-59 ----------------------- END ---------------- + // ----------------- Fix for LANG-59 ----------------------- END + // ---------------- boolean roundUp = false; for (int i = 0; i < fields.length; i++) { for (int j = 0; j < fields[i].length; j++) { if (fields[i][j] == field) { - //This is our field... we stop looping + // This is our field... we stop looping if (round && roundUp) { if (field == DateUtils.SEMI_MONTH) { - //This is a special case that's hard to generalize - //If the date is 1, we round up to 16, otherwise - // we subtract 15 days and add 1 month + // This is a special case that's hard to generalize + // If the date is 1, we round up to 16, otherwise + // we subtract 15 days and add 1 month if (val.get(Calendar.DATE) == 1) { val.add(Calendar.DATE, 15); } else { @@ -684,57 +817,61 @@ private static void modify(Calendar val, int field, boolean round) { val.add(Calendar.MONTH, 1); } } else { - //We need at add one to this field since the - // last number causes us to round up + // We need at add one to this field since the + // last number causes us to round up val.add(fields[i][0], 1); } } return; } } - //We have various fields that are not easy roundings + // We have various fields that are not easy roundings int offset = 0; boolean offsetSet = false; - //These are special types of fields that require different rounding rules + // These are special types of fields that require different rounding + // rules switch (field) { - case DateUtils.SEMI_MONTH: - if (fields[i][0] == Calendar.DATE) { - //If we're going to drop the DATE field's value, - // we want to do this our own way. - //We need to subtrace 1 since the date has a minimum of 1 - offset = val.get(Calendar.DATE) - 1; - //If we're above 15 days adjustment, that means we're in the - // bottom half of the month and should stay accordingly. - if (offset >= 15) { - offset -= 15; - } - //Record whether we're in the top or bottom half of that range - roundUp = offset > 7; - offsetSet = true; + case DateUtils.SEMI_MONTH: + if (fields[i][0] == Calendar.DATE) { + // If we're going to drop the DATE field's value, + // we want to do this our own way. + // We need to subtrace 1 since the date has a minimum of 1 + offset = val.get(Calendar.DATE) - 1; + // If we're above 15 days adjustment, that means we're in + // the + // bottom half of the month and should stay accordingly. + if (offset >= 15) { + offset -= 15; } - break; - case Calendar.AM_PM: - if (fields[i][0] == Calendar.HOUR_OF_DAY) { - //If we're going to drop the HOUR field's value, - // we want to do this our own way. - offset = val.get(Calendar.HOUR_OF_DAY); - if (offset >= 12) { - offset -= 12; - } - roundUp = offset > 6; - offsetSet = true; + // Record whether we're in the top or bottom half of that + // range + roundUp = offset > 7; + offsetSet = true; + } + break; + case Calendar.AM_PM: + if (fields[i][0] == Calendar.HOUR_OF_DAY) { + // If we're going to drop the HOUR field's value, + // we want to do this our own way. + offset = val.get(Calendar.HOUR_OF_DAY); + if (offset >= 12) { + offset -= 12; } - break; + roundUp = offset > 6; + offsetSet = true; + } + break; } if (!offsetSet) { int min = val.getActualMinimum(fields[i][0]); int max = val.getActualMaximum(fields[i][0]); - //Calculate the offset from the minimum allowed value + // Calculate the offset from the minimum allowed value offset = val.get(fields[i][0]) - min; - //Set roundUp if this is more than half way between the minimum and maximum + // Set roundUp if this is more than half way between the minimum + // and maximum roundUp = offset > ((max - min) / 2); } - //We need to remove this field + // We need to remove this field if (offset != 0) { val.set(fields[i][0], val.get(fields[i][0]) - offset); } @@ -743,30 +880,40 @@ private static void modify(Calendar val, int field, boolean round) { } - //----------------------------------------------------------------------- - /** - *This constructs an Iterator
over each day in a date
- * range defined by a focus date and range style.
For instance, passing Thursday, July 4, 2002 and a
- * RANGE_MONTH_SUNDAY
will return an Iterator
- * that starts with Sunday, June 30, 2002 and ends with Saturday, August 3,
- * 2002, returning a Calendar instance for each intermediate day.
This method provides an iterator that returns Calendar objects. - * The days are progressed using {@link Calendar#add(int, int)}.
- * - * @param focus the date to work with, not null - * @param rangeStyle the style constant to use. Must be one of - * {@link DateUtils#RANGE_MONTH_SUNDAY}, - * {@link DateUtils#RANGE_MONTH_MONDAY}, - * {@link DateUtils#RANGE_WEEK_SUNDAY}, - * {@link DateUtils#RANGE_WEEK_MONDAY}, - * {@link DateUtils#RANGE_WEEK_RELATIVE}, - * {@link DateUtils#RANGE_WEEK_CENTER} + // ----------------------------------------------------------------------- + /** + *
+ * This constructs an Iterator
over each day in a date range
+ * defined by a focus date and range style.
+ *
+ * For instance, passing Thursday, July 4, 2002 and a
+ * RANGE_MONTH_SUNDAY
will return an Iterator
that
+ * starts with Sunday, June 30, 2002 and ends with Saturday, August 3, 2002,
+ * returning a Calendar instance for each intermediate day.
+ *
+ * This method provides an iterator that returns Calendar objects. The days + * are progressed using {@link Calendar#add(int, int)}. + *
+ * + * @param focus + * the date to work with, not null + * @param rangeStyle + * the style constant to use. Must be one of + * {@link DateUtils#RANGE_MONTH_SUNDAY}, + * {@link DateUtils#RANGE_MONTH_MONDAY}, + * {@link DateUtils#RANGE_WEEK_SUNDAY}, + * {@link DateUtils#RANGE_WEEK_MONDAY}, + * {@link DateUtils#RANGE_WEEK_RELATIVE}, + * {@link DateUtils#RANGE_WEEK_CENTER} * @return the date iterator, which always returns Calendar instances - * @throws IllegalArgumentException if the date isnull
- * @throws IllegalArgumentException if the rangeStyle is invalid
+ * @throws IllegalArgumentException
+ * if the date is null
+ * @throws IllegalArgumentException
+ * if the rangeStyle is invalid
*/
public static Iterator iterator(Date focus, int rangeStyle) {
if (focus == null) {
@@ -778,28 +925,38 @@ public static Iterator iterator(Date focus, int rangeStyle) {
}
/**
- * This constructs an Iterator
over each day in a date
- * range defined by a focus date and range style.
For instance, passing Thursday, July 4, 2002 and a
- * RANGE_MONTH_SUNDAY
will return an Iterator
- * that starts with Sunday, June 30, 2002 and ends with Saturday, August 3,
- * 2002, returning a Calendar instance for each intermediate day.
This method provides an iterator that returns Calendar objects. - * The days are progressed using {@link Calendar#add(int, int)}.
- * - * @param focus the date to work with - * @param rangeStyle the style constant to use. Must be one of - * {@link DateUtils#RANGE_MONTH_SUNDAY}, - * {@link DateUtils#RANGE_MONTH_MONDAY}, - * {@link DateUtils#RANGE_WEEK_SUNDAY}, - * {@link DateUtils#RANGE_WEEK_MONDAY}, - * {@link DateUtils#RANGE_WEEK_RELATIVE}, - * {@link DateUtils#RANGE_WEEK_CENTER} + *
+ * This constructs an Iterator
over each day in a date range
+ * defined by a focus date and range style.
+ *
+ * For instance, passing Thursday, July 4, 2002 and a
+ * RANGE_MONTH_SUNDAY
will return an Iterator
that
+ * starts with Sunday, June 30, 2002 and ends with Saturday, August 3, 2002,
+ * returning a Calendar instance for each intermediate day.
+ *
+ * This method provides an iterator that returns Calendar objects. The days + * are progressed using {@link Calendar#add(int, int)}. + *
+ * + * @param focus + * the date to work with + * @param rangeStyle + * the style constant to use. Must be one of + * {@link DateUtils#RANGE_MONTH_SUNDAY}, + * {@link DateUtils#RANGE_MONTH_MONDAY}, + * {@link DateUtils#RANGE_WEEK_SUNDAY}, + * {@link DateUtils#RANGE_WEEK_MONDAY}, + * {@link DateUtils#RANGE_WEEK_RELATIVE}, + * {@link DateUtils#RANGE_WEEK_CENTER} * @return the date iterator - * @throws IllegalArgumentException if the date isnull
- * @throws IllegalArgumentException if the rangeStyle is invalid
+ * @throws IllegalArgumentException
+ * if the date is null
+ * @throws IllegalArgumentException
+ * if the rangeStyle is invalid
*/
public static Iterator iterator(Calendar focus, int rangeStyle) {
if (focus == null) {
@@ -810,47 +967,47 @@ public static Iterator iterator(Calendar focus, int rangeStyle) {
int startCutoff = Calendar.SUNDAY;
int endCutoff = Calendar.SATURDAY;
switch (rangeStyle) {
- case RANGE_MONTH_SUNDAY:
- case RANGE_MONTH_MONDAY:
- //Set start to the first of the month
- start = truncate(focus, Calendar.MONTH);
- //Set end to the last of the month
- end = (Calendar) start.clone();
- end.add(Calendar.MONTH, 1);
- end.add(Calendar.DATE, -1);
- //Loop start back to the previous sunday or monday
- if (rangeStyle == RANGE_MONTH_MONDAY) {
- startCutoff = Calendar.MONDAY;
- endCutoff = Calendar.SUNDAY;
- }
- break;
+ case RANGE_MONTH_SUNDAY:
+ case RANGE_MONTH_MONDAY:
+ // Set start to the first of the month
+ start = truncate(focus, Calendar.MONTH);
+ // Set end to the last of the month
+ end = (Calendar) start.clone();
+ end.add(Calendar.MONTH, 1);
+ end.add(Calendar.DATE, -1);
+ // Loop start back to the previous sunday or monday
+ if (rangeStyle == RANGE_MONTH_MONDAY) {
+ startCutoff = Calendar.MONDAY;
+ endCutoff = Calendar.SUNDAY;
+ }
+ break;
+ case RANGE_WEEK_SUNDAY:
+ case RANGE_WEEK_MONDAY:
+ case RANGE_WEEK_RELATIVE:
+ case RANGE_WEEK_CENTER:
+ // Set start and end to the current date
+ start = truncate(focus, Calendar.DATE);
+ end = truncate(focus, Calendar.DATE);
+ switch (rangeStyle) {
case RANGE_WEEK_SUNDAY:
+ // already set by default
+ break;
case RANGE_WEEK_MONDAY:
+ startCutoff = Calendar.MONDAY;
+ endCutoff = Calendar.SUNDAY;
+ break;
case RANGE_WEEK_RELATIVE:
+ startCutoff = focus.get(Calendar.DAY_OF_WEEK);
+ endCutoff = startCutoff - 1;
+ break;
case RANGE_WEEK_CENTER:
- //Set start and end to the current date
- start = truncate(focus, Calendar.DATE);
- end = truncate(focus, Calendar.DATE);
- switch (rangeStyle) {
- case RANGE_WEEK_SUNDAY:
- //already set by default
- break;
- case RANGE_WEEK_MONDAY:
- startCutoff = Calendar.MONDAY;
- endCutoff = Calendar.SUNDAY;
- break;
- case RANGE_WEEK_RELATIVE:
- startCutoff = focus.get(Calendar.DAY_OF_WEEK);
- endCutoff = startCutoff - 1;
- break;
- case RANGE_WEEK_CENTER:
- startCutoff = focus.get(Calendar.DAY_OF_WEEK) - 3;
- endCutoff = focus.get(Calendar.DAY_OF_WEEK) + 3;
- break;
- }
+ startCutoff = focus.get(Calendar.DAY_OF_WEEK) - 3;
+ endCutoff = focus.get(Calendar.DAY_OF_WEEK) + 3;
break;
- default:
- throw new IllegalArgumentException("The range style " + rangeStyle + " is not valid.");
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("The range style " + rangeStyle + " is not valid.");
}
if (startCutoff < Calendar.SUNDAY) {
startCutoff += 7;
@@ -874,23 +1031,30 @@ public static Iterator iterator(Calendar focus, int rangeStyle) {
}
/**
- * This constructs an Iterator
over each day in a date
- * range defined by a focus date and range style.
For instance, passing Thursday, July 4, 2002 and a
- * RANGE_MONTH_SUNDAY
will return an Iterator
- * that starts with Sunday, June 30, 2002 and ends with Saturday, August 3,
- * 2002, returning a Calendar instance for each intermediate day.
Date
or Calendar
- * @param rangeStyle the style constant to use. Must be one of the range
- * styles listed for the {@link #iterator(Calendar, int)} method.
+ *
+ * This constructs an Iterator
over each day in a date range
+ * defined by a focus date and range style.
+ *
+ * For instance, passing Thursday, July 4, 2002 and a
+ * RANGE_MONTH_SUNDAY
will return an Iterator
that
+ * starts with Sunday, June 30, 2002 and ends with Saturday, August 3, 2002,
+ * returning a Calendar instance for each intermediate day.
+ *
Date
or
+ * Calendar
+ * @param rangeStyle
+ * the style constant to use. Must be one of the range styles
+ * listed for the {@link #iterator(Calendar, int)} method.
* @return the date iterator
- * @throws IllegalArgumentException if the date
- * is null
- * @throws ClassCastException if the object type is
- * not a Date
or Calendar
+ * @throws IllegalArgumentException
+ * if the date is null
+ * @throws ClassCastException
+ * if the object type is not a Date
or
+ * Calendar
*/
public static Iterator iterator(Object focus, int rangeStyle) {
if (focus == null) {
@@ -906,17 +1070,21 @@ public static Iterator iterator(Object focus, int rangeStyle) {
}
/**
- * Date iterator.
+ *+ * Date iterator. + *
*/ static class DateIterator implements Iterator { private final Calendar endFinal; private final Calendar spot; - + /** - * Constructs a DateIterator that ranges from one date to another. - * - * @param startFinal start date (inclusive) - * @param endFinal end date (not inclusive) + * Constructs a DateIterator that ranges from one date to another. + * + * @param startFinal + * start date (inclusive) + * @param endFinal + * end date (not inclusive) */ DateIterator(Calendar startFinal, Calendar endFinal) { super(); @@ -927,8 +1095,9 @@ static class DateIterator implements Iterator { /** * Has the iterator not reached the end date yet? - * - * @returntrue
if the iterator has yet to reach the end date
+ *
+ * @return true
if the iterator has yet to reach the end
+ * date
*/
public boolean hasNext() {
return spot.before(endFinal);
@@ -936,7 +1105,7 @@ public boolean hasNext() {
/**
* Return the next calendar in the iteration
- *
+ *
* @return Object calendar for the next date
*/
public Object next() {
@@ -957,27 +1126,30 @@ public void remove() {
throw new UnsupportedOperationException();
}
}
-
- //-------------------------------------------------------------------------
+
+ // -------------------------------------------------------------------------
// Deprecated int constants
// TODO: Remove in 3.0
-
+
/**
* Number of milliseconds in a standard second.
*
- * @deprecated Use MILLIS_PER_SECOND. This will be removed in Commons Lang 3.0.
+ * @deprecated Use MILLIS_PER_SECOND. This will be removed in Commons Lang
+ * 3.0.
*/
public static final int MILLIS_IN_SECOND = 1000;
/**
* Number of milliseconds in a standard minute.
*
- * @deprecated Use MILLIS_PER_MINUTE. This will be removed in Commons Lang 3.0.
+ * @deprecated Use MILLIS_PER_MINUTE. This will be removed in Commons Lang
+ * 3.0.
*/
public static final int MILLIS_IN_MINUTE = 60 * 1000;
/**
* Number of milliseconds in a standard hour.
*
- * @deprecated Use MILLIS_PER_HOUR. This will be removed in Commons Lang 3.0.
+ * @deprecated Use MILLIS_PER_HOUR. This will be removed in Commons Lang
+ * 3.0.
*/
public static final int MILLIS_IN_HOUR = 60 * 60 * 1000;
/**
@@ -986,5 +1158,5 @@ public void remove() {
* @deprecated Use MILLIS_PER_DAY. This will be removed in Commons Lang 3.0.
*/
public static final int MILLIS_IN_DAY = 24 * 60 * 60 * 1000;
-
+
}
diff --git a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/EqualsBuilder.java b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/EqualsBuilder.java
index 33c1e14188..0f5d3ae58a 100644
--- a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/EqualsBuilder.java
+++ b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/EqualsBuilder.java
@@ -24,57 +24,68 @@
import java.util.List;
/**
- * Assists in implementing {@link Object#equals(Object)} methods.
- * - *This class provides methods to build a good equals method for any - * class. It follows rules laid out in - * Effective Java + *
+ * Assists in implementing {@link Object#equals(Object)} methods. + *
+ * + *
+ * This class provides methods to build a good equals method for any class. It
+ * follows rules laid out in Effective Java
* , by Joshua Bloch. In particular the rule for comparing doubles
,
* floats
, and arrays can be tricky. Also, making sure that
* equals()
and hashCode()
are consistent can be
- * difficult.
Two Objects that compare as equals must generate the same hash code, - * but two Objects with the same hash code do not have to be equal.
- * - *All relevant fields should be included in the calculation of equals. - * Derived fields may be ignored. In particular, any field used in - * generating a hash code must be used in the equals method, and vice - * versa.
- * - *Typical use for the code is as follows:
+ * difficult. + * + * + *+ * Two Objects that compare as equals must generate the same hash code, but two + * Objects with the same hash code do not have to be equal. + *
+ * + *+ * All relevant fields should be included in the calculation of equals. Derived + * fields may be ignored. In particular, any field used in generating a hash + * code must be used in the equals method, and vice versa. + *
+ * + *+ * Typical use for the code is as follows: + *
+ * ** public boolean equals(Object obj) { - * if (obj instanceof MyClass == false) { - * return false; - * } - * if (this == obj) { - * return true; - * } - * MyClass rhs = (MyClass) obj; - * return new EqualsBuilder() - * .appendSuper(super.equals(obj)) - * .append(field1, rhs.field1) - * .append(field2, rhs.field2) - * .append(field3, rhs.field3) - * .isEquals(); - * } + * if (obj instanceof MyClass == false) { + * return false; + * } + * if (this == obj) { + * return true; + * } + * MyClass rhs = (MyClass) obj; + * return new EqualsBuilder().appendSuper(super.equals(obj)).append(field1, rhs.field1) + * .append(field2, rhs.field2).append(field3, rhs.field3).isEquals(); + * } *- * - *
Alternatively, there is a method that uses reflection to determine
- * the fields to test. Because these fields are usually private, the method,
- * reflectionEquals
, uses AccessibleObject.setAccessible
to
- * change the visibility of the fields. This will fail under a security
- * manager, unless the appropriate permissions are set up correctly. It is
- * also slower than testing explicitly.
A typical invocation for this method would look like:
+ * + *
+ * Alternatively, there is a method that uses reflection to determine the fields
+ * to test. Because these fields are usually private, the method,
+ * reflectionEquals
, uses
+ * AccessibleObject.setAccessible
to change the visibility of the
+ * fields. This will fail under a security manager, unless the appropriate
+ * permissions are set up correctly. It is also slower than testing explicitly.
+ *
+ * A typical invocation for this method would look like: + *
+ * ** public boolean equals(Object obj) { - * return EqualsBuilder.reflectionEquals(this, obj); + * return EqualsBuilder.reflectionEquals(this, obj); * } *- * + * * @author Steve Downey * @author Stephen Colebourne * @author Gary Gregory @@ -84,41 +95,55 @@ * @version $Id: EqualsBuilder.java 437554 2006-08-28 06:21:41Z bayard $ */ public class EqualsBuilder { - + /** - * If the fields tested are equals. - * The default value is
true
.
+ * If the fields tested are equals. The default value is true
.
*/
private boolean isEquals = true;
/**
- * Constructor for EqualsBuilder.
- * - *Starts off assuming that equals is true
.
+ * Constructor for EqualsBuilder. + *
+ * + *
+ * Starts off assuming that equals is true
.
+ *
This method uses reflection to determine if the two Object
s
- * are equal.
It uses AccessibleObject.setAccessible
to gain access to private
- * fields. This means that it will throw a security exception if run under
- * a security manager, if the permissions are not set up correctly. It is also
- * not as efficient as testing explicitly.
Transient members will be not be tested, as they are likely derived - * fields, and not part of the value of the Object.
- * - *Static fields will not be tested. Superclass fields will be included.
- * - * @param lhsthis
object
- * @param rhs the other object
+ *
+ * This method uses reflection to determine if the two Object
s
+ * are equal.
+ *
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
+ *
+ * Transient members will be not be tested, as they are likely derived + * fields, and not part of the value of the Object. + *
+ * + *+ * Static fields will not be tested. Superclass fields will be included. + *
+ * + * @param lhs + *this
object
+ * @param rhs
+ * the other object
* @return true
if the two Objects have tested equals.
*/
public static boolean reflectionEquals(Object lhs, Object rhs) {
@@ -126,22 +151,33 @@ public static boolean reflectionEquals(Object lhs, Object rhs) {
}
/**
- * This method uses reflection to determine if the two Object
s
- * are equal.
It uses AccessibleObject.setAccessible
to gain access to private
- * fields. This means that it will throw a security exception if run under
- * a security manager, if the permissions are not set up correctly. It is also
- * not as efficient as testing explicitly.
Transient members will be not be tested, as they are likely derived - * fields, and not part of the value of the Object.
- * - *Static fields will not be tested. Superclass fields will be included.
- * - * @param lhsthis
object
- * @param rhs the other object
- * @param excludeFields array of field names to exclude from testing
+ *
+ * This method uses reflection to determine if the two Object
s
+ * are equal.
+ *
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
+ *
+ * Transient members will be not be tested, as they are likely derived + * fields, and not part of the value of the Object. + *
+ * + *+ * Static fields will not be tested. Superclass fields will be included. + *
+ * + * @param lhs + *this
object
+ * @param rhs
+ * the other object
+ * @param excludeFields
+ * array of field names to exclude from testing
* @return true
if the two Objects have tested equals.
*/
public static boolean reflectionEquals(Object lhs, Object rhs, String[] excludeFields) {
@@ -149,23 +185,34 @@ public static boolean reflectionEquals(Object lhs, Object rhs, String[] excludeF
}
/**
- * This method uses reflection to determine if the two Object
s
- * are equal.
It uses AccessibleObject.setAccessible
to gain access to private
- * fields. This means that it will throw a security exception if run under
- * a security manager, if the permissions are not set up correctly. It is also
- * not as efficient as testing explicitly.
If the TestTransients parameter is set to true
, transient
+ *
+ * This method uses reflection to determine if the two Object
s
+ * are equal.
+ *
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
+ *
+ * If the TestTransients parameter is set to true
, transient
* members will be tested, otherwise they are ignored, as they are likely
- * derived fields, and not part of the value of the Object
.
Static fields will not be tested. Superclass fields will be included.
- * - * @param lhsthis
object
- * @param rhs the other object
- * @param testTransients whether to include transient fields
+ * derived fields, and not part of the value of the Object
.
+ *
+ *
+ * + * Static fields will not be tested. Superclass fields will be included. + *
+ * + * @param lhs + *this
object
+ * @param rhs
+ * the other object
+ * @param testTransients
+ * whether to include transient fields
* @return true
if the two Objects have tested equals.
*/
public static boolean reflectionEquals(Object lhs, Object rhs, boolean testTransients) {
@@ -173,71 +220,97 @@ public static boolean reflectionEquals(Object lhs, Object rhs, boolean testTrans
}
/**
- * This method uses reflection to determine if the two Object
s
- * are equal.
It uses AccessibleObject.setAccessible
to gain access to private
- * fields. This means that it will throw a security exception if run under
- * a security manager, if the permissions are not set up correctly. It is also
- * not as efficient as testing explicitly.
If the testTransients parameter is set to true
, transient
+ *
+ * This method uses reflection to determine if the two Object
s
+ * are equal.
+ *
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
+ *
+ * If the testTransients parameter is set to true
, transient
* members will be tested, otherwise they are ignored, as they are likely
- * derived fields, and not part of the value of the Object
.
Static fields will not be included. Superclass fields will be appended - * up to and including the specified superclass. A null superclass is treated - * as java.lang.Object.
- * - * @param lhsthis
object
- * @param rhs the other object
- * @param testTransients whether to include transient fields
- * @param reflectUpToClass the superclass to reflect up to (inclusive),
- * may be null
+ * derived fields, and not part of the value of the Object
.
+ *
+ *
+ * + * Static fields will not be included. Superclass fields will be appended up + * to and including the specified superclass. A null superclass is treated + * as java.lang.Object. + *
+ * + * @param lhs + *this
object
+ * @param rhs
+ * the other object
+ * @param testTransients
+ * whether to include transient fields
+ * @param reflectUpToClass
+ * the superclass to reflect up to (inclusive), may be
+ * null
* @return true
if the two Objects have tested equals.
* @since 2.0
*/
- public static boolean reflectionEquals(Object lhs, Object rhs, boolean testTransients, Class reflectUpToClass) {
+ public static boolean reflectionEquals(Object lhs, Object rhs, boolean testTransients,
+ Class reflectUpToClass) {
return reflectionEquals(lhs, rhs, testTransients, reflectUpToClass, null);
}
/**
- * This method uses reflection to determine if the two Object
s
- * are equal.
It uses AccessibleObject.setAccessible
to gain access to private
- * fields. This means that it will throw a security exception if run under
- * a security manager, if the permissions are not set up correctly. It is also
- * not as efficient as testing explicitly.
If the testTransients parameter is set to true
, transient
+ *
+ * This method uses reflection to determine if the two Object
s
+ * are equal.
+ *
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
+ *
+ * If the testTransients parameter is set to true
, transient
* members will be tested, otherwise they are ignored, as they are likely
- * derived fields, and not part of the value of the Object
.
Static fields will not be included. Superclass fields will be appended - * up to and including the specified superclass. A null superclass is treated - * as java.lang.Object.
- * - * @param lhsthis
object
- * @param rhs the other object
- * @param testTransients whether to include transient fields
- * @param reflectUpToClass the superclass to reflect up to (inclusive),
- * may be null
- * @param excludeFields array of field names to exclude from testing
+ * derived fields, and not part of the value of the Object
.
+ *
+ *
+ * + * Static fields will not be included. Superclass fields will be appended up + * to and including the specified superclass. A null superclass is treated + * as java.lang.Object. + *
+ * + * @param lhs + *this
object
+ * @param rhs
+ * the other object
+ * @param testTransients
+ * whether to include transient fields
+ * @param reflectUpToClass
+ * the superclass to reflect up to (inclusive), may be
+ * null
+ * @param excludeFields
+ * array of field names to exclude from testing
* @return true
if the two Objects have tested equals.
* @since 2.0
*/
- public static boolean reflectionEquals(Object lhs, Object rhs, boolean testTransients, Class reflectUpToClass,
- String[] excludeFields) {
+ public static boolean reflectionEquals(Object lhs, Object rhs, boolean testTransients,
+ Class reflectUpToClass, String[] excludeFields) {
if (lhs == rhs) {
return true;
}
if (lhs == null || rhs == null) {
return false;
}
- // Find the leaf class since there may be transients in the leaf
+ // Find the leaf class since there may be transients in the leaf
// class or in classes between the leaf and root.
- // If we are not testing transients or a subclass has no ivars,
+ // If we are not testing transients or a subclass has no ivars,
// then a subclass can test equals to a superclass.
Class lhsClass = lhs.getClass();
Class rhsClass = rhs.getClass();
@@ -267,9 +340,10 @@ public static boolean reflectionEquals(Object lhs, Object rhs, boolean testTrans
}
} catch (IllegalArgumentException e) {
// In this case, we tried to test a subclass vs. a superclass and
- // the subclass has ivars or the ivars are transient and
+ // the subclass has ivars or the ivars are transient and
// we are testing transients.
- // If a subclass has ivars that we are trying to test them, we get an
+ // If a subclass has ivars that we are trying to test them, we get
+ // an
// exception and we know that the objects are not equal.
return false;
}
@@ -277,49 +351,55 @@ public static boolean reflectionEquals(Object lhs, Object rhs, boolean testTrans
}
/**
- * Appends the fields and values defined by the given object of the - * given Class.
- * - * @param lhs the left hand object - * @param rhs the right hand object - * @param clazz the class to append details of - * @param builder the builder to append to - * @param useTransients whether to test transient fields - * @param excludeFields array of field names to exclude from testing + *+ * Appends the fields and values defined by the given object of the given + * Class. + *
+ * + * @param lhs + * the left hand object + * @param rhs + * the right hand object + * @param clazz + * the class to append details of + * @param builder + * the builder to append to + * @param useTransients + * whether to test transient fields + * @param excludeFields + * array of field names to exclude from testing */ - private static void reflectionAppend( - Object lhs, - Object rhs, - Class clazz, - EqualsBuilder builder, - boolean useTransients, - String[] excludeFields) { + private static void reflectionAppend(Object lhs, Object rhs, Class clazz, + EqualsBuilder builder, boolean useTransients, String[] excludeFields) { Field[] fields = clazz.getDeclaredFields(); - List excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields) : Collections.EMPTY_LIST; + List excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields) + : Collections.EMPTY_LIST; AccessibleObject.setAccessible(fields, true); for (int i = 0; i < fields.length && builder.isEquals; i++) { Field f = fields[i]; - if (!excludedFieldList.contains(f.getName()) - && (f.getName().indexOf('$') == -1) - && (useTransients || !Modifier.isTransient(f.getModifiers())) - && (!Modifier.isStatic(f.getModifiers()))) { + if (!excludedFieldList.contains(f.getName()) && (f.getName().indexOf('$') == -1) + && (useTransients || !Modifier.isTransient(f.getModifiers())) + && (!Modifier.isStatic(f.getModifiers()))) { try { builder.append(f.get(lhs), f.get(rhs)); } catch (IllegalAccessException e) { - //this can't happen. Would get a Security exception instead - //throw a runtime exception in case the impossible happens. + // this can't happen. Would get a Security exception instead + // throw a runtime exception in case the impossible happens. throw new InternalError("Unexpected IllegalAccessException"); } } } } - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- /** - *Adds the result of super.equals()
to this builder.
super.equals()
+ *
+ * Adds the result of super.equals()
to this builder.
+ *
super.equals()
* @return EqualsBuilder - used to chain calls.
* @since 2.0
*/
@@ -331,14 +411,18 @@ public EqualsBuilder appendSuper(boolean superEquals) {
return this;
}
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
/**
- * Test if two Object
s are equal using their
- * equals
method.
+ * Test if two Object
s are equal using their
+ * equals
method.
+ *
long
+ * the left hand long
* @param rhs
- * the right hand long
+ * the right hand long
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(long lhs, long rhs) {
@@ -405,10 +490,14 @@ public EqualsBuilder append(long lhs, long rhs) {
}
/**
- * Test if two int
s are equal.
int
- * @param rhs the right hand int
+ *
+ * Test if two int
s are equal.
+ *
int
+ * @param rhs
+ * the right hand int
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(int lhs, int rhs) {
@@ -420,10 +509,14 @@ public EqualsBuilder append(int lhs, int rhs) {
}
/**
- * Test if two short
s are equal.
short
- * @param rhs the right hand short
+ *
+ * Test if two short
s are equal.
+ *
short
+ * @param rhs
+ * the right hand short
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(short lhs, short rhs) {
@@ -435,10 +528,14 @@ public EqualsBuilder append(short lhs, short rhs) {
}
/**
- * Test if two char
s are equal.
char
- * @param rhs the right hand char
+ *
+ * Test if two char
s are equal.
+ *
char
+ * @param rhs
+ * the right hand char
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(char lhs, char rhs) {
@@ -450,10 +547,14 @@ public EqualsBuilder append(char lhs, char rhs) {
}
/**
- * Test if two byte
s are equal.
byte
- * @param rhs the right hand byte
+ *
+ * Test if two byte
s are equal.
+ *
byte
+ * @param rhs
+ * the right hand byte
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(byte lhs, byte rhs) {
@@ -465,16 +566,24 @@ public EqualsBuilder append(byte lhs, byte rhs) {
}
/**
- * Test if two double
s are equal by testing that the
- * pattern of bits returned by doubleToLong
are equal.
This handles NaNs, Infinities, and -0.0
.
It is compatible with the hash code generated by
- * HashCodeBuilder
.
double
- * @param rhs the right hand double
+ *
+ * Test if two double
s are equal by testing that the pattern of
+ * bits returned by doubleToLong
are equal.
+ *
+ * This handles NaNs, Infinities, and -0.0
.
+ *
+ * It is compatible with the hash code generated by
+ * HashCodeBuilder
.
+ *
double
+ * @param rhs
+ * the right hand double
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(double lhs, double rhs) {
@@ -485,16 +594,24 @@ public EqualsBuilder append(double lhs, double rhs) {
}
/**
- * Test if two float
s are equal byt testing that the
- * pattern of bits returned by doubleToLong are equal.
This handles NaNs, Infinities, and -0.0
.
It is compatible with the hash code generated by
- * HashCodeBuilder
.
float
- * @param rhs the right hand float
+ *
+ * Test if two float
s are equal byt testing that the pattern of
+ * bits returned by doubleToLong are equal.
+ *
+ * This handles NaNs, Infinities, and -0.0
.
+ *
+ * It is compatible with the hash code generated by
+ * HashCodeBuilder
.
+ *
float
+ * @param rhs
+ * the right hand float
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(float lhs, float rhs) {
@@ -505,12 +622,16 @@ public EqualsBuilder append(float lhs, float rhs) {
}
/**
- * Test if two booleans
s are equal.
boolean
- * @param rhs the right hand boolean
+ *
+ * Test if two booleans
s are equal.
+ *
boolean
+ * @param rhs
+ * the right hand boolean
* @return EqualsBuilder - used to chain calls.
- */
+ */
public EqualsBuilder append(boolean lhs, boolean rhs) {
if (isEquals == false) {
return this;
@@ -520,13 +641,19 @@ public EqualsBuilder append(boolean lhs, boolean rhs) {
}
/**
- * Performs a deep comparison of two Object
arrays.
This also will be called for the top level of - * multi-dimensional, ragged, and multi-typed arrays.
- * - * @param lhs the left handObject[]
- * @param rhs the right hand Object[]
+ *
+ * Performs a deep comparison of two Object
arrays.
+ *
+ * This also will be called for the top level of multi-dimensional, ragged, + * and multi-typed arrays. + *
+ * + * @param lhs + * the left handObject[]
+ * @param rhs
+ * the right hand Object[]
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(Object[] lhs, Object[] rhs) {
@@ -551,13 +678,19 @@ public EqualsBuilder append(Object[] lhs, Object[] rhs) {
}
/**
- * Deep comparison of array of long
. Length and all
- * values are compared.
The method {@link #append(long, long)} is used.
- * - * @param lhs the left handlong[]
- * @param rhs the right hand long[]
+ *
+ * Deep comparison of array of long
. Length and all values are
+ * compared.
+ *
+ * The method {@link #append(long, long)} is used. + *
+ * + * @param lhs + * the left handlong[]
+ * @param rhs
+ * the right hand long[]
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(long[] lhs, long[] rhs) {
@@ -582,13 +715,19 @@ public EqualsBuilder append(long[] lhs, long[] rhs) {
}
/**
- * Deep comparison of array of int
. Length and all
- * values are compared.
The method {@link #append(int, int)} is used.
- * - * @param lhs the left handint[]
- * @param rhs the right hand int[]
+ *
+ * Deep comparison of array of int
. Length and all values are
+ * compared.
+ *
+ * The method {@link #append(int, int)} is used. + *
+ * + * @param lhs + * the left handint[]
+ * @param rhs
+ * the right hand int[]
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(int[] lhs, int[] rhs) {
@@ -613,13 +752,19 @@ public EqualsBuilder append(int[] lhs, int[] rhs) {
}
/**
- * Deep comparison of array of short
. Length and all
- * values are compared.
The method {@link #append(short, short)} is used.
- * - * @param lhs the left handshort[]
- * @param rhs the right hand short[]
+ *
+ * Deep comparison of array of short
. Length and all values are
+ * compared.
+ *
+ * The method {@link #append(short, short)} is used. + *
+ * + * @param lhs + * the left handshort[]
+ * @param rhs
+ * the right hand short[]
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(short[] lhs, short[] rhs) {
@@ -644,13 +789,19 @@ public EqualsBuilder append(short[] lhs, short[] rhs) {
}
/**
- * Deep comparison of array of char
. Length and all
- * values are compared.
The method {@link #append(char, char)} is used.
- * - * @param lhs the left handchar[]
- * @param rhs the right hand char[]
+ *
+ * Deep comparison of array of char
. Length and all values are
+ * compared.
+ *
+ * The method {@link #append(char, char)} is used. + *
+ * + * @param lhs + * the left handchar[]
+ * @param rhs
+ * the right hand char[]
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(char[] lhs, char[] rhs) {
@@ -675,13 +826,19 @@ public EqualsBuilder append(char[] lhs, char[] rhs) {
}
/**
- * Deep comparison of array of byte
. Length and all
- * values are compared.
The method {@link #append(byte, byte)} is used.
- * - * @param lhs the left handbyte[]
- * @param rhs the right hand byte[]
+ *
+ * Deep comparison of array of byte
. Length and all values are
+ * compared.
+ *
+ * The method {@link #append(byte, byte)} is used. + *
+ * + * @param lhs + * the left handbyte[]
+ * @param rhs
+ * the right hand byte[]
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(byte[] lhs, byte[] rhs) {
@@ -706,13 +863,19 @@ public EqualsBuilder append(byte[] lhs, byte[] rhs) {
}
/**
- * Deep comparison of array of double
. Length and all
- * values are compared.
The method {@link #append(double, double)} is used.
- * - * @param lhs the left handdouble[]
- * @param rhs the right hand double[]
+ *
+ * Deep comparison of array of double
. Length and all values
+ * are compared.
+ *
+ * The method {@link #append(double, double)} is used. + *
+ * + * @param lhs + * the left handdouble[]
+ * @param rhs
+ * the right hand double[]
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(double[] lhs, double[] rhs) {
@@ -737,13 +900,19 @@ public EqualsBuilder append(double[] lhs, double[] rhs) {
}
/**
- * Deep comparison of array of float
. Length and all
- * values are compared.
The method {@link #append(float, float)} is used.
- * - * @param lhs the left handfloat[]
- * @param rhs the right hand float[]
+ *
+ * Deep comparison of array of float
. Length and all values are
+ * compared.
+ *
+ * The method {@link #append(float, float)} is used. + *
+ * + * @param lhs + * the left handfloat[]
+ * @param rhs
+ * the right hand float[]
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(float[] lhs, float[] rhs) {
@@ -768,13 +937,19 @@ public EqualsBuilder append(float[] lhs, float[] rhs) {
}
/**
- * Deep comparison of array of boolean
. Length and all
- * values are compared.
The method {@link #append(boolean, boolean)} is used.
- * - * @param lhs the left handboolean[]
- * @param rhs the right hand boolean[]
+ *
+ * Deep comparison of array of boolean
. Length and all values
+ * are compared.
+ *
+ * The method {@link #append(boolean, boolean)} is used. + *
+ * + * @param lhs + * the left handboolean[]
+ * @param rhs
+ * the right hand boolean[]
* @return EqualsBuilder - used to chain calls.
*/
public EqualsBuilder append(boolean[] lhs, boolean[] rhs) {
@@ -799,9 +974,11 @@ public EqualsBuilder append(boolean[] lhs, boolean[] rhs) {
}
/**
- * Returns true
if the fields that have been checked
- * are all equal.
+ * Returns true
if the fields that have been checked are all
+ * equal.
+ *
isEquals
value.
*
- * @param isEquals The value to set.
+ * @param isEquals
+ * The value to set.
* @since 2.1
*/
protected void setEquals(boolean isEquals) {
diff --git a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/HashCodeBuilder.java b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/HashCodeBuilder.java
index 57c8aef5d4..668545d271 100644
--- a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/HashCodeBuilder.java
+++ b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/common/HashCodeBuilder.java
@@ -32,15 +32,18 @@
*
*
*
- * This class enables a good hashCode
method to be built for any class. It follows the rules laid out in
- * the book Effective Java by Joshua Bloch. Writing a
- * good hashCode
method is actually quite difficult. This class aims to simplify the process.
+ * This class enables a good hashCode
method to be built for any
+ * class. It follows the rules laid out in the book Effective Java
+ * by Joshua Bloch. Writing a good hashCode
method is actually
+ * quite difficult. This class aims to simplify the process.
*
- * All relevant fields from the object should be included in the hashCode
method. Derived fields may be
- * excluded. In general, any field used in the equals
method must be used in the hashCode
- * method.
+ * All relevant fields from the object should be included in the
+ * hashCode
method. Derived fields may be excluded. In general, any
+ * field used in the equals
method must be used in the
+ * hashCode
method.
*
@@ -53,7 +56,7 @@ * int age; * boolean smoker; * ... - * + * * public int hashCode() { * // you pick a hard-coded, randomly chosen, non-zero, odd number * // ideally different for each class @@ -67,14 +70,17 @@ * * *
- * If required, the superclass hashCode()
can be added using {@link #appendSuper}.
+ * If required, the superclass hashCode()
can be added using
+ * {@link #appendSuper}.
*
- * Alternatively, there is a method that uses reflection to determine the fields to test. Because these fields are
- * usually private, the method, reflectionHashCode
, uses AccessibleObject.setAccessible
- * to change the visibility of the fields. This will fail under a security manager, unless the appropriate permissions
- * are set up correctly. It is also slower than testing explicitly.
+ * Alternatively, there is a method that uses reflection to determine the fields
+ * to test. Because these fields are usually private, the method,
+ * reflectionHashCode
, uses
+ * AccessibleObject.setAccessible
to change the visibility of the
+ * fields. This will fail under a security manager, unless the appropriate
+ * permissions are set up correctly. It is also slower than testing explicitly.
*
@@ -83,7 +89,7 @@ * *
* public int hashCode() { - * return HashCodeBuilder.reflectionHashCode(this); + * return HashCodeBuilder.reflectionHashCode(this); * } ** @@ -96,7 +102,8 @@ public class HashCodeBuilder { /** *
- * A registry of objects used by reflection methods to detect cyclical object references and avoid infinite loops. + * A registry of objects used by reflection methods to detect cyclical + * object references and avoid infinite loops. *
* * @since 2.3 @@ -111,7 +118,8 @@ protected synchronized Object initialValue() { /** *- * Returns the registry of objects being traversed by the reflection methods in the current thread. + * Returns the registry of objects being traversed by the reflection methods + * in the current thread. *
* * @return Set the registry of objects being traversed @@ -123,13 +131,14 @@ static Set getRegistry() { /** *
- * Returns true
if the registry contains the given object. Used by the reflection methods to avoid
- * infinite loops.
+ * Returns true
if the registry contains the given object. Used
+ * by the reflection methods to avoid infinite loops.
*
true
if the registry contains the given object.
+ * @return boolean true
if the registry contains the given
+ * object.
* @since 2.3
*/
static boolean isRegistered(Object value) {
@@ -138,7 +147,8 @@ static boolean isRegistered(Object value) {
/**
*
- * Appends the fields and values defined by the given object of the given Class
.
+ * Appends the fields and values defined by the given object of the given
+ * Class
.
*
- * It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
- * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
- * also not as efficient as testing explicitly.
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
*
- * Transient members will be not be used, as they are likely derived fields, and not part of the value of the
- * Object
.
+ * Transient members will be not be used, as they are likely derived fields,
+ * and not part of the value of the Object
.
*
@@ -204,8 +219,9 @@ private static void reflectionAppend(Object object, Class clazz, HashCodeBuilder *
* *- * Two randomly chosen, non-zero, odd numbers must be passed in. Ideally these should be different for each class, - * however this is not vital. Prime numbers are preferred, especially for the multiplier. + * Two randomly chosen, non-zero, odd numbers must be passed in. Ideally + * these should be different for each class, however this is not vital. + * Prime numbers are preferred, especially for the multiplier. *
* * @param initialNonZeroOddNumber @@ -220,8 +236,10 @@ private static void reflectionAppend(Object object, Class clazz, HashCodeBuilder * @throws IllegalArgumentException * if the number is zero or even */ - public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object object) { - return reflectionHashCode(initialNonZeroOddNumber, multiplierNonZeroOddNumber, object, false, null, null); + public static int reflectionHashCode(int initialNonZeroOddNumber, + int multiplierNonZeroOddNumber, Object object) { + return reflectionHashCode(initialNonZeroOddNumber, multiplierNonZeroOddNumber, object, + false, null, null); } /** @@ -230,14 +248,16 @@ public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplier * * *
- * It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
- * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
- * also not as efficient as testing explicitly.
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
*
- * If the TestTransients parameter is set to true
, transient members will be tested, otherwise they
- * are ignored, as they are likely derived fields, and not part of the value of the Object
.
+ * If the TestTransients parameter is set to true
, transient
+ * members will be tested, otherwise they are ignored, as they are likely
+ * derived fields, and not part of the value of the Object
.
*
@@ -245,8 +265,9 @@ public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplier *
* *- * Two randomly chosen, non-zero, odd numbers must be passed in. Ideally these should be different for each class, - * however this is not vital. Prime numbers are preferred, especially for the multiplier. + * Two randomly chosen, non-zero, odd numbers must be passed in. Ideally + * these should be different for each class, however this is not vital. + * Prime numbers are preferred, especially for the multiplier. *
* * @param initialNonZeroOddNumber @@ -263,15 +284,16 @@ public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplier * @throws IllegalArgumentException * if the number is zero or even */ - public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object object, - boolean testTransients) { - return reflectionHashCode(initialNonZeroOddNumber, multiplierNonZeroOddNumber, object, testTransients, null, - null); + public static int reflectionHashCode(int initialNonZeroOddNumber, + int multiplierNonZeroOddNumber, Object object, boolean testTransients) { + return reflectionHashCode(initialNonZeroOddNumber, multiplierNonZeroOddNumber, object, + testTransients, null, null); } /** - * Calls {@link #reflectionHashCode(int, int, Object, boolean, Class, String[])} with excludeFields set to - *null
.
+ * Calls
+ * {@link #reflectionHashCode(int, int, Object, boolean, Class, String[])}
+ * with excludeFields set to null
.
*
* @param initialNonZeroOddNumber
* a non-zero, odd number used as the initial value
@@ -282,13 +304,15 @@ public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplier
* @param testTransients
* whether to include transient fields
* @param reflectUpToClass
- * the superclass to reflect up to (inclusive), may be null
+ * the superclass to reflect up to (inclusive), may be
+ * null
* @return int hash code
*/
- public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object object,
- boolean testTransients, Class reflectUpToClass) {
- return reflectionHashCode(initialNonZeroOddNumber, multiplierNonZeroOddNumber, object, testTransients,
- reflectUpToClass, null);
+ public static int reflectionHashCode(int initialNonZeroOddNumber,
+ int multiplierNonZeroOddNumber, Object object, boolean testTransients,
+ Class reflectUpToClass) {
+ return reflectionHashCode(initialNonZeroOddNumber, multiplierNonZeroOddNumber, object,
+ testTransients, reflectUpToClass, null);
}
/**
@@ -297,24 +321,28 @@ public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplier
*
*
*
- * It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
- * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
- * also not as efficient as testing explicitly.
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
*
- * If the TestTransients parameter is set to true
, transient members will be tested, otherwise they
- * are ignored, as they are likely derived fields, and not part of the value of the Object
.
+ * If the TestTransients parameter is set to true
, transient
+ * members will be tested, otherwise they are ignored, as they are likely
+ * derived fields, and not part of the value of the Object
.
*
- * Static fields will not be included. Superclass fields will be included up to and including the specified - * superclass. A null superclass is treated as java.lang.Object. + * Static fields will not be included. Superclass fields will be included up + * to and including the specified superclass. A null superclass is treated + * as java.lang.Object. *
* *- * Two randomly chosen, non-zero, odd numbers must be passed in. Ideally these should be different for each class, - * however this is not vital. Prime numbers are preferred, especially for the multiplier. + * Two randomly chosen, non-zero, odd numbers must be passed in. Ideally + * these should be different for each class, however this is not vital. + * Prime numbers are preferred, especially for the multiplier. *
* * @param initialNonZeroOddNumber @@ -326,9 +354,11 @@ public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplier * @param testTransients * whether to include transient fields * @param reflectUpToClass - * the superclass to reflect up to (inclusive), may benull
+ * the superclass to reflect up to (inclusive), may be
+ * null
* @param excludeFields
- * array of field names to exclude from use in calculation of hash code
+ * array of field names to exclude from use in calculation of
+ * hash code
* @return int hash code
* @throws IllegalArgumentException
* if the Object is null
@@ -336,13 +366,16 @@ public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplier
* if the number is zero or even
* @since 2.0
*/
- public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object object,
- boolean testTransients, Class reflectUpToClass, String[] excludeFields) {
+ public static int reflectionHashCode(int initialNonZeroOddNumber,
+ int multiplierNonZeroOddNumber, Object object, boolean testTransients,
+ Class reflectUpToClass, String[] excludeFields) {
if (object == null) {
- throw new IllegalArgumentException("The object to build a hash code for must not be null");
+ throw new IllegalArgumentException(
+ "The object to build a hash code for must not be null");
}
- HashCodeBuilder builder = new HashCodeBuilder(initialNonZeroOddNumber, multiplierNonZeroOddNumber);
+ HashCodeBuilder builder = new HashCodeBuilder(initialNonZeroOddNumber,
+ multiplierNonZeroOddNumber);
Class clazz = object.getClass();
reflectionAppend(object, clazz, builder, testTransients, excludeFields);
while (clazz.getSuperclass() != null && clazz != reflectUpToClass) {
@@ -358,18 +391,20 @@ public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplier
*
*
* - * This constructor uses two hard coded choices for the constants needed to build a hash code. + * This constructor uses two hard coded choices for the constants needed to + * build a hash code. *
* *
- * It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
- * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
- * also not as efficient as testing explicitly.
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
*
- * Transient members will be not be used, as they are likely derived fields, and not part of the value of the
- * Object
.
+ * Transient members will be not be used, as they are likely derived fields,
+ * and not part of the value of the Object
.
*
@@ -392,18 +427,21 @@ public static int reflectionHashCode(Object object) { *
* *- * This constructor uses two hard coded choices for the constants needed to build a hash code. + * This constructor uses two hard coded choices for the constants needed to + * build a hash code. *
* *
- * It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
- * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
- * also not as efficient as testing explicitly.
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
*
- * If the TestTransients parameter is set to true
, transient members will be tested, otherwise they
- * are ignored, as they are likely derived fields, and not part of the value of the Object
.
+ * If the TestTransients parameter is set to true
, transient
+ * members will be tested, otherwise they are ignored, as they are likely
+ * derived fields, and not part of the value of the Object
.
*
@@ -430,18 +468,20 @@ public static int reflectionHashCode(Object object, boolean testTransients) { *
* *- * This constructor uses two hard coded choices for the constants needed to build a hash code. + * This constructor uses two hard coded choices for the constants needed to + * build a hash code. *
* *
- * It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
- * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
- * also not as efficient as testing explicitly.
+ * It uses AccessibleObject.setAccessible
to gain access to
+ * private fields. This means that it will throw a security exception if run
+ * under a security manager, if the permissions are not set up correctly. It
+ * is also not as efficient as testing explicitly.
*
- * Transient members will be not be used, as they are likely derived fields, and not part of the value of the
- * Object
.
+ * Transient members will be not be used, as they are likely derived fields,
+ * and not part of the value of the Object
.
*
@@ -451,7 +491,8 @@ public static int reflectionHashCode(Object object, boolean testTransients) {
* @param object
* the Object to create a hashCode
for
* @param excludeFields
- * array of field names to exclude from use in calculation of hash code
+ * array of field names to exclude from use in calculation of
+ * hash code
* @return int hash code
* @throws IllegalArgumentException
* if the object is null
@@ -462,7 +503,8 @@ public static int reflectionHashCode(Object object, String[] excludeFields) {
/**
*
- * Registers the given object. Used by the reflection methods to avoid infinite loops. + * Registers the given object. Used by the reflection methods to avoid + * infinite loops. *
* * @param value @@ -512,7 +554,8 @@ static void unregister(Object value) { /** *
- * Uses two hard coded choices for the constants needed to build a hashCode
.
+ * Uses two hard coded choices for the constants needed to build a
+ * hashCode
.
*
- * Two randomly chosen, non-zero, odd numbers must be passed in. Ideally these should be different for each class, - * however this is not vital. + * Two randomly chosen, non-zero, odd numbers must be passed in. Ideally + * these should be different for each class, however this is not vital. *
* *
@@ -559,9 +602,9 @@ public HashCodeBuilder(int initialNonZeroOddNumber, int multiplierNonZeroOddNumb
* Append a hashCode
for a boolean
.
*
- * This adds iConstant * 1
to the hashCode
and not a 1231
or
- * 1237
as done in java.lang.Boolean. This is in accordance with the Effective Java
- * design.
+ * This adds iConstant * 1
to the hashCode
and not
+ * a 1231
or 1237
as done in java.lang.Boolean.
+ * This is in accordance with the Effective Java
design.
*
The maximum size to which the padding constant(s) can expand.
+ *+ * The maximum size to which the padding constant(s) can expand. + *
*/ private static final int PAD_LIMIT = 8192; - + /** ** Replaces all occurrences of a String within another String. @@ -137,10 +138,12 @@ public static String replace(String text, String repl, String with, int max) { public static boolean isEmpty(String str) { return str == null || str.length() == 0; } - + /** - *
Checks if a String is whitespace, empty ("") or null.
- * + *+ * Checks if a String is whitespace, empty ("") or null. + *
+ * ** StringUtils.isBlank(null) = true * StringUtils.isBlank("") = true @@ -148,8 +151,9 @@ public static boolean isEmpty(String str) { * StringUtils.isBlank("bob") = false * StringUtils.isBlank(" bob ") = false *- * - * @param str the String to check, may be null + * + * @param str + * the String to check, may be null * @return
true
if the String is null, empty or whitespace
* @since 2.0
*/
@@ -165,10 +169,12 @@ public static boolean isBlank(String str) {
}
return true;
}
-
+
/**
- * Checks if a String is not empty (""), not null and not whitespace only.
- * + *+ * Checks if a String is not empty (""), not null and not whitespace only. + *
+ * ** StringUtils.isNotBlank(null) = false * StringUtils.isNotBlank("") = false @@ -176,28 +182,34 @@ public static boolean isBlank(String str) { * StringUtils.isNotBlank("bob") = true * StringUtils.isNotBlank(" bob ") = true *- * - * @param str the String to check, may be null - * @return
true
if the String is
- * not empty and not null and not whitespace
+ *
+ * @param str
+ * the String to check, may be null
+ * @return true
if the String is not empty and not null and not
+ * whitespace
* @since 2.0
*/
public static boolean isNotBlank(String str) {
return !StringUtils.isBlank(str);
- }
-
+ }
+
/**
- * Converts a String to upper case as per {@link String#toUpperCase()}.
- * - *A null
input String returns null
.
+ * Converts a String to upper case as per {@link String#toUpperCase()}. + *
+ * + *
+ * A null
input String returns null
.
+ *
* StringUtils.upperCase(null) = null * StringUtils.upperCase("") = "" * StringUtils.upperCase("aBc") = "ABC" *- * - * @param str the String to upper case, may be null + * + * @param str + * the String to upper case, may be null * @return the upper cased String,
null
if null String input
*/
public static String upperCase(String str) {
@@ -208,17 +220,22 @@ public static String upperCase(String str) {
}
/**
- * Converts a String to lower case as per {@link String#toLowerCase()}.
- * - *A null
input String returns null
.
+ * Converts a String to lower case as per {@link String#toLowerCase()}. + *
+ * + *
+ * A null
input String returns null
.
+ *
* StringUtils.lowerCase(null) = null * StringUtils.lowerCase("") = "" * StringUtils.lowerCase("aBc") = "abc" *- * - * @param str the String to lower case, may be null + * + * @param str + * the String to lower case, may be null * @return the lower cased String,
null
if null String input
*/
public static String lowerCase(String str) {
@@ -229,10 +246,14 @@ public static String lowerCase(String str) {
}
/**
- * Right pad a String with a specified character.
- * - *The String is padded to the size of size
.
+ * Right pad a String with a specified character. + *
+ * + *
+ * The String is padded to the size of size
.
+ *
* StringUtils.rightPad(null, *, *) = null * StringUtils.rightPad("", 3, 'z') = "zzz" @@ -241,12 +262,15 @@ public static String lowerCase(String str) { * StringUtils.rightPad("bat", 1, 'z') = "bat" * StringUtils.rightPad("bat", -1, 'z') = "bat" *- * - * @param str the String to pad out, may be null - * @param size the size to pad to - * @param padChar the character to pad with - * @return right padded String or original String if no padding is necessary, - *
null
if null String input
+ *
+ * @param str
+ * the String to pad out, may be null
+ * @param size
+ * the size to pad to
+ * @param padChar
+ * the character to pad with
+ * @return right padded String or original String if no padding is
+ * necessary, null
if null String input
* @since 2.0
*/
public static String rightPad(String str, int size, char padChar) {
@@ -264,10 +288,14 @@ public static String rightPad(String str, int size, char padChar) {
}
/**
- * Right pad a String with a specified String.
- * - *The String is padded to the size of size
.
+ * Right pad a String with a specified String. + *
+ * + *
+ * The String is padded to the size of size
.
+ *
* StringUtils.rightPad(null, *, *) = null * StringUtils.rightPad("", 3, "z") = "zzz" @@ -279,12 +307,15 @@ public static String rightPad(String str, int size, char padChar) { * StringUtils.rightPad("bat", 5, null) = "bat " * StringUtils.rightPad("bat", 5, "") = "bat " *- * - * @param str the String to pad out, may be null - * @param size the size to pad to - * @param padStr the String to pad with, null or empty treated as single space - * @return right padded String or original String if no padding is necessary, - *
null
if null String input
+ *
+ * @param str
+ * the String to pad out, may be null
+ * @param size
+ * the size to pad to
+ * @param padStr
+ * the String to pad with, null or empty treated as single space
+ * @return right padded String or original String if no padding is
+ * necessary, null
if null String input
*/
public static String rightPad(String str, int size, String padStr) {
if (str == null) {
@@ -316,28 +347,33 @@ public static String rightPad(String str, int size, String padStr) {
return str.concat(new String(padding));
}
}
-
+
/**
- * Returns padding using the specified delimiter repeated - * to a given length.
- * + *+ * Returns padding using the specified delimiter repeated to a given length. + *
+ * ** StringUtils.padding(0, 'e') = "" * StringUtils.padding(3, 'e') = "eee" * StringUtils.padding(-2, 'e') = IndexOutOfBoundsException *- * - *
Note: this method doesn't not support padding with
- * Unicode Supplementary Characters
- * as they require a pair of char
s to be represented.
- * If you are needing to support full I18N of your applications
- * consider using {@link #repeat(String, int)} instead.
+ *
+ *
+ * Note: this method doesn't not support padding with Unicode
+ * Supplementary Characters as they require a pair of char
s
+ * to be represented. If you are needing to support full I18N of your
+ * applications consider using {@link #repeat(String, int)} instead.
*
repeat < 0
+ * @throws IndexOutOfBoundsException
+ * if repeat < 0
* @see #repeat(String, int)
*/
private static String padding(int repeat, char padChar) throws IndexOutOfBoundsException {
@@ -350,13 +386,17 @@ private static String padding(int repeat, char padChar) throws IndexOutOfBoundsE
}
return new String(buf);
}
-
+
/**
- * Compares two Strings, returning true
if they are equal.
null
s are handled without exceptions. Two null
- * references are considered to be equal. The comparison is case sensitive.
+ * Compares two Strings, returning true
if they are equal.
+ *
+ * null
s are handled without exceptions. Two null
+ * references are considered to be equal. The comparison is case sensitive.
+ *
* StringUtils.equals(null, null) = true * StringUtils.equals(null, "abc") = false @@ -364,24 +404,30 @@ private static String padding(int repeat, char padChar) throws IndexOutOfBoundsE * StringUtils.equals("abc", "abc") = true * StringUtils.equals("abc", "ABC") = false *- * + * * @see java.lang.String#equals(Object) - * @param str1 the first String, may be null - * @param str2 the second String, may be null + * @param str1 + * the first String, may be null + * @param str2 + * the second String, may be null * @return
true
if the Strings are equal, case sensitive, or
- * both null
+ * both null
*/
public static boolean equals(String str1, String str2) {
return str1 == null ? str2 == null : str1.equals(str2);
}
/**
- * Compares two Strings, returning true
if they are equal ignoring
- * the case.
null
s are handled without exceptions. Two null
- * references are considered equal. Comparison is case insensitive.
+ * Compares two Strings, returning true
if they are equal
+ * ignoring the case.
+ *
+ * null
s are handled without exceptions. Two null
+ * references are considered equal. Comparison is case insensitive.
+ *
* StringUtils.equalsIgnoreCase(null, null) = true * StringUtils.equalsIgnoreCase(null, "abc") = false @@ -389,18 +435,21 @@ public static boolean equals(String str1, String str2) { * StringUtils.equalsIgnoreCase("abc", "abc") = true * StringUtils.equalsIgnoreCase("abc", "ABC") = true *- * + * * @see java.lang.String#equalsIgnoreCase(String) - * @param str1 the first String, may be null - * @param str2 the second String, may be null + * @param str1 + * the first String, may be null + * @param str2 + * the second String, may be null * @return
true
if the Strings are equal, case insensitive, or
- * both null
+ * both null
*/
public static boolean equalsIgnoreCase(String str1, String str2) {
return str1 == null ? str2 == null : str1.equalsIgnoreCase(str2);
}
-
- public static String replaceTokens(String tokenName, String replacementValue, String originalText) {
+
+ public static String replaceTokens(String tokenName, String replacementValue,
+ String originalText) {
MapChecks if the String contains only unicode digits. - * A decimal point is not a unicode digit and returns false.
- * - *null
will return false
.
- * An empty String ("") will return true
.
+ * Checks if the String contains only unicode digits. A decimal point is not + * a unicode digit and returns false. + *
+ * + *
+ * null
will return false
. An empty String ("")
+ * will return true
.
+ *
* StringUtils.isNumeric(null) = false * StringUtils.isNumeric("") = true @@ -462,8 +515,9 @@ public static String formatString(String format, String arg) { * StringUtils.isNumeric("12-3") = false * StringUtils.isNumeric("12.3") = false *- * - * @param str the String to check, may be null + * + * @param str + * the String to check, may be null * @return
true
if only contains digits, and is non-null
*/
public static boolean isNumeric(String str) {
@@ -477,6 +531,6 @@ public static boolean isNumeric(String str) {
}
}
return true;
- }
-
+ }
+
}
diff --git a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/AbstractDbPlatform.java b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/AbstractDbPlatform.java
index 3e53cf706d..1111af0c6e 100644
--- a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/AbstractDbPlatform.java
+++ b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/AbstractDbPlatform.java
@@ -44,20 +44,20 @@ abstract public class AbstractDbPlatform implements IDbPlatform {
protected String defaultCatalog;
protected SqlBuilder sqlBuilder;
-
+
protected TriggerBuilder triggerBuilder;
-
+
protected Parameters parameters;
-
+
public AbstractDbPlatform(Parameters parameters) {
this.parameters = parameters == null ? new Parameters() : parameters;
}
-
+
public Parameters getParameters() {
return parameters;
}
-
+
public TriggerBuilder getTriggerBuilder() {
return triggerBuilder;
}
@@ -65,7 +65,7 @@ public TriggerBuilder getTriggerBuilder() {
public SqlBuilder getSqlBuilder() {
return sqlBuilder;
}
-
+
public boolean isLob(int type) {
return type == Types.CLOB || type == Types.BLOB || type == Types.BINARY
|| type == Types.VARBINARY || type == Types.LONGVARBINARY ||
diff --git a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/DbPlatformInfo.java b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/DbPlatformInfo.java
index cbc095e9be..e001097485 100644
--- a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/DbPlatformInfo.java
+++ b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/DbPlatformInfo.java
@@ -33,27 +33,27 @@
* and native type mappings.
*/
public class DbPlatformInfo {
-
+
/** The Log to which logging calls will be made. */
private final Log log = LogFactory.getLog(DbPlatformInfo.class);
-
+
private boolean scriptModeOn = false;
-
- private boolean sqlCommentsOn = false;
-
+
+ private boolean sqlCommentsOn = false;
+
private boolean dateOverridesToTimestamp = false;
-
+
private String identifierQuoteString = "\"";
/** Whether delimited identifiers are used or not. */
private boolean delimitedIdentifierModeOn = false;
-
+
private boolean emptyStringNulled = false;
-
+
private boolean blankCharColumnSpacePadded = false;
-
+
private boolean nonBlankCharColumnSpacePadded = false;
-
+
/**
* Whether the database requires the explicit stating of NULL as the default
* value.
@@ -79,10 +79,10 @@ public class DbPlatformInfo {
* statement.
*/
private boolean foreignKeysEmbedded = false;
-
+
/**
- * Determines whether foreign keys of a table read from a live database
- * are alphabetically sorted.
+ * Determines whether foreign keys of a table read from a live database are
+ * alphabetically sorted.
*/
private boolean foreignKeysSorted = false;
@@ -204,9 +204,9 @@ public class DbPlatformInfo {
/** The text separating individual sql commands. */
private String sqlCommandDelimiter = ";";
-
+
private boolean requiresAutoCommitFalseToSetFetchSize = false;
-
+
private boolean needsToSelectLobData;
/** Contains non-default mappings from jdbc to native types. */
@@ -332,11 +332,11 @@ public boolean isPrimaryKeyEmbedded() {
public void setPrimaryKeyEmbedded(boolean primaryKeyEmbedded) {
this.primaryKeyEmbedded = primaryKeyEmbedded;
}
-
+
public boolean isForeignKeysSorted() {
return foreignKeysSorted;
}
-
+
public void setForeignKeysSorted(boolean foreignKeySorted) {
this.foreignKeysSorted = foreignKeySorted;
}
@@ -965,8 +965,8 @@ public void addNativeTypeMapping(String jdbcTypeName, String nativeType) {
}
} catch (Exception ex) {
// ignore -> won't be defined
- log.log(LogLevel.WARN, ex,
- "Cannot add native type mapping for undefined jdbc type %s", jdbcTypeName);
+ log.log(LogLevel.WARN, ex, "Cannot add native type mapping for undefined jdbc type %s",
+ jdbcTypeName);
}
}
@@ -997,8 +997,7 @@ public void addNativeTypeMapping(String jdbcTypeName, String nativeType,
}
} catch (Exception ex) {
// ignore -> won't be defined
- log.log(
- LogLevel.WARN,
+ log.log(LogLevel.WARN,
ex,
"Cannot add native type mapping for undefined jdbc type %s , target jdbc type %s",
jdbcTypeName, targetJdbcTypeName);
@@ -1144,31 +1143,31 @@ public void setHasPrecisionAndScale(int sqlTypeCode, boolean hasPrecisionAndScal
typesWithPrecisionAndScale.remove(new Integer(sqlTypeCode));
}
}
-
+
public void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn) {
this.delimitedIdentifierModeOn = delimitedIdentifierModeOn;
}
-
+
public boolean isDelimitedIdentifierModeOn() {
return delimitedIdentifierModeOn;
- }
-
+ }
+
public boolean isDateOverridesToTimestamp() {
return dateOverridesToTimestamp;
}
-
+
public void setDateOverridesToTimestamp(boolean dateOverridesToTimestamp) {
this.dateOverridesToTimestamp = dateOverridesToTimestamp;
}
-
+
public String getIdentifierQuoteString() {
return identifierQuoteString;
}
-
+
public void setIdentifierQuoteString(String identifierQuoteString) {
this.identifierQuoteString = identifierQuoteString;
}
-
+
public void setBlankCharColumnSpacePadded(boolean blankCharColumnSpacePadded) {
this.blankCharColumnSpacePadded = blankCharColumnSpacePadded;
}
@@ -1184,7 +1183,7 @@ public void setEmptyStringNulled(boolean emptyStringNulled) {
public boolean isEmptyStringNulled() {
return emptyStringNulled;
}
-
+
public void setNonBlankCharColumnSpacePadded(boolean nonBlankCharColumnSpacePadded) {
this.nonBlankCharColumnSpacePadded = nonBlankCharColumnSpacePadded;
}
@@ -1193,11 +1192,10 @@ public boolean isNonBlankCharColumnSpacePadded() {
return nonBlankCharColumnSpacePadded;
}
-
public boolean isSqlCommentsOn() {
return sqlCommentsOn;
}
-
+
public void setSqlCommentsOn(boolean sqlCommentsOn) {
this.sqlCommentsOn = sqlCommentsOn;
}
@@ -1205,24 +1203,24 @@ public void setSqlCommentsOn(boolean sqlCommentsOn) {
public void setScriptModeOn(boolean scriptModeOn) {
this.scriptModeOn = scriptModeOn;
}
-
+
public boolean isScriptModeOn() {
return scriptModeOn;
}
-
+
public void setRequiresAutoCommitFalseToSetFetchSize(
boolean requiresAutoCommitFalseToSetFetchSize) {
this.requiresAutoCommitFalseToSetFetchSize = requiresAutoCommitFalseToSetFetchSize;
}
-
+
public boolean isRequiresAutoCommitFalseToSetFetchSize() {
return requiresAutoCommitFalseToSetFetchSize;
}
-
+
public void setNeedsToSelectLobData(boolean needsToSelectLobData) {
this.needsToSelectLobData = needsToSelectLobData;
}
-
+
public boolean isNeedsToSelectLobData() {
return needsToSelectLobData;
}
diff --git a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/IDbPlatform.java b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/IDbPlatform.java
index 77ce17d792..ec21b52d59 100644
--- a/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/IDbPlatform.java
+++ b/future/symmetric3-core/src/main/java/org/jumpmind/symmetric/core/db/IDbPlatform.java
@@ -9,38 +9,39 @@
import org.jumpmind.symmetric.core.model.Table;
import org.jumpmind.symmetric.core.sql.ISqlConnection;
-public interface IDbPlatform {
-
+public interface IDbPlatform {
+
public DbPlatformInfo getPlatformInfo();
-
+
public Parameters getParameters();
-
+
public String getAlterScriptFor(Table... tables);
-
+
public void alter(boolean failOnError, Table... tables);
-
+
public Database findDatabase(String catalogName, String schemaName);
-
+
public Table findTable(String tableName);
- public Table findTable(String catalogName, String schemaName, String tableName, boolean useCached);
+ public Table findTable(String catalogName, String schemaName, String tableName,
+ boolean useCached);
public List