summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.foundation/src/main/java/net/wotonomy
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-07-05 12:43:13 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-07-05 12:43:13 -0400
commit6d46c473d41c6c47e6b8bd8c676d925e544bd378 (patch)
tree796d51bfff52f8f3fa383b2d26847b7c8160677b /projects/net.wotonomy.foundation/src/main/java/net/wotonomy
parent02bc52037e9ccccca672d6156d9c325c74fe28b3 (diff)
More cleanup
Diffstat (limited to 'projects/net.wotonomy.foundation/src/main/java/net/wotonomy')
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSCoding.java35
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java14
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSMutableRange.java1
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java9
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNumberFormatter.java2
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSPropertyListSerialization.java14
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSelector.java2
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimeZone.java23
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimestamp.java15
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimestampFormatter.java2
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/Introspector.java8
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/NetworkClassLoader.java25
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/PropertyListParser.java12
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/URLResourceReader.java5
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/ValueConverter.java78
15 files changed, 162 insertions, 83 deletions
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSCoding.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSCoding.java
index c578dbc..330e682 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSCoding.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSCoding.java
@@ -39,11 +39,13 @@ public interface NSCoding {
public static class _BigDecimalSupport extends _BigIntegerSupport {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** Not yet implemented */
+ @Override
public Object decodeObject(NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -58,11 +60,13 @@ public interface NSCoding {
public static class _BigIntegerSupport extends Support {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** Not yet implemented */
+ @Override
public Object decodeObject(NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -87,6 +91,7 @@ public interface NSCoding {
public static class _DoubleSupport extends _NumberSupport {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -101,6 +106,7 @@ public interface NSCoding {
public static class _FloatSupport extends _NumberSupport {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -115,6 +121,7 @@ public interface NSCoding {
public static class _LongSupport extends _NumberSupport {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -129,6 +136,7 @@ public interface NSCoding {
public static class _IntegerSupport extends _NumberSupport {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -143,6 +151,7 @@ public interface NSCoding {
public static class _ShortSupport extends _NumberSupport {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -157,6 +166,7 @@ public interface NSCoding {
public static class _ByteSupport extends _NumberSupport {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -171,16 +181,19 @@ public interface NSCoding {
public static class _NumberSupport extends Support {
/** Not yet implemented */
- public Class classForCoder(Object obj) {
+ @Override
+ public Class<?> classForCoder(Object obj) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** Not yet implemented */
+ @Override
public Object decodeObject(NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -195,11 +208,13 @@ public interface NSCoding {
public static class _CharacterSupport extends Support {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** Not yet implemented */
+ @Override
public Object decodeObject(NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -214,11 +229,13 @@ public interface NSCoding {
public static class _DateSupport extends Support {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** Not yet implemented */
+ @Override
public Object decodeObject(NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -233,11 +250,13 @@ public interface NSCoding {
public static class _StringSupport extends Support {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** Not yet implemented */
+ @Override
public Object decodeObject(NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -252,11 +271,13 @@ public interface NSCoding {
public static class _BooleanSupport extends Support {
/** Not yet implemented */
+ @Override
public void encodeWithCoder(Object obj, NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** Not yet implemented */
+ @Override
public Object decodeObject(NSCoder nscoder) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -270,13 +291,13 @@ public interface NSCoding {
/** Helper class for NSCoding. */
public static abstract class Support {
- private static NSMutableDictionary classSupportMap = new NSMutableDictionary(16);
+ private static NSMutableDictionary<Class<?>, Support> classSupportMap = new NSMutableDictionary<>(16);
- public static Support supportForClass(Class aClass) {
+ public static Support supportForClass(Class<?> aClass) {
Support support = null;
- Class realClass = aClass;
+ Class<?> realClass = aClass;
while (support == null && realClass != null) {
- support = (Support) classSupportMap.objectForKey(realClass);
+ support = classSupportMap.objectForKey(realClass);
if (support == null)
realClass.getSuperclass();
// Cache if we had to look to a superclass.
@@ -286,7 +307,7 @@ public interface NSCoding {
return support;
}
- public static void setSupportForClass(Support support, Class class1) {
+ public static void setSupportForClass(Support support, Class<?> class1) {
classSupportMap.setObjectForKey(support, class1);
}
@@ -294,7 +315,7 @@ public interface NSCoding {
* Return the class of a given object. It boggles the mind as to why this is not
* a static, but in the original, it's not. &lt;sigh&gt;
*/
- public Class classForCoder(Object obj) {
+ public Class<?> classForCoder(Object obj) {
return obj.getClass();
}
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java
index 72c9fc8..a93fff9 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java
@@ -49,13 +49,23 @@ public interface NSKeyValueCodingAdditions extends NSKeyValueCoding {
* Returns a Map of the specified keys to their values, each of which might be
* obtained by calling valueForKey.
*/
- NSDictionary<String, Object> valuesForKeys(List<String> aKeyList);
+ default NSDictionary<String, Object> valuesForKeys(List<String> aKeyList) {
+ NSDictionary<String, Object> ret = new NSMutableDictionary<>();
+
+ for (String key : aKeyList) {
+ ret.put(key, valueForKey(key));
+ }
+
+ return ret;
+ }
/**
* Takes the keys from the specified map as properties and applies the
* corresponding values, each of which might be set by calling takeValueForKey.
*/
- void takeValuesFromDictionary(Map<String, Object> aMap);
+ default void takeValuesFromDictionary(Map<String, Object> aMap) {
+ aMap.forEach((key, val) -> takeValueForKey(val, key));
+ }
/**
* Static utility methods that call the appropriate method if the object
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSMutableRange.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSMutableRange.java
index 2bfb692..d529f23 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSMutableRange.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSMutableRange.java
@@ -85,6 +85,7 @@ public class NSMutableRange extends NSRange {
/**
* Returns a copy of this range.
*/
+ @Override
public Object clone() {
return new NSMutableRange(location(), length());
}
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java
index 4fbd8af..90d09a4 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java
@@ -33,7 +33,7 @@ public class NSNotification {
protected String name;
protected Object object;
- protected Map userInfo;
+ protected Map<? extends Object, ? extends Object> userInfo;
// for debugging only
private Throwable stackTrace;
@@ -57,7 +57,7 @@ public class NSNotification {
* Constructor specifying name, object, and a Map containing application
* specific information.
*/
- public NSNotification(String aName, Object anObject, Map aUserInfo) {
+ public NSNotification(String aName, Object anObject, Map<? extends Object, ? extends Object> aUserInfo) {
name = aName;
object = anObject;
if (showStack)
@@ -84,7 +84,7 @@ public class NSNotification {
* specific information relating to this notification, or null if no such data
* exists.
*/
- public NSDictionary userInfo() {
+ public NSDictionary<? extends Object, ? extends Object> userInfo() {
if (userInfo == null)
return null;
return new NSDictionary<>(userInfo);
@@ -95,7 +95,7 @@ public class NSNotification {
* notification, or null if no such data exists. Note: this method is not in the
* spec.
*/
- public Map userInfoMap() {
+ public Map<? extends Object, ? extends Object> userInfoMap() {
return userInfo;
}
@@ -111,6 +111,7 @@ public class NSNotification {
/**
* Returns a human-readable string representation.
*/
+ @Override
public String toString() {
return "[ " + name() + " : " + object() + " : " + userInfo() + " ]";
}
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNumberFormatter.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNumberFormatter.java
index 7e6386d..11e266c 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNumberFormatter.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNumberFormatter.java
@@ -33,6 +33,8 @@ import java.text.DecimalFormat;
*/
public class NSNumberFormatter extends DecimalFormat {
+ private static final long serialVersionUID = 7972222004050211308L;
+
public NSNumberFormatter() {
super();
}
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSPropertyListSerialization.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSPropertyListSerialization.java
index b52dc2d..b819662 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSPropertyListSerialization.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSPropertyListSerialization.java
@@ -1,6 +1,11 @@
package net.wotonomy.foundation;
+/**
+ * Class for serializing/unserializing property lists in the .plist format
+ *
+ *
+ */
public class NSPropertyListSerialization {
public static final int PLIST_ARRAY = 0;
@@ -21,11 +26,11 @@ public class NSPropertyListSerialization {
*
* @s The string representation of a NSArray object.
*/
- public static NSArray arrayForString(String s) {
+ public static NSArray<Object> arrayForString(String s) {
s = s.trim();
if (!(s.charAt(0) == TOKEN_BEGIN[PLIST_ARRAY] && s.charAt(s.length() - 1) == TOKEN_END[PLIST_ARRAY]))
return null;
- NSMutableArray arr = new NSMutableArray();
+ NSMutableArray<Object> arr = new NSMutableArray<>();
int pos = 1;
int valbegin = -1;
while (pos < s.length()) {
@@ -88,13 +93,12 @@ public class NSPropertyListSerialization {
*
* @s The string representation of a NSDictionary.
*/
- public static NSDictionary dictionaryForString(String s) {
+ public static NSDictionary<Object, Object> dictionaryForString(String s) {
s = s.trim();
if (!(s.charAt(0) == TOKEN_BEGIN[PLIST_DICTIONARY] && s.charAt(s.length() - 1) == TOKEN_END[PLIST_DICTIONARY]))
return null;
- NSMutableDictionary d = new NSMutableDictionary();
+ NSMutableDictionary<Object, Object> d = new NSMutableDictionary<>();
int pos = 1;
- boolean parsing = true;
Object key = null;
int valbegin = -1;
while (pos < s.length()) {
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSelector.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSelector.java
index 8f5969a..caaea25 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSelector.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSelector.java
@@ -33,6 +33,8 @@ import net.wotonomy.foundation.internal.PropertyComparator;
* @version $Revision: 892 $
*/
public class NSSelector implements Comparator, Serializable {
+ private static final long serialVersionUID = 2531682514697198972L;
+
protected NSMutableDictionary methodMap; // map of classes to methods
protected String methodName;
protected Class[] parameterTypes;
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimeZone.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimeZone.java
index 7c7b4da..411bc3b 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimeZone.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimeZone.java
@@ -28,8 +28,7 @@ import java.util.Locale;
import java.util.TimeZone;
/**
- * A channel to the database, representing a communication stream within a
- * context of an adaptor.
+ * A time zone for an NSTimeStamp
*
* @author cgruber@israfil.net
* @author $Author: cgruber $
@@ -37,11 +36,14 @@ import java.util.TimeZone;
*/
public class NSTimeZone extends TimeZone implements Cloneable, Serializable, NSCoding {
- protected static class __NSTZPeriodComparator extends NSComparator {
+ private static final long serialVersionUID = -2771392108329800748L;
+
+ protected static class __NSTZPeriodComparator extends NSComparator<__NSTZPeriod> {
protected boolean _ascending = false;
- public int compare(Object obj, Object obj1) throws NSComparator.ComparisonException {
+ @Override
+ public int compare(__NSTZPeriod obj, __NSTZPeriod obj1) throws NSComparator.ComparisonException {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -101,6 +103,7 @@ public class NSTimeZone extends TimeZone implements Cloneable, Serializable, NSC
return getClass();
}
+ @Override
public Object clone() {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -145,10 +148,12 @@ public class NSTimeZone extends TimeZone implements Cloneable, Serializable, NSC
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public void setID(String s) {
throw new IllegalStateException(getClass().getName() + " is immutable.");
}
+ @Override
public void setRawOffset(int i) {
throw new IllegalStateException(getClass().getName() + " is immutable.");
}
@@ -185,34 +190,42 @@ public class NSTimeZone extends TimeZone implements Cloneable, Serializable, NSC
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public boolean equals(Object obj) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public String getDisplayName(boolean flag, int i, Locale locale) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public String getID() {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public int getOffset(int i, int j, int k, int l, int i1, int j1) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public int getRawOffset() {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public synchronized int hashCode() {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public boolean hasSameRules(TimeZone timezone) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public boolean inDaylightTime(Date date) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -241,10 +254,12 @@ public class NSTimeZone extends TimeZone implements Cloneable, Serializable, NSC
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public String toString() {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public boolean useDaylightTime() {
throw new UnsupportedOperationException("Not Yet Implemented");
}
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimestamp.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimestamp.java
index 03590f2..57c728d 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimestamp.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimestamp.java
@@ -36,10 +36,13 @@ import java.util.TimeZone;
public class NSTimestamp extends Timestamp implements NSCoding {
+ private static final long serialVersionUID = 8450053854095874663L;
+
public static class IntRef {
public int value = 0;
+ @Override
public String toString() {
return getClass().getName() + " < value = " + value + " >";
}
@@ -71,7 +74,7 @@ public class NSTimestamp extends Timestamp implements NSCoding {
return l * 1000L;
}
- public Class classForCoder() {
+ public Class<?> classForCoder() {
return getClass();
}
@@ -205,6 +208,7 @@ public class NSTimestamp extends Timestamp implements NSCoding {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public String toString() {
throw new UnsupportedOperationException("Not Yet Implemented");
}
@@ -217,44 +221,53 @@ public class NSTimestamp extends Timestamp implements NSCoding {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public void setNanos(int i) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** @deprecated This method deprecated in parent java.util.Date */
+ @Override
public void setDate(int i) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** @deprecated This method deprecated in parent java.util.Date */
+ @Override
public void setHours(int i) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** @deprecated This method deprecated in parent java.util.Date */
+ @Override
public void setMinutes(int i) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** @deprecated This method deprecated in parent java.util.Date */
+ @Override
public void setMonth(int i) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** @deprecated This method deprecated in parent java.util.Date */
+ @Override
public void setSeconds(int i) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public void setTime(long l) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
+ @Override
public long getTime() {
throw new UnsupportedOperationException("Not Yet Implemented");
}
/** @deprecated This method deprecated in parent java.util.Date */
+ @Override
public void setYear(int i) {
throw new UnsupportedOperationException("Not Yet Implemented");
}
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimestampFormatter.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimestampFormatter.java
index c8fbc44..3abac66 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimestampFormatter.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSTimestampFormatter.java
@@ -34,6 +34,8 @@ import java.text.SimpleDateFormat;
*/
public class NSTimestampFormatter extends SimpleDateFormat {
+ private static final long serialVersionUID = -4480420834738564573L;
+
public NSTimestampFormatter() {
super();
}
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/Introspector.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/Introspector.java
index 09687e2..870ff83 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/Introspector.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/Introspector.java
@@ -35,7 +35,7 @@ import java.util.Set;
* <br>
*
* Of particular note are the get() and set() methods, which will attempt to get
- * and set artibrary values on arbitrary objects to the best of its ability,
+ * and set arbitrary values on arbitrary objects to the best of its ability,
* converting values as appropriate. Properties of the form
* "property.nestedproperty.anotherproperty" are supported to get and set values
* on property values directly.<br>
@@ -72,10 +72,10 @@ public class Introspector {
// wildcard value - using this class to represent a "wildcard" generic class.
// we have to do this when matching methods by parameter types and a
// null value is passed in - can't tell what class the null should be.
- public static Class WILD = Introspector.class;
+ public static Class<?> WILD = Introspector.class;
// empty class array - prevents having to create one every time
- private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+ private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class[0];
// use OGNL for property access
private static boolean useOGNL;
@@ -99,7 +99,7 @@ public class Introspector {
* parameters.
* @return The appropriate method for the class, or null if not found.
*/
- static public Method getPropertyReadMethod(Class objectClass, String aProperty, Class[] paramTypes) {
+ static public Method getPropertyReadMethod(Class<?> objectClass, String aProperty, Class<?>[] paramTypes) {
Method result = null;
result = getMethodFromClass(objectClass, aProperty, paramTypes, true);
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/NetworkClassLoader.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/NetworkClassLoader.java
index 7761876..a36c616 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/NetworkClassLoader.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/NetworkClassLoader.java
@@ -79,8 +79,8 @@ import java.util.Hashtable;
*/
public class NetworkClassLoader extends ClassLoader {
private ClassLoader parent = null; // parent classloader
- private Hashtable classCache = new Hashtable();
- private Hashtable urlset = new Hashtable();
+ private Hashtable<String, Class<?>> classCache = new Hashtable<>();
+ private Hashtable<URL, URLResourceReader> urlset = new Hashtable<>();
/**
* Creates a new instance of the class loader.
@@ -132,14 +132,15 @@ public class NetworkClassLoader extends ClassLoader {
/**
* @return An enumeration of URLs where this class loader looks for classes.
*/
- public Enumeration getURLs() {
+ public Enumeration<URL> getURLs() {
return urlset.keys();
}
/**
* Call this to bypass the implementation of loadClass.
*/
- public Class findClass(String name) {
+ @Override
+ public Class<?> findClass(String name) {
byte[] b = loadClassData(name);
if (b == null)
return null;
@@ -158,7 +159,7 @@ public class NetworkClassLoader extends ClassLoader {
protected byte[] loadResource(String resource) {
byte[] barray = null;
- for (Enumeration e = urlset.keys(); e.hasMoreElements();) {
+ for (Enumeration<URL> e = urlset.keys(); e.hasMoreElements();) {
URL url = (URL) e.nextElement();
try {
@@ -182,11 +183,12 @@ public class NetworkClassLoader extends ClassLoader {
* Overridden to search for a resource and return a "jar"-style URL or normal
* "file" URL as necessary.
*/
+ @Override
protected URL findResource(String name) { // System.out.println( "findResource: " + name );
URL url;
byte[] barray = null;
- for (Enumeration e = urlset.keys(); e.hasMoreElements();) {
+ for (Enumeration<URL> e = urlset.keys(); e.hasMoreElements();) {
url = (URL) e.nextElement();
try {
barray = loadResource(url, name); // loads fully: wasteful
@@ -216,6 +218,7 @@ public class NetworkClassLoader extends ClassLoader {
* @return The resource as the input stream if such a resource exists, otherwise
* returns null.
*/
+ @Override
public InputStream getResourceAsStream(String name) {
// System.out.println( "getResourceAsStream: " + name );
InputStream istream = null;
@@ -257,12 +260,13 @@ public class NetworkClassLoader extends ClassLoader {
* @param The class data bytes.
* @return The class object.
*/
- protected Class defineClass(String classname, byte[] classdata) {
+ protected Class<?> defineClass(String classname, byte[] classdata) {
return defineClass(classname, classdata, 0, classdata.length);
}
- public synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
- Class c = null;
+ @Override
+ public synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ Class<?> c = null;
// Algorithm: (Please do not change the order; unless you
// have a good reason to do so).
@@ -293,7 +297,7 @@ public class NetworkClassLoader extends ClassLoader {
}
// Lets see if the class is in the cache..
- c = (Class) classCache.get(name);
+ c = (Class<?>) classCache.get(name);
if (c != null)
return c;
@@ -328,6 +332,7 @@ public class NetworkClassLoader extends ClassLoader {
* This method resets this ClassLoader's state and resets the references for
* garbage collection.
*/
+ @Override
protected void finalize() throws Throwable {
// Cleanup real well. Otherwise, this can be
// a major source of memory leaks...
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/PropertyListParser.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/PropertyListParser.java
index 3698325..c44a892 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/PropertyListParser.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/PropertyListParser.java
@@ -26,7 +26,7 @@ import java.io.*;
* return the top-level object represented by the plist.
* <p>
*
- * A property list is a heirarchical data structure containing only Maps, Lists,
+ * A property list is a hierarchical data structure containing only Maps, Lists,
* and Strings -- nothing else. In other words, a property list is either a Map,
* List, or String instance, with the restrictions that the collections may only
* contain Map, List, or String instances.
@@ -79,7 +79,7 @@ import java.io.*;
* are thrown with the line number and column of the problem.
* <p>
*
- * Currenty, HashMaps and ArrayLists are the actual Map and List classes used
+ * Currently, HashMaps and ArrayLists are the actual Map and List classes used
* when creating the property list.
* <p>
*
@@ -456,8 +456,8 @@ public class PropertyListParser {
return stringBuffer.toString();
}
- private List readList() {
- List newList = new ArrayList();
+ private List<Object> readList() {
+ List<Object> newList = new ArrayList<>();
currIndex++; // skip over '('
skipCommentWhitespace();
@@ -488,8 +488,8 @@ public class PropertyListParser {
return newList;
}
- private Map readMap() {
- HashMap newMap = new HashMap();
+ private Map<Object, Object> readMap() {
+ HashMap<Object, Object> newMap = new HashMap<>();
currIndex++; // skip over open brace
skipCommentWhitespace();
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/URLResourceReader.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/URLResourceReader.java
index 8694564..92862f6 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/URLResourceReader.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/URLResourceReader.java
@@ -72,7 +72,7 @@ import java.util.zip.ZipInputStream;
* @author Harish Prabandham
*/
public class URLResourceReader {
- private Hashtable resourceCache = new Hashtable();
+ private Hashtable<String, Object> resourceCache = new Hashtable<>();
private boolean iszip = true;
private URL url = null;
private boolean cache = true;
@@ -147,7 +147,7 @@ public class URLResourceReader {
/**
* Returns an Enumeration of all "known" resource names.
*/
- public Enumeration getResourceNames() {
+ public Enumeration<String> getResourceNames() {
return resourceCache.keys();
}
@@ -188,6 +188,7 @@ public class URLResourceReader {
resourceCache = null;
}
+ @Override
public String toString() {
return url.toString();
}
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/ValueConverter.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/ValueConverter.java
index 3d995e5..551e4ce 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/ValueConverter.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/internal/ValueConverter.java
@@ -177,7 +177,7 @@ public class ValueConverter {
anObject = preprocess(anObject);
if (anObject instanceof Number) {
- return new Short(((Number) anObject).shortValue());
+ return Short.valueOf(((Number) anObject).shortValue());
}
try {
@@ -194,16 +194,16 @@ public class ValueConverter {
static public Integer getInteger(Object anObject) {
if (anObject == null)
- return new Integer(0);
+ return Integer.valueOf(0);
if ("".equals(anObject))
- return new Integer(0);
+ return Integer.valueOf(0);
if (anObject instanceof Integer)
return (Integer) anObject;
anObject = preprocess(anObject);
if (anObject instanceof Number) {
- return new Integer(((Number) anObject).intValue());
+ return Integer.valueOf(((Number) anObject).intValue());
}
try {
@@ -220,16 +220,16 @@ public class ValueConverter {
static public Long getLong(Object anObject) {
if (anObject == null)
- return new Long(0);
+ return Long.valueOf(0);
if ("".equals(anObject))
- return new Long(0);
+ return Long.valueOf(0);
if (anObject instanceof Long)
return (Long) anObject;
anObject = preprocess(anObject);
if (anObject instanceof Number) {
- return new Long(((Number) anObject).longValue());
+ return Long.valueOf(((Number) anObject).longValue());
}
try {
@@ -246,16 +246,16 @@ public class ValueConverter {
static public Double getDouble(Object anObject) {
if (anObject == null)
- return new Double(0.0);
+ return Double.valueOf(0.0);
if ("".equals(anObject))
- return new Double(0);
+ return Double.valueOf(0);
if (anObject instanceof Double)
return (Double) anObject;
anObject = preprocess(anObject);
if (anObject instanceof Number) {
- return new Double(((Number) anObject).doubleValue());
+ return Double.valueOf(((Number) anObject).doubleValue());
}
try {
@@ -272,16 +272,16 @@ public class ValueConverter {
static public Float getFloat(Object anObject) {
if (anObject == null)
- return new Float(0.0);
+ return Float.valueOf(0.0f);
if ("".equals(anObject))
- return new Float(0.0);
+ return Float.valueOf(0.0f);
if (anObject instanceof Float)
return (Float) anObject;
anObject = preprocess(anObject);
if (anObject instanceof Number) {
- return new Float(((Number) anObject).floatValue());
+ return Float.valueOf(((Number) anObject).floatValue());
}
try {
@@ -298,18 +298,18 @@ public class ValueConverter {
static public Character getCharacter(Object anObject) {
if (anObject == null)
- return new Character((char) 0);
+ return Character.valueOf((char) 0);
if (anObject instanceof Character)
return (Character) anObject;
anObject = preprocess(anObject);
if (anObject instanceof Number) {
- return new Character((char) ((Number) anObject).byteValue());
+ return Character.valueOf((char) ((Number) anObject).byteValue());
}
try {
- return new Character(anObject.toString().charAt(0));
+ return Character.valueOf(anObject.toString().charAt(0));
} catch (Exception exc) {
return null;
}
@@ -322,16 +322,16 @@ public class ValueConverter {
static public Byte getByte(Object anObject) {
if (anObject == null)
- return new Byte(Byte.MIN_VALUE);
+ return Byte.valueOf(Byte.MIN_VALUE);
if ("".equals(anObject))
- return new Byte(Byte.MIN_VALUE);
+ return Byte.valueOf(Byte.MIN_VALUE);
if (anObject instanceof Byte)
return (Byte) anObject;
anObject = preprocess(anObject);
if (anObject instanceof Number) {
- return new Byte(((Number) anObject).byteValue());
+ return Byte.valueOf(((Number) anObject).byteValue());
}
try {
@@ -364,14 +364,14 @@ public class ValueConverter {
return (Boolean) anObject;
}
if (anObject instanceof Number) {
- return new Boolean(((Number) anObject).doubleValue() == 0.0);
+ return Boolean.valueOf(((Number) anObject).doubleValue() == 0.0);
}
if (anObject instanceof String) {
if (anObject.toString().toLowerCase().equals("yes")) {
return Boolean.TRUE;
}
- return new Boolean((String) anObject);
+ return Boolean.valueOf((String) anObject);
}
return null;
@@ -396,24 +396,25 @@ public class ValueConverter {
* in any other way, resorts to creating a new collection of the specified type
* containing the specified object.
*/
- static public Collection getCollection(Object anObject, Class aCollectionClass) {
+ @SuppressWarnings("unchecked")
+ static public Collection<?> getCollection(Object anObject, Class<?> aCollectionClass) {
if (anObject == null)
return null;
if (aCollectionClass.isAssignableFrom(anObject.getClass())) {
- return (Collection) anObject;
+ return (Collection<?>) anObject;
}
- Collection converted = null;
+ Collection<Object> converted = null;
// convert to collection class
if (anObject instanceof Collection) {
- converted = (Collection) anObject;
+ converted = (Collection<Object>) anObject;
} else
// try to convert an array
if (anObject.getClass().isArray()) {
try {
int length = Array.getLength(anObject);
- converted = new LinkedList();
+ converted = new LinkedList<>();
for (int i = 0; i < length; i++) {
converted.add(Array.get(anObject, i));
}
@@ -423,25 +424,25 @@ public class ValueConverter {
} else
// convert map values to collection and pass through
if (anObject instanceof Map) {
- converted = ((Map) anObject).values();
+ converted = ((Map<?, Object>) anObject).values();
}
// fall back on list containing the object
if (converted == null) {
- converted = new LinkedList();
+ converted = new LinkedList<>();
converted.add(anObject);
}
- Collection result = null;
+ Collection<Object> result = null;
if (converted != null) {
try {
// collections required to have the copy constructor.
- Constructor ctor = aCollectionClass.getConstructor(new Class[] { Collection.class });
- result = (Collection) ctor.newInstance(new Object[] { converted });
+ Constructor<?> ctor = aCollectionClass.getConstructor(new Class[] { Collection.class });
+ result = (Collection<Object>) ctor.newInstance(new Object[] { converted });
} catch (Exception exc) {
try {
- result = new LinkedList();
+ result = new LinkedList<>();
result.addAll(converted);
} catch (Exception exc2) {
// all attempts failed
@@ -456,7 +457,8 @@ public class ValueConverter {
/**
* Convert the object to the specified array type.
*/
- static public Object getArray(Object anObject, Class anArrayClass) {
+ @SuppressWarnings("unchecked")
+ static public Object getArray(Object anObject, Class<?> anArrayClass) {
if (anObject == null)
return null;
@@ -475,14 +477,14 @@ public class ValueConverter {
}
// convert map values to collection and pass through
if (anObject instanceof Map) {
- anObject = ((Map) anObject).values();
+ anObject = ((Map<?, Object>) anObject).values();
}
// try to convert a collection
if (anObject instanceof Collection) {
try {
- int length = ((Collection) anObject).size();
+ int length = ((Collection<?>) anObject).size();
Object result = Array.newInstance(anArrayClass.getComponentType(), length);
- Iterator it = ((Collection) anObject).iterator();
+ Iterator<?> it = ((Collection<?>) anObject).iterator();
for (int i = 0; i < length; i++) {
Array.set(result, i, it.next());
}
@@ -545,12 +547,12 @@ public class ValueConverter {
public static Object invert(Object anObject) {
if (anObject == null)
return null;
- Class aClass = anObject.getClass();
+ Class<?> aClass = anObject.getClass();
if (((anObject instanceof Number) && !(anObject instanceof Byte) && !(anObject instanceof Character))
|| (aClass == short.class) || (aClass == int.class) || (aClass == long.class) || (aClass == float.class)
|| (aClass == double.class)) {
- return convertObjectToClass(new Double(getDoubleValue(anObject) * -1), aClass);
+ return convertObjectToClass(Double.valueOf(getDoubleValue(anObject) * -1), aClass);
}
Boolean converted = getBoolean(anObject);