Skip to content

Commit 071a59a

Browse files
committed
cleanup javadocs and dead code
1 parent 9490c8b commit 071a59a

10 files changed

Lines changed: 260 additions & 630 deletions

File tree

src/main/java/org/teachingextensions/approvals/lite/util/ClassUtils.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,7 @@
66
import java.util.List;
77

88
public class ClassUtils {
9-
/**
10-
* ********************************************************************
11-
*/
12-
public static String getClassName(Class<?> clazz) {
13-
String name = clazz.getName();
14-
int divider = name.lastIndexOf(".");
15-
return name.substring(divider + 1);
16-
}
179

18-
/**
19-
* ********************************************************************
20-
*/
2110
public static Class<?> getWrapperClass(Class<?> primitiveType) {
2211
if (boolean.class.equals(primitiveType)) {
2312
return Boolean.class;
@@ -39,10 +28,7 @@ public static Class<?> getWrapperClass(Class<?> primitiveType) {
3928
return primitiveType;
4029
}
4130
}
42-
/************************************************************************/
43-
/**
44-
* ********************************************************************
45-
*/
31+
4632
public static boolean hasMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
4733
try {
4834
return clazz.getMethod(methodName, parameterTypes) != null;
Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package org.teachingextensions.approvals.lite.util;
22

33
import java.util.Calendar;
4-
import java.util.Date;
54

65
public class DateDifference {
7-
public static final String STANDARD_TIME_TEXT[] = {"Year", "Years", "Month", "Months", "Week", "Weeks", "Day", "Days", "Hour", "Hours", "Min", "Mins", "Sec", "Secs", "Milli", "Millis"};
86
public static final String MILLISECONDS = "milliseconds";
97
public static final String SECONDS = "seconds";
108
public static final String MINUTES = "minutes";
@@ -17,38 +15,17 @@ public class DateDifference {
1715
// assumes a 30 day month
1816
private static int TIME_SCALE[] = {Calendar.YEAR, Calendar.MONTH, Calendar.WEEK_OF_YEAR, Calendar.DATE, Calendar.HOUR, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND};
1917
private static long DIVIDERS[] = {1000 * 60 * 60 * 24 * 365L, 1000 * 60 * 60 * 24 * 30L, 1000 * 60 * 60 * 24 * 7L, 1000 * 60 * 60 * 24L, 1000 * 60 * 60L, 1000 * 60L, 1000L, 1L};
20-
/**
21-
* ********************************************************************
22-
*/
18+
2319
private long milli;
2420

25-
/**
26-
* ********************************************************************
27-
*/
2821
public DateDifference(long timeDifference) {
2922
this.milli = timeDifference;
3023
}
3124

32-
/**
33-
* ********************************************************************
34-
*/
35-
public DateDifference(Date date1, Date date2) {
36-
milli = date1.getTime() - date2.getTime();
37-
if (milli < 0) {
38-
milli = milli * -1;
39-
}
40-
}
41-
42-
/**
43-
* ********************************************************************
44-
*/
4525
public static long getAbsoluteDifference(int unit, long time) {
4626
return time / DIVIDERS[getTimeScaleIndex(unit)];
4727
}
4828

49-
/**
50-
* ********************************************************************
51-
*/
5229
public static long getRemainingDifference(int wantedUnit, int roundTo, long time) {
5330
int wantedIndex = getTimeScaleIndex(wantedUnit);
5431
int roundToIndex = getTimeScaleIndex(roundTo);
@@ -57,7 +34,7 @@ public static long getRemainingDifference(int wantedUnit, int roundTo, long time
5734
}
5835
return (time % DIVIDERS[roundToIndex]) / DIVIDERS[wantedIndex];
5936
}
60-
/***********************************************************************/
37+
6138
/**
6239
* @return the index in TIME_SCALE[] of the largest Unit to be > 0
6340
*/
@@ -68,10 +45,11 @@ private int getMaximumTimeUnit() {
6845
}
6946
return i;
7047
}
71-
/***********************************************************************/
48+
7249
/**
7350
* Finds the index for a Calendar.DATE ect.
7451
*
52+
* @param calendarTime the time scale to find
7553
* @return the index in TIME_SCALE[]
7654
*/
7755
public static int getTimeScaleIndex(int calendarTime) {
@@ -82,9 +60,6 @@ public static int getTimeScaleIndex(int calendarTime) {
8260
return i;
8361
}
8462

85-
/**
86-
* *******************************************************************
87-
*/
8863
private static long getStandardRoundedTime(int unitIndex, boolean forceAbsolute, long time) {
8964
if (unitIndex == 0 || forceAbsolute) {
9065
return getAbsoluteDifference(TIME_SCALE[unitIndex], time);
@@ -93,9 +68,6 @@ private static long getStandardRoundedTime(int unitIndex, boolean forceAbsolute,
9368
}
9469
}
9570

96-
/**
97-
* *******************************************************************
98-
*/
9971
public String getTimeText(int amount, int maxUnit, int minUnit, String nowText, String agoText, String units[]) {
10072
if (amount == 0) {
10173
throw new Error("getTimeText() requires amount > 0");
@@ -122,13 +94,4 @@ public String getTimeText(int amount, int maxUnit, int minUnit, String nowText,
12294
}
12395
return timeText;
12496
}
125-
126-
/**
127-
* *******************************************************************
128-
*/
129-
public String getStandardTimeText(int amountShown) {
130-
return getTimeText(amountShown, Calendar.YEAR, Calendar.MILLISECOND, "now", "", STANDARD_TIME_TEXT);
131-
}
132-
/************************************************************************/
133-
/************************************************************************/
13497
}
Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
package org.teachingextensions.approvals.lite.util;
22

3-
import java.sql.Timestamp;
4-
import java.text.ParseException;
5-
import java.text.SimpleDateFormat;
63
import java.util.Calendar;
74
import java.util.Date;
85
import java.util.GregorianCalendar;
96

10-
/**
11-
* A static class of convenience functions for database access
12-
*/
137
public class DateUtils {
148
private static int TIME_SCALE[] = {Calendar.YEAR,
159
Calendar.MONTH,
@@ -20,29 +14,6 @@ public class DateUtils {
2014
Calendar.SECOND,
2115
Calendar.MILLISECOND};
2216

23-
public static boolean isSame(Date firstDate, Date secondDate, int smallestUnits) {
24-
if ((firstDate == null) || (secondDate == null)) {
25-
return (firstDate == secondDate);
26-
}
27-
return isSame(firstDate.getTime(), secondDate.getTime(), smallestUnits);
28-
}
29-
30-
public static boolean isSame(long firstDate, long secondDate, int smallestUnits) {
31-
if (!ArrayUtils.contains(TIME_SCALE, smallestUnits)) {
32-
throw new Error("Invalid Timescale " + smallestUnits);
33-
}
34-
GregorianCalendar first = new GregorianCalendar();
35-
first.setTime(new Date(firstDate));
36-
setSignificantDigit(first, smallestUnits);
37-
GregorianCalendar second = new GregorianCalendar();
38-
second.setTime(new Date(secondDate));
39-
setSignificantDigit(second, smallestUnits);
40-
return (first.getTime().getTime() == second.getTime().getTime());
41-
}
42-
43-
/**
44-
* ********************************************************************
45-
*/
4617
public static Calendar setSignificantDigit(Calendar calendar, int smallestUnits) {
4718
boolean removeOn = false;
4819
for (int i : TIME_SCALE) {
@@ -74,9 +45,6 @@ public static void main(String args[]) {
7445
MySystem.variable("End Of Day", rollToEndOfDay(new Date()).getTime());
7546
}
7647

77-
/**
78-
* ********************************************************************
79-
*/
8048
public static GregorianCalendar rollToEndOfDay(Date date) {
8149
GregorianCalendar gregorianCalendar = new GregorianCalendar();
8250
gregorianCalendar.setTime(date);
@@ -87,40 +55,4 @@ public static GregorianCalendar rollToEndOfDay(Date date) {
8755
return gregorianCalendar;
8856
}
8957

90-
/**
91-
* *******************************************************************
92-
*/
93-
public static Timestamp asTimestamp(Date date) {
94-
return new Timestamp(date.getTime());
95-
}
96-
97-
/**
98-
* ********************************************************************
99-
*/
100-
public static boolean isToday(Date date) {
101-
return DateUtils.isSame(date, new Date(), Calendar.DATE);
102-
}
103-
104-
/**
105-
* ********************************************************************
106-
*/
107-
public static Calendar asCalendar(Date date) {
108-
GregorianCalendar gregorianCalendar = new GregorianCalendar();
109-
gregorianCalendar.setTime(date);
110-
return gregorianCalendar;
111-
}
112-
113-
/************************************************************************/
114-
/**
115-
* @param date "yyyy/MM/dd"
116-
*/
117-
public static Timestamp parse(String date) {
118-
SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy/MM/dd");
119-
try {
120-
return asTimestamp(format.parse(date));
121-
} catch (ParseException e) {
122-
throw ObjectUtils.throwAsError(e);
123-
}
124-
}
125-
/************************************************************************/
12658
}

src/main/java/org/teachingextensions/approvals/lite/util/DualOutputStream.java

Lines changed: 0 additions & 93 deletions
This file was deleted.

src/main/java/org/teachingextensions/approvals/lite/util/Filter.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
package org.teachingextensions.approvals.lite.util;
22

3-
/**
4-
* Listens to the state of a EnabledConditions object
5-
*/
6-
7-
83
public interface Filter<T> {
94
/**
5+
* @param object the item to check
106
* @return true if the object would be extracted by the filter
117
* @throws IllegalArgumentException if the object is not supported by the filter
128
*/

src/main/java/org/teachingextensions/approvals/lite/util/FilterUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class FilterUtils {
1111
* @param fromObjects a collection of objects to filter
1212
* @param filter an optional parameter which indicates whether the item is extracted
1313
* @return a new List containing all elements of the list for which isExtracted() would return true
14+
* @param <T> the kind of items to filter
1415
*/
1516
public static <T> ArrayList<T> retainExtracted(T fromObjects[], Filter filter) throws IllegalArgumentException {
1617
return fromObjects == null ? new ArrayList<T>() : filter(Arrays.asList(fromObjects), filter, true);

0 commit comments

Comments
 (0)