summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-10-06 16:53:36 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-10-06 16:53:36 -0400
commit76adca11afff1649621d462ca67589f76ff29603 (patch)
tree8cf9ffe0dfbc522566042cb6297ec075708099dd
parent9c681f38b742b26b841eb42bc19879cb90ac03de (diff)
UpdatesHEADtrunk
-rw-r--r--projects/net.wotonomy.all/pom.xml3
-rw-r--r--projects/net.wotonomy.datastore/pom.xml3
-rw-r--r--projects/net.wotonomy.foundation/pom.xml3
-rw-r--r--projects/net.wotonomy.persistence/pom.xml3
-rw-r--r--projects/net.wotonomy.ui/pom.xml3
-rw-r--r--projects/net.wotonomy.web/pom.xml3
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOApplication.java2
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOComponent.java38
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODynamicElement.java4
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOElement.java2
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOElementBindings.java91
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOHyperlink.java1
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOResponse.java13
-rw-r--r--projects/pom.xml3
14 files changed, 140 insertions, 32 deletions
diff --git a/projects/net.wotonomy.all/pom.xml b/projects/net.wotonomy.all/pom.xml
index 002ea02..8316b1d 100644
--- a/projects/net.wotonomy.all/pom.xml
+++ b/projects/net.wotonomy.all/pom.xml
@@ -1,4 +1,5 @@
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.wotonomy</groupId>
<artifactId>wotonomy-all</artifactId>
diff --git a/projects/net.wotonomy.datastore/pom.xml b/projects/net.wotonomy.datastore/pom.xml
index 7dfad9e..2db3202 100644
--- a/projects/net.wotonomy.datastore/pom.xml
+++ b/projects/net.wotonomy.datastore/pom.xml
@@ -1,4 +1,5 @@
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.wotonomy</groupId>
diff --git a/projects/net.wotonomy.foundation/pom.xml b/projects/net.wotonomy.foundation/pom.xml
index 4a347cc..3e85c9a 100644
--- a/projects/net.wotonomy.foundation/pom.xml
+++ b/projects/net.wotonomy.foundation/pom.xml
@@ -1,4 +1,5 @@
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.wotonomy</groupId>
diff --git a/projects/net.wotonomy.persistence/pom.xml b/projects/net.wotonomy.persistence/pom.xml
index 13bb0c3..813ec4c 100644
--- a/projects/net.wotonomy.persistence/pom.xml
+++ b/projects/net.wotonomy.persistence/pom.xml
@@ -1,4 +1,5 @@
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.wotonomy</groupId>
diff --git a/projects/net.wotonomy.ui/pom.xml b/projects/net.wotonomy.ui/pom.xml
index a02fd93..04af0d1 100644
--- a/projects/net.wotonomy.ui/pom.xml
+++ b/projects/net.wotonomy.ui/pom.xml
@@ -1,4 +1,5 @@
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.wotonomy</groupId>
diff --git a/projects/net.wotonomy.web/pom.xml b/projects/net.wotonomy.web/pom.xml
index 1ac517e..d3903fe 100644
--- a/projects/net.wotonomy.web/pom.xml
+++ b/projects/net.wotonomy.web/pom.xml
@@ -1,4 +1,5 @@
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.wotonomy</groupId>
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 570a97d..6103b0d 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
@@ -594,7 +594,7 @@ public class WOApplication extends HttpServlet {
/**
* Returns either a dynamic element or a component for the specified name.
*/
- public WOElement dynamicElementWithName(String anElementName, NSDictionary<String, Object> anAssociationMap, WOElement aBodyElement,
+ public WOElement dynamicElementWithName(String anElementName, NSDictionary<String, WOAssociation> anAssociationMap, WOElement aBodyElement,
List<Locale> aLanguageList) {
WOElement element = null;
Class<? extends WODynamicElement> c = null;
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOComponent.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOComponent.java
index 327e024..a5157fe 100644
--- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOComponent.java
+++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOComponent.java
@@ -180,8 +180,8 @@ public class WOComponent extends WOElement implements WOActionResults, net.woton
return null;
WOElement result = null;
try {
- NSDictionary bindings = processDeclaration(aDeclaration);
- List elements = new LinkedList();
+ NSDictionary<String, WOElementBindings> bindings = processDeclaration(aDeclaration);
+ List<WOElement> elements = new LinkedList<>();
int index = processTemplate(elements, anHTMLString, 0, bindings, aLanguageList);
if (index == -1) {
if (elements.size() == 1) {
@@ -581,13 +581,14 @@ public class WOComponent extends WOElement implements WOActionResults, net.woton
* interesting tags, and calling itself recursively as necessary. Returns the
* index to resume parsing, or -1 if done.
*/
- static private int processTemplate(List elements, String template, int index, Map bindings, List aLanguageList)
+ static private int processTemplate(List<WOElement> elements, String template, int index, Map<String, WOElementBindings> bindings, List aLanguageList)
throws java.io.IOException { // System.out.println( "processTemplate: " + index );
if (template == null)
return -1;
int start = index;
+ // TODO proper XML/HTML parsing?
while (true) {
// search for start of next tag
start = template.indexOf('<', start);
@@ -667,7 +668,7 @@ public class WOComponent extends WOElement implements WOActionResults, net.woton
WOElement body = null;
if (hasBody) {
- List childElements = new LinkedList();
+ List<WOElement> childElements = new LinkedList<>();
index = processTemplate(childElements, template, index, bindings, aLanguageList);
start = index;
@@ -685,16 +686,22 @@ public class WOComponent extends WOElement implements WOActionResults, net.woton
WOElement element = null;
String nameProperty = (String) params.get(NAME_KEY);
- NSDictionary original = (NSDictionary) bindings.get(nameProperty);
- // System.out.println( nameProperty + " : " + associations );
- if (original == null) {
- original = NSDictionary.EmptyDictionary;
+ WOElementBindings original;
+ if (!bindings.containsKey(nameProperty)) {
+ original = null;
System.err.println("No associations for: " + nameProperty);
System.err.println(bindings);
+ } else {
+ original = bindings.get(nameProperty);
}
- NSDictionary associations = new NSMutableDictionary(original);
- String elementClass = (String) associations.remove(WOApplication.ELEMENT_CLASS);
+ NSDictionary<String, WOAssociation> associations;
+ if (original == null) {
+ associations = new NSMutableDictionary<String, WOAssociation>((NSDictionary<String, WOAssociation>)NSDictionary.EmptyDictionary);
+ } else {
+ associations = new NSMutableDictionary<String, WOAssociation>(original);
+ }
+ String elementClass = original.getElementClass();
WOApplication application = WOApplication.application();
element = application.dynamicElementWithName(elementClass, associations, body, aLanguageList);
@@ -848,9 +855,9 @@ public class WOComponent extends WOElement implements WOActionResults, net.woton
* Parses the declarations in the specified content and returns a map of element
* names to maps of attribute names to WOAssociations.
*/
- private static NSDictionary processDeclaration(String content) {
+ private static NSDictionary<String, WOElementBindings> processDeclaration(String content) {
int index;
- NSMutableDictionary result = new NSMutableDictionary();
+ NSMutableDictionary<String, WOElementBindings> result = new NSMutableDictionary<>();
// strip out comments
StringBuffer stripped = new StringBuffer();
@@ -923,7 +930,7 @@ public class WOComponent extends WOElement implements WOActionResults, net.woton
token = tokens.nextToken();
}
- NSMutableDictionary associations = new NSMutableDictionary();
+ NSMutableDictionary<String, WOAssociation> associations = new NSMutableDictionary<>();
if (!token.equals("}")) {
String line, key, value;
@@ -972,8 +979,9 @@ public class WOComponent extends WOElement implements WOActionResults, net.woton
throw new RuntimeException("Error parsing declaration: expected } but found: '" + token + "'");
}
}
- associations.put(WOApplication.ELEMENT_CLASS, cl); // store classname
- result.put(name, associations);
+ //associations.put(WOApplication.ELEMENT_CLASS, cl); // store classname
+
+ result.put(name, new WOElementBindings(associations, cl));
}
// System.out.println( "processDeclaration: " + result );
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 8cae72c..62ea6ae 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
@@ -39,7 +39,7 @@ public abstract class WODynamicElement extends WOElement {
private static final long serialVersionUID = -5383805382837136590L;
protected String name;
protected WOElement rootElement;
- protected NSDictionary<String, Object> associations;
+ protected NSDictionary<String, WOAssociation> associations;
/**
* The default constructor.
@@ -57,7 +57,7 @@ public abstract class WODynamicElement extends WOElement {
* and the values are associations to be applied to the context's current
* component.
*/
- public WODynamicElement(String aName, NSDictionary<String, Object> anAssociationMap, WOElement aRootElement) {
+ public WODynamicElement(String aName, NSDictionary<String, WOAssociation> anAssociationMap, WOElement aRootElement) {
this();
name = aName;
associations = anAssociationMap;
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 b1c4282..5f701f1 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
@@ -32,7 +32,7 @@ import net.wotonomy.foundation.NSDictionary;
*/
public abstract class WOElement implements WOActionResults, Serializable {
private static final long serialVersionUID = 3854088436393061500L;
- NSDictionary associations;
+ NSDictionary<String, WOAssociation> associations;
/**
* Default constructor. Performs necessary initialization.
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOElementBindings.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOElementBindings.java
new file mode 100644
index 0000000..e474a1f
--- /dev/null
+++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOElementBindings.java
@@ -0,0 +1,91 @@
+package net.wotonomy.web;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+
+public class WOElementBindings implements Map<String, WOAssociation> {
+ private Map<String, WOAssociation> bindings;
+ private String elementClass;
+
+ public WOElementBindings(Map<String, WOAssociation> bindings, String elementClass) {
+ this.bindings = bindings;
+ this.elementClass = elementClass;
+ }
+
+ public String getElementClass() {
+ return elementClass;
+ }
+
+ // Delegate methods to Map
+ @Override
+ public int size() {
+ return bindings.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return bindings.isEmpty();
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ return bindings.containsKey(key);
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return bindings.containsValue(value);
+ }
+
+ @Override
+ public WOAssociation get(Object key) {
+ return bindings.get(key);
+ }
+
+ @Override
+ public WOAssociation put(String key, WOAssociation value) {
+ return bindings.put(key, value);
+ }
+
+ @Override
+ public WOAssociation remove(Object key) {
+ return bindings.remove(key);
+ }
+
+ @Override
+ public void putAll(Map<? extends String, ? extends WOAssociation> m) {
+ bindings.putAll(m);
+ }
+
+ @Override
+ public void clear() {
+ bindings.clear();
+ }
+
+ @Override
+ public Set<String> keySet() {
+ return bindings.keySet();
+ }
+
+ @Override
+ public Collection<WOAssociation> values() {
+ return bindings.values();
+ }
+
+ @Override
+ public Set<Entry<String, WOAssociation>> entrySet() {
+ return bindings.entrySet();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return bindings.equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return bindings.hashCode();
+ }
+}
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOHyperlink.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOHyperlink.java
index e2041d5..3c1fd06 100644
--- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOHyperlink.java
+++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOHyperlink.java
@@ -55,6 +55,7 @@ import net.wotonomy.foundation.NSDictionary;
* @version $Revision: 905 $
*/
public class WOHyperlink extends WODynamicElement {
+ private static final long serialVersionUID = -7615256188185925861L;
protected String string;
protected String href;
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOResponse.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOResponse.java
index 6e729cb..0b436fc 100644
--- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOResponse.java
+++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOResponse.java
@@ -74,7 +74,7 @@ public class WOResponse extends WOMessage implements WOActionResults {
setHeader(dateString, "Date");
setHeader(dateString, "Expires");
setHeader("no-cache", "Pragma");
- setHeaders(new NSArray(new Object[] { "private", "no-cache", "max-age = 0" }), "Cache-Control");
+ setHeaders(new NSArray<>(new String[] { "private", "no-cache", "max-age = 0" }), "Cache-Control");
// System.out.println( "disableClientCaching: " + dateString );
}
@@ -100,7 +100,8 @@ public class WOResponse extends WOMessage implements WOActionResults {
}
String key;
- java.util.Enumeration e, f;
+ java.util.Enumeration<String> e;
+ java.util.Enumeration<String> f;
// set content type: might be overwritten by headers below
response.setContentType("text/html");
@@ -114,7 +115,7 @@ public class WOResponse extends WOMessage implements WOActionResults {
f = _headers.allKeys().objectEnumerator();
while (f.hasMoreElements()) {
key = f.nextElement().toString();
- e = ((NSArray) _headers.objectForKey(key)).objectEnumerator();
+ e = ((NSArray<String>) _headers.objectForKey(key)).objectEnumerator();
if (e.hasMoreElements()) {
// overwrite existing header
response.setHeader(key, e.nextElement().toString());
@@ -125,9 +126,9 @@ public class WOResponse extends WOMessage implements WOActionResults {
}
// set cookies
- e = _cookies.allValues().objectEnumerator();
- while (e.hasMoreElements()) {
- response.addCookie((WOCookie) e.nextElement());
+ java.util.Enumeration<WOCookie> cookies = _cookies.allValues().objectEnumerator();
+ while (cookies.hasMoreElements()) {
+ response.addCookie(cookies.nextElement());
}
try {
diff --git a/projects/pom.xml b/projects/pom.xml
index 7c46448..ab78723 100644
--- a/projects/pom.xml
+++ b/projects/pom.xml
@@ -1,4 +1,5 @@
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.wotonomy</groupId>
<artifactId>wotonomy-root</artifactId>