org.sqlite.text
Class Collator

java.lang.Object
  extended by org.sqlite.callback.Callback
      extended by org.sqlite.callback.NamedCallback
          extended by org.sqlite.text.Collator
All Implemented Interfaces:
java.util.Comparator<java.lang.String>

public abstract class Collator
extends NamedCallback
implements java.util.Comparator<java.lang.String>

User-Defined Collating Sequence class.

See Also:
Define New Collating Sequences, JdbcConnection.createCollationSequence(org.sqlite.text.Collator), JdbcConnection.dropCollationSequence(org.sqlite.text.Collator), JdbcConnection.dropCollationSequence(java.lang.String)

Constructor Summary
Collator(java.lang.String name)
          Create new collation sequence with SQLITE_UTF8.
Collator(java.lang.String name, int enc)
          Create new collation sequence.
 
Method Summary
protected  int xCompare(byte[] source, byte[] target)
          Called from the sqlite3_step() function.
 
Methods inherited from class org.sqlite.callback.NamedCallback
getEncoding, getName
 
Methods inherited from class org.sqlite.callback.Callback
isRegistered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
compare, equals
 

Constructor Detail

Collator

public Collator(java.lang.String name)
Create new collation sequence with SQLITE_UTF8.

Parameters:
name - the name of the new collation sequence.
See Also:
NamedCallback.NamedCallback(java.lang.String)

Collator

public Collator(java.lang.String name,
                int enc)
Create new collation sequence.

Parameters:
name - the name of the new collation sequence.
enc - the most desirable encoding may be one of the constants SQLITE_UTF8, SQLITE_UTF16LE, SQLITE_UTF16BE or SQLITE_UTF16_ALIGNED.
See Also:
Text Encodings, NamedCallback.NamedCallback(java.lang.String, int)
Method Detail

xCompare

protected final int xCompare(byte[] source,
                             byte[] target)
                      throws java.io.UnsupportedEncodingException
Called from the sqlite3_step() function.

Parameters:
source - the source bytes to be compared.
target - the target bytes to be compared.
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
Throws:
java.io.UnsupportedEncodingException
See Also:
Comparator.compare(Object, Object)