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 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 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 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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 2006-2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.api; 028 029 030 031 import org.opends.server.admin.std.server.ApproximateMatchingRuleCfg; 032 import org.opends.server.types.ByteString; 033 import org.opends.server.types.ConditionResult; 034 035 036 037 /** 038 * This class defines the set of methods and structures that must be 039 * implemented by a Directory Server module that implements a matching 040 * rule used for approximate matching. 041 */ 042 @org.opends.server.types.PublicAPI( 043 stability=org.opends.server.types.StabilityLevel.VOLATILE, 044 mayInstantiate=false, 045 mayExtend=true, 046 mayInvoke=false) 047 public abstract class ApproximateMatchingRule 048 extends MatchingRule<ApproximateMatchingRuleCfg> 049 { 050 /** 051 * Indicates whether the two provided normalized values are 052 * approximately equal to each other. 053 * 054 * @param value1 The normalized form of the first value to 055 * compare. 056 * @param value2 The normalized form of the second value to 057 * compare. 058 * 059 * @return {@code true} if the provided values are approximately 060 * equal, or {@code false} if not. 061 */ 062 public abstract boolean approximatelyMatch(ByteString value1, 063 ByteString value2); 064 065 066 067 /** 068 * Indicates whether the provided attribute value should be 069 * considered a match for the given assertion value. This will only 070 * be used for the purpose of extensible matching. Other forms of 071 * matching against approximate matching rules should use the 072 * {@code areEqual} method. 073 * 074 * @param attributeValue The attribute value in a form that has 075 * been normalized according to this 076 * matching rule. 077 * @param assertionValue The assertion value in a form that has 078 * been normalized according to this 079 * matching rule. 080 * 081 * @return {@code TRUE} if the attribute value should be considered 082 * a match for the provided assertion value, {@code FALSE} 083 * if it does not match, or {@code UNDEFINED} if the result 084 * is undefined. 085 */ 086 public ConditionResult valuesMatch(ByteString attributeValue, 087 ByteString assertionValue) 088 { 089 if (approximatelyMatch(attributeValue, assertionValue)) 090 { 091 return ConditionResult.TRUE; 092 } 093 else 094 { 095 return ConditionResult.FALSE; 096 } 097 } 098 } 099