FileDocCategorySizeDatePackage
CollationElementTable.javaAPI DocphoneME MR2 API (J2ME)9250Wed May 02 18:00:46 BST 2007com.sun.j2me.global

CollationElementTable

public abstract class CollationElementTable extends Object
This interface is used to get collation elements from one or more unicode code points.

Fields Summary
public static final int
TERMINAL_CODE_POINT
A value which is used to terminate the code point sequence when traversing possible contractions.
public static final int
INVALID_BOOKMARK_VALUE
A value which represents an invalid bookmark. It can be returned by the {@link #getChildBookmark} method when trying to get the bookmark for a non-existing contraction.
protected static final int
L1_MASK
A mask to decode the L1 weight value of an encoded collation element.
protected static final int
L2_MASK
A mask to decode the L2 weight value of an encoded collation element.
protected static final int
L3_MASK
A mask to decode the L3 weight value of an encoded collation element.
protected static final int
VW_FLAG
A flag indicating a code point with a variable weight.
protected static final int
SINGLE_CE_FLAG
A flag indicating a single encoded collation element.
protected static final int
BOOKMARK_FLAG
A flag indicating a bookmark.
protected static final int
L2_SHIFT
A shift value to decode the L2 weight value of an encoded collation element.
protected static final int
L3_SHIFT
A shift value to decode the L3 weight value of an encoded collation element.
Constructors Summary
Methods Summary
public abstract intgetChildBookmark(int bookmark, int cp)
This method can be used to traverse the contractions. The traversing starts when the {@link #getCollationElements} method returns a bookmark instead of collation elements. The returned bookmark, which represents a code point sequence consisting only of one code point, can be further tested if it's extensible by various other code points.

If a partial match is found, the method returns another bookmark which represents the new sequence. The new bookmark can be further "refined" as well. To get the collation elements for the sequence, the sequence has to be terminated by the getChildBookmark(bookmark, TERMINAL_CODE_POINT) call. If the call returns a valid bookmark, it is guaranteed, that the getCollationElements method will return the collation elements for this final bookmark.

If no match can be found for the given bookmark and the code point value, the method returns INVALID_BOOKMARK_VALUE.

param
bookmark the bookmark
param
cp a code point value or TERMINAL_CODE_POINT
return
the new bookmark for the new code point sequence if a match is found or INVALID_BOOKMARK_VALUE if no match can be found in the table
see
#getCollationElements

public abstract intgetCollationElements(int[] buffer, int offset, int cp)
Returns the collation element/elements for the given code point/points. Each returned collation element is encoded in a single integer value, which can be further decoded by the static methods of this class.

There are three types of possible return value and two types of the input values.

If the parameters are an integer buffer, an offset to this buffer and a single code point, the method can return:

  1. A single encoded collation element value, when the code point decomposes into one collation element and it isn't a starting code point of any contraction. In this case nothing is written into the buffer.
  2. The number of encoded collation elements, when the code point decomposes into more than one collation elements and it isn't a starting code point of any contraction. The encoded collation elements are written to the buffer on the given offset.
  3. A bookmark value, when the given code point is a starting code point of a contraction. Nothing is written into the buffer.

If the parameters are an integer buffer, an offset to this buffer and a bookmark, the method can return:

  1. A single encoded collation element value, when the code point sequence behind the bookmark decomposes into one collation element. Nothing is written into the buffer.
  2. The number of encoded collation elements, when the code point sequence behind the bookmark decomposes into more than one collation elements. The encoded collation elements are written to the buffer on the given offset.
  3. A zero value, when the given bookmark is invalid or it doesn't target the complete (terminated) code point sequence.

param
buffer the array for the decomposition
param
offset the offset from the beginning of the array, where to place the collation elements
param
cp a code point or a bookmark
return
a single encoded collation element or the number of returned collation elements or a bookmark or INVALID_BOOKMARK_VALUE
see
#isBookmark
see
#isSingleCollationEl
see
#getChildBookmark

public static final intgetL1(int ecol)
Returns the L1 weight value of an encoded collation element.

param
ecol the encoded collation element
return
the L1 weight value

   

                              
          
        return ecol & L1_MASK;
    
public static final intgetL2(int ecol)
Returns the L2 weight value of an encoded collation element.

param
ecol the encoded collation element
return
the L2 weight value

        return (ecol & L2_MASK) >>> L2_SHIFT;
    
public static final intgetL3(int ecol)
Returns the L3 weight value of an encoded collation element.

param
ecol the encoded collation element
return
the L3 weight value

        return (ecol & L3_MASK) >>> L3_SHIFT;
    
public abstract intgetMaxContractionLength()
Returns the length of the longest possible contraction in the table.

return
the longest contraction

public static final booleanisBookmark(int cbc)
Test if the given value is a bookmark.

param
cbc the value
return
true if the value is a bookmark
see
#getCollationElements

        return (cbc & BOOKMARK_FLAG) != 0;
    
public static final booleanisSingleCollationEl(int cbc)
Test if the given value is a single encoded collation element.

param
cbc the value
return
true if the value is a single encoded collation element
see
#getCollationElements

        return (cbc & SINGLE_CE_FLAG) != 0;
    
public static final booleanisVariableElement(int ecol)
Test if the given collation element has a variable weight.

param
ecol the encoded collation element
return
true if the collation element has a variable weight

        return (ecol & VW_FLAG) != 0;