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 java.io.Serializable; 032 import java.util.Comparator; 033 034 import org.opends.server.admin.std.server.OrderingMatchingRuleCfg; 035 import org.opends.server.types.ByteString; 036 import org.opends.server.types.ConditionResult; 037 038 039 040 /** 041 * This class defines the set of methods and structures that must be 042 * implemented by a Directory Server module that implements a matching 043 * rule used for determining the correct order of values when sorting 044 * or processing range filters. 045 */ 046 @org.opends.server.types.PublicAPI( 047 stability=org.opends.server.types.StabilityLevel.VOLATILE, 048 mayInstantiate=false, 049 mayExtend=true, 050 mayInvoke=false) 051 public abstract class OrderingMatchingRule 052 extends MatchingRule<OrderingMatchingRuleCfg> 053 implements Comparator<byte[]>, Serializable 054 { 055 /** 056 * The serial version identifier required to satisfy the compiler 057 * because this class implements the {@code java.io.Serializable} 058 * interface. This value was generated using the {@code serialver} 059 * command-line utility included with the Java SDK. 060 */ 061 private static final long serialVersionUID = -5322529685787024597L; 062 063 064 065 /** 066 * Compares the first value to the second and returns a value that 067 * indicates their relative order. 068 * 069 * @param value1 The normalized form of the first value to 070 * compare. 071 * @param value2 The normalized form of the second value to 072 * compare. 073 * 074 * @return A negative integer if {@code value1} should come before 075 * {@code value2} in ascending order, a positive integer if 076 * {@code value1} should come after {@code value2} in 077 * ascending order, or zero if there is no difference 078 * between the values with regard to ordering. 079 */ 080 public abstract int compareValues(ByteString value1, 081 ByteString value2); 082 083 084 085 /** 086 * Indicates whether the provided attribute value should be 087 * considered a match for the given assertion value. This will only 088 * be used for the purpose of extensible matching. 089 * <BR><BR> 090 * Note that ordering matching rules by default do not support 091 * extensible matching, and therefore this method will always return 092 * {@code UNDEFINED}. If an ordering matching rule does support 093 * extensible matching operations, then it should override this 094 * method and provide an appropriate implementation. 095 * 096 * @param attributeValue The attribute value in a form that has 097 * been normalized according to this 098 * matching rule. 099 * @param assertionValue The assertion value in a form that has 100 * been normalized according to this 101 * matching rule. 102 * 103 * @return {@code true} if the attribute value should be considered 104 * a match for the provided assertion value, or 105 * {@code false} if not. 106 */ 107 public ConditionResult valuesMatch(ByteString attributeValue, 108 ByteString assertionValue) 109 { 110 return ConditionResult.UNDEFINED; 111 } 112 } 113