incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1234460 [14/30] - in /incubator/isis/trunk/framework/viewer: bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/ bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/components/ bdd/common/src/main/java/org/apache/isis/viewer...
Date Sun, 22 Jan 2012 08:05:57 GMT
Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/ScalarValueRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/ScalarValueRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/ScalarValueRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/ScalarValueRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,20 +16,19 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.domainobjects;
-
+package org.apache.isis.viewer.json.applib.domainobjects;
+
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.codehaus.jackson.JsonNode;
-
-
-public class ScalarValueRepresentation extends DomainRepresentation {
-
-    public ScalarValueRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-    
+
+public class ScalarValueRepresentation extends DomainRepresentation {
+
+    public ScalarValueRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
     public JsonRepresentation getValue() {
         return getRepresentation("value");
     }
-
-}
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/TransientDomainObjectRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/TransientDomainObjectRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/TransientDomainObjectRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/TransientDomainObjectRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,20 +16,19 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.domainobjects;
-
+package org.apache.isis.viewer.json.applib.domainobjects;
+
 import org.apache.isis.viewer.json.applib.links.LinkRepresentation;
 import org.codehaus.jackson.JsonNode;
-
-
-public class TransientDomainObjectRepresentation extends AbstractDomainObjectRepresentation {
-
-    public TransientDomainObjectRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-    
+
+public class TransientDomainObjectRepresentation extends AbstractDomainObjectRepresentation {
+
+    public TransientDomainObjectRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
     public LinkRepresentation getPersistLink() {
         return getLink("links[rel=persist]");
     }
-    
-}
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/AbstractTypeMemberRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/AbstractTypeMemberRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/AbstractTypeMemberRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/AbstractTypeMemberRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,15 +16,15 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.domaintypes;
-
+package org.apache.isis.viewer.json.applib.domaintypes;
+
 import org.apache.isis.viewer.json.applib.domainobjects.DomainRepresentation;
 import org.codehaus.jackson.JsonNode;
-
-public abstract class AbstractTypeMemberRepresentation extends DomainRepresentation  {
-
-    public AbstractTypeMemberRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-
-}
+
+public abstract class AbstractTypeMemberRepresentation extends DomainRepresentation {
+
+    public AbstractTypeMemberRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/ActionDescriptionRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/ActionDescriptionRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/ActionDescriptionRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/ActionDescriptionRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,18 +16,18 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.domaintypes;
-
+package org.apache.isis.viewer.json.applib.domaintypes;
+
 import org.codehaus.jackson.JsonNode;
-
-public class ActionDescriptionRepresentation extends AbstractTypeMemberRepresentation  {
-
-    public ActionDescriptionRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
+
+public class ActionDescriptionRepresentation extends AbstractTypeMemberRepresentation {
+
+    public ActionDescriptionRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
 
     public String getId() {
         return getString("id");
     }
-
-}
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/ActionParameterDescriptionRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/ActionParameterDescriptionRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/ActionParameterDescriptionRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/ActionParameterDescriptionRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,14 +16,14 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.domaintypes;
-
+package org.apache.isis.viewer.json.applib.domaintypes;
+
 import org.codehaus.jackson.JsonNode;
-
-public class ActionParameterDescriptionRepresentation extends AbstractTypeMemberRepresentation {
-
-    public ActionParameterDescriptionRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-
-}
+
+public class ActionParameterDescriptionRepresentation extends AbstractTypeMemberRepresentation {
+
+    public ActionParameterDescriptionRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/CollectionDescriptionRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/CollectionDescriptionRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/CollectionDescriptionRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/CollectionDescriptionRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,14 +16,14 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.domaintypes;
-
+package org.apache.isis.viewer.json.applib.domaintypes;
+
 import org.codehaus.jackson.JsonNode;
-
-public class CollectionDescriptionRepresentation extends AbstractTypeMemberRepresentation {
-
-    public CollectionDescriptionRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-
-}
+
+public class CollectionDescriptionRepresentation extends AbstractTypeMemberRepresentation {
+
+    public CollectionDescriptionRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/DomainTypeRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/DomainTypeRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/DomainTypeRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/DomainTypeRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,15 +16,15 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.domaintypes;
-
+package org.apache.isis.viewer.json.applib.domaintypes;
+
 import org.apache.isis.viewer.json.applib.domainobjects.DomainRepresentation;
 import org.codehaus.jackson.JsonNode;
-
-public class DomainTypeRepresentation extends DomainRepresentation {
-
-    public DomainTypeRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-
-}
+
+public class DomainTypeRepresentation extends DomainRepresentation {
+
+    public DomainTypeRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/DomainTypeResource.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/DomainTypeResource.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/DomainTypeResource.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/DomainTypeResource.java Sun Jan 22 08:05:17 2012
@@ -32,88 +32,78 @@ import org.jboss.resteasy.annotations.Cl
 @Path("/domainTypes")
 public interface DomainTypeResource {
 
-
-    ///////////////////////////////////////////////////////
+    // /////////////////////////////////////////////////////
     // domainTypes (list of all )
-    ///////////////////////////////////////////////////////
+    // /////////////////////////////////////////////////////
 
     @GET
     @Path("/")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_TYPE_LIST })
-    @ClientResponseType(entityType=String.class)
+    @ClientResponseType(entityType = String.class)
     public abstract Response domainTypes();
 
-    
-    ///////////////////////////////////////////////////////
+    // /////////////////////////////////////////////////////
     // domainType + member description
-    ///////////////////////////////////////////////////////
+    // /////////////////////////////////////////////////////
 
     @GET
     @Path("/{domainType}")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_TYPE })
-    @ClientResponseType(entityType=String.class)
+    @ClientResponseType(entityType = String.class)
     public abstract Response domainType(@PathParam("domainType") final String domainType);
 
     @GET
     @Path("/{domainType}/properties/{propertyId}")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_PROPERTY_DESCRIPTION })
-    @ClientResponseType(entityType=String.class)
-    public abstract Response typeProperty(@PathParam("domainType") final String domainType,
-        @PathParam("propertyId") final String propertyId);
+    @ClientResponseType(entityType = String.class)
+    public abstract Response typeProperty(@PathParam("domainType") final String domainType, @PathParam("propertyId") final String propertyId);
 
     @GET
     @Path("/{domainType}/collections/{collectionId}")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_COLLECTION_DESCRIPTION })
-    @ClientResponseType(entityType=String.class)
-    public abstract Response typeCollection(@PathParam("domainType") final String domainType,
-        @PathParam("collectionId") final String collectionId);
+    @ClientResponseType(entityType = String.class)
+    public abstract Response typeCollection(@PathParam("domainType") final String domainType, @PathParam("collectionId") final String collectionId);
 
     @GET
     @Path("/{domainType}/actions/{actionId}")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_DESCRIPTION })
-    @ClientResponseType(entityType=String.class)
-    public abstract Response typeAction(@PathParam("domainType") final String domainType,
-        @PathParam("actionId") final String actionId);
+    @ClientResponseType(entityType = String.class)
+    public abstract Response typeAction(@PathParam("domainType") final String domainType, @PathParam("actionId") final String actionId);
 
     @GET
     @Path("/{domainType}/actions/{actionId}/params/{paramNum}")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_PARAMETER_DESCRIPTION })
-    @ClientResponseType(entityType=String.class)
-    public abstract Response typeActionParam(@PathParam("domainType") final String domainType,
-        @PathParam("actionId") final String actionId, @PathParam("paramNum") final String paramName);
+    @ClientResponseType(entityType = String.class)
+    public abstract Response typeActionParam(@PathParam("domainType") final String domainType, @PathParam("actionId") final String actionId, @PathParam("paramNum") final String paramName);
 
-    
-    ////////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////////
     // domain type actions
-    ////////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////////
 
     @GET
     @Path("/{domainType}/isSubtypeOf/invoke")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_TYPE_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
-    @ClientResponseType(entityType=String.class)
-    public abstract Response domainTypeIsSubtypeOf(
-        @PathParam("domainType") final String domainType,
-        @QueryParam("supertype") String superType,            // simple style
-        @QueryParam("args") final String argumentsQueryString // formal style 
-        );
+    @ClientResponseType(entityType = String.class)
+    public abstract Response domainTypeIsSubtypeOf(@PathParam("domainType") final String domainType, @QueryParam("supertype") String superType, // simple
+                                                                                                                                                // style
+            @QueryParam("args") final String argumentsQueryString // formal
+                                                                  // style
+    );
 
     @GET
     @Path("/{domainType}/isSupertypeOf/invoke")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_TYPE_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
-    @ClientResponseType(entityType=String.class)
-    public abstract Response domainTypeIsSupertypeOf(
-        @PathParam("domainType") final String domainType,
-        @QueryParam("supertype") String superType,            // simple style
-        @QueryParam("args") final String argumentsQueryString // formal style 
-        );
+    @ClientResponseType(entityType = String.class)
+    public abstract Response domainTypeIsSupertypeOf(@PathParam("domainType") final String domainType, @QueryParam("supertype") String superType, // simple
+                                                                                                                                                  // style
+            @QueryParam("args") final String argumentsQueryString // formal
+                                                                  // style
+    );
 
     @GET
     @Path("/{domainType}/newTransientInstance/invoke")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_TYPE_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
-    @ClientResponseType(entityType=String.class)
-    public Response newTransientInstance(
-        @QueryParam("domainType") final String domainType, 
-        @QueryParam("args") final String args);
-
+    @ClientResponseType(entityType = String.class)
+    public Response newTransientInstance(@QueryParam("domainType") final String domainType, @QueryParam("args") final String args);
 
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/PropertyDescriptionRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/PropertyDescriptionRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/PropertyDescriptionRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/PropertyDescriptionRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,14 +16,14 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.domaintypes;
-
+package org.apache.isis.viewer.json.applib.domaintypes;
+
 import org.codehaus.jackson.JsonNode;
-
-public class PropertyDescriptionRepresentation extends AbstractTypeMemberRepresentation  {
-
-    public PropertyDescriptionRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-
-}
+
+public class PropertyDescriptionRepresentation extends AbstractTypeMemberRepresentation {
+
+    public PropertyDescriptionRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/TypeActionResultRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/TypeActionResultRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/TypeActionResultRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/TypeActionResultRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,15 +16,15 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.domaintypes;
-
+package org.apache.isis.viewer.json.applib.domaintypes;
+
 import org.apache.isis.viewer.json.applib.domainobjects.DomainRepresentation;
 import org.codehaus.jackson.JsonNode;
-
-public class TypeActionResultRepresentation extends DomainRepresentation {
-
-    public TypeActionResultRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-
-}
+
+public class TypeActionResultRepresentation extends DomainRepresentation {
+
+    public TypeActionResultRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/TypeListRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/TypeListRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/TypeListRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domaintypes/TypeListRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,15 +16,15 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.domaintypes;
-
+package org.apache.isis.viewer.json.applib.domaintypes;
+
 import org.apache.isis.viewer.json.applib.domainobjects.DomainRepresentation;
 import org.codehaus.jackson.JsonNode;
-
-public class TypeListRepresentation extends DomainRepresentation {
-
-    public TypeListRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-
-}
+
+public class TypeListRepresentation extends DomainRepresentation {
+
+    public TypeListRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/errors/ErrorRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/errors/ErrorRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/errors/ErrorRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/errors/ErrorRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,15 +16,15 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.errors;
-
+package org.apache.isis.viewer.json.applib.errors;
+
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.codehaus.jackson.JsonNode;
-
-public class ErrorRepresentation extends JsonRepresentation  {
-
-    public ErrorRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-
-}
+
+public class ErrorRepresentation extends JsonRepresentation {
+
+    public ErrorRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,27 +16,28 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.homepage;
-
+package org.apache.isis.viewer.json.applib.homepage;
+
 import org.apache.isis.viewer.json.applib.domainobjects.DomainRepresentation;
 import org.apache.isis.viewer.json.applib.links.LinkRepresentation;
 import org.codehaus.jackson.JsonNode;
-
-public class HomePageRepresentation extends DomainRepresentation {
-
-    public HomePageRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-
-    public LinkRepresentation getUser() {
-        return getLinkWithRel("user");
-    }
-    public LinkRepresentation getServices() {
-        return getLinkWithRel("services");
-    }
-    public LinkRepresentation getVersion() {
-        return getLinkWithRel("version");
-    }
-
-
-}
+
+public class HomePageRepresentation extends DomainRepresentation {
+
+    public HomePageRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+    public LinkRepresentation getUser() {
+        return getLinkWithRel("user");
+    }
+
+    public LinkRepresentation getServices() {
+        return getLinkWithRel("services");
+    }
+
+    public LinkRepresentation getVersion() {
+        return getLinkWithRel("version");
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageResource.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageResource.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageResource.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageResource.java Sun Jan 22 08:05:17 2012
@@ -32,18 +32,17 @@ public interface HomePageResource {
 
     @GET
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_HOME_PAGE })
-    @ClientResponseType(entityType=String.class)
+    @ClientResponseType(entityType = String.class)
     public Response homePage();
-    
-    
+
     /**
-     * Not part of the RO spec; this resource always returns 401, and is intended to be redirected to
-     * if credentials cannot be obtained.
+     * Not part of the RO spec; this resource always returns 401, and is
+     * intended to be redirected to if credentials cannot be obtained.
      */
     @GET
     @Path("/notAuthenticated")
     @Produces({ MediaType.APPLICATION_JSON })
-    @ClientResponseType(entityType=String.class)
+    @ClientResponseType(entityType = String.class)
     public Response notAuthenticated();
 
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/links/LinkRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/links/LinkRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/links/LinkRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/links/LinkRepresentation.java Sun Jan 22 08:05:17 2012
@@ -18,9 +18,7 @@
  */
 package org.apache.isis.viewer.json.applib.links;
 
-
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
 
 import org.apache.isis.viewer.json.applib.ClientRequestConfigurer;
 import org.apache.isis.viewer.json.applib.HttpMethod;
@@ -32,23 +30,22 @@ import org.codehaus.jackson.node.JsonNod
 import org.codehaus.jackson.node.ObjectNode;
 import org.jboss.resteasy.client.ClientExecutor;
 
-
 public final class LinkRepresentation extends JsonRepresentation {
-    
+
     public LinkRepresentation() {
         this(new ObjectNode(JsonNodeFactory.instance));
         withMethod(HttpMethod.GET);
     }
 
-    public LinkRepresentation(JsonNode jsonNode) {
+    public LinkRepresentation(final JsonNode jsonNode) {
         super(jsonNode);
     }
 
     public String getRel() {
         return asObjectNode().path("rel").getTextValue();
     }
-    
-    public LinkRepresentation withRel(String rel) {
+
+    public LinkRepresentation withRel(final String rel) {
         asObjectNode().put("rel", rel);
         return this;
     }
@@ -56,7 +53,8 @@ public final class LinkRepresentation ex
     public String getHref() {
         return asObjectNode().path("href").getTextValue();
     }
-    public LinkRepresentation withHref(String href) {
+
+    public LinkRepresentation withHref(final String href) {
         asObjectNode().put("href", href);
         return this;
     }
@@ -68,24 +66,26 @@ public final class LinkRepresentation ex
     public String getTitle() {
         return getString("title");
     }
+
     public LinkRepresentation withTitle(final String title) {
         asObjectNode().put("title", title);
         return this;
     }
 
     public HttpMethod getHttpMethod() {
-        String methodStr = asObjectNode().path("method").getTextValue();
+        final String methodStr = asObjectNode().path("method").getTextValue();
         return HttpMethod.valueOf(methodStr);
     }
 
     public MediaType getType() {
-        String typeStr = asObjectNode().path("type").getTextValue();
-        if(typeStr == null) { return MediaType.APPLICATION_JSON_TYPE; }
+        final String typeStr = asObjectNode().path("type").getTextValue();
+        if (typeStr == null) {
+            return MediaType.APPLICATION_JSON_TYPE;
+        }
         return MediaType.valueOf(typeStr);
     }
 
-
-    public LinkRepresentation withMethod(HttpMethod httpMethod) {
+    public LinkRepresentation withMethod(final HttpMethod httpMethod) {
         asObjectNode().put("method", httpMethod.name());
         return this;
     }
@@ -94,35 +94,36 @@ public final class LinkRepresentation ex
      * Returns the "arguments" json-property of the link (a map).
      * 
      * <p>
-     * If there is no &quot;arguments&quot; node, then as a convenience
-     * will return an empty map.
+     * If there is no &quot;arguments&quot; node, then as a convenience will
+     * return an empty map.
+     * 
      * @return
      */
     public JsonRepresentation getArguments() {
-        JsonNode arguments = asObjectNode().get("arguments");
-        if(arguments.isNull()) {
+        final JsonNode arguments = asObjectNode().get("arguments");
+        if (arguments.isNull()) {
             return JsonRepresentation.newMap();
         }
         return new JsonRepresentation(arguments);
     }
-    
-    public <T> RestfulResponse<JsonRepresentation> follow(ClientExecutor executor) throws Exception {
+
+    public <T> RestfulResponse<JsonRepresentation> follow(final ClientExecutor executor) throws Exception {
         return follow(executor, null);
     }
-    
-    public <T extends JsonRepresentation> RestfulResponse<T> follow(ClientExecutor executor, JsonRepresentation requestArgs) throws Exception {
-        
+
+    public <T extends JsonRepresentation> RestfulResponse<T> follow(final ClientExecutor executor, final JsonRepresentation requestArgs) throws Exception {
+
         final ClientRequestConfigurer clientRequestConfigurer = ClientRequestConfigurer.create(executor, getHref());
-        
+
         clientRequestConfigurer.accept(MediaType.APPLICATION_JSON_TYPE);
         clientRequestConfigurer.setHttpMethod(getHttpMethod());
-        
+
         clientRequestConfigurer.configureArgs(requestArgs);
-        
+
         final RestfulRequest restfulRequest = new RestfulRequest(clientRequestConfigurer);
         return restfulRequest.executeT();
     }
-    
+
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -133,21 +134,27 @@ public final class LinkRepresentation ex
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
+    public boolean equals(final Object obj) {
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
-        LinkRepresentation other = (LinkRepresentation) obj;
+        }
+        final LinkRepresentation other = (LinkRepresentation) obj;
         if (getHref() == null) {
-            if (other.getHref() != null)
+            if (other.getHref() != null) {
                 return false;
-        } else if (!getHref().equals(other.getHref()))
+            }
+        } else if (!getHref().equals(other.getHref())) {
             return false;
-        if (getHttpMethod() != other.getHttpMethod())
+        }
+        if (getHttpMethod() != other.getHttpMethod()) {
             return false;
+        }
         return true;
     }
 
@@ -156,6 +163,4 @@ public final class LinkRepresentation ex
         return "Link [rel=" + getRel() + ", href=" + getHref() + ", method=" + getHttpMethod() + ", type=" + getType() + "]";
     }
 
-
-    
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/links/Rel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/links/Rel.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/links/Rel.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/links/Rel.java Sun Jan 22 08:05:17 2012
@@ -16,53 +16,26 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.links;
-
-public enum Rel {
-    // IANA registered
-    SELF("self"),
-    DESCRIBEDBY("describedby"),
-    UP("up"), 
-    HELP("help"), 
-    ICON("icon"), 
-    
+package org.apache.isis.viewer.json.applib.links;
+
+public enum Rel {
+    // IANA registered
+    SELF("self"), DESCRIBEDBY("describedby"), UP("up"), HELP("help"), ICON("icon"),
+
     // Restful Objects namespace
-    ICON16("icon16"),
-    ICON32("icon32"),
-    OBJECT("object"), 
-    SERVICE("service"), 
-    CHOICE("choice"), 
-    DEFAULT("default"), 
-    DETAILS("details"), 
-    MODIFY("modify"), 
-    CLEAR("clear"), 
-    ADD_TO("addto"),
-    REMOVE_FROM("removefrom"), 
-    INVOKE("invoke"), 
-    PERSIST("persist"), 
-    PROPERTY("property"), 
-    COLLECTION("collection"), 
-    ACTION("action"), 
-    TYPE_ACTION("typeaction"), 
-    ACTION_PARAM("actionparam"), 
-    RETURN_TYPE("returntype"), 
-    ELEMENT_TYPE("elementtype"), 
-    VERSION("version"), 
-    USER("user"),
-    SERVICES("services"), 
-    TYPES("types"),
-    DOMAIN_TYPE("domaintype"),
-    
+    ICON16("icon16"), ICON32("icon32"), OBJECT("object"), SERVICE("service"), CHOICE("choice"), DEFAULT("default"), DETAILS("details"), MODIFY("modify"), CLEAR("clear"), ADD_TO("addto"), REMOVE_FROM("removefrom"), INVOKE("invoke"), PERSIST("persist"), PROPERTY("property"), COLLECTION("collection"), ACTION(
+            "action"), TYPE_ACTION("typeaction"), ACTION_PARAM("actionparam"), RETURN_TYPE("returntype"), ELEMENT_TYPE("elementtype"), VERSION("version"), USER("user"), SERVICES("services"), TYPES("types"), DOMAIN_TYPE("domaintype"),
+
     // implementation specific
-    CONTRIBUTED_BY("contributedby") 
-    ;
-    
-    private final String name;
-    private Rel(String name) {
-        this.name = name;
-    }
-    
-    public String getName() {
-        return name;
-    }
+    CONTRIBUTED_BY("contributedby");
+
+    private final String name;
+
+    private Rel(final String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserRepresentation.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserRepresentation.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserRepresentation.java Sun Jan 22 08:05:17 2012
@@ -16,33 +16,32 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.user;
-
+package org.apache.isis.viewer.json.applib.user;
+
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.apache.isis.viewer.json.applib.domainobjects.DomainRepresentation;
 import org.codehaus.jackson.JsonNode;
-
-
-public class UserRepresentation extends DomainRepresentation {
-
-    public UserRepresentation(JsonNode jsonNode) {
-        super(jsonNode);
-    }
-    
-    public String getUserName() {
-        return getString("userName");
-    }
-
-    public String getFriendlyName() {
-        return getString("friendlyName");
-    }
-
-    public String getEmail() {
-        return getString("email");
-    }
-
-    public JsonRepresentation getRoles() {
-        return getRepresentation("roles").ensureArray();
-    }
-
-}
+
+public class UserRepresentation extends DomainRepresentation {
+
+    public UserRepresentation(final JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+    public String getUserName() {
+        return getString("userName");
+    }
+
+    public String getFriendlyName() {
+        return getString("friendlyName");
+    }
+
+    public String getEmail() {
+        return getString("email");
+    }
+
+    public JsonRepresentation getRoles() {
+        return getRepresentation("roles").ensureArray();
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserResource.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserResource.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserResource.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserResource.java Sun Jan 22 08:05:17 2012
@@ -32,7 +32,7 @@ public interface UserResource {
 
     @GET
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_USER })
-    @ClientResponseType(entityType=String.class)
+    @ClientResponseType(entityType = String.class)
     public Response user();
 
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/Enums.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/Enums.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/Enums.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/Enums.java Sun Jan 22 08:05:17 2012
@@ -16,48 +16,48 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.util;
-
-public final class Enums {
-    
-    private Enums() {}
-
-    public static String enumToHttpHeader(Enum<?> anEnum) {
-        return enumNameToHttpHeader(anEnum.name());
-    }
-
-    public static String enumNameToHttpHeader(String name) {
-        StringBuilder builder = new StringBuilder();
-        boolean nextUpper = true;
-        for(char c: name.toCharArray()) {
-            if(c == '_') {
-                nextUpper = true;
-                builder.append("-");
-            } else {
-                builder.append(nextUpper?c:Character.toLowerCase(c));
-                nextUpper = false;
-            }
-        }
-        return builder.toString();
-    }
-
-    public static String enumToCamelCase(Enum<?> anEnum) {
-        return enumNameToCamelCase(anEnum.name());
-    }
-
-    private static String enumNameToCamelCase(String name) {
-        StringBuilder builder = new StringBuilder();
-        boolean nextUpper = false;
-        for(char c: name.toCharArray()) {
-            if(c == '_') {
-                nextUpper = true;
-            } else {
-                builder.append(nextUpper?c:Character.toLowerCase(c));
-                nextUpper = false;
-            }
-        }
-        return builder.toString();
-    }
-
-
-}
+package org.apache.isis.viewer.json.applib.util;
+
+public final class Enums {
+
+    private Enums() {
+    }
+
+    public static String enumToHttpHeader(final Enum<?> anEnum) {
+        return enumNameToHttpHeader(anEnum.name());
+    }
+
+    public static String enumNameToHttpHeader(final String name) {
+        final StringBuilder builder = new StringBuilder();
+        boolean nextUpper = true;
+        for (final char c : name.toCharArray()) {
+            if (c == '_') {
+                nextUpper = true;
+                builder.append("-");
+            } else {
+                builder.append(nextUpper ? c : Character.toLowerCase(c));
+                nextUpper = false;
+            }
+        }
+        return builder.toString();
+    }
+
+    public static String enumToCamelCase(final Enum<?> anEnum) {
+        return enumNameToCamelCase(anEnum.name());
+    }
+
+    private static String enumNameToCamelCase(final String name) {
+        final StringBuilder builder = new StringBuilder();
+        boolean nextUpper = false;
+        for (final char c : name.toCharArray()) {
+            if (c == '_') {
+                nextUpper = true;
+            } else {
+                builder.append(nextUpper ? c : Character.toLowerCase(c));
+                nextUpper = false;
+            }
+        }
+        return builder.toString();
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonMapper.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonMapper.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonMapper.java Sun Jan 22 08:05:17 2012
@@ -16,157 +16,164 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.util;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.isis.viewer.json.applib.JsonRepresentation;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.JsonParser;
-import org.codehaus.jackson.JsonProcessingException;
-import org.codehaus.jackson.Version;
-import org.codehaus.jackson.map.BeanProperty;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.DeserializationContext;
-import org.codehaus.jackson.map.DeserializerProvider;
-import org.codehaus.jackson.map.JsonDeserializer;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.JsonSerializer;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
-import org.codehaus.jackson.map.SerializerProvider;
-import org.codehaus.jackson.map.deser.BeanDeserializerFactory;
-import org.codehaus.jackson.map.deser.JsonNodeDeserializer;
-import org.codehaus.jackson.map.deser.StdDeserializerProvider;
-import org.codehaus.jackson.map.module.SimpleModule;
-import org.codehaus.jackson.type.JavaType;
-import org.jboss.resteasy.client.ClientResponse;
-
-
-public final class JsonMapper {
-
-    /**
-     * Provides polymorphic deserialization to any subtype of {@link JsonRepresentation}.
-     */
-    @SuppressWarnings("deprecation")
-    private static final class JsonRepresentationDeserializerFactory extends BeanDeserializerFactory {
-        @Override
-        public JsonDeserializer<Object> createBeanDeserializer(DeserializationConfig config, DeserializerProvider p, JavaType type, BeanProperty property) throws JsonMappingException {
-            Class<?> rawClass = type.getRawClass();
-            if (JsonRepresentation.class.isAssignableFrom(rawClass)) {
-                try {
-                    // ensure has a constructor taking a JsonNode
-                    Constructor<?> rawClassConstructor = rawClass.getConstructor(JsonNode.class);
-                    return new JsonRepresentationDeserializer(rawClassConstructor);
-                } catch (SecurityException e) {
-                    // fall through
-                } catch (NoSuchMethodException e) {
-                    // fall through
-                }
-            } 
-            return super.createBeanDeserializer(config, p, type, property);
-        }
-
-        private static final class JsonRepresentationDeserializer extends JsonDeserializer<Object> {
-            private JsonDeserializer<? extends JsonNode> jsonNodeDeser = 
-                JsonNodeDeserializer.getDeserializer(JsonNode.class);
-            
-            private final Constructor<?> rawClassConstructor;
-            public JsonRepresentationDeserializer(Constructor<?> rawClassConstructor) {
-                this.rawClassConstructor = rawClassConstructor;
-            }
-
-            @Override
-            public JsonRepresentation deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
-                JsonNode jsonNode = jsonNodeDeser.deserialize(jp, ctxt);
-                try {
-                    return (JsonRepresentation) rawClassConstructor.newInstance(jsonNode);
-                } catch (Exception e) {
-                    throw new IllegalStateException(e); 
-                }
-            }
-        }
-    }
-
-
-    private static class JsonRepresentationSerializer extends JsonSerializer<Object> {
-        @Override
-        public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
-            JsonRepresentation jsonRepresentation = (JsonRepresentation) value;
-            JsonNode jsonNode = jsonRepresentation.asJsonNode();
-            jgen.writeTree(jsonNode);
-        }
-    }
-
-    private static ObjectMapper createObjectMapper() {
-        // it's a shame that the serialization and deserialization mechanism used aren't symmetric... but it works.
-        DeserializerProvider deserializerProvider = new StdDeserializerProvider(new JsonRepresentationDeserializerFactory());
-        ObjectMapper objectMapper = new ObjectMapper(null, null, deserializerProvider);
-        SimpleModule jsonModule = new SimpleModule("json", new Version(1,0,0,null));
-        jsonModule.addSerializer(JsonRepresentation.class, new JsonRepresentationSerializer());
-        objectMapper.registerModule(jsonModule);
-        
-        objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
-        objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-        return objectMapper;
-    }
-
-
-    private static JsonMapper instance = new JsonMapper();
-
-    // threadsafe
-    public final static JsonMapper instance() {
-        return instance;
-    }
-    
-    private final ObjectMapper objectMapper;
-
-    private JsonMapper() {
-        objectMapper = createObjectMapper();
-    }
-
-    @SuppressWarnings("unchecked")
-    public Map<String, Object> readAsMap(String json) throws JsonParseException, JsonMappingException, IOException {
-        return read(json, LinkedHashMap.class);
-    }
-
-    public List<?> readAsList(String json) throws JsonParseException, JsonMappingException, IOException {
-        return read(json, ArrayList.class);
-    }
-
-    public JsonRepresentation read(String json) throws JsonParseException, JsonMappingException, IOException {
-        return read(json, JsonRepresentation.class);
-    }
-
-    public <T> T read(String json, Class<T> requiredType) throws JsonParseException, JsonMappingException, IOException {
-        return (T) objectMapper.readValue(json, requiredType);        
-    }
-
-    public <T> T read(Response response, Class<T> requiredType) throws JsonParseException, JsonMappingException, IOException {
-        final ClientResponse<?> clientResponse = (ClientResponse<?>)response; // a shame, but needed if calling resources directly
-        Object entityObj = clientResponse.getEntity(String.class);
-        if(entityObj == null) {
-            return null;
-        }
-        if(!(entityObj instanceof String)) {
-            throw new IllegalArgumentException("response entity must be a String (was " + entityObj.getClass().getName() + ")");
-        }
-        String entity = (String) entityObj;
-
-        return read(entity, requiredType);
-    }
-
-    public String write(Object object) throws JsonGenerationException, JsonMappingException, IOException {
-        return objectMapper.writeValueAsString(object);
-    }
-
+package org.apache.isis.viewer.json.applib.util;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.Version;
+import org.codehaus.jackson.map.BeanProperty;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.DeserializerProvider;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.codehaus.jackson.map.deser.BeanDeserializerFactory;
+import org.codehaus.jackson.map.deser.JsonNodeDeserializer;
+import org.codehaus.jackson.map.deser.StdDeserializerProvider;
+import org.codehaus.jackson.map.module.SimpleModule;
+import org.codehaus.jackson.type.JavaType;
+import org.jboss.resteasy.client.ClientResponse;
+
+public final class JsonMapper {
+
+    /**
+     * Provides polymorphic deserialization to any subtype of
+     * {@link JsonRepresentation}.
+     */
+    @SuppressWarnings("deprecation")
+    private static final class JsonRepresentationDeserializerFactory extends BeanDeserializerFactory {
+        @Override
+        public JsonDeserializer<Object> createBeanDeserializer(final DeserializationConfig config, final DeserializerProvider p, final JavaType type, final BeanProperty property) throws JsonMappingException {
+            final Class<?> rawClass = type.getRawClass();
+            if (JsonRepresentation.class.isAssignableFrom(rawClass)) {
+                try {
+                    // ensure has a constructor taking a JsonNode
+                    final Constructor<?> rawClassConstructor = rawClass.getConstructor(JsonNode.class);
+                    return new JsonRepresentationDeserializer(rawClassConstructor);
+                } catch (final SecurityException e) {
+                    // fall through
+                } catch (final NoSuchMethodException e) {
+                    // fall through
+                }
+            }
+            return super.createBeanDeserializer(config, p, type, property);
+        }
+
+        private static final class JsonRepresentationDeserializer extends JsonDeserializer<Object> {
+            private final JsonDeserializer<? extends JsonNode> jsonNodeDeser = JsonNodeDeserializer.getDeserializer(JsonNode.class);
+
+            private final Constructor<?> rawClassConstructor;
+
+            public JsonRepresentationDeserializer(final Constructor<?> rawClassConstructor) {
+                this.rawClassConstructor = rawClassConstructor;
+            }
+
+            @Override
+            public JsonRepresentation deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
+                final JsonNode jsonNode = jsonNodeDeser.deserialize(jp, ctxt);
+                try {
+                    return (JsonRepresentation) rawClassConstructor.newInstance(jsonNode);
+                } catch (final Exception e) {
+                    throw new IllegalStateException(e);
+                }
+            }
+        }
+    }
+
+    private static class JsonRepresentationSerializer extends JsonSerializer<Object> {
+        @Override
+        public void serialize(final Object value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException {
+            final JsonRepresentation jsonRepresentation = (JsonRepresentation) value;
+            final JsonNode jsonNode = jsonRepresentation.asJsonNode();
+            jgen.writeTree(jsonNode);
+        }
+    }
+
+    private static ObjectMapper createObjectMapper() {
+        // it's a shame that the serialization and deserialization mechanism
+        // used aren't symmetric... but it works.
+        final DeserializerProvider deserializerProvider = new StdDeserializerProvider(new JsonRepresentationDeserializerFactory());
+        final ObjectMapper objectMapper = new ObjectMapper(null, null, deserializerProvider);
+        final SimpleModule jsonModule = new SimpleModule("json", new Version(1, 0, 0, null));
+        jsonModule.addSerializer(JsonRepresentation.class, new JsonRepresentationSerializer());
+        objectMapper.registerModule(jsonModule);
+
+        objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
+        objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        return objectMapper;
+    }
+
+    private static JsonMapper instance = new JsonMapper();
+
+    // threadsafe
+    public final static JsonMapper instance() {
+        return instance;
+    }
+
+    private final ObjectMapper objectMapper;
+
+    private JsonMapper() {
+        objectMapper = createObjectMapper();
+    }
+
+    @SuppressWarnings("unchecked")
+    public Map<String, Object> readAsMap(final String json) throws JsonParseException, JsonMappingException, IOException {
+        return read(json, LinkedHashMap.class);
+    }
+
+    public List<?> readAsList(final String json) throws JsonParseException, JsonMappingException, IOException {
+        return read(json, ArrayList.class);
+    }
+
+    public JsonRepresentation read(final String json) throws JsonParseException, JsonMappingException, IOException {
+        return read(json, JsonRepresentation.class);
+    }
+
+    public <T> T read(final String json, final Class<T> requiredType) throws JsonParseException, JsonMappingException, IOException {
+        return objectMapper.readValue(json, requiredType);
+    }
+
+    public <T> T read(final Response response, final Class<T> requiredType) throws JsonParseException, JsonMappingException, IOException {
+        final ClientResponse<?> clientResponse = (ClientResponse<?>) response; // a
+                                                                               // shame,
+                                                                               // but
+                                                                               // needed
+                                                                               // if
+                                                                               // calling
+                                                                               // resources
+                                                                               // directly
+        final Object entityObj = clientResponse.getEntity(String.class);
+        if (entityObj == null) {
+            return null;
+        }
+        if (!(entityObj instanceof String)) {
+            throw new IllegalArgumentException("response entity must be a String (was " + entityObj.getClass().getName() + ")");
+        }
+        final String entity = (String) entityObj;
+
+        return read(entity, requiredType);
+    }
+
+    public String write(final Object object) throws JsonGenerationException, JsonMappingException, IOException {
+        return objectMapper.writeValueAsString(object);
+    }
+
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonNodeUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonNodeUtils.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonNodeUtils.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonNodeUtils.java Sun Jan 22 08:05:17 2012
@@ -16,59 +16,61 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.List;
-
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.node.JsonNodeFactory;
-import org.codehaus.jackson.node.ObjectNode;
-
-import com.google.common.base.Charsets;
-
-public class JsonNodeUtils {
-    
-    private JsonNodeUtils(){}
-
-    public static InputStream asInputStream(JsonNode jsonNode) {
-        String jsonStr = jsonNode.toString();
-        byte[] bytes = jsonStr.getBytes(Charsets.UTF_8);
-        return new ByteArrayInputStream(bytes);
-    }
-
-    /**
-     * Walks the path, ensuring keys exist and are maps, or creating required
-     * maps as it goes.
-     * 
-     * <p>
-     * For example, if given a list ("a", "b", "c") and starting with an empty map,
-     * then will create:
-     * <pre>
+package org.apache.isis.viewer.json.applib.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.List;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.node.JsonNodeFactory;
+import org.codehaus.jackson.node.ObjectNode;
+
+import com.google.common.base.Charsets;
+
+public class JsonNodeUtils {
+
+    private JsonNodeUtils() {
+    }
+
+    public static InputStream asInputStream(final JsonNode jsonNode) {
+        final String jsonStr = jsonNode.toString();
+        final byte[] bytes = jsonStr.getBytes(Charsets.UTF_8);
+        return new ByteArrayInputStream(bytes);
+    }
+
+    /**
+     * Walks the path, ensuring keys exist and are maps, or creating required
+     * maps as it goes.
+     * 
+     * <p>
+     * For example, if given a list ("a", "b", "c") and starting with an empty
+     * map, then will create:
+     * 
+     * <pre>
      * {
      *   "a": {
      *     "b: {
      *       "c": {
      *       }       
      *     }
-     *   }
-     * }
-     */
-    public static ObjectNode walkNodeUpTo(ObjectNode node, List<String> keys) {
-        for (String key : keys) {
-            JsonNode jsonNode = node.get(key);
-            if(jsonNode == null) {
-                jsonNode = new ObjectNode(JsonNodeFactory.instance);
-                node.put(key, jsonNode);
-            } else {
-                if(!jsonNode.isObject()) {
-                    throw new IllegalArgumentException(String.format("walking path: '%s', existing key '%s' is not a map", keys, key));
-                }
-            }
-            node = (ObjectNode) jsonNode;
-        }
-        return (ObjectNode) node;
-    }
-
-}
+     *   }
+     * }
+     */
+    public static ObjectNode walkNodeUpTo(ObjectNode node, final List<String> keys) {
+        for (final String key : keys) {
+            JsonNode jsonNode = node.get(key);
+            if (jsonNode == null) {
+                jsonNode = new ObjectNode(JsonNodeFactory.instance);
+                node.put(key, jsonNode);
+            } else {
+                if (!jsonNode.isObject()) {
+                    throw new IllegalArgumentException(String.format("walking path: '%s', existing key '%s' is not a map", keys, key));
+                }
+            }
+            node = (ObjectNode) jsonNode;
+        }
+        return node;
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/Parser.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/Parser.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/Parser.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/Parser.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.json.applib.util;
-
+package org.apache.isis.viewer.json.applib.util;
+
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
@@ -35,317 +35,328 @@ import com.google.common.base.Joiner;
 import com.google.common.base.Splitter;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
-
-public abstract class Parser<T> {
-    public T valueOf(List<String> str) {
-        if(str == null) {
-            return null;
-        }
-        if(str.size()==0)
-            return null;
-        return valueOf(str.get(0));
-    }
-    public T valueOf(String[] str) {
-        if(str == null) {
-            return null;
-        }
-        if(str.length==0)
-            return null;
-        return valueOf(str[0]);
+
+public abstract class Parser<T> {
+    public T valueOf(final List<String> str) {
+        if (str == null) {
+            return null;
+        }
+        if (str.size() == 0) {
+            return null;
+        }
+        return valueOf(str.get(0));
+    }
+
+    public T valueOf(final String[] str) {
+        if (str == null) {
+            return null;
+        }
+        if (str.length == 0) {
+            return null;
+        }
+        return valueOf(str[0]);
     }
-    public T valueOf(JsonRepresentation jsonRepresentation) {
-        if(jsonRepresentation == null) {
+
+    public T valueOf(final JsonRepresentation jsonRepresentation) {
+        if (jsonRepresentation == null) {
             return null;
         }
         return valueOf(jsonRepresentation.asString());
     }
-    public JsonRepresentation asJsonRepresentation(T t) {
+
+    public JsonRepresentation asJsonRepresentation(final T t) {
         return JsonRepresentation.newMap("dummy", asString(t)).getRepresentation("dummy");
     }
-    
-
-    public abstract T valueOf(String str);
-    public abstract String asString(T t);
-
-    public final static Parser<String> forString() {
-        return new Parser<String>() {
-            @Override
-            public String valueOf(String str) {
-                return str;
-            }
-            @Override
-            public String asString(String t) {
-                return t;
-            }
-        };
-    }
-
-    public static Parser<Date> forDate() {
-
-        return new Parser<Date>() {
-            private final SimpleDateFormat RFC1123_DATE_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyyy HH:mm:ss z");
-
-            @Override
-            public Date valueOf(String str) {
-                if(str == null) {
-                    return null;
-                }
-                try {
-                    return RFC1123_DATE_FORMAT.parse(str);
-                } catch (ParseException e) {
-                    return null;
-                }
-            }
-            @Override
-            public String asString(Date t) {
-                return RFC1123_DATE_FORMAT.format(t);
-            }
-        };
-    }
-
-    public static Parser<CacheControl> forCacheControl() {
-        return new Parser<CacheControl>(){
-            @Override
-            public CacheControl valueOf(String str) {
-                if(str == null) {
-                    return null;
-                }
-                final CacheControl cacheControl = CacheControl.valueOf(str);
-                // workaround for bug in CacheControl's equals() method
-                cacheControl.getCacheExtension(); 
-                cacheControl.getNoCacheFields();
-                return cacheControl;
-            }
-            @Override
-            public String asString(CacheControl cacheControl) {
-                return cacheControl.toString();
-            }};
-    }
-
-    public static Parser<MediaType> forMediaType() {
-        return new Parser<MediaType>() {
-            @Override
-            public MediaType valueOf(String str) {
-                if(str == null) {
-                    return null;
-                }
-                return MediaType.valueOf(str);
-            }
-
-            @Override
-            public String asString(MediaType t) {
-                return t.toString();
-            }
-            
-        };
-    }
-
-    public static Parser<Boolean> forBoolean() {
-        return new Parser<Boolean>() {
-            @Override
-            public Boolean valueOf(String str) {
-                if(str == null) {
-                    return null;
-                }
-                return str.equals("yes")?Boolean.TRUE:Boolean.FALSE;
-            }
-
-            @Override
-            public String asString(Boolean t) {
-                return t?"yes":"no";
-            }
-            
-        };
-    }
-
-    public static Parser<Integer> forInteger() {
-        return new Parser<Integer>() {
-
-            @Override
-            public Integer valueOf(String str) {
-                if(str == null) {
-                    return null;
-                }
-                return Integer.valueOf(str);
-            }
-
-            @Override
-            public String asString(Integer t) {
-                return t.toString();
-            }};
-    }
-
-    public static Parser<List<String>> forListOfStrings() {
-        return new Parser<List<String>>() {
-
-            @Override
-            public List<String> valueOf(List<String> strings) {
-                if(strings == null) {
-                    return Collections.emptyList();
-                }
-                if(strings.size() == 1) {
-                    // special case processing to handle comma-separated values
-                    return valueOf(strings.get(0));
-                }
-                return strings;
-            }
-            
-            @Override
-            public List<String> valueOf(String[] strings) {
-                if(strings == null) {
-                    return Collections.emptyList();
-                }
-                if(strings.length == 1) {
-                    // special case processing to handle comma-separated values
-                    return valueOf(strings[0]);
-                }
-                return Arrays.asList(strings);
-            }
-            
-            @Override
-            public List<String> valueOf(String str) {
-                if(str == null) {
-                    return Collections.emptyList();
-                }
-                return Lists.newArrayList(Splitter.on(",").split(str));
-            }
-
-            @Override
-            public String asString(List<String> strings) {
-                return Joiner.on(",").join(strings);
-            }
-        };
-    }
-
-    public static Parser<List<List<String>>> forListOfListOfStrings() {
-        return new Parser<List<List<String>>>() {
-
-            @Override
-            public List<List<String>> valueOf(List<String> str) {
-                if(str == null) {
-                    return null;
-                }
-                if(str.size()==0)
-                    return null;
-                List<List<String>> listOfLists = Lists.newArrayList();
-                for (String s : str) {
-                    final Iterable<String> split = Splitter.on('.').split(s);
-                    listOfLists.add(Lists.newArrayList(split));
-                }
-                return listOfLists;
-            }
-            
-            @Override
-            public List<List<String>> valueOf(String[] str) {
-                if(str == null) {
-                    return null;
-                }
-                if(str.length==0)
-                    return null;
-                return valueOf(Arrays.asList(str));
-            }
-
-            @Override
-            public List<List<String>> valueOf(String str) {
-                if(str == null || str.isEmpty()) {
-                    return Collections.emptyList();
-                }
-                final Iterable<String> listOfStrings = Splitter.on(',').split(str);
-                return Lists.transform(Lists.newArrayList(listOfStrings), new Function<String, List<String>>() {
-
-                    @Override
-                    public List<String> apply(String input) {
-                        return Lists.newArrayList(Splitter.on('.').split(input));
-                    }
-                });
-            }
-
-            @Override
-            public String asString(List<List<String>> listOfLists) {
-                List<String> listOfStrings = Lists.transform(listOfLists, new Function<List<String>, String>() {
-                    @Override
-                    public String apply(List<String> listOfStrings) {
-                        return Joiner.on('.').join(listOfStrings);
-                    }
-                });
-                return Joiner.on(',').join(listOfStrings);
-            }
-        };
-    }
-
-
-    public static Parser<String[]> forArrayOfStrings() {
-        return new Parser<String[]>() {
-
-            @Override
-            public String[] valueOf(List<String> strings) {
-                if(strings == null) {
-                    return new String[]{};
-                }
-                if(strings.size() == 1) {
-                    // special case processing to handle comma-separated values
-                    return valueOf(strings.get(0));
-                }
-                return strings.toArray(new String[]{});
-            }
-            
-            @Override
-            public String[] valueOf(String[] strings) {
-                if(strings == null) {
-                    return new String[]{};
-                }
-                if(strings.length == 1) {
-                    // special case processing to handle comma-separated values
-                    return valueOf(strings[0]);
-                }
-                return strings;
-            }
-            
-            @Override
-            public String[] valueOf(String str) {
-                if(str == null) {
-                    return new String[]{};
-                }
-                Iterable<String> split = Splitter.on(",").split(str);
-                return Iterables.toArray(split, String.class);
-            }
-
-            @Override
-            public String asString(String[] strings) {
-                return Joiner.on(",").join(strings);
-            }
-        };
-    }
-    
-    public static Parser<List<MediaType>> forListOfMediaTypes() {
-        return new Parser<List<MediaType>>() {
-
-            @Override
-            public List<MediaType> valueOf(String str) {
-                if(str == null) {
-                    return Collections.emptyList();
-                }
-                final List<String> strings = Lists.newArrayList(Splitter.on(",").split(str));
-                return Lists.transform(strings, (Function<? super String, ? extends MediaType>) new Function<String, MediaType>() {
-
-                    @Override
-                    public MediaType apply(String input) {
-                        return MediaType.valueOf(input);
-                    }
-                });
-            }
-
-            @Override
-            public String asString(List<MediaType> listOfMediaTypes) {
-                final List<String> strings = Lists.transform(listOfMediaTypes, new Function<MediaType, String>() {
-                    @Override
-                    public String apply(MediaType input) {
-                        return input.toString();
-                    }
-                });
-                return Joiner.on(",").join(strings);
-            }
-        };
-    }
-    
-}
+
+    public abstract T valueOf(String str);
+
+    public abstract String asString(T t);
+
+    public final static Parser<String> forString() {
+        return new Parser<String>() {
+            @Override
+            public String valueOf(final String str) {
+                return str;
+            }
+
+            @Override
+            public String asString(final String t) {
+                return t;
+            }
+        };
+    }
+
+    public static Parser<Date> forDate() {
+
+        return new Parser<Date>() {
+            private final SimpleDateFormat RFC1123_DATE_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyyy HH:mm:ss z");
+
+            @Override
+            public Date valueOf(final String str) {
+                if (str == null) {
+                    return null;
+                }
+                try {
+                    return RFC1123_DATE_FORMAT.parse(str);
+                } catch (final ParseException e) {
+                    return null;
+                }
+            }
+
+            @Override
+            public String asString(final Date t) {
+                return RFC1123_DATE_FORMAT.format(t);
+            }
+        };
+    }
+
+    public static Parser<CacheControl> forCacheControl() {
+        return new Parser<CacheControl>() {
+            @Override
+            public CacheControl valueOf(final String str) {
+                if (str == null) {
+                    return null;
+                }
+                final CacheControl cacheControl = CacheControl.valueOf(str);
+                // workaround for bug in CacheControl's equals() method
+                cacheControl.getCacheExtension();
+                cacheControl.getNoCacheFields();
+                return cacheControl;
+            }
+
+            @Override
+            public String asString(final CacheControl cacheControl) {
+                return cacheControl.toString();
+            }
+        };
+    }
+
+    public static Parser<MediaType> forMediaType() {
+        return new Parser<MediaType>() {
+            @Override
+            public MediaType valueOf(final String str) {
+                if (str == null) {
+                    return null;
+                }
+                return MediaType.valueOf(str);
+            }
+
+            @Override
+            public String asString(final MediaType t) {
+                return t.toString();
+            }
+
+        };
+    }
+
+    public static Parser<Boolean> forBoolean() {
+        return new Parser<Boolean>() {
+            @Override
+            public Boolean valueOf(final String str) {
+                if (str == null) {
+                    return null;
+                }
+                return str.equals("yes") ? Boolean.TRUE : Boolean.FALSE;
+            }
+
+            @Override
+            public String asString(final Boolean t) {
+                return t ? "yes" : "no";
+            }
+
+        };
+    }
+
+    public static Parser<Integer> forInteger() {
+        return new Parser<Integer>() {
+
+            @Override
+            public Integer valueOf(final String str) {
+                if (str == null) {
+                    return null;
+                }
+                return Integer.valueOf(str);
+            }
+
+            @Override
+            public String asString(final Integer t) {
+                return t.toString();
+            }
+        };
+    }
+
+    public static Parser<List<String>> forListOfStrings() {
+        return new Parser<List<String>>() {
+
+            @Override
+            public List<String> valueOf(final List<String> strings) {
+                if (strings == null) {
+                    return Collections.emptyList();
+                }
+                if (strings.size() == 1) {
+                    // special case processing to handle comma-separated values
+                    return valueOf(strings.get(0));
+                }
+                return strings;
+            }
+
+            @Override
+            public List<String> valueOf(final String[] strings) {
+                if (strings == null) {
+                    return Collections.emptyList();
+                }
+                if (strings.length == 1) {
+                    // special case processing to handle comma-separated values
+                    return valueOf(strings[0]);
+                }
+                return Arrays.asList(strings);
+            }
+
+            @Override
+            public List<String> valueOf(final String str) {
+                if (str == null) {
+                    return Collections.emptyList();
+                }
+                return Lists.newArrayList(Splitter.on(",").split(str));
+            }
+
+            @Override
+            public String asString(final List<String> strings) {
+                return Joiner.on(",").join(strings);
+            }
+        };
+    }
+
+    public static Parser<List<List<String>>> forListOfListOfStrings() {
+        return new Parser<List<List<String>>>() {
+
+            @Override
+            public List<List<String>> valueOf(final List<String> str) {
+                if (str == null) {
+                    return null;
+                }
+                if (str.size() == 0) {
+                    return null;
+                }
+                final List<List<String>> listOfLists = Lists.newArrayList();
+                for (final String s : str) {
+                    final Iterable<String> split = Splitter.on('.').split(s);
+                    listOfLists.add(Lists.newArrayList(split));
+                }
+                return listOfLists;
+            }
+
+            @Override
+            public List<List<String>> valueOf(final String[] str) {
+                if (str == null) {
+                    return null;
+                }
+                if (str.length == 0) {
+                    return null;
+                }
+                return valueOf(Arrays.asList(str));
+            }
+
+            @Override
+            public List<List<String>> valueOf(final String str) {
+                if (str == null || str.isEmpty()) {
+                    return Collections.emptyList();
+                }
+                final Iterable<String> listOfStrings = Splitter.on(',').split(str);
+                return Lists.transform(Lists.newArrayList(listOfStrings), new Function<String, List<String>>() {
+
+                    @Override
+                    public List<String> apply(final String input) {
+                        return Lists.newArrayList(Splitter.on('.').split(input));
+                    }
+                });
+            }
+
+            @Override
+            public String asString(final List<List<String>> listOfLists) {
+                final List<String> listOfStrings = Lists.transform(listOfLists, new Function<List<String>, String>() {
+                    @Override
+                    public String apply(final List<String> listOfStrings) {
+                        return Joiner.on('.').join(listOfStrings);
+                    }
+                });
+                return Joiner.on(',').join(listOfStrings);
+            }
+        };
+    }
+
+    public static Parser<String[]> forArrayOfStrings() {
+        return new Parser<String[]>() {
+
+            @Override
+            public String[] valueOf(final List<String> strings) {
+                if (strings == null) {
+                    return new String[] {};
+                }
+                if (strings.size() == 1) {
+                    // special case processing to handle comma-separated values
+                    return valueOf(strings.get(0));
+                }
+                return strings.toArray(new String[] {});
+            }
+
+            @Override
+            public String[] valueOf(final String[] strings) {
+                if (strings == null) {
+                    return new String[] {};
+                }
+                if (strings.length == 1) {
+                    // special case processing to handle comma-separated values
+                    return valueOf(strings[0]);
+                }
+                return strings;
+            }
+
+            @Override
+            public String[] valueOf(final String str) {
+                if (str == null) {
+                    return new String[] {};
+                }
+                final Iterable<String> split = Splitter.on(",").split(str);
+                return Iterables.toArray(split, String.class);
+            }
+
+            @Override
+            public String asString(final String[] strings) {
+                return Joiner.on(",").join(strings);
+            }
+        };
+    }
+
+    public static Parser<List<MediaType>> forListOfMediaTypes() {
+        return new Parser<List<MediaType>>() {
+
+            @Override
+            public List<MediaType> valueOf(final String str) {
+                if (str == null) {
+                    return Collections.emptyList();
+                }
+                final List<String> strings = Lists.newArrayList(Splitter.on(",").split(str));
+                return Lists.transform(strings, new Function<String, MediaType>() {
+
+                    @Override
+                    public MediaType apply(final String input) {
+                        return MediaType.valueOf(input);
+                    }
+                });
+            }
+
+            @Override
+            public String asString(final List<MediaType> listOfMediaTypes) {
+                final List<String> strings = Lists.transform(listOfMediaTypes, new Function<MediaType, String>() {
+                    @Override
+                    public String apply(final MediaType input) {
+                        return input.toString();
+                    }
+                });
+                return Joiner.on(",").join(strings);
+            }
+        };
+    }
+
+}



Mime
View raw message