summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequest.java
diff options
context:
space:
mode:
Diffstat (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequest.java')
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORequest.java39
1 files changed, 23 insertions, 16 deletions
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<Locale> 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<String, NSArray<Object>> headerMap, NSData aData,
+ NSDictionary<Object, Object> 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<String> 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<String> 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<String> 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<Object, Object> info = new NSMutableDictionary<>();
+ java.util.Enumeration<String> 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<String> 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<Locale> 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<String> 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<String> formValuesForKey(String aKey) {
+ NSMutableArray<String> 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 <C> NSArray<C> arrayFromEnumeration(java.util.Enumeration<C> e) {
+ NSMutableArray<C> result = new NSMutableArray<>();
while (e.hasMoreElements()) {
result.addObject(e.nextElement());
}