Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Declare text files with unix file ending
*.conf text eol=lf
*.config text eol=lf
*.css text eol=lf
*.dtd text eol=lf
*.esp text eol=lf
*.ecma text eol=lf
*.groovy text eol=lf
*.hbrs text eol=lf
*.hbs text eol=lf
*.htm text eol=lf
*.html text eol=lf
*.java text eol=lf
*.jpage text eol=lf
*.js text eol=lf
*.json text eol=lf
*.jsp text eol=lf
*.mustache text eol=lf
*.tld text eol=lf
*.launch text eol=lf
*.log text eol=lf
*.php text eol=lf
*.pl text eol=lf
*.project text eol=lf
*.properties text eol=lf
*.props text eol=lf
*.sass text eol=lf
*.scss text eol=lf
*.sh text eol=lf
*.shtm text eol=lf
*.shtml text eol=lf
*.sql text eol=lf
*.svg text eol=lf
*.txt text eol=lf
*.vm text eol=lf
*.xml text eol=lf
*.xsd text eol=lf
*.xsl text eol=lf
*.xslt text eol=lf
*.yml text eol=lf
*.yaml text eol=lf


# Declare windows-specific text files with windows file ending
*.asp text eol=crlf
*.asax text eol=crlf
*.asa text eol=crlf
*.aspx text eol=crlf
*.bat text eol=crlf
*.cmd text eol=crlf
*.cs text eol=crlf
*.csproj text eol=crlf
*.reg text eol=crlf
*.sln text eol=crlf
34 changes: 34 additions & 0 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Build validation

name: Build

on:
push:
branches:
- develop
pull_request:
workflow_dispatch:

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [17]
Comment thread
stefanseifert marked this conversation as resolved.
os: [ubuntu-latest]
distribution: [temurin]

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java }}
cache: maven

- name: Build and verify
run: mvn -Pcontinuous-integration -B -U clean verify
31 changes: 31 additions & 0 deletions .github/workflows/maven-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Deploy snapshots to Sonatype OSS repository and deploy site to GitHub Pages

name: Deploy

on:
push:
branches:
- develop
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: maven

- name: Build, verify, deploy
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: mvn -Pcontinuous-integration -B -U clean deploy
24 changes: 0 additions & 24 deletions .github/workflows/maven.yml

This file was deleted.

56 changes: 29 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
*.class
*~
.*.swp
.*.swo
.loadpath
.buildpath
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
maven-eclipse.xml
infinitest.filters

node_modules/
npm-debug.log

.nodejs
.project
.settings
.classpath
.metadata
.springBeans
.settings
.externalToolBuilders
.pmd
.eclipse-pmd
.checkstyle
.idea
.vagrant
*.iml
*.ipr
*.iws
git.properties
*.log
.checkstyle
nbproject
.DS_Store
target
test-output
nbactions.xml
build
release.properties
**/pom.xml.backup
**/release.properties
**/pom.xml.branch
**/pom.xml.next
**/pom.xml.releaseBackup
**/pom.xml.tag
atlassian-ide-plugin.xml
*.retry
.rubygems
.sass-cache
.rubygems-gem-maven-plugin
*.sublime-*
*nbactions*.xml
.temp/
.vlt
.vlt-sync*
.brackets.json
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

15 changes: 4 additions & 11 deletions LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
Copyright (c) 2012, Ryan J. McDonough
All rights reserved.

====================================================================
Licensed under the Apache License, Version 2.0. Text as follows.


Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -185,15 +178,15 @@ Licensed under the Apache License, Version 2.0. Text as follows.
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright {yyyy} {name of copyright owner}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -205,4 +198,4 @@ Licensed under the Apache License, Version 2.0. Text as follows.
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.
limitations under the License.
62 changes: 19 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Handy URI Templates
# wcm.io Caravan Handy URI Templates
[![Build](https://github.com/wcm-io-caravan/wcm-io-handy-uri-templates/actions/workflows/maven-build.yml/badge.svg?branch=develop)](https://github.com/wcm-io-caravan/wcm-io-handy-uri-templates/actions?query=workflow%3ABuild+branch%3Adevelop)
[![Maven Central](https://img.shields.io/maven-central/v/io.wcm.caravan/wcm-io-handy-uri-templates)](https://repo1.maven.org/maven2/io/wcm/caravan/wcm-io-handy-uri-templates/)

[![Join the chat at https://gitter.im/damnhandy/Handy-URI-Templates](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/damnhandy/Handy-URI-Templates?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Build Status](https://secure.travis-ci.org/damnhandy/Handy-URI-Templates.png?branch=master)](http://travis-ci.org/damnhandy/Handy-URI-Templates)
> [!NOTE]
> This project is a fork of [Handy URI Templates](https://github.com/damnhandy/Handy-URI-Templates) originally developed by Ryan McGeary.
Comment thread
stefanseifert marked this conversation as resolved.
> We are grateful for the original implementation, which served as the foundation for this work.
>
> This fork fixes compatibility issues with JDK 21+ environments and otherwise can be used as drop-in replacement.

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.damnhandy/handy-uri-templates/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.damnhandy/handy-uri-templates)

Handy URI Templates is a uritemplate processor implementing [RFC6570](http://tools.ietf.org/html/rfc6570) written in Java. If you are looking for a non-Java implementation, please check the [RFC6570 implementations page](http://code.google.com/p/uri-templates/wiki/Implementations). The current implementation is based on the final release of the uri template spec. The template processor supports the following features:

Expand All @@ -20,51 +24,23 @@ Handy URI Templates is a uritemplate processor implementing [RFC6570](http://too

As of version `1.1.1`, Handy URI Templates passes all tests defined by the [uritemplate-test](https://github.com/uri-templates/uritemplate-test) suite.

You can view [code coverage here](https://damnhandy.github.io/Handy-URI-Templates/cobertura/).

The complete [JavaDocs are here](http://damnhandy.github.io/Handy-URI-Templates/apidocs/).

## API Documentation

JavaDocs are available on [Javadocs.io](http://www.javadoc.io/doc/com.damnhandy/handy-uri-templates)
JavaDocs are available on [Javadocs.io](http://www.javadoc.io/doc/io.wcm.caravan/wcm-io-handy-uri-templates)

## Maven

To use the latest version of Handy URI Templates, you need to add the following dependency to your `pom.xml`:

```xml
<dependency>
<groupId>com.damnhandy</groupId>
<artifactId>handy-uri-templates</artifactId>
<version>2.1.7</version>
</dependency>
```

The next version of Handy URI Templates includes some big changes to the API. If you want to be daring, you can use the `SNAPSHOT` release:

```xml
<dependency>
<groupId>com.damnhandy</groupId>
<artifactId>handy-uri-templates</artifactId>
<version>2.1.8-SNAPSHOT</version>
<groupId>io.wcm.caravan</groupId>
<artifactId>wcm-io-handy-uri-templates</artifactId>
<version><!-- latest version --></version>
</dependency>
```



In order to use a SNAPSHOT release, you'll have to add the Sonatype snapshots repository:

```xml
<repository>
<id>sonatype-nexus-snapshots</id>
<name>sonatype-nexus-snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
```

You can also download the artifact directly at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Chandy-uri-templates)


## Basic Usage

Using the library is simple:
Expand Down Expand Up @@ -121,13 +97,13 @@ When `Request.getUrl()` is called, it will return:

"https://api.github.com/repos/damnhandy/Handy-URI-Templates/commits"

Please have a look at the example [test case](https://github.com/damnhandy/Handy-URI-Templates/blob/master/src/test/java/com/damnhandy/uri/template/examples/TestGitHubApis.java) for more details.
Please have a look at the example [test case](https://github.com/wcm-io-caravan/wcm-io-handy-uri-templates/blob/develop/src/test/java/com/damnhandy/uri/template/examples/TestGitHubApis.java) for more details.

Usage with the [Apache HTTP Client](http://hc.apache.org/httpcomponents-client-ga/index.html) is just as similar.

## Supported Value Types

While the `set()` method of the [UriTemplate](http://damnhandy.github.com/Handy-URI-Templates/apidocs/com/damnhandy/uri/template/UriTemplate.html) accepts any Java object, the following Java types are preferred:
While the `set()` method of the [UriTemplate](http://www.javadoc.io/doc/io.wcm.caravan/wcm-io-handy-uri-templates/latest/com/damnhandy/uri/template/UriTemplate.html) accepts any Java object, the following Java types are preferred:

* Primitive and Object types such as:
* int & Integer
Expand Down Expand Up @@ -166,9 +142,9 @@ The URI Template spec supports [composite values](http://tools.ietf.org/html/rfc

## POJOs as Composite Values

The template processor can treat simple Java objects as composite value. When a POJO is set on a template variable and the variable specifies the an explode modifier "*", a [VarExploder](http://damnhandy.github.com/Handy-URI-Templates/apidocs/com/damnhandy/uri/template/VarExploder.html) is invoked. The purpose of the `VarExploder` is to expose the object properties as name/value pairs.
The template processor can treat simple Java objects as composite value. When a POJO is set on a template variable and the variable specifies the an explode modifier "*", a [VarExploder](http://www.javadoc.io/doc/io.wcm.caravan/wcm-io-handy-uri-templates/latest/com/damnhandy/uri/template/VarExploder.html) is invoked. The purpose of the `VarExploder` is to expose the object properties as name/value pairs.

For most use cases, the [DefaultVarExploder](http://damnhandy.github.com/Handy-URI-Templates/apidocs/com/damnhandy/uri/template/DefaultVarExploder.html) should be sufficient. The `DefaultVarExploder` is a VarExploder implementation that takes in a Java object and extracts the properties for use in a URI Template. This class is called by default when a POJO is passed into the UriTemplate and the explode modifier is present on the variable. Given the following URI template expression:
For most use cases, the [DefaultVarExploder](http://www.javadoc.io/doc/io.wcm.caravan/wcm-io-handy-uri-templates/latest/com/damnhandy/uri/template/DefaultVarExploder.html) should be sufficient. The `DefaultVarExploder` is a VarExploder implementation that takes in a Java object and extracts the properties for use in a URI Template. This class is called by default when a POJO is passed into the UriTemplate and the explode modifier is present on the variable. Given the following URI template expression:

/mapper{?address*}

Expand All @@ -187,7 +163,7 @@ The expanded URI will be:

/mapper?city=Newport%20Beach&state=CA

The [DefaultVarExploder](http://damnhandy.github.com/Handy-URI-Templates/apidocs/com/damnhandy/uri/template/DefaultVarExploder.html) breaks down the object properties as follows:
The [DefaultVarExploder](http://www.javadoc.io/doc/io.wcm.caravan/wcm-io-handy-uri-templates/latest/com/damnhandy/uri/template/DefaultVarExploder.html) breaks down the object properties as follows:

* All properties that contain a non-null return value will be included
* Getters or fields annotated with `@UriTransient` will be excluded
Expand All @@ -197,15 +173,15 @@ The [DefaultVarExploder](http://damnhandy.github.com/Handy-URI-Templates/apidocs

Please refer to the JavaDoc for more details on how the `DefaultVarExploder` works.

Should the [DefaultVarExploder](http://damnhandy.github.com/Handy-URI-Templates/apidocs/com/damnhandy/uri/template/DefaultVarExploder.html) not be suitable for your needs, custom [VarExploder](http://damnhandy.github.com/Handy-URI-Templates/apidocs/com/damnhandy/uri/template/VarExploder.html) implementations can be added by rolling your own implementation. A custom VarExploder implementation can be used by wrapping your object in your implementation:
Should the [DefaultVarExploder](http://www.javadoc.io/doc/io.wcm.caravan/wcm-io-handy-uri-templates/latest/com/damnhandy/uri/template/DefaultVarExploder.html) not be suitable for your needs, custom [VarExploder](http://www.javadoc.io/doc/io.wcm.caravan/wcm-io-handy-uri-templates/latest/com/damnhandy/uri/template/VarExploder.html) implementations can be added by rolling your own implementation. A custom VarExploder implementation can be used by wrapping your object in your implementation:

```java
UriTemplate.fromTemplate("/mapper{?address*}")
.set("address", new MyCustomVarExploder(address))
.expand();
```

Note: All [VarExploder](http://damnhandy.github.com/Handy-URI-Templates/apidocs/com/damnhandy/uri/template/VarExploder.html) implementations are ONLY invoked when the explode modifier "*" is declared in the URI Template expression. If the variable declaration does not specify the explode modifier, an exception is raised.
Note: All [VarExploder](http://www.javadoc.io/doc/io.wcm.caravan/wcm-io-handy-uri-templates/latest/com/damnhandy/uri/template/VarExploder.html) implementations are ONLY invoked when the explode modifier "*" is declared in the URI Template expression. If the variable declaration does not specify the explode modifier, an exception is raised.

License
-------
Expand Down
Loading