From 02bc52037e9ccccca672d6156d9c325c74fe28b3 Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 1 Jul 2024 17:27:48 -0400 Subject: Update a whole bunch of things Yeah... not a great commit message. t.b.h, I could maybe've split the commit into more parts; but that would be quite a lot off effort and would have a pretty decent chance of at least one of the commits leaving the repository in a non-working state. For the future, will want to try and commit more often so there aren't these mega-commits where it's just "a whole bunch of stuff changed" --- .../java/net/wotonomy/web/ObservableArray.java | 75 ++++++++++++++-------- .../src/main/java/net/wotonomy/web/URI.java | 17 ++--- .../main/java/net/wotonomy/web/WOApplication.java | 49 ++++++++------ .../main/java/net/wotonomy/web/WODirectAction.java | 9 +-- .../wotonomy/web/WODirectActionRequestHandler.java | 1 + .../java/net/wotonomy/web/WODynamicElement.java | 6 ++ .../src/main/java/net/wotonomy/web/WOElement.java | 1 + .../src/main/java/net/wotonomy/web/WOMessage.java | 28 ++++---- .../main/java/net/wotonomy/web/WORepetition.java | 4 ++ .../src/main/java/net/wotonomy/web/WORequest.java | 39 ++++++----- .../java/net/wotonomy/web/WORequestHandler.java | 2 +- .../net/wotonomy/web/WOServletSessionStore.java | 2 +- .../src/main/java/net/wotonomy/web/WOSession.java | 2 + .../java/net/wotonomy/web/xml/XMLRPCDecoder.java | 1 + 14 files changed, 143 insertions(+), 93 deletions(-) (limited to 'projects/net.wotonomy.web/src/main/java') diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/ObservableArray.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/ObservableArray.java index 1c91115..90d234d 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/ObservableArray.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/ObservableArray.java @@ -36,7 +36,8 @@ import net.wotonomy.foundation.NSRange; * probably call each other. However, EOObserverCenter will only register us * once per object. */ -class ObservableArray extends NSMutableArray { +class ObservableArray extends NSMutableArray { + private static final long serialVersionUID = 1166339693880765234L; EOObserving observer; ObservableArray(EOObserving anObserver) { @@ -46,6 +47,7 @@ class ObservableArray extends NSMutableArray { /** * Removes the last object from the array. */ + @Override public void removeLastObject() { remove(count() - 1); } @@ -53,6 +55,7 @@ class ObservableArray extends NSMutableArray { /** * Removes the object at the specified index. */ + @Override public void removeObjectAtIndex(int index) { remove(index); } @@ -60,13 +63,15 @@ class ObservableArray extends NSMutableArray { /** * Adds all objects in the specified collection. */ - public void addObjectsFromArray(Collection aCollection) { + @Override + public void addObjectsFromArray(Collection aCollection) { addAll(aCollection); } /** * Removes all objects from the array. */ + @Override public void removeAllObjects() { clear(); } @@ -75,7 +80,8 @@ class ObservableArray extends NSMutableArray { * Removes all objects equivalent to the specified object within the range of * specified indices. */ - public void removeObject(Object anObject, NSRange aRange) { + @Override + public void removeObject(T anObject, NSRange aRange) { if ((anObject == null) || (aRange == null)) return; @@ -94,7 +100,8 @@ class ObservableArray extends NSMutableArray { * Removes all instances of the specified object within the range of specified * indices, comparing by reference. */ - public void removeIdenticalObject(Object anObject, NSRange aRange) { + @Override + public void removeIdenticalObject(T anObject, NSRange aRange) { if ((anObject == null) || (aRange == null)) return; @@ -112,13 +119,15 @@ class ObservableArray extends NSMutableArray { /** * Removes all objects in the specified collection from the array. */ - public void removeObjectsInArray(Collection aCollection) { + @Override + public void removeObjectsInArray(Collection aCollection) { removeAll(aCollection); } /** * Removes all objects in the indices within the specified range from the array. */ + @Override public void removeObjectsInRange(NSRange aRange) { if (aRange == null) return; @@ -134,7 +143,8 @@ class ObservableArray extends NSMutableArray { * objects are removed. If otherRange is larger than currentRange, the extra * objects are added. */ - public void replaceObjectsInRange(NSRange currentRange, List otherArray, NSRange otherRange) { + @Override + public void replaceObjectsInRange(NSRange currentRange, List otherArray, NSRange otherRange) { if ((currentRange == null) || (otherArray == null) || (otherRange == null)) return; @@ -145,8 +155,7 @@ class ObservableArray extends NSMutableArray { otherRange = new NSRange(loc, otherArray.size() - loc); } - Object o; - List subList = subList(currentRange.location(), currentRange.maxRange()); + List subList = subList(currentRange.location(), currentRange.maxRange()); int otherIndex = otherRange.location(); // TODO: Test this logic. for (int i = 0; i < subList.size(); i++) { @@ -168,7 +177,8 @@ class ObservableArray extends NSMutableArray { * Clears the current array and then populates it with the contents of the * specified collection. */ - public void setArray(Collection aCollection) { + @Override + public void setArray(Collection aCollection) { clear(); addAll(aCollection); } @@ -176,6 +186,7 @@ class ObservableArray extends NSMutableArray { /** * Removes all objects equivalent to the specified object. */ + @Override public void removeObject(Object anObject) { remove(anObject); } @@ -183,7 +194,8 @@ class ObservableArray extends NSMutableArray { /** * Removes all occurences of the specified object, comparing by reference. */ - public void removeIdenticalObject(Object anObject) { + @Override + public void removeIdenticalObject(T anObject) { EOObserverCenter.removeObserver(observer, anObject); super.removeIdenticalObject(anObject); } @@ -191,83 +203,96 @@ class ObservableArray extends NSMutableArray { /** * Inserts the specified object into this array at the specified index. */ - public void insertObjectAtIndex(Object anObject, int anIndex) { + @Override + public void insertObjectAtIndex(T anObject, int anIndex) { add(anIndex, anObject); } /** * Replaces the object at the specified index with the specified object. */ - public void replaceObjectAtIndex(int anIndex, Object anObject) { + @Override + public void replaceObjectAtIndex(int anIndex, T anObject) { set(anIndex, anObject); } /** * Adds the specified object to the end of this array. */ - public void addObject(Object anObject) { + @Override + public void addObject(T anObject) { add(anObject); } // interface List: mutators - public void add(int index, Object element) { + @Override + public void add(int index, T element) { EOObserverCenter.addObserver(observer, element); super.add(index, element); } - public boolean add(Object o) { + @Override + public boolean add(T o) { EOObserverCenter.addObserver(observer, o); return super.add(o); } - public boolean addAll(Collection coll) { - Iterator it = coll.iterator(); + @Override + public boolean addAll(Collection coll) { + Iterator it = coll.iterator(); while (it.hasNext()) { EOObserverCenter.addObserver(observer, it.next()); } return super.addAll(coll); } - public boolean addAll(int index, Collection c) { - Iterator it = c.iterator(); + @Override + public boolean addAll(int index, Collection c) { + Iterator it = c.iterator(); while (it.hasNext()) { EOObserverCenter.addObserver(observer, it.next()); } return super.addAll(index, c); } + @Override public void clear() { - Iterator it = iterator(); + Iterator it = iterator(); while (it.hasNext()) { EOObserverCenter.removeObserver(observer, it.next()); } super.clear(); } - public Object remove(int index) { + @Override + public T remove(int index) { EOObserverCenter.removeObserver(observer, get(index)); return super.remove(index); } + @Override public boolean remove(Object o) { EOObserverCenter.removeObserver(observer, o); return super.remove(o); } - public boolean removeAll(Collection coll) { - Iterator it = coll.iterator(); + @Override + public boolean removeAll(Collection coll) { + Iterator it = coll.iterator(); while (it.hasNext()) { EOObserverCenter.removeObserver(observer, it.next()); } return super.removeAll(coll); } - public boolean retainAll(Collection coll) { + @Override + public boolean retainAll(Collection coll) { throw new UnsupportedOperationException(); } - public Object set(int index, Object element) { + @Override + public T set(int index, T element) { EOObserverCenter.removeObserver(observer, get(index)); EOObserverCenter.addObserver(observer, element); return super.set(index, element); diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/URI.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/URI.java index ba608a4..99716bf 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/URI.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/URI.java @@ -70,16 +70,13 @@ import java.io.IOException; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.URL; -import java.security.AccessController; import java.util.BitSet; import java.util.Hashtable; import java.util.Locale; -import sun.security.action.GetPropertyAction; - /** * The interface for the URI(Uniform Resource Identifiers) version of RFC 2396. - * This class has the purpose of supportting of parsing a URI reference to + * This class has the purpose of supporting of parsing a URI reference to * extend any specific protocols, the character encoding of the protocol to be * transported and the charset of the document. *

@@ -166,7 +163,7 @@ import sun.security.action.GetPropertyAction; * @author Sung-Gu * @version $Revision: 905 $ $Date: 2002/03/14 15:14:01 */ -class URI implements Cloneable, Comparable, Serializable { +class URI implements Cloneable, Comparable, Serializable { // ----------------------------------------------------------- Constructors @@ -571,7 +568,7 @@ class URI implements Cloneable, Comparable, Serializable { // in order to support backward compatiblity _documentCharset = LocaleToCharsetMap.getCharset(locale); } else { - _documentCharset = (String) AccessController.doPrivileged(new GetPropertyAction("file.encoding")); + _documentCharset = "UTF-8"; //(String) AccessController.doPrivileged(new GetPropertyAction("file.encoding")); } } @@ -3459,9 +3456,7 @@ class URI implements Cloneable, Comparable, Serializable { * @exception ClassCastException not URI argument * @throws NullPointerException null object */ - public int compareTo(Object obj) { - - URI another = (URI) obj; + public int compareTo(URI another) { if (!equals(_authority, another.getRawAuthority())) return -1; return toString().compareTo(another.toString()); @@ -3582,9 +3577,9 @@ class URI implements Cloneable, Comparable, Serializable { */ public static class LocaleToCharsetMap { - private static Hashtable map; + private static Hashtable map; static { - map = new Hashtable(); + map = new Hashtable<>(); map.put("ar", "ISO-8859-6"); map.put("be", "ISO-8859-5"); map.put("bg", "ISO-8859-5"); diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOApplication.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOApplication.java index 692e6b5..6d0dfc1 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOApplication.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOApplication.java @@ -28,7 +28,6 @@ import jakarta.servlet.http.HttpServletResponse; import net.wotonomy.foundation.NSArray; import net.wotonomy.foundation.NSDictionary; import net.wotonomy.foundation.NSMutableDictionary; -import net.wotonomy.web.util.BrowserLauncher; /** * A pure java implementation of WOApplication.
@@ -46,10 +45,12 @@ import net.wotonomy.web.util.BrowserLauncher; * @version $Revision: 905 $ */ public class WOApplication extends HttpServlet { + private static final long serialVersionUID = 2417528899972745905L; + /** * A tricky way to allow multiple WOApplications in the same servlet container. */ - static private ThreadLocal threadLocal; + static private ThreadLocal threadLocal; // static private WOApplication application; /** @@ -61,7 +62,7 @@ public class WOApplication extends HttpServlet { private String name; private WORequestHandler defaultRequestHandler; - private NSMutableDictionary requestHandlers; + private NSMutableDictionary requestHandlers; private WOSessionStore sessionStore; private WOResourceManager resourceManager; private boolean pageRefreshOnBacktrack; @@ -81,13 +82,13 @@ public class WOApplication extends HttpServlet { public WOApplication() { if (threadLocal == null) { - threadLocal = new ThreadLocal(); + threadLocal = new ThreadLocal<>(); } threadLocal.set(this); // application = this; resourceManager = createResourceManager(); - requestHandlers = new NSMutableDictionary(); + requestHandlers = new NSMutableDictionary<>(); defaultRequestHandler = new WODirectActionRequestHandler(); registerRequestHandler(defaultRequestHandler, directActionRequestHandlerKey()); registerRequestHandler(new WOComponentRequestHandler(), componentRequestHandlerKey()); @@ -107,6 +108,7 @@ public class WOApplication extends HttpServlet { * sends the response to the appropriate WORequestHandler, and then updates the * servlet response from the resulting WOResponse. */ + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { threadLocal.set(this); @@ -121,6 +123,7 @@ public class WOApplication extends HttpServlet { * gets and posts similarly. Override to handle post requests in a different * manner. */ + @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { doGet(req, resp); @@ -298,7 +301,7 @@ public class WOApplication extends HttpServlet { /** * Returns the keys under which request handlers are registered. */ - public NSArray registeredRequestHandlerKeys() { + public NSArray registeredRequestHandlerKeys() { return requestHandlers.allKeys(); } @@ -314,9 +317,11 @@ public class WOApplication extends HttpServlet { * Returns the request handler that would best service the specified request. */ public WORequestHandler handlerForRequest(WORequest aRequest) { - WORequestHandler result = requestHandlerForKey(aRequest.requestHandlerKey()); + WORequestHandler result; if (aRequest == null) result = defaultRequestHandler(); + // TODO verify it was correct to move this down one + result = requestHandlerForKey(aRequest.requestHandlerKey()); return result; } @@ -470,7 +475,7 @@ public class WOApplication extends HttpServlet { WOSession result = null; try { // using our class loader, which is hopefully dynamic. - result = (WOSession) getLocalClass("Session").newInstance(); + result = (WOSession) getLocalClass("Session").getDeclaredConstructor().newInstance(); } catch (Throwable t) { // ignore: fall back to WOSession // t.printStackTrace(); @@ -503,11 +508,11 @@ public class WOApplication extends HttpServlet { WOComponent result = null; try { // using our class loader, which is hopefully dynamic. - Class c = getLocalClass(aName); + Class c = getLocalClass(aName); if (c != null) { // get constructor - Constructor ctor; + Constructor ctor; try { ctor = c.getConstructor(new Class[] { WOContext.class }); } catch (NoSuchMethodException nsme) { @@ -519,7 +524,7 @@ public class WOApplication extends HttpServlet { result = (WOComponent) ctor.newInstance(new Object[] { aContext }); } else // call back on default constructor (deprecated) { - result = (WOComponent) c.newInstance(); + result = (WOComponent) c.getDeclaredConstructor().newInstance(); } } } catch (Throwable t) { @@ -544,13 +549,14 @@ public class WOApplication extends HttpServlet { * that, from the WOApplication package, or finally from the root of the class * path. Returns null if not found. */ - Class getLocalClass(String aName) { - Class result = null; + @SuppressWarnings("unchecked") + Class getLocalClass(String aName) { + Class result = null; if (getClass() != WOApplication.class) { - result = loadLocalClass(getClass(), aName); + result = (Class) loadLocalClass(getClass(), aName); } if (result == null) { - result = loadLocalClass(WOApplication.class, aName); + result = (Class) loadLocalClass(WOApplication.class, aName); } if (result == null) { result = loadLocalClass(null, aName); @@ -558,7 +564,8 @@ public class WOApplication extends HttpServlet { return result; } - private static final Class loadLocalClass(Class aClass, String aName) { + @SuppressWarnings("unchecked") + private static final Class loadLocalClass(Class aClass, String aName) { ClassLoader loader; String packageName = ""; if (aClass != null) { @@ -575,7 +582,7 @@ public class WOApplication extends HttpServlet { } try { - return loader.loadClass(packageName + aName); + return (Class) loader.loadClass(packageName + aName); } catch (ClassNotFoundException e) { return null; } @@ -589,7 +596,7 @@ public class WOApplication extends HttpServlet { public WOElement dynamicElementWithName(String anElementName, NSDictionary anAssociationMap, WOElement aBodyElement, List aLanguageList) { WOElement element = null; - Class c = null; + Class c = null; try { c = getLocalClass(anElementName); if (c == null) { @@ -599,8 +606,8 @@ public class WOApplication extends HttpServlet { } // get constructor - Class[] params = new Class[] { String.class, NSDictionary.class, WOElement.class }; - Constructor ctor = c.getConstructor(params); + Class[] params = new Class[] { String.class, NSDictionary.class, WOElement.class }; + Constructor ctor = c.getConstructor(params); // create instance of class if (ctor != null) { @@ -886,7 +893,7 @@ public class WOApplication extends HttpServlet { * Subclasses may call this method to start a self-hosted web server to serve * themselves directly (for testing). */ - public static void main(String[] argv, Class subclass) { + public static void main(String[] argv, Class subclass) { // TODO fix this later /*try { int port = 0; diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectAction.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectAction.java index 0ad4181..002e2a3 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectAction.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectAction.java @@ -90,6 +90,7 @@ public class WODirectAction { */ public WOSession existingSession() { // FIXME: this is incorrect + // To do this correctly, probably want to use WOSessionStore HttpSession session = request.servletRequest().getSession(); if (session == null) return null; @@ -156,7 +157,7 @@ public class WODirectAction { Method m; Object key; Object value; - java.util.Enumeration e = anArray.objectEnumerator(); + java.util.Enumeration e = anArray.objectEnumerator(); while (e.hasMoreElements()) { key = e.nextElement(); value = request.formValuesForKey(key.toString()); @@ -167,7 +168,7 @@ public class WODirectAction { if (m != null) { // if value isn't null, try to convert it to type if (value != null) { - Class[] paramTypes = m.getParameterTypes(); + Class[] paramTypes = m.getParameterTypes(); if (!paramTypes[0].isAssignableFrom(value.getClass())) { // TODO: find a constructor whose parameter // is assignable from value.getClass() @@ -196,7 +197,7 @@ public class WODirectAction { Method m; Object key; Object value; - java.util.Enumeration e = anArray.objectEnumerator(); + java.util.Enumeration e = anArray.objectEnumerator(); while (e.hasMoreElements()) { key = e.nextElement(); value = request.formValueForKey(key.toString()); @@ -207,7 +208,7 @@ public class WODirectAction { if (m != null) { // if value isn't null, try to convert it to type if (value != null) { - Class[] paramTypes = m.getParameterTypes(); + Class[] paramTypes = m.getParameterTypes(); Object convertedValue = ValueConverter.convertObjectToClass(value, paramTypes[0]); if (convertedValue != null) { value = convertedValue; diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectActionRequestHandler.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectActionRequestHandler.java index 228f387..77a5428 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectActionRequestHandler.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectActionRequestHandler.java @@ -33,6 +33,7 @@ import net.wotonomy.foundation.NSArray; * @version $Revision: 905 $ */ public class WODirectActionRequestHandler extends WORequestHandler { + @Override public WOResponse handleRequest(WORequest aRequest) { WOResponse response = null; diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODynamicElement.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODynamicElement.java index 6abb7d6..6cf7acd 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODynamicElement.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODynamicElement.java @@ -36,6 +36,7 @@ import net.wotonomy.foundation.NSMutableDictionary; * @version $Revision: 905 $ */ public abstract class WODynamicElement extends WOElement { + private static final long serialVersionUID = -5383805382837136590L; protected String name; protected WOElement rootElement; protected NSDictionary associations; @@ -68,6 +69,7 @@ public abstract class WODynamicElement extends WOElement { * context before the start of the request-response cycle. If the context has a * current component, that component becomes this component's parent. */ + @Override void ensureAwakeInContext(WOContext aContext) { if (rootElement != null) { rootElement.ensureAwakeInContext(aContext); @@ -168,6 +170,7 @@ public abstract class WODynamicElement extends WOElement { * are associated with the element in the binding. This implementation does * nothing. */ + @Override public void takeValuesFromRequest(WORequest aRequest, WOContext aContext) { } @@ -181,6 +184,7 @@ public abstract class WODynamicElement extends WOElement { * the action specified in the binding, and return the result of that action. * This implementation returns null. */ + @Override public WOActionResults invokeAction(WORequest aRequest, WOContext aContext) { return null; } @@ -190,10 +194,12 @@ public abstract class WODynamicElement extends WOElement { * to a user request. The message should be forwarded to any child elements so * that the entire tree is traversed. This implementation does nothing. */ + @Override public void appendToResponse(WOResponse aResponse, WOContext aContext) { // does nothing } + @Override public WOResponse generateResponse() { return null; } diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOElement.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOElement.java index 184eeea..b1c4282 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOElement.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOElement.java @@ -31,6 +31,7 @@ import net.wotonomy.foundation.NSDictionary; * @version $Revision: 905 $ */ public abstract class WOElement implements WOActionResults, Serializable { + private static final long serialVersionUID = 3854088436393061500L; NSDictionary associations; /** diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOMessage.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOMessage.java index f2310c2..d051a53 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOMessage.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOMessage.java @@ -33,9 +33,9 @@ import net.wotonomy.foundation.NSMutableDictionary; public class WOMessage { protected String _contentEncoding = "ISO8859_1"; - protected NSMutableDictionary _headers = new NSMutableDictionary(); - protected NSMutableDictionary _cookies = new NSMutableDictionary(); - private NSMutableDictionary _userInfo = new NSMutableDictionary(); + protected NSMutableDictionary> _headers = new NSMutableDictionary<>(); + protected NSMutableDictionary _cookies = new NSMutableDictionary<>(); + private NSMutableDictionary _userInfo = new NSMutableDictionary<>(); protected NSMutableData _contentData = new NSMutableData(); public WOMessage() { @@ -59,7 +59,7 @@ public class WOMessage { /** * Sets the specified array of values as headers under the specified key. */ - public void setHeaders(NSArray headerArray, String aKey) { + public void setHeaders(NSArray headerArray, String aKey) { _headers.setObjectForKey(headerArray, aKey); } @@ -67,13 +67,13 @@ public class WOMessage { * Sets the specified header value for the specified key. */ public void setHeader(String aValue, String aKey) { - _headers.setObjectForKey(new NSArray(aValue), aKey); + _headers.setObjectForKey(new NSArray<>(aValue), aKey); } /** * Returns an array of all the header keys that have been set in the response. */ - public NSArray headerKeys() { + public NSArray headerKeys() { return _headers.allKeys(); } @@ -81,8 +81,8 @@ public class WOMessage { * Returns an array of all the header values for the specified key, or null if * the key does not exist. */ - public NSArray headersForKey(String aKey) { - return (NSArray) _headers.objectForKey(aKey); + public NSArray headersForKey(String aKey) { + return _headers.objectForKey(aKey); } /** @@ -90,7 +90,7 @@ public class WOMessage { * since most header keys will have a single value. */ public String headerForKey(String aKey) { - NSArray values = (NSArray) _headers.objectForKey(aKey); + NSArray values = _headers.objectForKey(aKey); if (values != null && values.count() > 0) { return values.objectAtIndex(0).toString(); } @@ -118,8 +118,8 @@ public class WOMessage { * application-specific uses and are available to other actions and components * in the request-response cycle. */ - public void setUserInfo(NSDictionary aDict) { - _userInfo = new NSMutableDictionary(aDict); + public void setUserInfo(NSDictionary aDict) { + _userInfo = new NSMutableDictionary<>(aDict); } /** @@ -127,8 +127,8 @@ public class WOMessage { * application-specific uses are are available to other actions and components * in the request-response cycle. */ - public NSDictionary userInfo() { - return new NSDictionary(_userInfo); + public NSDictionary userInfo() { + return new NSDictionary<>(_userInfo); } /** @@ -195,7 +195,7 @@ public class WOMessage { * Returns an array of cookies currently being sent with the response. Contains * whatever cookies have previously been set in this response. */ - public NSArray cookies() { + public NSArray cookies() { return _cookies.allValues(); } diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java index 53615a4..607ab97 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java @@ -24,6 +24,7 @@ import java.util.Iterator; import net.wotonomy.foundation.NSDictionary; public class WORepetition extends WODynamicElement { + private static final long serialVersionUID = -8039846464450349317L; protected int count; protected int index; @@ -71,6 +72,7 @@ public class WORepetition extends WODynamicElement { return list; } + @Override public void takeValuesFromRequest(WORequest r, WOContext c) { c.appendZeroElementIDComponent(); pullValuesFromParent(c.component()); @@ -91,6 +93,7 @@ public class WORepetition extends WODynamicElement { c.deleteLastElementIDComponent(); } + @Override public WOActionResults invokeAction(WORequest r, WOContext c) { c.appendZeroElementIDComponent(); pullValuesFromParent(c.component()); @@ -116,6 +119,7 @@ public class WORepetition extends WODynamicElement { return null; } + @Override public void appendToResponse(WOResponse r, WOContext c) { c.appendZeroElementIDComponent(); pullValuesFromParent(c.component()); diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequest.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequest.java index 5664e59..3991b34 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequest.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequest.java @@ -20,6 +20,7 @@ package net.wotonomy.web; import java.io.InputStream; import java.util.Enumeration; +import java.util.Locale; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; @@ -43,7 +44,7 @@ import net.wotonomy.foundation.NSMutableDictionary; public class WORequest extends WOResponse { HttpServletRequest request; private WOApplication application; - private NSArray languages; + private NSArray languages; private String requestHandlerKey; private String requestHandlerPath; private String pageName; @@ -61,11 +62,11 @@ public class WORequest extends WOResponse { /** * Standard constructor. Method and URL are required. HeaderMap is a map of * header names to arrays containing one or more values. Data is the content of - * the request. UserInfo contains application-defined paramters that get passed + * the request. UserInfo contains application-defined parameters that get passed * to all objects involved in dispatching the request. */ - public WORequest(String aMethod, String aURL, String aProtocolName, NSDictionary headerMap, NSData aData, - NSDictionary userInfo) { + public WORequest(String aMethod, String aURL, String aProtocolName, NSDictionary> headerMap, NSData aData, + NSDictionary userInfo) { throw new RuntimeException("This constructor is not yet supported."); } @@ -97,7 +98,7 @@ public class WORequest extends WOResponse { requestHandlerPath = requestHandlerPath.substring(i); } - Enumeration e = requestHandlerPathArray().objectEnumerator(); + Enumeration e = requestHandlerPathArray().objectEnumerator(); // skipping session ID for now if (e.hasMoreElements()) { pageName = e.nextElement().toString(); @@ -131,6 +132,7 @@ public class WORequest extends WOResponse { * Returns the name of the protocol (presumably HTTP) and the version used by * the client as sent in the request headers. */ + @Override public String httpVersion() { return request.getProtocol(); } @@ -138,7 +140,8 @@ public class WORequest extends WOResponse { /** * Returns an array of the header names in this request in no particular order. */ - public NSArray headerKeys() { + @Override + public NSArray headerKeys() { return arrayFromEnumeration(request.getHeaderNames()); } @@ -146,7 +149,8 @@ public class WORequest extends WOResponse { * Returns an array of the header values for the specified key in no particular * order. */ - public NSArray headersForKey(String aString) { + @Override + public NSArray headersForKey(String aString) { return arrayFromEnumeration(request.getHeaders(aString)); } @@ -154,6 +158,7 @@ public class WORequest extends WOResponse { * Returns one value for the specified header key. Provided as a convenience * since most headers have only one value. Returns null if not found. */ + @Override public String headerForKey(String aKey) { return request.getHeader(aKey); } @@ -163,6 +168,7 @@ public class WORequest extends WOResponse { * content is determined by the "content-type" header. On error, null is * returned. */ + @Override public NSData content() { // TODO: This is broken! NSMutableData data = new NSMutableData(); @@ -186,11 +192,12 @@ public class WORequest extends WOResponse { * Returns the application-specific userInfo dictionary. This implementation * returns the servlet attribute map. */ + @Override public NSDictionary userInfo() { // TODO: Test this logic. Object key, value; - NSMutableDictionary info = new NSMutableDictionary(); - java.util.Enumeration e = request.getAttributeNames(); + NSMutableDictionary info = new NSMutableDictionary<>(); + java.util.Enumeration e = request.getAttributeNames(); while (e.hasMoreElements()) { key = e.nextElement(); value = request.getAttribute(e.nextElement().toString()); @@ -205,7 +212,7 @@ public class WORequest extends WOResponse { * Returns the items in the request handler path parsed by the "/" delimiter and * put into an array. */ - public NSArray requestHandlerPathArray() { + public NSArray requestHandlerPathArray() { return NSArray.componentsSeparatedByString(requestHandlerPath(), "/"); } @@ -214,7 +221,7 @@ public class WORequest extends WOResponse { * The strings are returned in java Locale format, meaning dashes (-) are * converted to underbars (_): see java.util.Locale.toString(). */ - public NSArray browserLanguages() { + public NSArray browserLanguages() { if (languages == null) { languages = arrayFromEnumeration(request.getLocales()); } @@ -284,15 +291,15 @@ public class WORequest extends WOResponse { /** * Returns an array containing all the form keys in the request. */ - public NSArray formValueKeys() { + public NSArray formValueKeys() { return arrayFromEnumeration(request.getParameterNames()); } /** * Returns an array of the values for the specified key in no particular order. */ - public NSArray formValuesForKey(String aKey) { - NSMutableArray result = new NSMutableArray(); + public NSArray formValuesForKey(String aKey) { + NSMutableArray result = new NSMutableArray<>(); String[] values = request.getParameterValues(aKey); if (values != null) { for (int i = 0; i < values.length; i++) { @@ -500,8 +507,8 @@ public class WORequest extends WOResponse { /** * Convenience method to populate an NSArray from an Enumeration. */ - private static NSArray arrayFromEnumeration(java.util.Enumeration e) { - NSMutableArray result = new NSMutableArray(); + private static NSArray arrayFromEnumeration(java.util.Enumeration e) { + NSMutableArray result = new NSMutableArray<>(); while (e.hasMoreElements()) { result.addObject(e.nextElement()); } diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequestHandler.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequestHandler.java index 7e3c624..3adf51e 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequestHandler.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequestHandler.java @@ -48,7 +48,7 @@ public abstract class WORequestHandler { * it has been modified. Returns null if not found. Because this method is not * in the specification, it has only package access. */ - Class loadClass(String aName) { + Class loadClass(String aName) { try { return loader.loadClass(aName, true); } catch (ClassNotFoundException cnfe) { diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOServletSessionStore.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOServletSessionStore.java index fde7f18..3de29b7 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOServletSessionStore.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOServletSessionStore.java @@ -126,7 +126,7 @@ public class WOServletSessionStore extends WOSessionStore { loader = aClassLoader; } - protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { + protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { return loader.loadClass(v.getName()); } } diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOSession.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOSession.java index 58a45f0..c8c1f4d 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOSession.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOSession.java @@ -42,6 +42,8 @@ import net.wotonomy.foundation.NSMutableDictionary; * @version $Revision: 905 $ */ public class WOSession implements Serializable, NSKeyValueCodingAdditions { + private static final long serialVersionUID = -5060204676319332437L; + // NOTE: need to set this when deserialized and on creation transient private HttpSession session; diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java index 54658c0..ed27d7c 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java @@ -51,6 +51,7 @@ public class XMLRPCDecoder implements XMLDecoder { * @return The object that was constructed from the XML content, or null if no * object could be constructed. */ + @Override public Object decode(InputStream anInputStream, String aDescription, URL aURL) { Object result = null; -- cgit v1.2.3