commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From britter <...@git.apache.org>
Subject [GitHub] commons-lang pull request #213: LANG-1288: Add a builder to StringEscapeUtil...
Date Fri, 18 Nov 2016 21:47:02 GMT
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/213#discussion_r88745205
  
    --- Diff: src/main/java/org/apache/commons/lang3/StringEscapeUtils.java ---
    @@ -429,6 +429,65 @@ public StringEscapeUtils() {
           super();
         }
     
    +    /**
    +     * <p>Convenience wrapper for {@link java.lang.StringBuilder} providing escape
methods.</p>
    +     *
    +     * <p>Example:</p>
    +     * <pre>
    +     * new Builder(ESCAPE_HTML4)
    +     *      .append("&lt;p>")
    +     *      .escape("This is paragraph 1 and special chars like &amp; get escaped.")
    +     *      .append("&lt;/p>&lt;p>")
    +     *      .escape("This is paragraph 2 &amp; more...")
    +     *      .append("&lt;/p>")
    +     *      .toString()
    +     * </pre>
    +     * 
    +     * @since 3.6
    +     */
    +    public static class Builder {
    +
    +        private final StringBuilder sb;
    +        private final CharSequenceTranslator translator;
    +
    +        public Builder(final CharSequenceTranslator translator) {
    --- End diff --
    
    I'd rather have a private constructor and then put a static factory method into `StringEscapeUtils`
instead of having the inner class that one needs to construct like `new StringEscapeUtils.Builder(ESCAPE)`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message