diff --git a/.idea/misc.xml b/.idea/misc.xml index b018d04..2fa2388 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,6 +3,7 @@ + diff --git a/README.md b/README.md index cdfbbcb..df26021 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ This project provides a collection of useful template renderers. | [rife.render.Capitalize](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.Capitalize) | Capitalizes a template value | | [rife.render.Lowercase](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.Lowercase) | Converts a template value to lowercase | | [rife.render.Rot13](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.Rot13) | Translates a template value to/from ROT13 | -| [rife.render.SwapCase](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.SwapCase) | Swap case of a template value | +| [rife.render.SwapCase](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.SwapCase) | Swaps case of a template value | | [rife.render.Trim](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.Trim) | Removes leading and trailing whitespace from a template value | | [rife.render.Uncapitalize](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.Uncapitalize) | Uncapitalizes a template value | | [rife.render.Uppercase](https://github.com/rife2/rife2-template-renderers/wiki/rife.render.Uppercase) | Converts a template value to uppercase | diff --git a/src/main/java/rife/render/Abbreviate.java b/src/main/java/rife/render/Abbreviate.java index b0b38e5..dfacacb 100644 --- a/src/main/java/rife/render/Abbreviate.java +++ b/src/main/java/rife/render/Abbreviate.java @@ -21,7 +21,7 @@ import rife.template.ValueRenderer; /** - * Abbreviate a template value with ellipses. + * Abbreviates a template value with ellipses. * * Usage: * @@ -36,7 +36,18 @@ */ public class Abbreviate implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 23849f3..f11f97f 100644 --- a/src/main/java/rife/render/BeatTime.java +++ b/src/main/java/rife/render/BeatTime.java @@ -38,7 +38,12 @@ */ public class BeatTime implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 7805b4c..e0d769f 100644 --- a/src/main/java/rife/render/Capitalize.java +++ b/src/main/java/rife/render/Capitalize.java @@ -37,7 +37,12 @@ */ public class Capitalize implements ValueRenderer { /** - * {@inheritDoc} + * 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) { diff --git a/src/main/java/rife/render/DateIso.java b/src/main/java/rife/render/DateIso.java index a2f1f9e..0da04e6 100644 --- a/src/main/java/rife/render/DateIso.java +++ b/src/main/java/rife/render/DateIso.java @@ -23,7 +23,7 @@ import java.time.ZonedDateTime; /** - * Return the current date in ISO 8601 format. + * Renders the current date in ISO 8601 format. * * Usage: * @@ -38,7 +38,12 @@ */ public class DateIso implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 805a6cd..e8513bb 100644 --- a/src/main/java/rife/render/DateTimeIso.java +++ b/src/main/java/rife/render/DateTimeIso.java @@ -24,7 +24,7 @@ import java.time.ZonedDateTime; /** - * Return the current date and time in ISO 8601 format. + * Renders the current date and time in ISO 8601 format. * * Usage: * @@ -39,7 +39,15 @@ */ public class DateTimeIso implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 3a33842..2bdbd54 100644 --- a/src/main/java/rife/render/DateTimeRfc2822.java +++ b/src/main/java/rife/render/DateTimeRfc2822.java @@ -23,7 +23,7 @@ import java.time.ZonedDateTime; /** - * Return the current date and time in RFC 2822 format. + * Renders the current date and time in RFC 2822 format. * * Usage: * @@ -38,7 +38,12 @@ */ public class DateTimeRfc2822 implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 95d1e30..e00b24c 100644 --- a/src/main/java/rife/render/EncodeBase64.java +++ b/src/main/java/rife/render/EncodeBase64.java @@ -40,7 +40,12 @@ */ public class EncodeBase64 implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 ee14bdd..b67959d 100644 --- a/src/main/java/rife/render/EncodeHtml.java +++ b/src/main/java/rife/render/EncodeHtml.java @@ -38,7 +38,12 @@ */ public class EncodeHtml implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 bbf6043..cee3e8b 100644 --- a/src/main/java/rife/render/EncodeHtmlEntities.java +++ b/src/main/java/rife/render/EncodeHtmlEntities.java @@ -36,7 +36,12 @@ */ public class EncodeHtmlEntities implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 52c757d..27de902 100644 --- a/src/main/java/rife/render/EncodeJs.java +++ b/src/main/java/rife/render/EncodeJs.java @@ -38,7 +38,12 @@ */ public class EncodeJs implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 95fbf34..8e17b29 100644 --- a/src/main/java/rife/render/EncodeJson.java +++ b/src/main/java/rife/render/EncodeJson.java @@ -38,7 +38,12 @@ */ public class EncodeJson implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 061da96..afd2a48 100644 --- a/src/main/java/rife/render/EncodeUnicode.java +++ b/src/main/java/rife/render/EncodeUnicode.java @@ -38,7 +38,12 @@ */ public class EncodeUnicode implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 a6c554f..b977353 100644 --- a/src/main/java/rife/render/EncodeUrl.java +++ b/src/main/java/rife/render/EncodeUrl.java @@ -38,7 +38,12 @@ */ public class EncodeUrl implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 b1c6eff..00b0faa 100644 --- a/src/main/java/rife/render/EncodeXml.java +++ b/src/main/java/rife/render/EncodeXml.java @@ -38,7 +38,12 @@ */ public class EncodeXml implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 f2fc815..fec124d 100644 --- a/src/main/java/rife/render/FormatCreditCard.java +++ b/src/main/java/rife/render/FormatCreditCard.java @@ -36,7 +36,12 @@ */ public class FormatCreditCard implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 8513222..6f9f2ec 100644 --- a/src/main/java/rife/render/Lowercase.java +++ b/src/main/java/rife/render/Lowercase.java @@ -37,7 +37,12 @@ */ public class Lowercase implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 eb96702..fe0a709 100644 --- a/src/main/java/rife/render/Mask.java +++ b/src/main/java/rife/render/Mask.java @@ -35,8 +35,30 @@ * @since 1.0 */ public class Mask implements ValueRenderer { + /** - * {@inheritDoc} + * 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 */ @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 a07fb9b..b6cb9d1 100644 --- a/src/main/java/rife/render/Normalize.java +++ b/src/main/java/rife/render/Normalize.java @@ -36,7 +36,12 @@ */ public class Normalize implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 ddf8091..47f74c0 100644 --- a/src/main/java/rife/render/QrCode.java +++ b/src/main/java/rife/render/QrCode.java @@ -36,7 +36,12 @@ */ public class QrCode implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 f2f0859..50b4576 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 final static Logger LOGGER = Logger.getLogger(RenderUtils.class.getName()); + private static final Logger LOGGER = Logger.getLogger(RenderUtils.class.getName()); private RenderUtils() { // no-op diff --git a/src/main/java/rife/render/Rot13.java b/src/main/java/rife/render/Rot13.java index d9e5326..75e3dd7 100644 --- a/src/main/java/rife/render/Rot13.java +++ b/src/main/java/rife/render/Rot13.java @@ -36,7 +36,12 @@ */ public class Rot13 implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 1ceeec9..204d7c6 100644 --- a/src/main/java/rife/render/ShortenUrl.java +++ b/src/main/java/rife/render/ShortenUrl.java @@ -38,7 +38,12 @@ */ public class ShortenUrl implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 4278768..1fd996a 100644 --- a/src/main/java/rife/render/SwapCase.java +++ b/src/main/java/rife/render/SwapCase.java @@ -21,7 +21,7 @@ import rife.template.ValueRenderer; /** - * Swap case of a template value. + * Swaps case of a template value. * * Usage: * @@ -35,9 +35,13 @@ * @since 1.0 */ public class SwapCase implements ValueRenderer { - /** - * {@inheritDoc} + * 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 */ @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 a62c44b..01bf5b2 100644 --- a/src/main/java/rife/render/TimeIso.java +++ b/src/main/java/rife/render/TimeIso.java @@ -23,7 +23,7 @@ import java.time.ZonedDateTime; /** - * Return the current time in ISO 8601 format. + * Renders the current time in ISO 8601 format. * * Usage: * @@ -38,7 +38,12 @@ */ public class TimeIso implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 f3b2980..a0951b4 100644 --- a/src/main/java/rife/render/Trim.java +++ b/src/main/java/rife/render/Trim.java @@ -36,7 +36,12 @@ */ public class Trim implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 53b8a45..20b0aad 100644 --- a/src/main/java/rife/render/Uncapitalize.java +++ b/src/main/java/rife/render/Uncapitalize.java @@ -37,7 +37,12 @@ */ public class Uncapitalize implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 31ecd9a..92e57a5 100644 --- a/src/main/java/rife/render/Uppercase.java +++ b/src/main/java/rife/render/Uppercase.java @@ -22,7 +22,7 @@ import rife.tools.Localization; /** - * Convert a template value to uppercase. + * Converts a template value to uppercase. * * Usage: * @@ -37,7 +37,12 @@ */ public class Uppercase implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 2fe1a5d..14bb2de 100644 --- a/src/main/java/rife/render/Uptime.java +++ b/src/main/java/rife/render/Uptime.java @@ -38,7 +38,12 @@ */ public class Uptime implements ValueRenderer { /** - * {@inheritDoc} + * 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 */ @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 b79911a..cb8c8f5 100644 --- a/src/main/java/rife/render/Year.java +++ b/src/main/java/rife/render/Year.java @@ -37,9 +37,13 @@ * @since 1.0 */ public class Year implements ValueRenderer { - /** - * {@inheritDoc} + * 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 */ @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 2fab8c9..8c369d6 100644 --- a/src/test/java/rife/render/DisabledOnCi.java +++ b/src/test/java/rife/render/DisabledOnCi.java @@ -30,7 +30,7 @@ * @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 d02571f..bc390d4 100644 --- a/src/test/java/rife/render/TestEncode.java +++ b/src/test/java/rife/render/TestEncode.java @@ -56,7 +56,7 @@ void testEncodeJs() { 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");
Abbreviate a template value with ellipses.
Abbreviates a template value with ellipses.
Usage:
Returns the template value abbreviated with ellipses.
Two parameters can be specified:
mark
...
max
-1
Return the current date in ISO 8601 format.
Renders the current date in ISO 8601 format.
Return the current date and time in ISO 8601 format.
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.
Return the current date and time in RFC 2822 format.
Renders the current date and time in RFC 2822 format.
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:
*
0
false
Swap case of a template value.
Swaps case of a template value.
Return the current time in ISO 8601 format.
Renders the current time in ISO 8601 format.
Convert a template value to uppercase.
Converts a template value to uppercase.