From 5b601a3d6bb200494c4e8d1b82e6b8953bd4cfb9 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Tue, 20 Oct 2009 04:19:47 +0000 Subject: [PATCH] Applying Sebb's patch from LANG-540 making the NumericEntityEscaper class immutable git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@826947 13f79535-47bb-0310-9956-ffa450edef68 --- .../text/translate/NumericEntityEscaper.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/java/org/apache/commons/lang/text/translate/NumericEntityEscaper.java b/src/java/org/apache/commons/lang/text/translate/NumericEntityEscaper.java index 6cf5e760a..4f096b5a2 100644 --- a/src/java/org/apache/commons/lang/text/translate/NumericEntityEscaper.java +++ b/src/java/org/apache/commons/lang/text/translate/NumericEntityEscaper.java @@ -25,9 +25,15 @@ */ public class NumericEntityEscaper extends CodePointTranslator { - private int below = 0; - private int above = Integer.MAX_VALUE; - private boolean between = true; + private final int below; + private final int above; + private final boolean between; + + private NumericEntityEscaper(int below, int above, boolean between) { + this.below = below; + this.above = above; + this.between = between; + } public static NumericEntityEscaper below(int codepoint) { return outsideOf(codepoint, Integer.MAX_VALUE); @@ -38,18 +44,11 @@ public static NumericEntityEscaper above(int codepoint) { } public static NumericEntityEscaper between(int codepointLow, int codepointHigh) { - NumericEntityEscaper escaper = new NumericEntityEscaper(); - escaper.above = codepointHigh; - escaper.below = codepointLow; - return escaper; + return new NumericEntityEscaper(codepointLow, codepointHigh, true); } public static NumericEntityEscaper outsideOf(int codepointLow, int codepointHigh) { - NumericEntityEscaper escaper = new NumericEntityEscaper(); - escaper.above = codepointHigh; - escaper.below = codepointLow; - escaper.between = false; - return escaper; + return new NumericEntityEscaper(codepointLow, codepointHigh, false); } /**