Class DbNameIndex

  • All Implemented Interfaces:
    Direct Known Subclasses:
    NGKDbNameIndex, PostgreSQLNameIndex

    public class DbNameIndex
    extends Object
    implements StringIndex
    Implements a StringIndex that stores and retrieves the names from a table in a database.

    Note that this class is not threadsafe by itself. it needs to be synchronized by the using application.

    Due to a bug with oracle that treats empty strings a null values (see JCR-815), all empty strings are replaced by a ' '. since names never start with a space, this it not problematic yet.

    • Field Detail

      • nameSelectSQL

        protected String nameSelectSQL
      • indexSelectSQL

        protected String indexSelectSQL
      • nameInsertSQL

        protected String nameInsertSQL
    • Constructor Detail

    • Method Detail

      • init

        protected void init​(String schemaObjectPrefix)
                     throws SQLException
        Inits this index and prepares the statements.
        schemaObjectPrefix - the prefix for table names
        SQLException - if the statements cannot be prepared.
      • close

        public void close()
        Closes this index and releases it's resources.
      • stringToIndex

        public int stringToIndex​(String string)
        Returns the index for a given string. If the given string is not already indexed, the implementation can either automatically index it or throw an exception.
        Specified by:
        stringToIndex in interface StringIndex
        string - the indexed (or to be indexed) string
        index of the string
      • insertString

        protected int insertString​(String string)
        Inserts a string into the database and returns the new index.
        string - the string to insert
        the new index.
      • getIndex

        protected int getIndex​(String string)
        Retrieves the index from the database for the given string.
        string - the string to retrieve the index for
        the index or -1 if not found.