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 * Copyright 2010-2014 UnboundID Corp. 026 */ 027 package com.unboundid.directory.sdk.common.schema; 028 029 030 031 import java.util.List; 032 033 import com.unboundid.ldap.sdk.LDAPException; 034 import com.unboundid.util.ByteString; 035 import com.unboundid.util.NotExtensible; 036 import com.unboundid.util.ThreadSafety; 037 import 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) 048 public 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 * Indicates whether the provided value matches the given substring assertion. 069 * 070 * @param normValue The normalized form of the value to be compared. 071 * @param normSubInitial The normalized form of the subInitial element for 072 * the substring assertion. It may be {@code null} if 073 * there is no subInitial element. 074 * @param normSubAny The normalized forms of the subAny elements for the 075 * substring assertion. It may be empty or 076 * {@code null} if there is no subInitial element. 077 * @param normSubFinal The normalized form of the subFinal element for 078 * the substring assertion. It may be {@code null} if 079 * there is no subFinal element. 080 * 081 * @return {@code true} if the provided value matches the given substring 082 * assertion, or {@code false} if not. 083 */ 084 boolean valueMatchesSubstring(final ByteString normValue, 085 final ByteString normSubInitial, 086 final List<ByteString> normSubAny, 087 final ByteString normSubFinal); 088 }