View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    https://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.dsmlv2.request;
21  
22  import org.apache.directory.api.ldap.model.entry.Value;
23  
24  /**
25   * The search request filter Matching Rule assertion
26   * 
27   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
28   */
29  public class ExtensibleMatchFilter extends Filter
30  {
31      /** Matching rule */
32      private String matchingRule;
33  
34      /** Matching rule type */
35      private String type;
36  
37      /** Matching rule value */
38      private org.apache.directory.api.ldap.model.entry.Value matchValue;
39  
40      /** The dnAttributes flag */
41      private boolean dnAttributes = false;
42  
43  
44      /**
45       * Get the dnAttributes flag
46       * 
47       * @return Returns the dnAttributes.
48       */
49      public boolean isDnAttributes()
50      {
51          return dnAttributes;
52      }
53  
54  
55      /**
56       * Set the dnAttributes flag
57       * 
58       * @param dnAttributes The dnAttributes to set.
59       */
60      public void setDnAttributes( boolean dnAttributes )
61      {
62          this.dnAttributes = dnAttributes;
63      }
64  
65  
66      /**
67       * Get the matchingRule
68       * 
69       * @return Returns the matchingRule.
70       */
71      public String getMatchingRule()
72      {
73          return matchingRule;
74      }
75  
76  
77      /**
78       * Set the matchingRule
79       * 
80       * @param matchingRule The matchingRule to set.
81       */
82      public void setMatchingRule( String matchingRule )
83      {
84          this.matchingRule = matchingRule;
85      }
86  
87  
88      /**
89       * Get the matchValue
90       * 
91       * @return Returns the matchValue.
92       */
93      public Value getMatchValue()
94      {
95          return matchValue;
96      }
97  
98  
99      /**
100      * Set the matchValue
101      * 
102      * @param matchValue The matchValue to set.
103      */
104     public void setMatchValue( 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     @Override
138     public String toString()
139     {
140         StringBuilder sb = new StringBuilder();
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 }