@@ -53,6 +58,8 @@
+
+
@@ -106,4 +113,4 @@
-
+
\ No newline at end of file
diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar
index 1c1580c..15c39db 100644
Binary files a/lib/bld/bld-wrapper.jar and b/lib/bld/bld-wrapper.jar differ
diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties
index c1d316f..d3d50c0 100644
--- a/lib/bld/bld-wrapper.properties
+++ b/lib/bld/bld-wrapper.properties
@@ -1,8 +1,8 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
-bld.downloadLocation=
-bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.9
-bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.0
+bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.7
+bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.3
bld.extension-tests=com.uwyn.rife2:bld-tests-badge:1.4.6
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
-bld.version=2.2.1
+bld.downloadLocation=
+bld.version=1.9.0
diff --git a/src/bld/java/rife/render/TemplateRenderersBuild.java b/src/bld/java/rife/render/TemplateRenderersBuild.java
index 4f4fc5e..d8b05d1 100644
--- a/src/bld/java/rife/render/TemplateRenderersBuild.java
+++ b/src/bld/java/rife/render/TemplateRenderersBuild.java
@@ -27,6 +27,7 @@ import rife.bld.publish.PublishInfo;
import rife.bld.publish.PublishLicense;
import rife.bld.publish.PublishScm;
+import java.io.IOException;
import java.util.List;
import static rife.bld.dependencies.Repository.*;
@@ -40,7 +41,7 @@ public class TemplateRenderersBuild extends Project {
public TemplateRenderersBuild() {
pkg = "rife.render";
name = "rife2-template-renderers";
- version = version(1, 2, 1, "SNAPSHOT");
+ version = version(1, 1, 5);
javaRelease = 17;
downloadSources = true;
@@ -48,11 +49,11 @@ public class TemplateRenderersBuild extends Project {
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
scope(compile)
- .include(dependency("com.uwyn.rife2", "rife2", version(1, 9, 1)));
+ .include(dependency("com.uwyn.rife2", "rife2", version(1, 7, 3)));
scope(test)
- .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 0)))
- .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 0)))
- .include(dependency("org.assertj", "assertj-core", version(3, 27, 3)));
+ .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2)))
+ .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2)))
+ .include(dependency("org.assertj", "assertj-core", version(3, 25, 3)));
javadocOperation().javadocOptions()
.docTitle("RIFE2 Template Renderers")
@@ -61,13 +62,13 @@ public class TemplateRenderersBuild extends Project {
.link("https://rife2.github.io/rife2/");
publishOperation()
- .repository(version.isSnapshot() ? SONATYPE_SNAPSHOTS
+ .repository(version.isSnapshot() ? repository(SONATYPE_SNAPSHOTS.location())
.withCredentials(property("sonatypeUser"), property("sonatypePassword"))
- : SONATYPE_RELEASES
+ : repository(SONATYPE_RELEASES.location())
.withCredentials(property("sonatypeUser"), property("sonatypePassword")))
- .repository(version.isSnapshot() ? RIFE2_SNAPSHOTS
+ .repository(version.isSnapshot() ? repository(RIFE2_SNAPSHOTS.location())
.withCredentials(property("rife2Username"), property("rife2Password"))
- : RIFE2_RELEASES
+ : repository(RIFE2_RELEASES.location())
.withCredentials(property("rife2Username"), property("rife2Password")))
.info(new PublishInfo()
.groupId("com.uwyn.rife2")
@@ -75,21 +76,13 @@ public class TemplateRenderersBuild extends Project {
.name("RIFE2 Template Renderers")
.description("Template Renderers for the RIFE2 web framework")
.url("https://github.com/rife2/rife2-template-renderers")
- .developer(new PublishDeveloper()
- .id("ethauvin")
- .name("Erik C. Thauvin")
- .email("erik@thauvin.net")
+ .developer(new PublishDeveloper().id("ethauvin").name("Erik C. Thauvin").email("erik@thauvin.net")
.url("https://erik.thauvin.net/"))
- .developer(new PublishDeveloper()
- .id("gbevin")
- .name("Geert Bevin")
- .email("gbevin@uwyn.com")
+ .developer(new PublishDeveloper().id("gbevin").name("Geert Bevin").email("gbevin@uwyn.com")
.url("https://github.com/gbevin"))
- .license(new PublishLicense()
- .name("The Apache License, Version 2.0")
- .url("https://www.apache.org/licenses/LICENSE-2.0.txt"))
- .scm(new PublishScm()
- .connection("scm:git:https://github.com/rife2/rife2-template-renderers.git")
+ .license(new PublishLicense().name("The Apache License, Version 2.0")
+ .url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
+ .scm(new PublishScm().connection("scm:git:https://github.com/rife2/rife2-template-renderers.git")
.developerConnection("scm:git:git@github.com:rife2/rife2-template-renderers.git")
.url("https://github.com/rife2/rife2-template-renderers"))
.signKey(property("signKey"))
@@ -101,14 +94,14 @@ public class TemplateRenderersBuild extends Project {
}
@BuildCommand(summary = "Generates JaCoCo Reports")
- public void jacoco() throws Exception {
+ public void jacoco() throws IOException {
new JacocoReportOperation()
.fromProject(this)
.execute();
}
@BuildCommand(summary = "Runs PMD analysis")
- public void pmd() throws Exception {
+ public void pmd() {
new PmdOperation()
.fromProject(this)
.failOnViolation(true)
@@ -122,4 +115,4 @@ public class TemplateRenderersBuild extends Project {
.apiKey(property("testsBadgeApiKey"))
.fromProject(this));
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/rife/render/Abbreviate.java b/src/main/java/rife/render/Abbreviate.java
index dfacacb..b0b38e5 100644
--- a/src/main/java/rife/render/Abbreviate.java
+++ b/src/main/java/rife/render/Abbreviate.java
@@ -21,7 +21,7 @@ import rife.template.Template;
import rife.template.ValueRenderer;
/**
- * Abbreviates a template value with ellipses.
+ * Abbreviate a template value with ellipses.
*
* Usage:
*
@@ -36,18 +36,7 @@ import rife.template.ValueRenderer;
*/
public class Abbreviate implements ValueRenderer {
/**
- * Returns the template value abbreviated with ellipses.
- *
- * Two parameters can be specified:
- *
- * mark
: the string that will be used to abbreviate the value. Default is ...
- * max
: the maximum number of characters to render. Default is -1
(no abbreviation).
- *
- *
- * @param template the template that contains the value
- * @param valueId the id of the value to render
- * @param differentiator a generic string that can be used to differentiate the rendering
- * @return the abbreviated value, or the original value if no abbreviation is necessary
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/BeatTime.java b/src/main/java/rife/render/BeatTime.java
index f11f97f..23849f3 100644
--- a/src/main/java/rife/render/BeatTime.java
+++ b/src/main/java/rife/render/BeatTime.java
@@ -38,12 +38,7 @@ import java.time.ZonedDateTime;
*/
public class BeatTime implements ValueRenderer {
/**
- * Returns the current time in Swatch Internet (.beat) Time format.
- *
- * @param template the template instance
- * @param valueId the value id
- * @param differentiator the differentiator
- * @return the rendered value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/Capitalize.java b/src/main/java/rife/render/Capitalize.java
index e0d769f..7805b4c 100644
--- a/src/main/java/rife/render/Capitalize.java
+++ b/src/main/java/rife/render/Capitalize.java
@@ -37,12 +37,7 @@ import rife.tools.StringUtils;
*/
public class Capitalize implements ValueRenderer {
/**
- * Returns the template value by capitalizing it.
- *
- * @param template the template containing the value to be rendered
- * @param valueId the identifier of the value to render
- * @param differentiator a string used to differentiate the rendering
- * @return the capitalized and encoded value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/CapitalizeWords.java b/src/main/java/rife/render/CapitalizeWords.java
deleted file mode 100644
index e95e6f8..0000000
--- a/src/main/java/rife/render/CapitalizeWords.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2023-2024 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * 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.
- *
- */
-
-package rife.render;
-
-import rife.template.Template;
-import rife.template.ValueRenderer;
-
-/**
- * Capitalizes words of a template value.
- *
- * Usage:
- *
- *
- * <!--v render:rife.render.CapitalizeWords:valueId/-->
- * {{v render:rife.render.CapitalizeWords:valueId/}}
- *
- *
- * @author Erik C. Thauvin
- * @see rife.render.CapitalizeWords
- * @since 1.2
- */
-public class CapitalizeWords implements ValueRenderer {
- /**
- * Returns the template value by capitalizing it.
- *
- * @param template the template containing the value to be rendered
- * @param valueId the identifier of the value to render
- * @param differentiator a string used to differentiate the rendering
- * @return the capitalized and encoded value
- */
- @Override
- public String render(Template template, String valueId, String differentiator) {
- return template.getEncoder().encode(RenderUtils.capitalizeWords(template.getValueOrAttribute(differentiator)));
- }
-}
diff --git a/src/main/java/rife/render/DateIso.java b/src/main/java/rife/render/DateIso.java
index 0da04e6..a2f1f9e 100644
--- a/src/main/java/rife/render/DateIso.java
+++ b/src/main/java/rife/render/DateIso.java
@@ -23,7 +23,7 @@ import rife.template.ValueRenderer;
import java.time.ZonedDateTime;
/**
- * Renders the current date in ISO 8601 format.
+ * Return the current date in ISO 8601 format.
*
* Usage:
*
@@ -38,12 +38,7 @@ import java.time.ZonedDateTime;
*/
public class DateIso implements ValueRenderer {
/**
- * Returns the current date in ISO 8601 format, encoded according to the template's encoding rules.
- *
- * @param template the template that is currently being rendered
- * @param valueId the value id that triggers the rendering of this value renderer
- * @param differentiator a differentiator that may be used to differentiate the rendering of this value renderer
- * @return the current date in ISO 8601 format, encoded according to the template's encoding rules
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/DateTimeIso.java b/src/main/java/rife/render/DateTimeIso.java
index e8513bb..805a6cd 100644
--- a/src/main/java/rife/render/DateTimeIso.java
+++ b/src/main/java/rife/render/DateTimeIso.java
@@ -24,7 +24,7 @@ import java.time.ZoneId;
import java.time.ZonedDateTime;
/**
- * Renders the current date and time in ISO 8601 format.
+ * Return the current date and time in ISO 8601 format.
*
* Usage:
*
@@ -39,15 +39,7 @@ import java.time.ZonedDateTime;
*/
public class DateTimeIso implements ValueRenderer {
/**
- * Renders the current date and time in ISO 8601 format.
- *
- * Additionally, it allows specifying a time zone through the template's default value properties with the key
- * {@code tz}. If no time zone is specified, the system default time zone is used.
- *
- * @param template the template that is currently being rendered
- * @param valueId the id of the value to be rendered
- * @param differentiator a differentiator that may be used to differentiate the rendering of this value renderer
- * @return the current date and time in ISO 8601 format
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/DateTimeRfc2822.java b/src/main/java/rife/render/DateTimeRfc2822.java
index 2bdbd54..3a33842 100644
--- a/src/main/java/rife/render/DateTimeRfc2822.java
+++ b/src/main/java/rife/render/DateTimeRfc2822.java
@@ -23,7 +23,7 @@ import rife.template.ValueRenderer;
import java.time.ZonedDateTime;
/**
- * Renders the current date and time in RFC 2822 format.
+ * Return the current date and time in RFC 2822 format.
*
* Usage:
*
@@ -38,12 +38,7 @@ import java.time.ZonedDateTime;
*/
public class DateTimeRfc2822 implements ValueRenderer {
/**
- * Returns the current date and time in RFC 2822 format.
- *
- * @param template the template instance
- * @param valueId the value id
- * @param differentiator the differentiator
- * @return the current date and time in RFC 2822 format
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/EncodeBase64.java b/src/main/java/rife/render/EncodeBase64.java
index e00b24c..95d1e30 100644
--- a/src/main/java/rife/render/EncodeBase64.java
+++ b/src/main/java/rife/render/EncodeBase64.java
@@ -40,12 +40,7 @@ import java.nio.charset.StandardCharsets;
*/
public class EncodeBase64 implements ValueRenderer {
/**
- * Returns the template value encoded to Base64.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the Base64-encoded value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/EncodeHtml.java b/src/main/java/rife/render/EncodeHtml.java
index b67959d..ee14bdd 100644
--- a/src/main/java/rife/render/EncodeHtml.java
+++ b/src/main/java/rife/render/EncodeHtml.java
@@ -38,12 +38,7 @@ import rife.tools.StringUtils;
*/
public class EncodeHtml implements ValueRenderer {
/**
- * Returns the template value encoded to HTML.
- *
- * @param template the template containing the value to be rendered
- * @param valueId the identifier of the value to render
- * @param differentiator a string used to differentiate the rendering
- * @return the HTML-encoded value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/EncodeHtmlEntities.java b/src/main/java/rife/render/EncodeHtmlEntities.java
index cee3e8b..bbf6043 100644
--- a/src/main/java/rife/render/EncodeHtmlEntities.java
+++ b/src/main/java/rife/render/EncodeHtmlEntities.java
@@ -36,12 +36,7 @@ import rife.template.ValueRenderer;
*/
public class EncodeHtmlEntities implements ValueRenderer {
/**
- * Returns the template value encoded to HTML decimal entities.
- *
- * @param template the template instance
- * @param valueId the value id
- * @param differentiator the differentiator
- * @return the encoded value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/EncodeJs.java b/src/main/java/rife/render/EncodeJs.java
index 27de902..52c757d 100644
--- a/src/main/java/rife/render/EncodeJs.java
+++ b/src/main/java/rife/render/EncodeJs.java
@@ -38,12 +38,7 @@ import rife.tools.StringUtils;
*/
public class EncodeJs implements ValueRenderer {
/**
- * Returns the template value encoded to JavaScript/ECMAScript.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the JavaScript/ECMAScript-encoded value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/EncodeJson.java b/src/main/java/rife/render/EncodeJson.java
index 8e17b29..95fbf34 100644
--- a/src/main/java/rife/render/EncodeJson.java
+++ b/src/main/java/rife/render/EncodeJson.java
@@ -38,12 +38,7 @@ import rife.tools.StringUtils;
*/
public class EncodeJson implements ValueRenderer {
/**
- * Returns the template value encoded to JSON.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the JSON-encoded value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/EncodeUnicode.java b/src/main/java/rife/render/EncodeUnicode.java
index afd2a48..061da96 100644
--- a/src/main/java/rife/render/EncodeUnicode.java
+++ b/src/main/java/rife/render/EncodeUnicode.java
@@ -38,12 +38,7 @@ import rife.tools.StringUtils;
*/
public class EncodeUnicode implements ValueRenderer {
/**
- * Returns the template value encoded to Unicode escape codes.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the Unicode escape codes-encoded value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/EncodeUrl.java b/src/main/java/rife/render/EncodeUrl.java
index b977353..a6c554f 100644
--- a/src/main/java/rife/render/EncodeUrl.java
+++ b/src/main/java/rife/render/EncodeUrl.java
@@ -38,12 +38,7 @@ import rife.tools.StringUtils;
*/
public class EncodeUrl implements ValueRenderer {
/**
- * Returns the template value encoded to URL.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the URL-encoded value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/EncodeXml.java b/src/main/java/rife/render/EncodeXml.java
index 00b0faa..b1c6eff 100644
--- a/src/main/java/rife/render/EncodeXml.java
+++ b/src/main/java/rife/render/EncodeXml.java
@@ -38,12 +38,7 @@ import rife.tools.StringUtils;
*/
public class EncodeXml implements ValueRenderer {
/**
- * Returns the template value encoded to XML.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the XML-encoded value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/FormatCreditCard.java b/src/main/java/rife/render/FormatCreditCard.java
index fec124d..f2fc815 100644
--- a/src/main/java/rife/render/FormatCreditCard.java
+++ b/src/main/java/rife/render/FormatCreditCard.java
@@ -36,12 +36,7 @@ import rife.template.ValueRenderer;
*/
public class FormatCreditCard implements ValueRenderer {
/**
- * Returns the last 4 digits of the template credit number value.
- *
- * @param template the {@link Template}
- * @param valueId the value id
- * @param differentiator the differentiator
- * @return the formatted value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/Lowercase.java b/src/main/java/rife/render/Lowercase.java
index 6f9f2ec..8513222 100644
--- a/src/main/java/rife/render/Lowercase.java
+++ b/src/main/java/rife/render/Lowercase.java
@@ -37,12 +37,7 @@ import rife.tools.Localization;
*/
public class Lowercase implements ValueRenderer {
/**
- * Returns the template value converted to lowercase.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the lowercase value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/Mask.java b/src/main/java/rife/render/Mask.java
index fe0a709..eb96702 100644
--- a/src/main/java/rife/render/Mask.java
+++ b/src/main/java/rife/render/Mask.java
@@ -35,30 +35,8 @@ import rife.template.ValueRenderer;
* @since 1.0
*/
public class Mask implements ValueRenderer {
-
/**
- * Renders a template value with characters of the value masked using the specified mask.
- *
- * The mask is specified as a template default value with the following syntax:
- *
- *
- * mask=<mask>[,unmasked=<unmasked>][,fromStart=<fromStart>]
- *
- *
- * Where:
- *
- *
- * - mask is the character to use for masking, defaulting to
*
- * - unmasked is the number of characters at the beginning of the value that should be left unmasked,
- * defaulting to
0
- * - fromStart is a boolean indicating whether the unmasked value should be counted from
- * the start of the value, defaulting to
false
- *
- *
- * @param template the template to render the value in
- * @param valueId the ID of the value to render
- * @param differentiator the differentiator of the value to render
- * @return the rendered value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/Normalize.java b/src/main/java/rife/render/Normalize.java
index b6cb9d1..a07fb9b 100644
--- a/src/main/java/rife/render/Normalize.java
+++ b/src/main/java/rife/render/Normalize.java
@@ -36,12 +36,7 @@ import rife.template.ValueRenderer;
*/
public class Normalize implements ValueRenderer {
/**
- * Returns the template value normalized for inclusion in a URL path.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the normalized value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/QrCode.java b/src/main/java/rife/render/QrCode.java
index 47f74c0..ddf8091 100644
--- a/src/main/java/rife/render/QrCode.java
+++ b/src/main/java/rife/render/QrCode.java
@@ -36,12 +36,7 @@ import rife.template.ValueRenderer;
*/
public class QrCode implements ValueRenderer {
/**
- * Returns the template value encoded as an SVG QR Code.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the SVG QR Code
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/RenderUtils.java b/src/main/java/rife/render/RenderUtils.java
index c05f5b9..43c92c1 100644
--- a/src/main/java/rife/render/RenderUtils.java
+++ b/src/main/java/rife/render/RenderUtils.java
@@ -83,7 +83,7 @@ public final class RenderUtils {
DateTimeFormatter.ofPattern("EEE, d MMM yyyy HH:mm:ss zzz").withLocale(Localization.getLocale());
private static final String DEFAULT_USER_AGENT =
"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0";
- private static final Logger LOGGER = Logger.getLogger(RenderUtils.class.getName());
+ private final static Logger LOGGER = Logger.getLogger(RenderUtils.class.getName());
private RenderUtils() {
// no-op
@@ -124,38 +124,6 @@ public final class RenderUtils {
return String.format("@%03d", beats);
}
- /**
- * Returns a {@code String} with the first letter of each word capitalized.
- *
- * @param src the source {@code String}
- * @return the capitalized {@code String}
- */
- public static String capitalizeWords(String src) {
- if (src == null || src.isBlank()) {
- return src;
- }
-
- var result = new StringBuilder();
- var capitalizeNext = true;
-
- for (var i = 0; i < src.length(); i++) {
- var c = src.charAt(i);
- if (Character.isWhitespace(c)) {
- capitalizeNext = true;
- result.append(c);
- } else {
- if (capitalizeNext) {
- result.append(Character.toUpperCase(c));
- } else {
- result.append(Character.toLowerCase(c));
- }
- capitalizeNext = false;
- }
- }
-
- return result.toString();
- }
-
/**
* Encodes the source {@code String} to the specified encoding.
*
@@ -248,9 +216,8 @@ public final class RenderUtils {
public static String fetchUrl(String url, String defaultContent) {
try {
var fetchUrl = new URL(url);
- HttpURLConnection connection = null;
try {
- connection = (HttpURLConnection) fetchUrl.openConnection();
+ var connection = (HttpURLConnection) fetchUrl.openConnection();
connection.setRequestProperty("User-Agent", DEFAULT_USER_AGENT);
var code = connection.getResponseCode();
if (code >= 200 && code <= 399) {
@@ -266,15 +233,10 @@ public final class RenderUtils {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, "An IO error occurred while connecting to " + fetchUrl.getHost(), ioe);
}
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
}
} catch (MalformedURLException ignored) {
// do nothing
}
-
return defaultContent;
}
@@ -372,20 +334,21 @@ public final class RenderUtils {
return src;
}
- var normalized = Normalizer.normalize(src.trim(), Normalizer.Form.NFD).toCharArray();
-
- var sb = new StringBuilder(normalized.length);
- for (var i = 0; i < normalized.length; i++) {
- var c = normalized[i];
- if (c <= '\u007F') { // ASCII only
- if (" &()-_=[{]}\\|;:,<.>/".indexOf(c) != -1) { // common separators
- if (!sb.isEmpty() && i != normalized.length - 1 && sb.charAt(sb.length() - 1) != '-') {
- sb.append('-');
+ var normalized = Normalizer.normalize(src.trim(), Normalizer.Form.NFD);
+ var sb = new StringBuilder(normalized.length());
+ boolean space = false;
+ for (var c : normalized.toCharArray()) {
+ if (c <= '\u007F') { // ascii only
+ if (!space && c == ' ') {
+ space = true;
+ sb.append('-');
+ } else {
+ space = false;
+ if (c >= '0' && c <= '9' || c >= 'a' && c <= 'z') {
+ sb.append(c);
+ } else if (c >= 'A' && c <= 'Z') {
+ sb.append((char) (c + 32)); // lowercase
}
- } else if (c >= '0' && c <= '9' || c >= 'a' && c <= 'z') { // letters & digits
- sb.append(c);
- } else if (c >= 'A' && c <= 'Z') { // uppercase letters
- sb.append((char) (c + 32)); // make lowercase
}
}
}
diff --git a/src/main/java/rife/render/Rot13.java b/src/main/java/rife/render/Rot13.java
index 75e3dd7..d9e5326 100644
--- a/src/main/java/rife/render/Rot13.java
+++ b/src/main/java/rife/render/Rot13.java
@@ -36,12 +36,7 @@ import rife.template.ValueRenderer;
*/
public class Rot13 implements ValueRenderer {
/**
- * Returns the template value translated to/from ROT13.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the ROT13 value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/ShortenUrl.java b/src/main/java/rife/render/ShortenUrl.java
index 204d7c6..1ceeec9 100644
--- a/src/main/java/rife/render/ShortenUrl.java
+++ b/src/main/java/rife/render/ShortenUrl.java
@@ -38,12 +38,7 @@ import rife.template.ValueRenderer;
*/
public class ShortenUrl implements ValueRenderer {
/**
- * Returns the template value shortened using is.gid.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the template shortened value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/SwapCase.java b/src/main/java/rife/render/SwapCase.java
index 1fd996a..4278768 100644
--- a/src/main/java/rife/render/SwapCase.java
+++ b/src/main/java/rife/render/SwapCase.java
@@ -21,7 +21,7 @@ import rife.template.Template;
import rife.template.ValueRenderer;
/**
- * Swaps case of a template value.
+ * Swap case of a template value.
*
* Usage:
*
@@ -35,13 +35,9 @@ import rife.template.ValueRenderer;
* @since 1.0
*/
public class SwapCase implements ValueRenderer {
+
/**
- * Returns the template value with swapped case.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the swapped case value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/TimeIso.java b/src/main/java/rife/render/TimeIso.java
index 01bf5b2..a62c44b 100644
--- a/src/main/java/rife/render/TimeIso.java
+++ b/src/main/java/rife/render/TimeIso.java
@@ -23,7 +23,7 @@ import rife.template.ValueRenderer;
import java.time.ZonedDateTime;
/**
- * Renders the current time in ISO 8601 format.
+ * Return the current time in ISO 8601 format.
*
* Usage:
*
@@ -38,12 +38,7 @@ import java.time.ZonedDateTime;
*/
public class TimeIso implements ValueRenderer {
/**
- * Returns the current time in ISO 8601 format.
- *
- * @param template the template that is currently being rendered
- * @param valueId the id of the value to be rendered
- * @param differentiator a differentiator that may be used to differentiate the rendering of this value renderer
- * @return the current time in ISO 8601 format
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/Trim.java b/src/main/java/rife/render/Trim.java
index a0951b4..f3b2980 100644
--- a/src/main/java/rife/render/Trim.java
+++ b/src/main/java/rife/render/Trim.java
@@ -36,12 +36,7 @@ import rife.template.ValueRenderer;
*/
public class Trim implements ValueRenderer {
/**
- * Renders the template value by removing leading and trailing whitespace.
- *
- * @param template the template instance
- * @param valueId the id of the value to render
- * @param differentiator an optional differentiator to use for cache invalidation
- * @return the trimmed value, or the original value if it is {@code null} or empty
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/Uncapitalize.java b/src/main/java/rife/render/Uncapitalize.java
index 20b0aad..53b8a45 100644
--- a/src/main/java/rife/render/Uncapitalize.java
+++ b/src/main/java/rife/render/Uncapitalize.java
@@ -37,12 +37,7 @@ import rife.tools.StringUtils;
*/
public class Uncapitalize implements ValueRenderer {
/**
- * Returns the un-capitalized template value.
- *
- * @param template the template to render
- * @param valueId the id of the value to render
- * @param differentiator the differentiator to use for the value lookup
- * @return the un-capitalized value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/Uppercase.java b/src/main/java/rife/render/Uppercase.java
index 92e57a5..31ecd9a 100644
--- a/src/main/java/rife/render/Uppercase.java
+++ b/src/main/java/rife/render/Uppercase.java
@@ -22,7 +22,7 @@ import rife.template.ValueRenderer;
import rife.tools.Localization;
/**
- * Converts a template value to uppercase.
+ * Convert a template value to uppercase.
*
* Usage:
*
@@ -37,12 +37,7 @@ import rife.tools.Localization;
*/
public class Uppercase implements ValueRenderer {
/**
- * Returns the template value converted to uppercase.
- *
- * @param template the template that contains the value
- * @param valueId the id of the value
- * @param differentiator the differentiator to use
- * @return the uppercased value
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/Uptime.java b/src/main/java/rife/render/Uptime.java
index 14bb2de..2fe1a5d 100644
--- a/src/main/java/rife/render/Uptime.java
+++ b/src/main/java/rife/render/Uptime.java
@@ -38,12 +38,7 @@ import java.lang.management.ManagementFactory;
*/
public class Uptime implements ValueRenderer {
/**
- * Renders the server uptime.
- *
- * @param template the template that is currently being rendered
- * @param valueId the id of the value to render
- * @param differentiator a differentiator that may be used to differentiate the rendering of this value renderer
- * @return the server uptime
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/main/java/rife/render/Year.java b/src/main/java/rife/render/Year.java
index cb8c8f5..b79911a 100644
--- a/src/main/java/rife/render/Year.java
+++ b/src/main/java/rife/render/Year.java
@@ -37,13 +37,9 @@ import java.time.ZonedDateTime;
* @since 1.0
*/
public class Year implements ValueRenderer {
+
/**
- * Renders the current year.
- *
- * @param template the template that is currently being rendered
- * @param valueId the id of the value to render
- * @param differentiator a differentiator that may be used to differentiate the rendering of this value renderer
- * @return the current year
+ * {@inheritDoc}
*/
@Override
public String render(Template template, String valueId, String differentiator) {
diff --git a/src/test/java/rife/render/DisabledOnCi.java b/src/test/java/rife/render/DisabledOnCi.java
index 8c369d6..2fab8c9 100644
--- a/src/test/java/rife/render/DisabledOnCi.java
+++ b/src/test/java/rife/render/DisabledOnCi.java
@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
* @author Erik C. Thauvin
* @since 1.0
*/
-@Target({ElementType.TYPE, ElementType.METHOD})
+@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(DisableOnCiCondition.class)
public @interface DisabledOnCi {
diff --git a/src/test/java/rife/render/TestEncode.java b/src/test/java/rife/render/TestEncode.java
index bc390d4..d02571f 100644
--- a/src/test/java/rife/render/TestEncode.java
+++ b/src/test/java/rife/render/TestEncode.java
@@ -56,7 +56,7 @@ class TestEncode {
assertThat(t.getContent()).isEqualTo("\\'\\\"\\\\\\/");
t = TemplateFactory.TXT.get("encodeJs");
- t.setAttribute(TestCase.FOO, "This is\f\b a\r\n\ttest");
+ t.setAttribute(TestCase.FOO, "This is\f\b a\r\n\ttest");
assertThat(t.getContent()).isEqualTo("This is\\f\\b a\\r\\n\\ttest");
t = TemplateFactory.HTML.get("encodeJs");
diff --git a/src/test/java/rife/render/TestRenderUtils.java b/src/test/java/rife/render/TestRenderUtils.java
index f1f8c46..6ab1a22 100644
--- a/src/test/java/rife/render/TestRenderUtils.java
+++ b/src/test/java/rife/render/TestRenderUtils.java
@@ -17,7 +17,6 @@
package rife.render;
-import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.jupiter.api.Test;
import java.util.Properties;
@@ -40,17 +39,6 @@ class TestRenderUtils {
assertThat(RenderUtils.abbreviate("", 10, "")).as("").isEmpty();
}
- @Test
- void testCapitalizeWords() {
- assertThat(RenderUtils.capitalizeWords("hello world")).isEqualTo("Hello World");
- assertThat(RenderUtils.capitalizeWords("java programming")).isEqualTo("Java Programming");
- assertThat(RenderUtils.capitalizeWords("TEST")).isEqualTo("Test");
- assertThat(RenderUtils.capitalizeWords("multiple spaces")).isEqualTo("Multiple Spaces");
- assertThat(RenderUtils.capitalizeWords("white\t\fspaces")).isEqualTo("White\t\fSpaces");
- assertThat(RenderUtils.capitalizeWords("")).isEmpty();
- assertThat(RenderUtils.capitalizeWords(null)).isNull();
- }
-
@Test
void testEncode() {
var p = new Properties();
@@ -108,14 +96,8 @@ class TestRenderUtils {
@Test
void testNormalize() {
- assertThat(RenderUtils.normalize("")).as("empty").isEmpty();
- assertThat(RenderUtils.normalize(" &()-_=[{]}\\|;:,<.>/")).as("blank").isEmpty();
- assertThat(RenderUtils.normalize(SAMPLE_GERMAN)).as("greman").isEqualTo("mochten-sie-ein-paar-apfel");
- assertThat(RenderUtils.normalize("foo bar, ,foo:bar,foo;(bar), {foo} & bar=foo.bar[foo|bar]"))
- .as("foo-bar")
- .isEqualTo("foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar");
- assertThat(RenderUtils.normalize("News for January 6, 2023 (Paris)")).as("docs example")
- .isEqualTo("news-for-january-6-2023-paris");
+ assertThat(RenderUtils.normalize("")).isEmpty();
+ assertThat(RenderUtils.normalize(SAMPLE_GERMAN)).isEqualTo("mochten-sie-ein-paar-apfel");
}
@Test
@@ -139,12 +121,10 @@ class TestRenderUtils {
@Test
void testValidateCreditCard() {
- try (var softly = new AutoCloseableSoftAssertions()) {
- softly.assertThat(RenderUtils.validateCreditCard("4505 4672 3366 6430")).as("visa").isTrue();
- softly.assertThat(RenderUtils.validateCreditCard("5189-5923-3915-0425")).as("mastercard").isTrue();
- softly.assertThat(RenderUtils.validateCreditCard("3433634926643302")).as("amex").isTrue();
- softly.assertThat(RenderUtils.validateCreditCard("6011 1076-8252 0629")).as("discover").isTrue();
- softly.assertThat(RenderUtils.validateCreditCard("0123456789012345")).as("invalid").isFalse();
- }
+ assertThat(RenderUtils.validateCreditCard("4505 4672 3366 6430")).as("visa").isTrue();
+ assertThat(RenderUtils.validateCreditCard("5189-5923-3915-0425")).as("mastercard").isTrue();
+ assertThat(RenderUtils.validateCreditCard("3433634926643302")).as("amex").isTrue();
+ assertThat(RenderUtils.validateCreditCard("6011 1076-8252 0629")).as("discover").isTrue();
+ assertThat(RenderUtils.validateCreditCard("0123456789012345")).as("invalid").isFalse();
}
}