Package org.marketcetera.util.misc
Class UCPFilter
- java.lang.Object
-
- org.marketcetera.util.misc.UCPFilter
-
- Direct Known Subclasses:
UCPFilter.UCPCharsetFilter
public abstract class UCPFilter extends Object
A filter for Unicode code points. It also maintains a cache of filters associated withCharsetinstances.For charset-based filters, this class may perform slowly when the cache is built, if the JVM is running with an active debugging agent. This is because the JRE implements the acceptability test by throwing and catching an exception, which is trapped by the agent; if the charset can only encode a small subset of the Unicode code points, then a lot of exceptions are thrown and caught, resulting in a performance degradation as the agent intercepts repeatedly (even if the debugger does not indicate an interest in exceptions).
- Since:
- 0.6.0
- Version:
- $Id: UCPFilter.java 16154 2012-07-14 16:34:05Z colin $
- Author:
- tlerios@marketcetera.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classUCPFilter.UCPCharsetFilterA filter for Unicode characters that can be encoded by a specific charset.
-
Field Summary
Fields Modifier and Type Field Description static UCPFilterALNUMA filter for Unicode code points that are letters or digits.static UCPFilterCHARA filter for Unicode characters that can be represented by a single char.static UCPFilterDIGITA filter for Unicode code points that are digits.static UCPFilterLETTERA filter for Unicode code points that are letters.private static HashMap<Charset,UCPFilter>mMapstatic UCPFilterVALIDA filter for Unicode characters deemed valid byStringUtils.isValid(int).
-
Constructor Summary
Constructors Constructor Description UCPFilter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static UCPFilterforCharset(Charset cs)Returns a filter for Unicode code points that can be encoded by the given charset.static UCPFiltergetDefaultCharset()Returns a filter for Unicode code points that can be encoded by the default JVM charset.static UCPFiltergetFileSystemCharset()Returns a filter for Unicode code points that can be encoded by the current system file encoding/charset (as specified in the system propertyfile.encoding).abstract booleanisAcceptable(int ucp)Checks whether the given Unicode code point is acceptable to the receiver.
-
-
-
Field Detail
-
VALID
public static final UCPFilter VALID
A filter for Unicode characters deemed valid byStringUtils.isValid(int).
-
CHAR
public static final UCPFilter CHAR
A filter for Unicode characters that can be represented by a single char.
-
DIGIT
public static final UCPFilter DIGIT
A filter for Unicode code points that are digits.
-
LETTER
public static final UCPFilter LETTER
A filter for Unicode code points that are letters.
-
ALNUM
public static final UCPFilter ALNUM
A filter for Unicode code points that are letters or digits.
-
-
Method Detail
-
forCharset
public static UCPFilter forCharset(Charset cs)
Returns a filter for Unicode code points that can be encoded by the given charset.- Parameters:
cs- The charset.- Returns:
- The filter.
-
getDefaultCharset
public static final UCPFilter getDefaultCharset()
Returns a filter for Unicode code points that can be encoded by the default JVM charset.- Returns:
- The filter.
-
getFileSystemCharset
public static final UCPFilter getFileSystemCharset()
Returns a filter for Unicode code points that can be encoded by the current system file encoding/charset (as specified in the system propertyfile.encoding).- Returns:
- The filter.
-
isAcceptable
public abstract boolean isAcceptable(int ucp)
Checks whether the given Unicode code point is acceptable to the receiver.- Parameters:
ucp- The code point.- Returns:
- True if so.
-
-