{"id":26715574,"url":"https://github.com/jebailey/sling-resourcelocator","last_synced_at":"2025-04-14T00:35:04.392Z","repository":{"id":43608829,"uuid":"61373532","full_name":"JEBailey/sling-resourcelocator","owner":"JEBailey","description":"Apache Sling Resource Locator Utility","archived":false,"fork":false,"pushed_at":"2018-02-11T12:46:47.000Z","size":216,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T14:49:20.855Z","etag":null,"topics":["fd","fluent-interface","predicates","sling"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JEBailey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-17T12:55:52.000Z","updated_at":"2019-11-22T23:05:07.000Z","dependencies_parsed_at":"2022-08-19T02:51:11.665Z","dependency_job_id":null,"html_url":"https://github.com/JEBailey/sling-resourcelocator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JEBailey%2Fsling-resourcelocator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JEBailey%2Fsling-resourcelocator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JEBailey%2Fsling-resourcelocator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JEBailey%2Fsling-resourcelocator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JEBailey","download_url":"https://codeload.github.com/JEBailey/sling-resourcelocator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248801877,"owners_count":21163739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fd","fluent-interface","predicates","sling"],"created_at":"2025-03-27T14:33:20.171Z","updated_at":"2025-04-14T00:35:04.347Z","avatar_url":"https://github.com/JEBailey.png","language":"Java","readme":"# Resource Locator Utility\n\n[![Join the chat at https://gitter.im/sling-resourcelocator/Lobby](https://badges.gitter.im/sling-resourcelocator/Lobby.svg)](https://gitter.im/sling-resourcelocator/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n* Resource Locator Utility for Apache Sling \n* Fluent interface for filtering of a resource tree.\n* Predefined predicates for Resources and Properties\n* Filter language to easily define predicates\n\nExample of a traversal.\n\n```java\nResourceLocator\n\t.startFrom(resource)\n\t.traversalControl(\n\t\twhere(property(\"jcr:primaryType\").is(\"cq:Page\")))\n\t.locateResources(\n\t\twhere(aChildResource(\"jcr:content\")\n\t\t\t.has(property(\"sling:resourceType\")\n\t\t\t.isNot(\"sas/components/page/folder\"))));\n```\n\nsame results using the filter language\n\n```java\nResourceLocator\n    .startFrom(resource)\n    .traversalControl(\"[jcr:primaryType] == 'cq:Page'\")\n    .locateResources(\"[jcr:content/sling:resourceType] != 'sas/components/page/folder'\");\n```\n\n\nThe ResourceLocator provides \n\n1. The ResourceLocator which provides a fluent interface to perform a recursive traversal of a given resource tree with the ability to set specific constraints and predicates.\n2. A series of predicates have been defined around the Resource object(s) to assist in filtering out unwanted resources. These predicates are independent of the ResourceLocator\n3. A domain specific language to create a predicate which filters the streamed resources.\n\n## Filter Language\nDerivative of JCR-SQL2.\n\n### Operators\n\n| Name       | Comparison Type | Description                                |\n| ---------  | --------------- | --------------------------------           |\n| and        | NA              | Logical AND                                |\n| \u0026\u0026         | NA              | Logical AND                                |\n| or         | NA              | Logical OR                                 |\n|\u0026#124;\u0026#124;| NA              | Logical OR                                 |\n| ==         | String          | Equal operator for Strings                 |\n| \u003c          | Number         | Less than operator for Numbers             |\n| \u003c=         | Number         | Less than or equal operator for Numbers    |\n| \u003e          | Number         | Greater than operator for Numbers          |\n| \u003e=         | Number         | Greater than or equal operator for Numbers |\n| !=         | String          | Is not equal to for Strings                |\n| less than  | Number         | less than operator for Numbers             |\n| greater than| Number        | greater than operator for Numbers          |\n| is          | String         | Equal operator for Strings                 |\n| is not      | String         | Is not equal operator for Strings          |\n| like        | String - Regex  | Regex match against String                |\n| like not    | String - Regex  | Regex match against String                |\n| not like    | String - Regex  | Same as 'like not'               |\n| contains         | String[] \u0026#124; String[] | String[] contains all of items |\n| contains not     | String[] | String[] does not contain all of the items |\n| contains any     | String[] | String[] contains at least one of items |\n| contains not any | String[] | String[] does not contain any of the items |\n### Logical Operators\nThe 'and' and 'or' operators are logical operators that string together conditions. 'And' operators take precedence. 'Or' operators evaluate from left to right\n\n\n### Values\n\nValues for comparison are obtained through multiple methods\n\n| Method       | Description                               |\n| ----------   | ----------------------------------------  |\n| Literal      | Single(') or double (\") quoted text in the query will be interpreted as a String. Boolean values of *true* and *false* will be translated to a String. |\n| Property     | A String between square brackets '[',']'s will be interpreted as a property value and will be retrieved from the Resource using the get method |\n| Function     | A string followed by parens containing an optional comma separated list of values. |\n\n### Types\nAll types are converted to either a String or a Number. For direct equivalence the comparison is done as a String. For relational comparisons the object will be adapted to a number.\n\n### Dates/Instants\nDates are a special, there are multiple ways to enter a date.\n\nInline, as part of the query, a date can be identified as a string that conforms to a standard ISO-8601 date time.\n\n\u003e '2013-08-08T16:32:59.000'\n\u003e\n\u003e '2013-08-08T16:32:59'\n\u003e\n\u003e '2013-08-08T16:32'\n\nAre all valid date representations that are defaulting to the UTC timezone.\n\nFor a ISO8601 date with timezone offset use the date function.\n\n\u003e date('2013-08-08T16:32:59.000+02:00')\n\nIf you need a different date format then the date function can accommodate that\n\n\u003e date('2013-08-08','yyyy-MM-dd')\n\nOr you could just add your own custom Function \n\nDates are transitionally represented as a java.util.Instant which is then converted to a String in ISO-8601 format or as a Long number based on the type of comparison. The number representing the time in milliseconds since the EPOCH UTC region\n\n### Functions\n\nFunctions provide the ability to add additional functionality to the Filter language. A Function is written in the format\n\n\u003e string '(' comma, separated, list() ')'\n\nAll functions MUST return either a String, a Number, or an Instant. Strings are assumed to be using the default UTF encoding.\n\nOOTB Functions are:\n\n| Name  | Arguments | Returns | Description                                                    |\n| ----  | --------- | ------- | -----------------------------------                            |\n| name  | none      | String  | Provides the name of the resource                              |\n| date  | 0 - 2     | Instant | First argument is string representation of the date, second argument is a standard Java DateFormat representation of the value. No argument returns the current time. |\n| path  | none\t\t| String  | path of the tested resource        |\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjebailey%2Fsling-resourcelocator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjebailey%2Fsling-resourcelocator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjebailey%2Fsling-resourcelocator/lists"}