Commons Lang
  1. Commons Lang
  2. LANG-260

StringEscapeUtils should expose escape*() methods taking Writer argument

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2
    • Component/s: None
    • Labels:
      None
    • Environment:

      N/A

      Description

      StringEscapeUtils.escapeXML(String) is the only exposed variant, but the package private Entities.XML class it uses under the covers has a variant taking a Writer. The StringEscapeUtils.escapeXML(Writer, String) variant would be much more efficient when incrementally escaping values and adding them one-by-one and could seemingly be exposed with very little effort. Ditto for the unescapeXML() case, and presumably other styles of escape/unescape (like HTML) that use the Entities class under the covers.

        Activity

        Hide
        Henri Yandell added a comment -

        Consider for 2.2. Haven't looked at the source in question for a few weeks, but it sounds fine at first glance.

        Show
        Henri Yandell added a comment - Consider for 2.2. Haven't looked at the source in question for a few weeks, but it sounds fine at first glance.
        Hide
        Henri Yandell added a comment -

        svn ci -m "Exposing the unescapeXml and escapeXml methods that take Writers - LANG-260. A recent thread
        did point out that there are problems with the concept of escaping Xml as a single method, and instead it needs to be an xml parser that escapes the body an
        d the attribute content differently - however we're obviously not there yet and I don't think making the existing 80/20 good enough code more usable hurts.
        " src/java/org/apache/commons/lang/StringEscapeUtils.java src/test/org/apache/commons/lang/StringEscapeUtilsTest.java
        Sending src/java/org/apache/commons/lang/StringEscapeUtils.java
        Sending src/test/org/apache/commons/lang/StringEscapeUtilsTest.java
        Transmitting file data ..
        Committed revision 412009.

        Show
        Henri Yandell added a comment - svn ci -m "Exposing the unescapeXml and escapeXml methods that take Writers - LANG-260 . A recent thread did point out that there are problems with the concept of escaping Xml as a single method, and instead it needs to be an xml parser that escapes the body an d the attribute content differently - however we're obviously not there yet and I don't think making the existing 80/20 good enough code more usable hurts. " src/java/org/apache/commons/lang/StringEscapeUtils.java src/test/org/apache/commons/lang/StringEscapeUtilsTest.java Sending src/java/org/apache/commons/lang/StringEscapeUtils.java Sending src/test/org/apache/commons/lang/StringEscapeUtilsTest.java Transmitting file data .. Committed revision 412009.
        Hide
        Holger Hoffstätte added a comment -

        StringWriter is just a glorified StringBuffer and has exactly no performance advantage to a correctly presized StringBuffer. I think the refactoring done for this has undone what I just commented on in LANG-287.

        Show
        Holger Hoffstätte added a comment - StringWriter is just a glorified StringBuffer and has exactly no performance advantage to a correctly presized StringBuffer. I think the refactoring done for this has undone what I just commented on in LANG-287 .
        Hide
        Henri Yandell added a comment -

        This went in 2.2, however LANG-287 is going in 2.3 - and if you check the revision numbers you'll see that this revision number is much lower than the other. Not to say LANG-287 hasn't been undone, but it wasn't this issue that did it as this was resolved before LANG-287 was even created.

        Show
        Henri Yandell added a comment - This went in 2.2, however LANG-287 is going in 2.3 - and if you check the revision numbers you'll see that this revision number is much lower than the other. Not to say LANG-287 hasn't been undone, but it wasn't this issue that did it as this was resolved before LANG-287 was even created.

          People

          • Assignee:
            Unassigned
            Reporter:
            Norval Hope
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development