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
010 * docs/licenses/cddl.txt
011 * or http://www.opensource.org/licenses/cddl1.php.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * docs/licenses/cddl.txt.  If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 *      Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 *      Portions Copyright 2010-2024 Ping Identity Corporation
026 */
027package com.unboundid.directory.sdk.common.schema;
028
029
030
031import java.util.List;
032
033import com.unboundid.ldap.sdk.LDAPException;
034import com.unboundid.util.ByteString;
035import com.unboundid.util.NotExtensible;
036import com.unboundid.util.ThreadSafety;
037import com.unboundid.util.ThreadSafetyLevel;
038
039
040
041/**
042 * This interface provides an API for interacting with substring matching rules,
043 * which can be used to determine whether a given value matches a provided
044 * substring assertion.
045 */
046@NotExtensible()
047@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
048public interface SubstringMatchingRule
049       extends MatchingRule
050{
051  /**
052   * Normalizes the provided value fragment into a form that can be used to
053   * efficiently compare it in a substring assertion.
054   *
055   * @param  substring  The substring value to be normalized.
056   *
057   * @return  The normalized form of the provided substring.
058   *
059   * @throws  LDAPException  If a problem is encountered while attempting to
060   *                         normalize the provided substring.
061   */
062  ByteString normalizeSubstring(final ByteString substring)
063             throws LDAPException;
064
065
066
067  /**
068   * Normalizes the provided value fragment into a form that can be used to
069   * efficiently compare it in a substring assertion.
070   *
071   * @param  type       The associated attribute type.
072   * @param  substring  The substring value to be normalized.
073   *
074   * @return  The normalized form of the provided substring.
075   *
076   * @throws  LDAPException  If a problem is encountered while attempting to
077   *                         normalize the provided substring.
078   */
079  ByteString normalizeSubstring(final AttributeType type,
080                                final ByteString substring)
081             throws LDAPException;
082
083
084
085  /**
086   * Indicates whether the provided value matches the given substring assertion.
087   *
088   * @param  normValue       The normalized form of the value to be compared.
089   * @param  normSubInitial  The normalized form of the subInitial element for
090   *                         the substring assertion.  It may be {@code null} if
091   *                         there is no subInitial element.
092   * @param  normSubAny      The normalized forms of the subAny elements for the
093   *                         substring assertion.  It may be empty or
094   *                         {@code null} if there is no subInitial element.
095   * @param  normSubFinal    The normalized form of the subFinal element for
096   *                         the substring assertion.  It may be {@code null} if
097   *                         there is no subFinal element.
098   *
099   * @return  {@code true} if the provided value matches the given substring
100   *          assertion, or {@code false} if not.
101   */
102  boolean valueMatchesSubstring(final ByteString normValue,
103                                final ByteString normSubInitial,
104                                final List<ByteString> normSubAny,
105                                final ByteString normSubFinal);
106}