001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.shared.dsmlv2.request; 021 022 023/** 024 * The search request filter Matching Rule assertion 025 * 026 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 027 */ 028public class ExtensibleMatchFilter extends Filter 029{ 030 /** Matching rule */ 031 private String matchingRule; 032 033 /** Matching rule type */ 034 private String type; 035 036 /** Matching rule value */ 037 private org.apache.directory.shared.ldap.model.entry.Value<?> matchValue; 038 039 /** The dnAttributes flag */ 040 private boolean dnAttributes = false; 041 042 043 044 /** 045 * Get the dnAttributes flag 046 * 047 * @return Returns the dnAttributes. 048 */ 049 public boolean isDnAttributes() 050 { 051 return dnAttributes; 052 } 053 054 055 /** 056 * Set the dnAttributes flag 057 * 058 * @param dnAttributes The dnAttributes to set. 059 */ 060 public void setDnAttributes( boolean dnAttributes ) 061 { 062 this.dnAttributes = dnAttributes; 063 } 064 065 066 /** 067 * Get the matchingRule 068 * 069 * @return Returns the matchingRule. 070 */ 071 public String getMatchingRule() 072 { 073 return matchingRule; 074 } 075 076 077 /** 078 * Set the matchingRule 079 * 080 * @param matchingRule The matchingRule to set. 081 */ 082 public void setMatchingRule( String matchingRule ) 083 { 084 this.matchingRule = matchingRule; 085 } 086 087 088 /** 089 * Get the matchValue 090 * 091 * @return Returns the matchValue. 092 */ 093 public org.apache.directory.shared.ldap.model.entry.Value<?> getMatchValue() 094 { 095 return matchValue; 096 } 097 098 099 /** 100 * Set the matchValue 101 * 102 * @param matchValue The matchValue to set. 103 */ 104 public void setMatchValue( org.apache.directory.shared.ldap.model.entry.Value<?> matchValue ) 105 { 106 this.matchValue = matchValue; 107 } 108 109 110 /** 111 * Get the type 112 * 113 * @return Returns the type. 114 */ 115 public String getType() 116 { 117 return type; 118 } 119 120 121 /** 122 * Set the type 123 * 124 * @param type The type to set. 125 */ 126 public void setType( String type ) 127 { 128 this.type = type; 129 } 130 131 132 /** 133 * Return a String representing an extended filter as of RFC 2254 134 * 135 * @return An Extened Filter String 136 */ 137 public String toString() 138 { 139 140 StringBuffer sb = new StringBuffer(); 141 142 if ( type != null ) 143 { 144 sb.append( type ); 145 } 146 147 if ( dnAttributes ) 148 { 149 sb.append( ":dn" ); 150 } 151 152 if ( matchingRule == null ) 153 { 154 155 if ( type == null ) 156 { 157 return "Extended Filter wrong syntax"; 158 } 159 } 160 else 161 { 162 sb.append( ':' ).append( matchingRule ); 163 } 164 165 sb.append( ":=" ).append( matchValue ); 166 167 return sb.toString(); 168 } 169}