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   *    http://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  
23  /**
24   * The search request filter Matching Rule assertion
25   * 
26   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
27   */
28  public class ExtensibleMatchFilter extends Filter
29  {
30      /** Matching rule */
31      private String matchingRule;
32  
33      /** Matching rule type */
34      private String type;
35  
36      /** Matching rule value */
37      private org.apache.directory.api.ldap.model.entry.Value<?> matchValue;
38  
39      /** The dnAttributes flag */
40      private boolean dnAttributes = false;
41  
42  
43      /**
44       * Get the dnAttributes flag
45       * 
46       * @return Returns the dnAttributes.
47       */
48      public boolean isDnAttributes()
49      {
50          return dnAttributes;
51      }
52  
53  
54      /**
55       * Set the dnAttributes flag
56       * 
57       * @param dnAttributes The dnAttributes to set.
58       */
59      public void setDnAttributes( boolean dnAttributes )
60      {
61          this.dnAttributes = dnAttributes;
62      }
63  
64  
65      /**
66       * Get the matchingRule
67       * 
68       * @return Returns the matchingRule.
69       */
70      public String getMatchingRule()
71      {
72          return matchingRule;
73      }
74  
75  
76      /**
77       * Set the matchingRule
78       * 
79       * @param matchingRule The matchingRule to set.
80       */
81      public void setMatchingRule( String matchingRule )
82      {
83          this.matchingRule = matchingRule;
84      }
85  
86  
87      /**
88       * Get the matchValue
89       * 
90       * @return Returns the matchValue.
91       */
92      public org.apache.directory.api.ldap.model.entry.Value<?> getMatchValue()
93      {
94          return matchValue;
95      }
96  
97  
98      /**
99       * Set the matchValue
100      * 
101      * @param matchValue The matchValue to set.
102      */
103     public void setMatchValue( org.apache.directory.api.ldap.model.entry.Value<?> matchValue )
104     {
105         this.matchValue = matchValue;
106     }
107 
108 
109     /**
110      * Get the type
111      * 
112      * @return Returns the type.
113      */
114     public String getType()
115     {
116         return type;
117     }
118 
119 
120     /**
121      * Set the type
122      * 
123      * @param type The type to set.
124      */
125     public void setType( String type )
126     {
127         this.type = type;
128     }
129 
130 
131     /**
132      * Return a String representing an extended filter as of RFC 2254
133      * 
134      * @return An Extened Filter String
135      */
136     public String toString()
137     {
138 
139         StringBuffer sb = new StringBuffer();
140 
141         if ( type != null )
142         {
143             sb.append( type );
144         }
145 
146         if ( dnAttributes )
147         {
148             sb.append( ":dn" );
149         }
150 
151         if ( matchingRule == null )
152         {
153 
154             if ( type == null )
155             {
156                 return "Extended Filter wrong syntax";
157             }
158         }
159         else
160         {
161             sb.append( ':' ).append( matchingRule );
162         }
163 
164         sb.append( ":=" ).append( matchValue );
165 
166         return sb.toString();
167     }
168 }