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
This commit is contained in:
Henri Yandell 2009-10-20 04:19:47 +00:00
parent d68da319fa
commit 5b601a3d6b

View File

@ -25,9 +25,15 @@
*/ */
public class NumericEntityEscaper extends CodePointTranslator { public class NumericEntityEscaper extends CodePointTranslator {
private int below = 0; private final int below;
private int above = Integer.MAX_VALUE; private final int above;
private boolean between = true; 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) { public static NumericEntityEscaper below(int codepoint) {
return outsideOf(codepoint, Integer.MAX_VALUE); return outsideOf(codepoint, Integer.MAX_VALUE);
@ -38,18 +44,11 @@ public static NumericEntityEscaper above(int codepoint) {
} }
public static NumericEntityEscaper between(int codepointLow, int codepointHigh) { public static NumericEntityEscaper between(int codepointLow, int codepointHigh) {
NumericEntityEscaper escaper = new NumericEntityEscaper(); return new NumericEntityEscaper(codepointLow, codepointHigh, true);
escaper.above = codepointHigh;
escaper.below = codepointLow;
return escaper;
} }
public static NumericEntityEscaper outsideOf(int codepointLow, int codepointHigh) { public static NumericEntityEscaper outsideOf(int codepointLow, int codepointHigh) {
NumericEntityEscaper escaper = new NumericEntityEscaper(); return new NumericEntityEscaper(codepointLow, codepointHigh, false);
escaper.above = codepointHigh;
escaper.below = codepointLow;
escaper.between = false;
return escaper;
} }
/** /**