org.sqlite

## Class Collation

- java.lang.Object
- - org.sqlite.Collation

    public abstract class Collation
    extends Object

Provides an interface for creating SQLite user-defined collations.

A subclass of `org.sqlite.Collation` can be registered with `Collation.create()` and called by the name it was given. All collations must implement `xCompare(String, String)`, which is called when SQLite compares two strings using the custom collation. Eg.

          Class.forName("org.sqlite.JDBC");
          Connection conn = DriverManager.getConnection("jdbc:sqlite:");

          Collation.create(conn, "REVERSE", new Collation() {
              protected int xCompare(String str1, String str2) {
                  return str1.compareTo(str2) * -1;
              }
          });

          conn.createStatement().execute("select c1 from t order by c1 collate REVERSE;");

### Constructor Summary

Constructors
Constructor and Description
`Collation()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`static void` `create(Connection conn, String name, Collation f)` Registers a given collation with the connection.
`static void` `destroy(Connection conn, String name)` Removes a named collation from the given connection.
`protected abstract int` `xCompare(String str1, String str2)` Called by SQLite as a custom collation to compare two strings.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Collation

    public Collation()

### Method Detail

#### create

    public static final void create(Connection conn,
                                    String name,
                                    Collation f)
                             throws SQLException

Registers a given collation with the connection.

Parameters:
  `conn` - The connection.
  `name` - The name of the collation.
  `f` - The collation to register.
Throws:
  `SQLException`

#### destroy

    public static final void destroy(Connection conn,
                                     String name)
                              throws SQLException

Removes a named collation from the given connection.

Parameters:
  `conn` - The connection to remove the collation from.
  `name` - The name of the collation.
Throws:
  `SQLException`

#### xCompare

    protected abstract int xCompare(String str1,
                                    String str2)

Called by SQLite as a custom collation to compare two strings.

Parameters:
  `str1` - the first string in the comparison
  `str2` - the second string in the comparison
Returns:
  an integer that is negative, zero, or positive if the first string is less than, equal to, or greater than the second, respectively