001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2009 Sun Microsystems, Inc.
025 *      Portions copyright 2014-2015 ForgeRock AS
026 */
027package org.forgerock.opendj.ldap.spi;
028
029import java.util.Collection;
030
031import org.forgerock.opendj.ldap.ByteSequence;
032import org.forgerock.opendj.ldap.ByteString;
033import org.forgerock.opendj.ldap.DecodeException;
034import org.forgerock.opendj.ldap.schema.Schema;
035
036/**
037 * This class is registered with a Backend and it provides callbacks
038 * for indexing attribute values. An index implementation will use
039 * this interface to create the keys for an attribute value.
040 */
041public interface Indexer {
042
043    /**
044     * Returns an index identifier associated with this indexer. An identifier
045     * should be selected based on the matching rule type. A unique identifier
046     * will map to a unique index database in the backend implementation. If
047     * multiple matching rules need to share the index database, the
048     * corresponding indexers should always use the same identifier.
049     *
050     * @return index ID A String containing the ID associated with this indexer.
051     */
052    String getIndexID();
053
054    /**
055     * Generates the set of index keys for an attribute.
056     *
057     * @param schema
058     *          The schema in which the associated matching rule is defined.
059     * @param value
060     *          The attribute value for which keys are required.
061     * @param keys
062     *          A collection where to add the created keys.
063     * @throws DecodeException if an error occurs while normalizing the value
064     */
065    void createKeys(Schema schema, ByteSequence value, Collection<ByteString> keys) throws DecodeException;
066
067}