This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git
commit 526d53aa4cca25fb57f9caac8676c4c9a8070ae4 Author: Bertrand Delacretaz <[email protected]> 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@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 "[email protected]" <[email protected]>.
