You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:36:42 UTC

[sling-org-apache-sling-hapi-client] 06/24: SLING-5390 - Allow HApi microdata client to fitler links and forms - contributed by Andrei Dulvac, thanks!

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 24ff60ea046e7b8984364ef369f15bb59e3d5c12
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Dec 18 13:27:21 2015 +0000

    SLING-5390 - Allow HApi microdata client to fitler links and forms - contributed by Andrei Dulvac, thanks!
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1720780 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/hapi/client/Item.java    | 10 ++++++++
 .../hapi/client/microdata/MicrodataDocument.java   | 28 ++++++++++++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/hapi/client/Item.java b/src/main/java/org/apache/sling/hapi/client/Item.java
index f1d8865..fa74107 100644
--- a/src/main/java/org/apache/sling/hapi/client/Item.java
+++ b/src/main/java/org/apache/sling/hapi/client/Item.java
@@ -44,11 +44,21 @@ public interface Item {
     Items link(String rel) throws ClientException;
 
     /**
+     * Returns all the child links
+     */
+    Items link() throws ClientException;
+
+    /**
      * Returns the child forms that have the given relation
      */
     Items form(String rel) throws ClientException;
 
     /**
+     * Returns all the child forms
+     */
+    Items form() throws ClientException;
+
+    /**
      * Returns the text value of the property.
      */
     String text() throws ClientException;
diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java b/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
index 2f6ee91..e71df99 100644
--- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
+++ b/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
@@ -133,12 +133,26 @@ public class MicrodataDocument implements Document {
 
         @Override
         public Items link(String rel) throws ClientException {
-            return new ItemsImpl(toItems(getProxy().el.select("link[rel=" + rel + "], a[rel=" + rel + "]")));
+            String selector = "link[rel=" + rel + "], a[rel=" + rel + "], link" + toClass(rel) + ", a" + toClass(rel);
+            return new ItemsImpl(toItems(getProxy().el.select(selector)));
+        }
+
+        @Override
+        public Items link() throws ClientException {
+            String selector = "link, a";
+            return new ItemsImpl(toItems(getProxy().el.select(selector)));
         }
 
         @Override
         public Items form(String rel) throws ClientException {
-            return new ItemsImpl(toItems(getProxy().el.select("form[data-rel=" + rel + "]")));
+            String selector = "form[data-rel=" + rel + "], form" + toClass(rel);
+            return new ItemsImpl(toItems(getProxy().el.select(selector)));
+        }
+
+        @Override
+        public Items form() throws ClientException {
+            String selector = "form";
+            return new ItemsImpl(toItems(getProxy().el.select(selector)));
         }
 
 
@@ -356,11 +370,21 @@ public class MicrodataDocument implements Document {
         }
 
         @Override
+        public Items link() throws ClientException {
+            return items.get(0).link();
+        }
+
+        @Override
         public Items form(String rel) throws ClientException {
             return items.get(0).form(rel);
         }
 
         @Override
+        public Items form() throws ClientException {
+            return items.get(0).form();
+        }
+
+        @Override
         public String text() throws ClientException {
             return items.get(0).text();
         }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.