6969 * <p>
7070 * Here is an example for a template using simple variables:
7171 *
72- * <pre>
72+ * <pre>{@code
7373 * PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}");
7474 * assert template.matches("v2/shelves") == false;
7575 * Map<String, String> values = template.match("v1/shelves/s1/books/b1");
7878 * expectedValues.put("book", "b1");
7979 * assert values.equals(expectedValues);
8080 * assert template.instantiate(values).equals("v1/shelves/s1/books/b1");
81- * </pre>
81+ * } </pre>
8282 *
8383 * Templates can use variables which match sub-paths. Example:
8484 *
85- * <pre>
85+ * <pre>{@code
8686 * PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}"};
8787 * assert template.match("v1/shelves/books/b1") == null;
8888 * Map<String, String> expectedValues = new HashMap<>();
8989 * expectedValues.put("name", "shelves/s1/books/b1");
9090 * assert template.match("v1/shelves/s1/books/b1").equals(expectedValues);
91- * </pre>
91+ * } </pre>
9292 *
9393 * Path templates can also be used with only wildcards. Each wildcard is associated with an implicit
9494 * variable {@code $n}, where n is the zero-based position of the wildcard. Example:
9595 *
96- * <pre>
96+ * <pre>{@code
9797 * PathTemplate template = PathTemplate.create("shelves/*/books/*"};
9898 * assert template.match("shelves/books/b1") == null;
9999 * Map<String, String> values = template.match("v1/shelves/s1/books/b1");
100100 * Map<String, String> expectedValues = new HashMap<>();
101101 * expectedValues.put("$0", s1");
102102 * expectedValues.put("$1", "b1");
103103 * assert values.equals(expectedValues);
104- * </pre>
104+ * } </pre>
105105 *
106106 * Paths input to matching can use URL relative syntax to indicate a host name by prefixing the host
107107 * name, as in {@code //somewhere.io/some/path}. The host name is matched into the special variable
108108 * {@link #HOSTNAME_VAR}. Patterns are agnostic about host names, and the same pattern can be used
109109 * for URL relative syntax and simple path syntax:
110110 *
111- * <pre>
111+ * <pre>{@code
112112 * PathTemplate template = PathTemplate.create("shelves/*"};
113113 * Map<String, String> expectedValues = new HashMap<>();
114114 * expectedValues.put(PathTemplate.HOSTNAME_VAR, "//somewhere.io");
117117 * expectedValues.clear();
118118 * expectedValues.put("$0", s1");
119119 * assert template.match("shelves/s1").equals(expectedValues);
120- * </pre>
120+ * } </pre>
121121 *
122122 * For the representation of a <em>resource name</em> see {@link TemplatedResourceName}, which is
123123 * based on path templates.
@@ -347,10 +347,10 @@ public PathTemplate withoutVars() {
347347 /**
348348 * Returns a path template for the sub-path of the given variable. Example:
349349 *
350- * <pre>
350+ * <pre>{@code
351351 * PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}");
352352 * assert template.subTemplate("name").toString().equals("shelves/*/books/*");
353- * </pre>
353+ * } </pre>
354354 *
355355 * The returned template will never have named variables, but only wildcards, which are dealt with
356356 * in matching and instantiation using '$n'-variables. See the documentation of
@@ -446,7 +446,7 @@ public void validate(String path, String exceptionMessagePrefix) {
446446 * For free wildcards in the template, the matching process creates variables named '$n', where
447447 * 'n' is the wildcard's position in the template (starting at n=0). For example:
448448 *
449- * <pre>
449+ * <pre>{@code
450450 * PathTemplate template = PathTemplate.create("shelves/*/books/*");
451451 * Map<String, String> expectedValues = new HashMap<>();
452452 * expectedValues.put("$0", "s1");
@@ -459,7 +459,7 @@ public void validate(String path, String exceptionMessagePrefix) {
459459 * expectedValues.put("$1", "b1");
460460 * assert template.validatedMatch("//somewhere.io/shelves/s1/books/b2", "User exception string")
461461 * .equals(expectedValues);
462- * </pre>
462+ * } </pre>
463463 *
464464 * All matched values will be properly unescaped using URL encoding rules (so long as URL encoding
465465 * has not been disabled by the {@link #createWithoutUrlEncoding} method).
@@ -498,7 +498,7 @@ public boolean matches(String path) {
498498 * For free wildcards in the template, the matching process creates variables named '$n', where
499499 * 'n' is the wildcard's position in the template (starting at n=0). For example:
500500 *
501- * <pre>
501+ * <pre>{@code
502502 * PathTemplate template = PathTemplate.create("shelves/*/books/*");
503503 * Map<String, String> expectedValues = new HashMap<>();
504504 * expectedValues.put("$0", "s1");
@@ -509,7 +509,7 @@ public boolean matches(String path) {
509509 * expectedValues.put("$0", "s1");
510510 * expectedValues.put("$1", "b1");
511511 * assert template.match("//somewhere.io/shelves/s1/books/b2").equals(expectedValues);
512- * </pre>
512+ * } </pre>
513513 *
514514 * All matched values will be properly unescaped using URL encoding rules (so long as URL encoding
515515 * has not been disabled by the {@link #createWithoutUrlEncoding} method).
@@ -523,13 +523,13 @@ public Map<String, String> match(String path) {
523523 * Matches the path, where the first segment is interpreted as the host name regardless of whether
524524 * it starts with '//' or not. Example:
525525 *
526- * <pre>
526+ * <pre>{@code
527527 * Map<String, String> expectedValues = new HashMap<>();
528528 * expectedValues.put(HOSTNAME_VAR, "//somewhere.io");
529529 * expectedValues.put("name", "shelves/s1");
530530 * assert template("{name=shelves/*}").matchFromFullName("somewhere.io/shelves/s1")
531531 * .equals(expectedValues);
532- * </pre>
532+ * } </pre>
533533 */
534534 @ Nullable
535535 public Map <String , String > matchFromFullName (String path ) {
@@ -721,12 +721,12 @@ public String instantiate(String... keysAndValues) {
721721 * Same like {@link #instantiate(Map)} but allows for unbound variables, which are substituted
722722 * using their original syntax. Example:
723723 *
724- * <pre>
724+ * <pre>{@code
725725 * PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}");
726726 * Map<String, String> partialMap = new HashMap<>();
727727 * partialMap.put("shelf", "s1");
728728 * assert template.instantiatePartial(partialMap).equals("v1/shelves/s1/books/{book}");
729- * </pre>
729+ * } </pre>
730730 *
731731 * The result of this call can be used to create a new template.
732732 */
0 commit comments