com.vgrs.xcode.common
Class UnicodeFilter

java.lang.Object
  extended by com.vgrs.xcode.common.UnicodeFilter
All Implemented Interfaces:
Filter

public class UnicodeFilter
extends java.lang.Object
implements Filter

Implements a set of Unicode codepoints and operations to determine whether certain codepoints fall inside or outside the set. Two different data structures are used to store codepoints internally.


Field Summary
static int RANGE_THRESHOLD
          This is the maximum number of ranges to allow on a plane before converting the data to a matrix.
static int UNICODE_PLANES
          The set of Unicode points is defined on the values 0 - 0x10ffff.
 
Constructor Summary
UnicodeFilter()
          Construct a UnicodeFilter
UnicodeFilter(java.lang.String aPrefix)
           
 
Method Summary
 void add(java.util.Collection<Range> aRanges)
          Stores the collection of Range objects in the filter
 void add(int aPoint)
          Adds the given code point to the filter
 void add(Range aRange)
          Store a range of integers in the UnicodeFilter.
 void add(Range[] aRanges)
          Adds an array of Range objects to the filter
 void assertAll(int[] aPoints)
          Asserts that the input array of code points exist in the filter.
 void assertNone(int[] aPoints)
          We know the exact offending codepoint at test time.
 java.lang.String getPrefix()
           
 boolean has(int aPoint)
          Test for intersection between a single integer and the UnicodeFilter
 boolean hasAll(int[] aPoints)
          Test for a non-zero intersection between an integer array and the UnicodeFilter
 boolean hasNone(int[] aPoints)
          Test for a zero intersection between an integer array and the UnicodeFilter
 void setPrefix(java.lang.String aPrefix)
           
 java.lang.String toFullString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RANGE_THRESHOLD

public static final int RANGE_THRESHOLD
This is the maximum number of ranges to allow on a plane before converting the data to a matrix. If there are only a handful of ranges, then the expense of a matrix is not justified. If the number of ranges exceeds RANGE_THRESHOLD, then a matrix of size 8K is generated and the range data is stored. Ranges contained entirely on the matrix are removed from the list.

See Also:
Constant Field Values

UNICODE_PLANES

public static final int UNICODE_PLANES
The set of Unicode points is defined on the values 0 - 0x10ffff. This is exactly 17 planes of size 0x10000. The UNICODE_PLANES variable is hard-coded with the value 17.

See Also:
Constant Field Values
Constructor Detail

UnicodeFilter

public UnicodeFilter()
Construct a UnicodeFilter


UnicodeFilter

public UnicodeFilter(java.lang.String aPrefix)
Parameters:
aPrefix - A string prefix associated with this filter
Method Detail

add

public void add(java.util.Collection<Range> aRanges)
         throws XcodeException
Description copied from interface: Filter
Stores the collection of Range objects in the filter

Specified by:
add in interface Filter
Parameters:
aRanges - collection of Range objects to add to the filter
Throws:
XcodeException

add

public void add(int aPoint)
         throws XcodeException
Description copied from interface: Filter
Adds the given code point to the filter

Specified by:
add in interface Filter
Parameters:
aPoint - the code point to add to the filter
Throws:
XcodeException

add

public void add(Range aRange)
         throws XcodeException
Store a range of integers in the UnicodeFilter.

Specified by:
add in interface Filter
Parameters:
aRange - An integer array of length two. The first element is the lower bound and the second element is the upper bound.
Throws:
XcodeException - If range is not valid Unicode

add

public void add(Range[] aRanges)
         throws XcodeException
Description copied from interface: Filter
Adds an array of Range objects to the filter

Specified by:
add in interface Filter
Parameters:
aRanges - Array of Range objects to add to the filter
Throws:
XcodeException

assertAll

public void assertAll(int[] aPoints)
               throws XcodeException
Description copied from interface: Filter
Asserts that the input array of code points exist in the filter. Even if a single code point does not exist in the filter, an XcodeException is thrown.

Specified by:
assertAll in interface Filter
Parameters:
aPoints - input array of code points to check if they are in the filter
Throws:
XcodeException

assertNone

public void assertNone(int[] aPoints)
                throws XcodeException
We know the exact offending codepoint at test time. Use this to throw a proper exception.

Specified by:
assertNone in interface Filter
Parameters:
aPoints - input array of code points to check if they are not present in the filter
Throws:
XcodeException

getPrefix

public java.lang.String getPrefix()
Returns:
the prefix identifying this UnicodeFilter

has

public boolean has(int aPoint)
Test for intersection between a single integer and the UnicodeFilter

Specified by:
has in interface Filter
Parameters:
aPoint - An integer
Returns:
If the code point does not exist in the filter, a value of false is returned. Otherwise, a value of true is returned.
Throws:
XcodeException - If an intersection is found

hasAll

public boolean hasAll(int[] aPoints)
Test for a non-zero intersection between an integer array and the UnicodeFilter

Specified by:
hasAll in interface Filter
Parameters:
aPoints - An integer array
Returns:
If a code point does not exist in the filter, a value of false is returned. Otherwise, a value of true is returned.
Throws:
XcodeException - If code points are not valid Unicode

hasNone

public boolean hasNone(int[] aPoints)
Test for a zero intersection between an integer array and the UnicodeFilter

Specified by:
hasNone in interface Filter
Parameters:
aPoints - An integer array
Returns:
If a code point exists in the filter, a value of false is returned. Otherwise, a value of true is returned.
Throws:
XcodeException - If code points are not valid Unicode

setPrefix

public void setPrefix(java.lang.String aPrefix)
Parameters:
aPrefix - the prefix identifying this UnicodeFilter

toFullString

public java.lang.String toFullString()
Returns:
String representation of the code points in this filter

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2000-2010 VeriSign Inc. All Rights Reserved