Abbreviates a template value with ellipses.
+ *Abbreviate a template value with ellipses.
* *Usage:
* @@ -36,18 +40,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).Capitalizes a template value.
@@ -37,15 +36,10 @@ 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) { - return template.getEncoder().encode(StringUtils.capitalize(template.getValueOrAttribute(differentiator))); + return RenderUtils.capitalize(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/DateIso.java b/lib/src/main/java/rife/render/DateIso.java similarity index 62% rename from src/main/java/rife/render/DateIso.java rename to lib/src/main/java/rife/render/DateIso.java index 0da04e6..b261268 100644 --- a/src/main/java/rife/render/DateIso.java +++ b/lib/src/main/java/rife/render/DateIso.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -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,15 +38,10 @@ 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) { - return template.getEncoder().encode(ZonedDateTime.now().format(RenderUtils.ISO_8601_DATE_FORMATTER)); + return ZonedDateTime.now().format(RenderUtils.ISO_8601_DATE_FORMATTER); } } diff --git a/src/main/java/rife/render/DateTimeIso.java b/lib/src/main/java/rife/render/DateTimeIso.java similarity index 54% rename from src/main/java/rife/render/DateTimeIso.java rename to lib/src/main/java/rife/render/DateTimeIso.java index e8513bb..683abb7 100644 --- a/src/main/java/rife/render/DateTimeIso.java +++ b/lib/src/main/java/rife/render/DateTimeIso.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -20,11 +20,14 @@ package rife.render; import rife.template.Template; import rife.template.ValueRenderer; +import java.io.IOException; +import java.io.StringReader; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.util.Properties; /** - *Renders the current date and time in ISO 8601 format.
+ *Return the current date and time in ISO 8601 format.
* *Usage:
* @@ -39,28 +42,25 @@ 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) { var defaultValue = template.getDefaultValue(valueId); if (defaultValue != null) { - var properties = RenderUtils.parsePropertiesString(template.getDefaultValue(valueId)); - var tz = "tz"; - if (properties.containsKey(tz)) { - return ZonedDateTime.now().format( - RenderUtils.ISO_8601_FORMATTER.withZone(ZoneId.of(properties.getProperty(tz)))); + var properties = new Properties(); + try { + var tz = "tz"; + properties.load(new StringReader(defaultValue)); + if (properties.containsKey(tz)) { + return ZonedDateTime.now().format( + RenderUtils.ISO_8601_FORMATTER.withZone(ZoneId.of(properties.getProperty(tz)))); + } + } catch (IOException ignore) { + // do nothing } } - return template.getEncoder().encode(ZonedDateTime.now().format(RenderUtils.ISO_8601_FORMATTER)); + return ZonedDateTime.now().format(RenderUtils.ISO_8601_FORMATTER); } } diff --git a/src/main/java/rife/render/DateTimeRfc2822.java b/lib/src/main/java/rife/render/DateTimeRfc2822.java similarity index 71% rename from src/main/java/rife/render/DateTimeRfc2822.java rename to lib/src/main/java/rife/render/DateTimeRfc2822.java index 2bdbd54..5058b70 100644 --- a/src/main/java/rife/render/DateTimeRfc2822.java +++ b/lib/src/main/java/rife/render/DateTimeRfc2822.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -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,15 +38,10 @@ 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) { - return template.getEncoder().encode(ZonedDateTime.now().format(RenderUtils.RFC_2822_FORMATTER)); + return ZonedDateTime.now().format(RenderUtils.RFC_2822_FORMATTER); } } diff --git a/src/main/java/rife/render/EncodeBase64.java b/lib/src/main/java/rife/render/EncodeBase64.java similarity index 69% rename from src/main/java/rife/render/EncodeBase64.java rename to lib/src/main/java/rife/render/EncodeBase64.java index e00b24c..c5bd854 100644 --- a/src/main/java/rife/render/EncodeBase64.java +++ b/lib/src/main/java/rife/render/EncodeBase64.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -40,18 +40,11 @@ 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) { - var properties = RenderUtils.parsePropertiesString(template.getDefaultValue(valueId)); - return RenderUtils.encode( - StringUtils.encodeBase64(template.getValueOrAttribute(differentiator).getBytes(StandardCharsets.UTF_8)), - properties); + return StringUtils.encodeBase64(template.getValueOrAttribute(differentiator) + .getBytes(StandardCharsets.UTF_8)); } } diff --git a/src/main/java/rife/render/EncodeHtml.java b/lib/src/main/java/rife/render/EncodeHtml.java similarity index 79% rename from src/main/java/rife/render/EncodeHtml.java rename to lib/src/main/java/rife/render/EncodeHtml.java index b67959d..858b6dd 100644 --- a/src/main/java/rife/render/EncodeHtml.java +++ b/lib/src/main/java/rife/render/EncodeHtml.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -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/lib/src/main/java/rife/render/EncodeHtmlEntities.java similarity index 82% rename from src/main/java/rife/render/EncodeHtmlEntities.java rename to lib/src/main/java/rife/render/EncodeHtmlEntities.java index cee3e8b..4f84839 100644 --- a/src/main/java/rife/render/EncodeHtmlEntities.java +++ b/lib/src/main/java/rife/render/EncodeHtmlEntities.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -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/lib/src/main/java/rife/render/EncodeJs.java similarity index 70% rename from src/main/java/rife/render/EncodeJs.java rename to lib/src/main/java/rife/render/EncodeJs.java index 27de902..caafb18 100644 --- a/src/main/java/rife/render/EncodeJs.java +++ b/lib/src/main/java/rife/render/EncodeJs.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -38,16 +38,10 @@ 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) { - var properties = RenderUtils.parsePropertiesString(template.getDefaultValue(valueId)); - return RenderUtils.encode(RenderUtils.encodeJs(template.getValueOrAttribute(differentiator)), properties); + return RenderUtils.encodeJs(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/EncodeJson.java b/lib/src/main/java/rife/render/EncodeJson.java similarity index 71% rename from src/main/java/rife/render/EncodeJson.java rename to lib/src/main/java/rife/render/EncodeJson.java index 8e17b29..60916f6 100644 --- a/src/main/java/rife/render/EncodeJson.java +++ b/lib/src/main/java/rife/render/EncodeJson.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -38,16 +38,10 @@ 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) { - var properties = RenderUtils.parsePropertiesString(template.getDefaultValue(valueId)); - return RenderUtils.encode(StringUtils.encodeJson(template.getValueOrAttribute(differentiator)), properties); + return StringUtils.encodeJson(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/EncodeUnicode.java b/lib/src/main/java/rife/render/EncodeUnicode.java similarity index 70% rename from src/main/java/rife/render/EncodeUnicode.java rename to lib/src/main/java/rife/render/EncodeUnicode.java index afd2a48..1d67bf1 100644 --- a/src/main/java/rife/render/EncodeUnicode.java +++ b/lib/src/main/java/rife/render/EncodeUnicode.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -38,16 +38,10 @@ 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) { - var properties = RenderUtils.parsePropertiesString(template.getDefaultValue(valueId)); - return RenderUtils.encode(StringUtils.encodeUnicode(template.getValueOrAttribute(differentiator)), properties); + return StringUtils.encodeUnicode(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/EncodeUrl.java b/lib/src/main/java/rife/render/EncodeUrl.java similarity index 71% rename from src/main/java/rife/render/EncodeUrl.java rename to lib/src/main/java/rife/render/EncodeUrl.java index b977353..f6201d5 100644 --- a/src/main/java/rife/render/EncodeUrl.java +++ b/lib/src/main/java/rife/render/EncodeUrl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -38,16 +38,10 @@ 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) { - var properties = RenderUtils.parsePropertiesString(template.getDefaultValue(valueId)); - return RenderUtils.encode(StringUtils.encodeUrl(template.getValueOrAttribute(differentiator)), properties); + return StringUtils.encodeUrl(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/EncodeXml.java b/lib/src/main/java/rife/render/EncodeXml.java similarity index 81% rename from src/main/java/rife/render/EncodeXml.java rename to lib/src/main/java/rife/render/EncodeXml.java index 00b0faa..743e084 100644 --- a/src/main/java/rife/render/EncodeXml.java +++ b/lib/src/main/java/rife/render/EncodeXml.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -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/lib/src/main/java/rife/render/FormatCreditCard.java similarity index 75% rename from src/main/java/rife/render/FormatCreditCard.java rename to lib/src/main/java/rife/render/FormatCreditCard.java index fec124d..840d66e 100644 --- a/src/main/java/rife/render/FormatCreditCard.java +++ b/lib/src/main/java/rife/render/FormatCreditCard.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -36,15 +36,10 @@ 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) { - return template.getEncoder().encode(RenderUtils.formatCreditCard(template.getValueOrAttribute(differentiator))); + return RenderUtils.formatCreditCard(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/Lowercase.java b/lib/src/main/java/rife/render/Lowercase.java similarity index 77% rename from src/main/java/rife/render/Lowercase.java rename to lib/src/main/java/rife/render/Lowercase.java index 6f9f2ec..d966142 100644 --- a/src/main/java/rife/render/Lowercase.java +++ b/lib/src/main/java/rife/render/Lowercase.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -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) { @@ -50,6 +45,6 @@ public class Lowercase implements ValueRenderer { if (value == null || value.isBlank()) { return value; } - return template.getEncoder().encode(value.toLowerCase(Localization.getLocale())); + return value.toLowerCase(Localization.getLocale()); } } diff --git a/lib/src/main/java/rife/render/Mask.java b/lib/src/main/java/rife/render/Mask.java new file mode 100644 index 0000000..897b415 --- /dev/null +++ b/lib/src/main/java/rife/render/Mask.java @@ -0,0 +1,64 @@ +/* + * Copyright 2023 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; + +import java.io.IOException; +import java.io.StringReader; +import java.util.Properties; + +/** + *Masks characters of a template value.
+ * + *Usage:
+ * + *+ * <!--v render:rife.render.Mask:valueId/--> + * {{v render:rife.render.Mask:valueId/}} + *+ * + * @author Erik C. Thauvin + * @see rife.render.Mask + * @since 1.0 + */ +public class Mask implements ValueRenderer { + /** + * {@inheritDoc} + */ + @Override + public String render(Template template, String valueId, String differentiator) { + var mask = "*"; + var unmasked = 0; + var fromStart = false; + var defaultValue = template.getDefaultValue(valueId); + if (defaultValue != null) { + var properties = new Properties(); + try { + properties.load(new StringReader(defaultValue)); + mask = properties.getProperty("mask", mask); + unmasked = Integer.parseInt(properties.getProperty("unmasked", "0")); + fromStart = "true".equalsIgnoreCase(properties.getProperty("fromStart", "false")); + } catch (IOException | NumberFormatException ignore) { + // do nothing + } + } + return RenderUtils.mask(template.getValueOrAttribute(differentiator), mask, unmasked, fromStart); + } +} diff --git a/src/main/java/rife/render/Normalize.java b/lib/src/main/java/rife/render/Normalize.java similarity index 73% rename from src/main/java/rife/render/Normalize.java rename to lib/src/main/java/rife/render/Normalize.java index b6cb9d1..636c8cb 100644 --- a/src/main/java/rife/render/Normalize.java +++ b/lib/src/main/java/rife/render/Normalize.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -36,15 +36,10 @@ 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) { - return template.getEncoder().encode(RenderUtils.normalize(template.getValueOrAttribute(differentiator))); + return RenderUtils.normalize(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/QrCode.java b/lib/src/main/java/rife/render/QrCode.java similarity index 70% rename from src/main/java/rife/render/QrCode.java rename to lib/src/main/java/rife/render/QrCode.java index 47f74c0..3521992 100644 --- a/src/main/java/rife/render/QrCode.java +++ b/lib/src/main/java/rife/render/QrCode.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -20,6 +20,10 @@ package rife.render; import rife.template.Template; import rife.template.ValueRenderer; +import java.io.IOException; +import java.io.StringReader; +import java.util.Properties; + /** *
Generates an SVG QR Code for a template value using goQR.me.
* @@ -36,17 +40,21 @@ 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) { - var properties = RenderUtils.parsePropertiesString(template.getDefaultValue(valueId)); - var size = properties.getProperty("size", "150x150"); + var size = "150x150"; + var defaultValue = template.getDefaultValue(valueId); + if (defaultValue != null) { + var properties = new Properties(); + try { + properties.load(new StringReader(defaultValue)); + size = properties.getProperty("size", size); + } catch (IOException ignore) { + // do nothing + } + } return RenderUtils.qrCode(template.getValueOrAttribute(differentiator), size); } } diff --git a/src/main/java/rife/render/RenderUtils.java b/lib/src/main/java/rife/render/RenderUtils.java similarity index 61% rename from src/main/java/rife/render/RenderUtils.java rename to lib/src/main/java/rife/render/RenderUtils.java index c05f5b9..f856408 100644 --- a/src/main/java/rife/render/RenderUtils.java +++ b/lib/src/main/java/rife/render/RenderUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -21,19 +21,16 @@ import rife.tools.Localization; import rife.tools.StringUtils; import java.io.IOException; -import java.io.StringReader; import java.net.HttpURLConnection; -import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.StandardCharsets; import java.text.Normalizer; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoField; import java.util.Properties; import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Collection of utility-type methods commonly used by the renderers. @@ -42,10 +39,6 @@ import java.util.logging.Logger; * @since 1.0 */ public final class RenderUtils { - /** - * The encoding property. - */ - public static final String ENCODING_PROPERTY = "encoding"; /** * ISO 8601 date formatter. * @@ -83,19 +76,18 @@ 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 RenderUtils() { // no-op } /** - * Abbreviates a {@code String} to the given length using a replacement marker. + * Abbreviates a String to the given length using a replacement marker. * - * @param src the source {@code String} - * @param max the maximum length of the resulting {@code String} - * @param marker the {@code String} used as a replacement marker - * @return the abbreviated {@code String} + * @param src the source String + * @param max the maximum length of the resulting String + * @param marker the String used as a replacement marker + * @return the abbreviated String */ public static String abbreviate(String src, int max, String marker) { if (src == null || src.isBlank() || marker == null) { @@ -114,102 +106,34 @@ public final class RenderUtils { /** * Returns the Swatch Internet (.beat) Time for the give date-time. * - * @param zonedDateTime the date and time + * @param zonedDateTime the date and time. * @return the .beat time. (eg.: {@code @248}) */ public static String beatTime(ZonedDateTime zonedDateTime) { var zdt = zonedDateTime.withZoneSameInstant(ZoneId.of("UTC+01:00")); - var beats = (int) ((zdt.getSecond() + (zdt.getMinute() * 60) + - (zdt.getHour() * 3600)) / 86.4); + var beats = (int) ((zdt.get(ChronoField.SECOND_OF_MINUTE) + (zdt.get(ChronoField.MINUTE_OF_HOUR) * 60) + + (zdt.get(ChronoField.HOUR_OF_DAY) * 3600)) / 86.4); return String.format("@%03d", beats); } /** - * Returns a {@code String} with the first letter of each word capitalized. + * Capitalizes a String. * - * @param src the source {@code String} - * @return the capitalized {@code String} + * @param src the source String + * @return the capitalized String */ - public static String capitalizeWords(String src) { + public static String capitalize(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(); + return src.substring(0, 1).toUpperCase(Localization.getLocale()) + src.substring(1); } /** - *Encodes the source {@code String} to the specified encoding.
+ * Encodes a String to JavaScript/ECMAScript. * - *The supported encodings are:
- * - *Returns the last 4 digits a credit card number.
- * - *Shortens a URL using is.gid.
* - *The URL {@code String} must be a valid http or https URL.
+ *The URL String must be a valid http or https URL.
* *Based on isgd-shorten
* @@ -503,8 +409,8 @@ public final class RenderUtils { /** * Swaps the case of a String. * - * @param src the {@code String} to swap the case of - * @return the modified {@code String} or null + * @param src the String to swap the case of + * @return the modified String or null */ @SuppressWarnings("PMD.AvoidReassigningLoopVariables") public static String swapCase(String src) { @@ -532,6 +438,19 @@ public final class RenderUtils { return new String(buff, 0, offset); } + /** + * Uncapitalizes a String. + * + * @param src the source String + * @return the uncapitalized String + */ + public static String uncapitalize(String src) { + if (src == null || src.isBlank()) { + return src; + } + return src.substring(0, 1).toLowerCase(Localization.getLocale()) + src.substring(1); + } + /** *Returns the formatted server uptime.
* @@ -554,7 +473,7 @@ public final class RenderUtils { * * @param uptime the uptime in milliseconds * @param properties the format properties - * @return the formatted uptime + * @return the formatted uptime. */ @SuppressWarnings("UnnecessaryUnicodeEscape") public static String uptime(long uptime, Properties properties) { @@ -601,43 +520,4 @@ public final class RenderUtils { return sb.toString(); } - - /** - * Validates a credit card number using the Luhn algorithm. - * - * @param cc the credit card number - * @return {@code true} if the credit card number is valid - */ - public static boolean validateCreditCard(String cc) { - try { - var len = cc.length(); - if (len >= 8 && len <= 19) { - // Luhn algorithm - var sum = 0; - boolean second = false; - int digit; - char c; - for (int i = len - 1; i >= 0; i--) { - c = cc.charAt(i); - if (c >= '0' && c <= '9') { - digit = cc.charAt(i) - '0'; - if (second) { - digit = digit * 2; - } - sum += digit / 10; - sum += digit % 10; - - second = !second; - } - } - if (sum % 10 == 0) { - return true; - } - } - } catch (NumberFormatException ignored) { - // do nothing - } - return false; - } - } \ No newline at end of file diff --git a/src/main/java/rife/render/Rot13.java b/lib/src/main/java/rife/render/Rot13.java similarity index 74% rename from src/main/java/rife/render/Rot13.java rename to lib/src/main/java/rife/render/Rot13.java index 75e3dd7..4bca6db 100644 --- a/src/main/java/rife/render/Rot13.java +++ b/lib/src/main/java/rife/render/Rot13.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -36,15 +36,10 @@ 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) { - return template.getEncoder().encode(RenderUtils.rot13(template.getValueOrAttribute(differentiator))); + return RenderUtils.rot13(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/ShortenUrl.java b/lib/src/main/java/rife/render/ShortenUrl.java similarity index 74% rename from src/main/java/rife/render/ShortenUrl.java rename to lib/src/main/java/rife/render/ShortenUrl.java index 204d7c6..b52c686 100644 --- a/src/main/java/rife/render/ShortenUrl.java +++ b/lib/src/main/java/rife/render/ShortenUrl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -38,15 +38,10 @@ 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) { - return template.getEncoder().encode(RenderUtils.shortenUrl(template.getValueOrAttribute(differentiator))); + return RenderUtils.shortenUrl(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/SwapCase.java b/lib/src/main/java/rife/render/SwapCase.java similarity index 71% rename from src/main/java/rife/render/SwapCase.java rename to lib/src/main/java/rife/render/SwapCase.java index 1fd996a..270f1f6 100644 --- a/src/main/java/rife/render/SwapCase.java +++ b/lib/src/main/java/rife/render/SwapCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -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,16 +35,12 @@ 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) { - return template.getEncoder().encode(RenderUtils.swapCase(template.getValueOrAttribute(differentiator))); + return RenderUtils.swapCase(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/TimeIso.java b/lib/src/main/java/rife/render/TimeIso.java similarity index 67% rename from src/main/java/rife/render/TimeIso.java rename to lib/src/main/java/rife/render/TimeIso.java index 01bf5b2..e1f0023 100644 --- a/src/main/java/rife/render/TimeIso.java +++ b/lib/src/main/java/rife/render/TimeIso.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -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,15 +38,10 @@ 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) { - return template.getEncoder().encode(ZonedDateTime.now().format(RenderUtils.ISO_8601_TIME_FORMATTER)); + return ZonedDateTime.now().format(RenderUtils.ISO_8601_TIME_FORMATTER); } } diff --git a/src/main/java/rife/render/Trim.java b/lib/src/main/java/rife/render/Trim.java similarity index 74% rename from src/main/java/rife/render/Trim.java rename to lib/src/main/java/rife/render/Trim.java index a0951b4..53a66e1 100644 --- a/src/main/java/rife/render/Trim.java +++ b/lib/src/main/java/rife/render/Trim.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -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) { @@ -49,6 +44,6 @@ public class Trim implements ValueRenderer { if (value == null || value.isEmpty()) { return value; } - return template.getEncoder().encode(value.trim()); + return value.trim(); } } diff --git a/src/main/java/rife/render/Uncapitalize.java b/lib/src/main/java/rife/render/Uncapitalize.java similarity index 72% rename from src/main/java/rife/render/Uncapitalize.java rename to lib/src/main/java/rife/render/Uncapitalize.java index 20b0aad..1e670a7 100644 --- a/src/main/java/rife/render/Uncapitalize.java +++ b/lib/src/main/java/rife/render/Uncapitalize.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -19,7 +19,6 @@ package rife.render; import rife.template.Template; import rife.template.ValueRenderer; -import rife.tools.StringUtils; /** *Un-capitalizes a template value.
@@ -37,15 +36,10 @@ 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) { - return template.getEncoder().encode(StringUtils.uncapitalize(template.getValueOrAttribute(differentiator))); + return RenderUtils.uncapitalize(template.getValueOrAttribute(differentiator)); } } diff --git a/src/main/java/rife/render/Uppercase.java b/lib/src/main/java/rife/render/Uppercase.java similarity index 74% rename from src/main/java/rife/render/Uppercase.java rename to lib/src/main/java/rife/render/Uppercase.java index 92e57a5..bb45bb7 100644 --- a/src/main/java/rife/render/Uppercase.java +++ b/lib/src/main/java/rife/render/Uppercase.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -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) { @@ -50,6 +45,6 @@ public class Uppercase implements ValueRenderer { if (value == null || value.isBlank()) { return value; } - return template.getEncoder().encode(value.toUpperCase(Localization.getLocale())); + return value.toUpperCase(Localization.getLocale()); } } diff --git a/src/main/java/rife/render/Uptime.java b/lib/src/main/java/rife/render/Uptime.java similarity index 63% rename from src/main/java/rife/render/Uptime.java rename to lib/src/main/java/rife/render/Uptime.java index 14bb2de..06b1371 100644 --- a/src/main/java/rife/render/Uptime.java +++ b/lib/src/main/java/rife/render/Uptime.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -20,7 +20,10 @@ package rife.render; import rife.template.Template; import rife.template.ValueRenderer; +import java.io.IOException; +import java.io.StringReader; import java.lang.management.ManagementFactory; +import java.util.Properties; /** * Renders the server uptime. @@ -38,23 +41,24 @@ 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) { - var properties = RenderUtils.parsePropertiesString(template.getDefaultValue(valueId)); - String uptime; - if (template.hasAttribute(Uptime.class.getName())) { - uptime = RenderUtils.uptime((long) template.getAttribute(Uptime.class.getName()), properties); - } else { - uptime = RenderUtils.uptime(ManagementFactory.getRuntimeMXBean().getUptime(), properties); + var properties = new Properties(); + var defaultValue = template.getDefaultValue(valueId); + if (defaultValue != null) { + try { + properties.load(new StringReader(defaultValue)); + } catch (IOException ignore) { + // ignore + } } - return template.getEncoder().encode(uptime); + if (template.hasAttribute(Uptime.class.getName())) { + return RenderUtils.uptime((long) template.getAttribute(Uptime.class.getName()), properties); + } else { + return RenderUtils.uptime(ManagementFactory.getRuntimeMXBean().getUptime(), properties); + } } } diff --git a/src/main/java/rife/render/Year.java b/lib/src/main/java/rife/render/Year.java similarity index 71% rename from src/main/java/rife/render/Year.java rename to lib/src/main/java/rife/render/Year.java index cb8c8f5..d146738 100644 --- a/src/main/java/rife/render/Year.java +++ b/lib/src/main/java/rife/render/Year.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -37,16 +37,12 @@ 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) { - return template.getEncoder().encode(ZonedDateTime.now().format(RenderUtils.ISO_8601_YEAR_FORMATTER)); + return ZonedDateTime.now().format(RenderUtils.ISO_8601_YEAR_FORMATTER); } } diff --git a/src/test/java/rife/render/TestCase.java b/lib/src/test/java/rife/render/TestCase.java similarity index 86% rename from src/test/java/rife/render/TestCase.java rename to lib/src/test/java/rife/render/TestCase.java index 2759ff6..cebd066 100644 --- a/src/test/java/rife/render/TestCase.java +++ b/lib/src/test/java/rife/render/TestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -40,9 +40,6 @@ class TestCase { var bean = new ValueBean("this IS a TEST."); t.setBean(bean); assertThat(t.getContent()).isEqualTo(bean.getValue() + ": this is a test."); - bean = new ValueBean(""); - t.setBean(bean); - assertThat(t.getContent()).isEqualTo(bean.getValue() + ": "); } @Test @@ -57,8 +54,6 @@ class TestCase { var t = TemplateFactory.TXT.get("trim"); t.setAttribute(FOO, "\t" + SAMPLE_TEXT + " \n"); assertThat(t.getContent()).isEqualTo(SAMPLE_TEXT); - t.setAttribute(FOO, ""); - assertThat(t.getContent()).isEmpty(); } @Test @@ -73,7 +68,5 @@ class TestCase { var t = TemplateFactory.TXT.get("uppercase"); t.setAttribute("bar", SAMPLE_TEXT); assertThat(t.getContent()).isEqualTo(SAMPLE_TEXT.toUpperCase(Localization.getLocale())); - t.setAttribute("bar", ""); - assertThat(t.getContent()).isEmpty(); } } \ No newline at end of file diff --git a/src/test/java/rife/render/TestDateTime.java b/lib/src/test/java/rife/render/TestDateTime.java similarity index 97% rename from src/test/java/rife/render/TestDateTime.java rename to lib/src/test/java/rife/render/TestDateTime.java index bfb8cc7..55bb519 100644 --- a/src/test/java/rife/render/TestDateTime.java +++ b/lib/src/test/java/rife/render/TestDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. diff --git a/src/test/java/rife/render/TestEncode.java b/lib/src/test/java/rife/render/TestEncode.java similarity index 66% rename from src/test/java/rife/render/TestEncode.java rename to lib/src/test/java/rife/render/TestEncode.java index bc390d4..c5bc8bd 100644 --- a/src/test/java/rife/render/TestEncode.java +++ b/lib/src/test/java/rife/render/TestEncode.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * Copyright 2023 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. @@ -28,10 +28,6 @@ class TestEncode { var t = TemplateFactory.TXT.get("encodeBase64"); t.setValue(TestCase.FOO, TestCase.SAMPLE_TEXT); assertThat(t.getContent()).isEqualTo(t.getValue(TestCase.FOO) + ": VGhpcyBpcyBhIHRlc3Qu"); - - t = TemplateFactory.HTML.get("encodeBase64"); - t.setValue(TestCase.FOO, TestCase.SAMPLE_TEXT + " URL Encoded."); - assertThat(t.getContent()).as("with URL encoding").contains("VGhpcyBpcyBhIHRlc3QuIFVSTCBFbmNvZGVkLg%3D%3D"); } @Test @@ -54,15 +50,6 @@ class TestEncode { var t = TemplateFactory.TXT.get("encodeJs"); t.setAttribute(TestCase.FOO, "'\"\\/"); assertThat(t.getContent()).isEqualTo("\\'\\\"\\\\\\/"); - - t = TemplateFactory.TXT.get("encodeJs"); - 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"); - t.setAttribute(TestCase.FOO, '"' + TestCase.SAMPLE_TEXT + '"'); - assertThat(t.getContent()).as("with unicode") - .isEqualTo("\\u005C\\u0022\\u0054\\u0068\\u0069\\u0073\\u0020\\u0069\\u0073\\u0020\\u0061\\u0020\\u0074\\u0065\\u0073\\u0074\\u002E\\u005C\\u0022"); } @Test @@ -70,10 +57,6 @@ class TestEncode { var t = TemplateFactory.JSON.get("encodeJson"); t.setAttribute(TestCase.FOO, "This is a \"•test\""); assertThat(t.getContent()).isEqualTo("{\n \"foo\": \"This is a \\\"\\u2022test\\\"\"\n}"); - - t = TemplateFactory.HTML.get("encodeJson"); - t.setAttribute(TestCase.FOO, "\"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/Mask.java b/src/main/java/rife/render/Mask.java deleted file mode 100644 index fe0a709..0000000 --- a/src/main/java/rife/render/Mask.java +++ /dev/null @@ -1,82 +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; - -/** - *
Masks characters of a template value.
- * - *Usage:
- * - *- * <!--v render:rife.render.Mask:valueId/--> - * {{v render:rife.render.Mask:valueId/}} - *- * - * @author Erik C. Thauvin - * @see rife.render.Mask - * @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:
- * - **
0
false