incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r591002 - in /incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource: NonExistingResource.java ResourceMetadata.java
Date Thu, 01 Nov 2007 13:41:02 GMT
Author: fmeschbe
Date: Thu Nov  1 06:41:01 2007
New Revision: 591002

URL: http://svn.apache.org/viewvc?rev=591002&view=rev
Log:
SLING-28 Create simple NonExistingResource class as proposed and convert
the ResourceMetadata into a class, which makes using it easier
(http://www.mail-archive.com/sling-dev@incubator.apache.org/msg00755.html)

Added:
    incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java
Modified:
    incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceMetadata.java

Added: incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java?rev=591002&view=auto
==============================================================================
--- incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java
(added)
+++ incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java
Thu Nov  1 06:41:01 2007
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.api.resource;
+
+/**
+ * Simple helper class representing nonexisting resources.
+ */
+public final class NonExistingResource implements Resource {
+
+    private final String resourceURI;
+
+    private final ResourceMetadata resourceMetadata;
+
+    public NonExistingResource(String resourceURI) {
+        this.resourceURI = resourceURI;
+
+        resourceMetadata = new ResourceMetadata();
+        resourceMetadata.put(ResourceMetadata.RESOLUTION_PATH, resourceURI);
+    }
+
+    public String getURI() {
+        return resourceURI;
+    }
+
+    public String getResourceType() {
+        return RESOURCE_TYPE_NON_EXISTING;
+    }
+
+    public ResourceMetadata getResourceMetadata() {
+        return resourceMetadata;
+    }
+
+    /** Returns null for a non-existing resource */
+    public Object getRawData() {
+        return null;
+    }
+
+    /** Returns null for a non-existing resource */
+    public Object getObject() {
+        return null;
+    }
+
+}

Modified: incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceMetadata.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceMetadata.java?rev=591002&r1=591001&r2=591002&view=diff
==============================================================================
--- incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceMetadata.java
(original)
+++ incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceMetadata.java
Thu Nov  1 06:41:01 2007
@@ -18,7 +18,8 @@
  */
 package org.apache.sling.api.resource;
 
-import java.util.Map;
+import java.util.HashMap;
+
 
 /**
  * The <code>ResourceMetadata</code> interface defines the API for the
@@ -34,7 +35,7 @@
  * Note, that the prefix <em>sling.</em> to key names is reserved for the
  * Sling implementation.
  */
-public interface ResourceMetadata extends Map<String, Object> {
+public class ResourceMetadata extends HashMap<String, Object> {
 
     /**
      * The name of the required property providing the part of the request URI



Mime
View raw message