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.api.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.api.ldap.model.entry.Value<?> matchValue;
038
039    /** The dnAttributes flag */
040    private boolean dnAttributes = false;
041
042
043    /**
044     * Get the dnAttributes flag
045     * 
046     * @return Returns the dnAttributes.
047     */
048    public boolean isDnAttributes()
049    {
050        return dnAttributes;
051    }
052
053
054    /**
055     * Set the dnAttributes flag
056     * 
057     * @param dnAttributes The dnAttributes to set.
058     */
059    public void setDnAttributes( boolean dnAttributes )
060    {
061        this.dnAttributes = dnAttributes;
062    }
063
064
065    /**
066     * Get the matchingRule
067     * 
068     * @return Returns the matchingRule.
069     */
070    public String getMatchingRule()
071    {
072        return matchingRule;
073    }
074
075
076    /**
077     * Set the matchingRule
078     * 
079     * @param matchingRule The matchingRule to set.
080     */
081    public void setMatchingRule( String matchingRule )
082    {
083        this.matchingRule = matchingRule;
084    }
085
086
087    /**
088     * Get the matchValue
089     * 
090     * @return Returns the matchValue.
091     */
092    public org.apache.directory.api.ldap.model.entry.Value<?> getMatchValue()
093    {
094        return matchValue;
095    }
096
097
098    /**
099     * 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}