abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1176196 - /abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Operation.java
Date Tue, 27 Sep 2011 05:05:25 GMT
Author: jmsnell
Date: Tue Sep 27 05:05:24 2011
New Revision: 1176196

URL: http://svn.apache.org/viewvc?rev=1176196&view=rev
Log:
Relatively minor changes introduced by http://tools.ietf.org/html/draft-gregorio-uritemplate-07

Modified:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Operation.java

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Operation.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Operation.java?rev=1176196&r1=1176195&r2=1176196&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Operation.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Operation.java
Tue Sep 27 05:05:24 2011
@@ -257,10 +257,22 @@ public abstract class Operation implemen
                 throw new RuntimeException(e);
             }
         } else if (val instanceof CharSequence) {
-            val = normalize((CharSequence)val);
+            val = trim(normalize((CharSequence)val),len);
             return encode((CharSequence)val, context.isIri(), reserved);
         } else if (val instanceof Byte) {
             return UrlEncoding.encode(((Byte)val).byteValue());
+        } else if (val instanceof Context) {
+          StringBuilder buf = new StringBuilder();
+          Context ctx = (Context) val;
+          for (String name : ctx) {
+            String _val = toString(ctx.resolve(name), context, reserved, false, null, null,
len);
+            if (buf.length() > 0)
+              buf.append(explode && explodeDelim != null ? explodeDelim : ",");
+            buf.append(name)
+               .append(explode ? '=' : ',')
+               .append(_val);
+          }
+          return buf.toString();
         } else if (val instanceof Iterable) {
             StringBuilder buf = new StringBuilder();
             Iterable<Object> i = (Iterable<Object>)val;
@@ -453,7 +465,8 @@ public abstract class Operation implemen
             boolean first = true;
             buf.append("?");
             for (VarSpec varspec : exp) {
-              String val = eval(varspec, context, false, "&", varspec.getName() + "=");
+              //String val = eval(varspec, context, false, "&", varspec.getName() + "=");
+              String val = eval(varspec, context, false, "&", ""); // Per Draft Seven
(http://tools.ietf.org/html/draft-gregorio-uritemplate-07)
               if (context.contains(varspec.getName())) {
                 if (!first) buf.append('&');
                 if ((val != null && !varspec.isExplode()) || varspec.isNoval()) {
@@ -478,8 +491,10 @@ public abstract class Operation implemen
         public String evaluate(Expression exp, Context context) {
             StringBuilder buf = new StringBuilder();
             for (VarSpec varspec : exp) {
-              String val = eval(varspec, context, false, "&", varspec.getName() + "=");
+              //String val = eval(varspec, context, false, "&", varspec.getName() + "=");
+              String val = eval(varspec, context, false, "&", ""); // Per Draft Seven
(http://tools.ietf.org/html/draft-gregorio-uritemplate-07)
               if (context.contains(varspec.getName())) {
+                if (varspec.isExplode()) buf.append('&');
                 if ((val != null && !varspec.isExplode()) || varspec.isNoval())
                   buf.append('&').append(varspec.getName());
                 if (val != null && !varspec.isExplode() && (!varspec.isNoval()
|| val.length() > 0) )



Mime
View raw message