directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r592082 [10/20] - in /directory/sandbox/felixk/studio-ldapbrowser-core: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/studio/ s...
Date Mon, 05 Nov 2007 16:52:07 GMT
Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterComponent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterComponent.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterComponent.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterComponent.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,281 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.core.model.filter;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.core.model.filter.parser.LdapFilterToken;
+
+
+/**
+ * The LdapFilterComponent is the base class for all filter components.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class LdapFilterComponent
+{
+
+    /** The parent filter. */
+    protected final LdapFilter parent;
+
+    /** The start token. */
+    protected LdapFilterToken startToken;
+
+    /** The filter list. */
+    protected List<LdapFilter> filterList;
+
+
+    /**
+     * The Constructor.
+     * 
+     * @param parent the parent filter, not null
+     */
+    protected LdapFilterComponent( LdapFilter parent )
+    {
+        if ( parent == null )
+        {
+            throw new IllegalArgumentException( "parent is null" );
+        }
+
+        this.parent = parent;
+        this.startToken = null;
+        this.filterList = new ArrayList<LdapFilter>( 2 );
+    }
+
+
+    /**
+     * Returns the parent filter of this filter component.
+     * 
+     * @return the parent filter, never null.
+     */
+    public final LdapFilter getParent()
+    {
+        return parent;
+    }
+
+
+    /**
+     * Sets the start token of the filter component. Checks if start token
+     * isn't set yet and if the given start token isn't null.
+     * 
+     * @param startToken
+     * 
+     * @return true if setting the start token was successful, false
+     *         otherwise.
+     */
+    public boolean setStartToken( LdapFilterToken startToken )
+    {
+        if ( this.startToken == null && startToken != null )
+        {
+            this.startToken = startToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Returns the start token of this filter component.
+     * 
+     * @return the start token or null if not set.
+     */
+    public final LdapFilterToken getStartToken()
+    {
+        return startToken;
+    }
+
+
+    /**
+     * Adds a filter to the list of subfilters. Checks if the start token
+     * was set before and if the filter isn't null.
+     * 
+     * @param filter
+     * 
+     * @return true if adding the filter was successful, false otherwise.
+     */
+    public boolean addFilter( LdapFilter filter )
+    {
+        if ( startToken != null && filter != null )
+        {
+            filterList.add( filter );
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Returns the subfilters of this filter component.
+     * 
+     * @return an array of subfilters or an empty array.
+     */
+    public LdapFilter[] getFilters()
+    {
+        LdapFilter[] filters = new LdapFilter[filterList.size()];
+        filterList.toArray( filters );
+        return filters;
+    }
+
+
+    /**
+     * Checks if this filter component including all subfilters is valid.
+     * 
+     * @return true if this filter component is valid.
+     */
+    public boolean isValid()
+    {
+        if ( startToken == null )
+        {
+            return false;
+        }
+
+        if ( filterList.isEmpty() )
+        {
+            return false;
+        }
+
+        for ( Iterator<LdapFilter> it = filterList.iterator(); it.hasNext(); )
+        {
+            LdapFilter filter = it.next();
+            if ( filter == null || !filter.isValid() )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+
+    /**
+     * Returns the invalid cause.
+     * 
+     * @return the invalid cause, or null if this filter is valid.
+     */
+    public abstract String getInvalidCause();
+
+
+    /**
+     * Returns the invalid filters. This may be the whole parent filter or
+     * any of the subfilters.
+     * 
+     * @return an array of invalid filters or an empty array if all filters
+     *         are valid.
+     */
+    public LdapFilter[] getInvalidFilters()
+    {
+        if ( startToken == null || filterList.isEmpty() )
+        {
+            return new LdapFilter[]
+                { parent };
+        }
+        else
+        {
+            List<LdapFilter> invalidFilterList = new ArrayList<LdapFilter>();
+            for ( Iterator<LdapFilter> it = filterList.iterator(); it.hasNext(); )
+            {
+                LdapFilter filter = it.next();
+                if ( filter != null )
+                {
+                    invalidFilterList.addAll( Arrays.asList( filter.getInvalidFilters() ) );
+                }
+            }
+            return invalidFilterList.toArray( new LdapFilter[invalidFilterList.size()] );
+        }
+    }
+
+
+    /**
+     * Returns all tokens of the filter component including all subfilters.
+     * 
+     * @return an array of tokens of an empty array.
+     */
+    public LdapFilterToken[] getTokens()
+    {
+        // collect tokens
+        List<LdapFilterToken> tokenList = new ArrayList<LdapFilterToken>();
+        if ( startToken != null )
+        {
+            tokenList.add( startToken );
+        }
+        for ( Iterator<LdapFilter> it = filterList.iterator(); it.hasNext(); )
+        {
+            LdapFilter filter = it.next();
+            if ( filter != null )
+            {
+                tokenList.addAll( Arrays.asList( filter.getTokens() ) );
+            }
+        }
+
+        // sort tokens
+        LdapFilterToken[] tokens = tokenList.toArray( new LdapFilterToken[tokenList.size()] );
+        Arrays.sort( tokens );
+
+        // return
+        return tokens;
+    }
+
+
+    /**
+     * Returns the filter at the given offset. This may be the whole parent
+     * filter or one of the subfilters.
+     * 
+     * @param offset the offset
+     * 
+     * @return the filter at the given offset or null is offset is out of
+     *         range.
+     */
+    public LdapFilter getFilter( int offset )
+    {
+        if ( startToken != null && startToken.getOffset() == offset )
+        {
+            return parent;
+        }
+        else if ( filterList != null || !filterList.isEmpty() )
+        {
+            for ( Iterator<LdapFilter> it = filterList.iterator(); it.hasNext(); )
+            {
+                LdapFilter filter = it.next();
+                if ( filter != null && filter.getFilter( offset ) != null )
+                {
+                    return filter.getFilter( offset );
+                }
+            }
+            return null;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterExtensibleComponent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterExtensibleComponent.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterExtensibleComponent.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterExtensibleComponent.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,499 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.core.model.filter;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.core.model.filter.parser.LdapFilterToken;
+
+
+/**
+ * The LdapFilterExtensibleComponent represents an extensible filter.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapFilterExtensibleComponent extends LdapFilterComponent
+{
+    private LdapFilterToken attributeToken;
+
+    private LdapFilterToken dnAttrColonToken;
+    private LdapFilterToken dnAttrToken;
+
+    private LdapFilterToken matchingRuleColonToken;
+    private LdapFilterToken matchingRuleToken;
+
+    private LdapFilterToken equalsColonToken;
+    private LdapFilterToken equalsToken;
+
+    private LdapFilterToken valueToken;
+
+
+    /**
+     * Creates a new instance of LdapFilterExtensibleComponent.
+     * 
+     * @param parent the parent filter
+     */
+    public LdapFilterExtensibleComponent( LdapFilter parent )
+    {
+        super( parent );
+    }
+
+
+    /**
+     * Sets the attribute token.
+     * 
+     * @param attributeToken the attribute token
+     * 
+     * @return true, if setting the attribute token was successful,false otherwise.
+     */
+    public boolean setAttributeToken( LdapFilterToken attributeToken )
+    {
+        if ( this.attributeToken == null && attributeToken != null
+            && attributeToken.getType() == LdapFilterToken.EXTENSIBLE_ATTRIBUTE )
+        {
+            if ( super.getStartToken() == null )
+            {
+                super.setStartToken( attributeToken );
+            }
+            this.attributeToken = attributeToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the attribute token.
+     * 
+     * @return the attribute token, or null if not set
+     */
+    public LdapFilterToken getAttributeToken()
+    {
+        return attributeToken;
+    }
+
+
+    /**
+     * Sets the dn attr colon token.
+     * 
+     * @param dnAttrColonToken the dn attr colon token
+     * 
+     * @return true, if setting the dn attr colon token was sucessful, false otherwise
+     */
+    public boolean setDnAttrColonToken( LdapFilterToken dnAttrColonToken )
+    {
+        if ( this.dnAttrColonToken == null && dnAttrColonToken != null
+            && dnAttrColonToken.getType() == LdapFilterToken.EXTENSIBLE_DNATTR_COLON )
+        {
+            if ( super.getStartToken() == null )
+            {
+                super.setStartToken( dnAttrColonToken );
+            }
+            this.dnAttrColonToken = dnAttrColonToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the dn attr colon token.
+     * 
+     * @return the dn attr colon token, or null if not set
+     */
+    public LdapFilterToken getDnAttrColonToken()
+    {
+        return dnAttrColonToken;
+    }
+
+
+    /**
+     * Sets the dn attr token.
+     * 
+     * @param dnAttrToken the dn attr token
+     * 
+     * @return true, if setting the dn attr token was successful, false otherwise
+     */
+    public boolean setDnAttrToken( LdapFilterToken dnAttrToken )
+    {
+        if ( this.dnAttrToken == null && dnAttrToken != null
+            && dnAttrToken.getType() == LdapFilterToken.EXTENSIBLE_DNATTR )
+        {
+            this.dnAttrToken = dnAttrToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the dn attr token.
+     * 
+     * @return the dn attr token, or null if not set
+     */
+    public LdapFilterToken getDnAttrToken()
+    {
+        return dnAttrToken;
+    }
+
+
+    /**
+     * Sets the matching rule colon token.
+     * 
+     * @param matchingRuleColonToken the matching rule colon token
+     * 
+     * @return true, if setting the matching rule colon token was successful, false otherwise
+     */
+    public boolean setMatchingRuleColonToken( LdapFilterToken matchingRuleColonToken )
+    {
+        if ( this.matchingRuleColonToken == null && matchingRuleColonToken != null
+            && matchingRuleColonToken.getType() == LdapFilterToken.EXTENSIBLE_MATCHINGRULEOID_COLON )
+        {
+            if ( super.getStartToken() == null )
+            {
+                super.setStartToken( matchingRuleColonToken );
+            }
+            this.matchingRuleColonToken = matchingRuleColonToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the matching rule colon token.
+     * 
+     * @return the matching rule colon token, or null if not set
+     */
+    public LdapFilterToken getMatchingRuleColonToken()
+    {
+        return matchingRuleColonToken;
+    }
+
+
+    /**
+     * Sets the matching rule token.
+     * 
+     * @param matchingRuleToken the matching rule token
+     * 
+     * @return true, if setting the matching rule token was successful, false otherwise
+     */
+    public boolean setMatchingRuleToken( LdapFilterToken matchingRuleToken )
+    {
+        if ( this.matchingRuleToken == null && matchingRuleToken != null
+            && matchingRuleToken.getType() == LdapFilterToken.EXTENSIBLE_MATCHINGRULEOID )
+        {
+            this.matchingRuleToken = matchingRuleToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the matching rule token.
+     * 
+     * @return the matching rule token, or null if not set
+     */
+    public LdapFilterToken getMatchingRuleToken()
+    {
+        return matchingRuleToken;
+    }
+
+
+    /**
+     * Sets the equals colon token.
+     * 
+     * @param equalsColonToken the equals colon token
+     * 
+     * @return true, if setting the equals colon token was sucessful, false otherwise
+     */
+    public boolean setEqualsColonToken( LdapFilterToken equalsColonToken )
+    {
+        if ( this.equalsColonToken == null && equalsColonToken != null
+            && equalsColonToken.getType() == LdapFilterToken.EXTENSIBLE_EQUALS_COLON )
+        {
+            this.equalsColonToken = equalsColonToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the equals colon token.
+     * 
+     * @return the equals colon token, or null if not set
+     */
+    public LdapFilterToken getEqualsColonToken()
+    {
+        return equalsColonToken;
+    }
+
+
+    /**
+     * Sets the equals token.
+     * 
+     * @param equalsToken the equals token
+     * 
+     * @return true, if setting the equals token was successful, false otherwise
+     */
+    public boolean setEqualsToken( LdapFilterToken equalsToken )
+    {
+        if ( this.equalsToken == null && equalsToken != null && equalsToken.getType() == LdapFilterToken.EQUAL )
+        {
+            this.equalsToken = equalsToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the equals token.
+     * 
+     * @return the equals token, or null if not set
+     */
+    public LdapFilterToken getEqualsToken()
+    {
+        return equalsToken;
+    }
+
+
+    /**
+     * Sets the value token.
+     * 
+     * @param valueToken the value token
+     * 
+     * @return true, if setting the value token was successful, false otherwise
+     */
+    public boolean setValueToken( LdapFilterToken valueToken )
+    {
+        if ( this.valueToken == null && valueToken != null && valueToken.getType() == LdapFilterToken.VALUE )
+        {
+            this.valueToken = valueToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the value token.
+     * 
+     * @return the value token, or null if not set
+     */
+    public LdapFilterToken getValueToken()
+    {
+        return this.valueToken;
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#isValid()
+     */
+    public boolean isValid()
+    {
+        return startToken != null
+            && equalsColonToken != null
+            & equalsToken != null
+            && valueToken != null
+            &&
+
+            ( ( attributeToken != null
+                && ( ( dnAttrColonToken == null && dnAttrToken == null ) || ( dnAttrColonToken != null && dnAttrToken != null ) ) && ( ( matchingRuleColonToken == null && matchingRuleToken == null ) || ( matchingRuleColonToken != null && matchingRuleToken != null ) ) ) || ( attributeToken == null
+                && ( ( dnAttrColonToken == null && dnAttrToken == null ) || ( dnAttrColonToken != null && dnAttrToken != null ) )
+                && matchingRuleColonToken != null && matchingRuleToken != null ) );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#getTokens()
+     */
+    public LdapFilterToken[] getTokens()
+    {
+        // collect tokens
+        List<LdapFilterToken> tokenList = new ArrayList<LdapFilterToken>();
+        if ( attributeToken != null )
+        {
+            tokenList.add( attributeToken );
+        }
+        if ( dnAttrColonToken != null )
+        {
+            tokenList.add( dnAttrColonToken );
+        }
+        if ( dnAttrToken != null )
+        {
+            tokenList.add( dnAttrToken );
+        }
+        if ( matchingRuleColonToken != null )
+        {
+            tokenList.add( matchingRuleColonToken );
+        }
+        if ( matchingRuleToken != null )
+        {
+            tokenList.add( matchingRuleToken );
+        }
+        if ( equalsColonToken != null )
+        {
+            tokenList.add( equalsColonToken );
+        }
+        if ( equalsToken != null )
+        {
+            tokenList.add( equalsToken );
+        }
+        if ( valueToken != null )
+        {
+            tokenList.add( valueToken );
+        }
+
+        // sort tokens
+        LdapFilterToken[] tokens = tokenList.toArray( new LdapFilterToken[tokenList.size()] );
+        Arrays.sort( tokens );
+
+        // return
+        return tokens;
+    }
+
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return ( attributeToken != null ? startToken.getValue() : "" )
+            + ( dnAttrColonToken != null ? dnAttrColonToken.getValue() : "" )
+            + ( dnAttrToken != null ? dnAttrToken.getValue() : "" )
+            + ( matchingRuleColonToken != null ? matchingRuleColonToken.getValue() : "" )
+            + ( matchingRuleToken != null ? matchingRuleToken.getValue() : "" )
+            + ( equalsColonToken != null ? equalsColonToken.getValue() : "" )
+            + ( equalsToken != null ? equalsToken.getValue() : "" )
+            + ( valueToken != null ? valueToken.getValue() : "" );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#addFilter(org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilter)
+     */
+    public boolean addFilter( LdapFilter filter )
+    {
+        return false;
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#getInvalidFilters()
+     */
+    public LdapFilter[] getInvalidFilters()
+    {
+        if ( isValid() )
+        {
+            return new LdapFilter[0];
+        }
+        else
+        {
+            return new LdapFilter[]
+                { parent };
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#getFilter(int)
+     */
+    public LdapFilter getFilter( int offset )
+    {
+        if ( startToken != null && startToken.getOffset() <= offset
+            && offset < startToken.getOffset() + toString().length() )
+        {
+            return parent;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#getInvalidCause()
+     */
+    public String getInvalidCause()
+    {
+        if ( dnAttrColonToken != null && dnAttrToken == null )
+        {
+            return "Missing dn";
+        }
+        else if ( matchingRuleColonToken != null && matchingRuleToken == null )
+        {
+            return "Missing matching rule";
+        }
+        else if ( equalsColonToken == null )
+        {
+            return "Missing colon";
+        }
+        else if ( equalsToken == null )
+        {
+            return "Missing equals";
+        }
+        else if ( attributeToken == null )
+        {
+            return "Missing attribute type";
+        }
+        else if ( valueToken != null )
+        {
+            return "Missing value";
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterExtensibleComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterItemComponent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterItemComponent.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterItemComponent.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterItemComponent.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,299 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.core.model.filter;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.core.model.filter.parser.LdapFilterToken;
+
+
+/**
+ * The LdapFilterExtensibleComponent represents an simple filter.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+
+public class LdapFilterItemComponent extends LdapFilterComponent
+{
+
+    /** The filtertype token. */
+    private LdapFilterToken filtertypeToken;
+
+    /** The value token. */
+    private LdapFilterToken valueToken;
+
+
+    /**
+     * Creates a new instance of LdapFilterItemComponent.
+     * 
+     * @param parent the parent filter
+     */
+    public LdapFilterItemComponent( LdapFilter parent )
+    {
+        super( parent );
+        this.filtertypeToken = null;
+        this.valueToken = null;
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#setStartToken(org.apache.directory.studio.ldapbrowser.core.model.filter.parser.LdapFilterToken)
+     */
+    public boolean setStartToken( LdapFilterToken attributeToken )
+    {
+        if ( attributeToken != null && attributeToken.getType() == LdapFilterToken.ATTRIBUTE )
+        {
+            super.setStartToken( attributeToken );
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Sets the attribute token.
+     * 
+     * @param attributeToken the attribute token
+     * 
+     * @return true, if setting the attribute token was successful, false otherwise
+     */
+    public boolean setAttributeToken( LdapFilterToken attributeToken )
+    {
+        return this.setStartToken( attributeToken );
+    }
+
+
+    /**
+     * Gets the attribute token.
+     * 
+     * @return the attribute token, null if not set
+     */
+    public LdapFilterToken getAttributeToken()
+    {
+        return getStartToken();
+    }
+
+
+    /**
+     * Sets the filtertype token.
+     * 
+     * @param filtertypeToken the filtertype token
+     * 
+     * @return true, if setting the filtertype token was successful, false otherwise
+     */
+    public boolean setFiltertypeToken( LdapFilterToken filtertypeToken )
+    {
+        if ( this.filtertypeToken == null
+            && filtertypeToken != null
+            && ( filtertypeToken.getType() == LdapFilterToken.EQUAL
+                || filtertypeToken.getType() == LdapFilterToken.GREATER
+                || filtertypeToken.getType() == LdapFilterToken.LESS
+                || filtertypeToken.getType() == LdapFilterToken.APROX || filtertypeToken.getType() == LdapFilterToken.PRESENT ) )
+        {
+            this.filtertypeToken = filtertypeToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the filter token.
+     * 
+     * @return the filter token, null if not set
+     */
+    public LdapFilterToken getFilterToken()
+    {
+        return filtertypeToken;
+    }
+
+
+    /**
+     * Sets the value token.
+     * 
+     * @param valueToken the value token
+     * 
+     * @return true, if setting the value token was successful, false otherwise
+     */
+    public boolean setValueToken( LdapFilterToken valueToken )
+    {
+        if ( this.valueToken == null && valueToken != null && valueToken.getType() == LdapFilterToken.VALUE )
+        {
+            this.valueToken = valueToken;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the value token.
+     * 
+     * @return the value token, null if not set
+     */
+    public LdapFilterToken getValueToken()
+    {
+        return valueToken;
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#isValid()
+     */
+    public boolean isValid()
+    {
+        return startToken != null && filtertypeToken != null
+            && ( valueToken != null || filtertypeToken.getType() == LdapFilterToken.PRESENT );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#getTokens()
+     */
+    public LdapFilterToken[] getTokens()
+    {
+        // collect tokens
+        List<LdapFilterToken> tokenList = new ArrayList<LdapFilterToken>();
+        if ( startToken != null )
+        {
+            tokenList.add( startToken );
+        }
+        if ( filtertypeToken != null )
+        {
+            tokenList.add( filtertypeToken );
+        }
+        if ( valueToken != null )
+        {
+            tokenList.add( valueToken );
+        }
+
+        // sort tokens
+        LdapFilterToken[] tokens = tokenList.toArray( new LdapFilterToken[tokenList.size()] );
+        Arrays.sort( tokens );
+
+        // return
+        return tokens;
+    }
+
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return ( startToken != null ? startToken.getValue() : "" )
+            + ( filtertypeToken != null ? filtertypeToken.getValue() : "" )
+            + ( valueToken != null ? valueToken.getValue() : "" );
+    }
+
+
+    /**
+     * This implementation does nothing and returns always false.
+     * 
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#addFilter(org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilter)
+     */
+    public boolean addFilter( LdapFilter filter )
+    {
+        return false;
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#getInvalidFilters()
+     */
+    public LdapFilter[] getInvalidFilters()
+    {
+        if ( isValid() )
+        {
+            return new LdapFilter[0];
+        }
+        else
+        {
+            return new LdapFilter[]
+                { parent };
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#getFilter(int)
+     */
+    public LdapFilter getFilter( int offset )
+    {
+        if ( startToken != null && startToken.getOffset() <= offset
+            && offset < startToken.getOffset() + startToken.getLength() )
+        {
+            return parent;
+        }
+        else if ( filtertypeToken != null && filtertypeToken.getOffset() <= offset
+            && offset < filtertypeToken.getOffset() + filtertypeToken.getLength() )
+        {
+            return parent;
+        }
+        else if ( valueToken != null && valueToken.getOffset() <= offset
+            && offset < valueToken.getOffset() + valueToken.getLength() )
+        {
+            return parent;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#getInvalidCause()
+     */
+    public String getInvalidCause()
+    {
+        if ( startToken == null )
+        {
+            return "Missing attribute name";
+        }
+        else if ( filtertypeToken == null )
+        {
+            return "Missing filter type, select one of '=', '>=', '<=','~='";
+        }
+        else if ( valueToken == null )
+        {
+            return "Missing value";
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapFilterItemComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapNotFilterComponent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapNotFilterComponent.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapNotFilterComponent.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapNotFilterComponent.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,109 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.core.model.filter;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.filter.parser.LdapFilterToken;
+
+
+/**
+ * The LdapNotFilterComponent represents an NOT filter branch.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapNotFilterComponent extends LdapFilterComponent
+{
+
+    /**
+     * Creates a new instance of LdapNotFilterComponent.
+     * 
+     * @param parent the parent filter
+     */
+    public LdapNotFilterComponent( LdapFilter parent )
+    {
+        super( parent );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#setStartToken(org.apache.directory.studio.ldapbrowser.core.model.filter.parser.LdapFilterToken)
+     */
+    public boolean setStartToken( LdapFilterToken notToken )
+    {
+        if ( notToken != null && notToken.getType() == LdapFilterToken.NOT )
+        {
+            return super.setStartToken( notToken );
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#addFilter(org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilter)
+     */
+    public boolean addFilter( LdapFilter filter )
+    {
+        if ( filterList.isEmpty() )
+        {
+            return super.addFilter( filter );
+        }
+        else
+        {
+            // There is already a filter in the list. A NOT filter
+            // can only contain one filter.
+            return false;
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#getInvalidCause()
+     */
+    public String getInvalidCause()
+    {
+        if ( startToken == null )
+        {
+            return "Missing NOT character '!'";
+        }
+        else if ( filterList == null || filterList.isEmpty() )
+        {
+            return "Missing filter expression";
+        }
+        else
+        {
+            return "Invalid NOT filter";
+        }
+    }
+
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return ( startToken != null ? "!" : "" ) + ( !filterList.isEmpty() ? filterList.get( 0 ).toString() : "" );
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapNotFilterComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapOrFilterComponent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapOrFilterComponent.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapOrFilterComponent.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapOrFilterComponent.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,102 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.core.model.filter;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.studio.ldapbrowser.core.model.filter.parser.LdapFilterToken;
+
+
+/**
+ * The LdapOrFilterComponent represents an OR filter branch.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapOrFilterComponent extends LdapFilterComponent
+{
+
+    /**
+     * Creates a new instance of LdapOrFilterComponent.
+     * 
+     * @param parent the parent filter
+     */
+    public LdapOrFilterComponent( LdapFilter parent )
+    {
+        super( parent );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#setStartToken(org.apache.directory.studio.ldapbrowser.core.model.filter.parser.LdapFilterToken)
+     */
+    public boolean setStartToken( LdapFilterToken orToken )
+    {
+        if ( orToken != null && orToken.getType() == LdapFilterToken.OR )
+        {
+            return super.setStartToken( orToken );
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent#getInvalidCause()
+     */
+    public String getInvalidCause()
+    {
+        if ( startToken == null )
+        {
+            return "Missing OR character '|'";
+        }
+        else if ( filterList == null || filterList.isEmpty() )
+        {
+            return "Missing filters";
+        }
+        else
+        {
+            return "Invalid OR filter";
+        }
+    }
+
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        String s = startToken != null ? "|" : "";
+        for ( Iterator it = filterList.iterator(); it.hasNext(); )
+        {
+            LdapFilter filter = ( LdapFilter ) it.next();
+            if ( filter != null )
+            {
+                s += filter.toString();
+            }
+        }
+        return s;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/LdapOrFilterComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterParser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterParser.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterParser.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterParser.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,336 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.core.model.filter.parser;
+
+
+import java.util.Stack;
+
+import org.apache.directory.studio.ldapbrowser.core.model.filter.LdapAndFilterComponent;
+import org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilter;
+import org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterComponent;
+import org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterExtensibleComponent;
+import org.apache.directory.studio.ldapbrowser.core.model.filter.LdapFilterItemComponent;
+import org.apache.directory.studio.ldapbrowser.core.model.filter.LdapNotFilterComponent;
+import org.apache.directory.studio.ldapbrowser.core.model.filter.LdapOrFilterComponent;
+
+
+/**
+ * The LdapFilterParser implements a parser for LDAP filters.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapFilterParser
+{
+
+    /** The scanner. */
+    private LdapFilterScanner scanner;
+
+    /** The filter stack. */
+    private Stack<LdapFilter> filterStack;
+
+    /** The parsed LDAP filter model. */
+    private LdapFilter model;
+
+
+    /**
+     * Creates a new instance of LdapFilterParser.
+     */
+    public LdapFilterParser()
+    {
+        this.scanner = new LdapFilterScanner();
+        this.model = new LdapFilter();
+    }
+
+
+    /**
+     * Gets the parsed LDAP filter model.
+     * 
+     * @return the parsed model
+     */
+    public LdapFilter getModel()
+    {
+        return model;
+    }
+
+
+    /**
+     * Parses the given LDAP filter.
+     * 
+     * @param ldapFilter the LDAP filter
+     */
+    public void parse( String ldapFilter )
+    {
+        // reset state
+        filterStack = new Stack<LdapFilter>();
+        scanner.reset( ldapFilter );
+        model = new LdapFilter();
+
+        // handle error tokens before filter
+        LdapFilterToken token = scanner.nextToken();
+        while ( token.getType() != LdapFilterToken.LPAR && token.getType() != LdapFilterToken.EOF )
+        {
+            handleError( false, token, model );
+            token = scanner.nextToken();
+        }
+
+        // check filter start
+        if ( token.getType() == LdapFilterToken.LPAR )
+        {
+            // start top level filter
+            model.setStartToken( token );
+            filterStack.push( model );
+
+            // loop till filter end or EOF
+            do
+            {
+                // next token
+                token = scanner.nextToken();
+
+                switch ( token.getType() )
+                {
+                    case LdapFilterToken.LPAR:
+                    {
+                        LdapFilter newFilter = new LdapFilter();
+                        newFilter.setStartToken( token );
+
+                        LdapFilter currentFilter = filterStack.peek();
+                        LdapFilterComponent filterComponent = currentFilter.getFilterComponent();
+                        if ( filterComponent != null && filterComponent.addFilter( newFilter ) )
+                        {
+                            filterStack.push( newFilter );
+                        }
+                        else
+                        {
+                            currentFilter.addOtherToken( token );
+                        }
+
+                        break;
+                    }
+                    case LdapFilterToken.RPAR:
+                    {
+                        LdapFilter currentFilter = filterStack.pop();
+                        handleError( currentFilter.setStopToken( token ), token, currentFilter );
+                        /*
+                         * if(!filterStack.isEmpty()) { LdapFilter parentFilter =
+                         * (LdapFilter) filterStack.peek(); LdapFilterComponent
+                         * filterComponent = parentFilter.getFilterComponent();
+                         * filterComponent.addFilter(currentFilter); }
+                         */
+                        break;
+                    }
+                    case LdapFilterToken.AND:
+                    {
+                        LdapFilter currentFilter = filterStack.peek();
+                        LdapAndFilterComponent filterComponent = new LdapAndFilterComponent( currentFilter );
+                        filterComponent.setStartToken( token );
+                        handleError( currentFilter.setFilterComponent( filterComponent ), token, currentFilter );
+                        break;
+                    }
+                    case LdapFilterToken.OR:
+                    {
+                        LdapFilter currentFilter = filterStack.peek();
+                        LdapOrFilterComponent filterComponent = new LdapOrFilterComponent( currentFilter );
+                        filterComponent.setStartToken( token );
+                        handleError( currentFilter.setFilterComponent( filterComponent ), token, currentFilter );
+                        break;
+                    }
+                    case LdapFilterToken.NOT:
+                    {
+                        LdapFilter currentFilter = filterStack.peek();
+                        LdapNotFilterComponent filterComponent = new LdapNotFilterComponent( currentFilter );
+                        filterComponent.setStartToken( token );
+                        handleError( currentFilter.setFilterComponent( filterComponent ), token, currentFilter );
+                        break;
+                    }
+                    case LdapFilterToken.ATTRIBUTE:
+                    {
+                        LdapFilter currentFilter = filterStack.peek();
+                        LdapFilterItemComponent filterComponent = new LdapFilterItemComponent( currentFilter );
+                        filterComponent.setAttributeToken( token );
+                        handleError( currentFilter.setFilterComponent( filterComponent ), token, currentFilter );
+                        break;
+                    }
+                    case LdapFilterToken.VALUE:
+                    {
+                        LdapFilter currentFilter = filterStack.peek();
+                        LdapFilterComponent filterComponent = currentFilter.getFilterComponent();
+                        if( filterComponent instanceof LdapFilterItemComponent )
+                        {
+                            handleError( ( filterComponent instanceof LdapFilterItemComponent )
+                                && ( ( LdapFilterItemComponent ) filterComponent ).setValueToken( token ), token,
+                                currentFilter );
+                        }
+                        else if( filterComponent instanceof LdapFilterExtensibleComponent )
+                        {
+                            handleError( ( filterComponent instanceof LdapFilterExtensibleComponent )
+                                && ( ( LdapFilterExtensibleComponent ) filterComponent ).setValueToken( token ), token,
+                                currentFilter );
+                        }
+                        else {
+                            handleError( false, token, currentFilter );
+                        }
+                        break;
+                    }
+                    case LdapFilterToken.EQUAL:
+                    case LdapFilterToken.GREATER:
+                    case LdapFilterToken.LESS:
+                    case LdapFilterToken.APROX:
+                    case LdapFilterToken.PRESENT:
+                    {
+                        LdapFilter currentFilter = filterStack.peek();
+                        LdapFilterComponent filterComponent = currentFilter.getFilterComponent();
+                        if( filterComponent instanceof LdapFilterItemComponent )
+                        {
+                            handleError( ( filterComponent instanceof LdapFilterItemComponent )
+                                && ( ( LdapFilterItemComponent ) filterComponent ).setFiltertypeToken( token ), token,
+                                currentFilter );
+                        }
+                        else if( filterComponent instanceof LdapFilterExtensibleComponent )
+                        {
+                            handleError( ( filterComponent instanceof LdapFilterExtensibleComponent )
+                                && ( ( LdapFilterExtensibleComponent ) filterComponent ).setEqualsToken( token ), token,
+                                currentFilter );
+                        }
+                        else {
+                            handleError( false, token, currentFilter );
+                        }
+                        break;
+                    }
+                    case LdapFilterToken.WHITESPACE:
+                    {
+                        LdapFilter currentFilter = filterStack.peek();
+                        currentFilter.addOtherToken( token );
+                        break;
+                    }
+                    case LdapFilterToken.EXTENSIBLE_ATTRIBUTE:
+                    {
+                        LdapFilter currentFilter = ( LdapFilter ) filterStack.peek();
+                        LdapFilterExtensibleComponent filterComponent = new LdapFilterExtensibleComponent( currentFilter );
+                        filterComponent.setAttributeToken( token );
+                        handleError( currentFilter.setFilterComponent( filterComponent ), token, currentFilter );
+                        break;
+                    }
+                    case LdapFilterToken.EXTENSIBLE_DNATTR_COLON:
+                    {
+                        LdapFilter currentFilter = ( LdapFilter ) filterStack.peek();
+                        LdapFilterComponent filterComponent = currentFilter.getFilterComponent();
+                        if( filterComponent == null )
+                        {
+                            filterComponent = new LdapFilterExtensibleComponent( currentFilter );
+                            (( LdapFilterExtensibleComponent ) filterComponent ).setDnAttrColonToken( token );
+                            handleError( currentFilter.setFilterComponent( filterComponent ), token, currentFilter );
+                        }
+                        else
+                        {
+                            handleError( ( filterComponent instanceof LdapFilterExtensibleComponent )
+                                && ( ( LdapFilterExtensibleComponent ) filterComponent ).setDnAttrColonToken( token ), token,
+                                currentFilter );
+                        }
+                        break;
+                    }
+                    case LdapFilterToken.EXTENSIBLE_DNATTR:
+                    {
+                        LdapFilter currentFilter = ( LdapFilter ) filterStack.peek();
+                        LdapFilterComponent filterComponent = currentFilter.getFilterComponent();
+                        handleError( ( filterComponent instanceof LdapFilterExtensibleComponent )
+                            && ( ( LdapFilterExtensibleComponent ) filterComponent ).setDnAttrToken( token ), token,
+                            currentFilter );
+                        break;
+                    }
+                    case LdapFilterToken.EXTENSIBLE_MATCHINGRULEOID_COLON:
+                    {
+                        LdapFilter currentFilter = ( LdapFilter ) filterStack.peek();
+                        LdapFilterComponent filterComponent = currentFilter.getFilterComponent();
+                        if( filterComponent == null )
+                        {
+                            filterComponent = new LdapFilterExtensibleComponent( currentFilter );
+                            (( LdapFilterExtensibleComponent ) filterComponent ).setMatchingRuleColonToken( token );
+                            handleError( currentFilter.setFilterComponent( filterComponent ), token, currentFilter );
+                        }
+                        else
+                        {
+                            handleError( ( filterComponent instanceof LdapFilterExtensibleComponent )
+                                && ( ( LdapFilterExtensibleComponent ) filterComponent ).setMatchingRuleColonToken( token ), token,
+                                currentFilter );
+                        }
+                        break;
+                    }
+                    case LdapFilterToken.EXTENSIBLE_MATCHINGRULEOID:
+                    {
+                        LdapFilter currentFilter = ( LdapFilter ) filterStack.peek();
+                        LdapFilterComponent filterComponent = currentFilter.getFilterComponent();
+                        handleError( ( filterComponent instanceof LdapFilterExtensibleComponent )
+                            && ( ( LdapFilterExtensibleComponent ) filterComponent ).setMatchingRuleToken( token ), token,
+                            currentFilter );
+                        break;
+                    }
+                    case LdapFilterToken.EXTENSIBLE_EQUALS_COLON:
+                        {
+                            LdapFilter currentFilter = ( LdapFilter ) filterStack.peek();
+                            LdapFilterComponent filterComponent = currentFilter.getFilterComponent();
+                            handleError( ( filterComponent instanceof LdapFilterExtensibleComponent )
+                                && ( ( LdapFilterExtensibleComponent ) filterComponent ).setEqualsColonToken( token ), token,
+                                currentFilter );
+                            break;
+                        }
+                    
+                    case LdapFilterToken.EOF:
+                    {
+                        model.addOtherToken( token );
+                        break;
+                    }
+                    default:
+                    {
+                        LdapFilter currentFilter = filterStack.peek();
+                        handleError( false, token, currentFilter );
+                    }
+                }
+            }
+            while ( !filterStack.isEmpty() && token.getType() != LdapFilterToken.EOF );
+        }
+
+        // handle error token after filter
+        token = scanner.nextToken();
+        while ( token.getType() != LdapFilterToken.EOF )
+        {
+            handleError( false, token, model );
+            token = scanner.nextToken();
+        }
+    }
+
+
+    /**
+     * Helper method to handle parse errors.
+     * 
+     * @param success the success flag
+     * @param filter the filter
+     * @param token the token
+     */
+    private void handleError( boolean success, LdapFilterToken token, LdapFilter filter )
+    {
+        if ( !success )
+        {
+            filter.addOtherToken( new LdapFilterToken( LdapFilterToken.ERROR, token.getValue(), token.getOffset() ) );
+        }
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterScanner.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterScanner.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterScanner.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterScanner.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,493 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.core.model.filter.parser;
+
+
+/**
+ * The LdapFilterScanner is a scanner for LDAP filters. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapFilterScanner
+{
+
+    // From RFC 2254:
+    // -------------
+    // The string representation of an LDAP search filter is defined by the
+    // following grammar, following the ABNF notation defined in [5]. The
+    // filter format uses a prefix notation.
+    //	
+    // filter = "(" filtercomp ")"
+    // filtercomp = and / or / not / item
+    // and = "&" filterlist
+    // or = "|" filterlist
+    // not = "!" filter
+    // filterlist = 1*filter
+    // item = simple / present / substring / extensible
+    // simple = attr filtertype value
+    // filtertype = equal / approx / greater / less
+    // equal = "="
+    // approx = "~="
+    // greater = ">="
+    // less = "<="
+    // extensible = attr [":dn"] [":" matchingrule] ":=" value
+    // / [":dn"] ":" matchingrule ":=" value
+    // present = attr "=*"
+    // substring = attr "=" [initial] any [final]
+    // initial = value
+    // any = "*" *(value "*")
+    // final = value
+    // attr = AttributeDescription from Section 4.1.5 of [1]
+    // matchingrule = MatchingRuleId from Section 4.1.9 of [1]
+    // value = AttributeValue from Section 4.1.6 of [1]
+    //	
+    // The attr, matchingrule, and value constructs are as described in the
+    // corresponding section of [1] given above.
+    //	
+    // If a value should contain any of the following characters
+    //	
+    // Character ASCII value
+    // ---------------------------
+    // * 0x2a
+    // ( 0x28
+    // ) 0x29
+    // \ 0x5c
+    // NUL 0x00
+    //	
+    // the character must be encoded as the backslash '\' character (ASCII
+    // 0x5c) followed by the two hexadecimal digits representing the ASCII
+    // value of the encoded character. The case of the two hexadecimal
+    // digits is not significant.
+
+    /** The filter to scan */
+    private String filter;
+
+    /** The current position */
+    private int pos;
+
+    /** The last token type. */
+    private int lastTokenType;
+
+
+    /**
+     * Creates a new instance of LdapFilterScanner.
+     */
+    public LdapFilterScanner()
+    {
+        super();
+        this.filter = "";
+    }
+
+
+    
+    /**
+     * Resets this scanner.
+     * 
+     * @param filter the new filter to scan
+     */
+    public void reset( String filter )
+    {
+        this.filter = filter;
+        this.pos = -1;
+        this.lastTokenType = LdapFilterToken.NEW;
+    }
+
+
+    /**
+     * Gets the character at the current position.
+     * 
+     * @return the character at the current position
+     */
+    private char currentChar()
+    {
+        return 0 <= pos && pos < filter.length() ? filter.charAt( pos ) : '\u0000';
+    }
+
+
+    
+    /**
+     * Increments the position counter and gets
+     * the character at that positon.
+     * 
+     * @return the character at the next position
+     */
+    private char nextChar()
+    {
+        pos++;
+        return currentChar();
+    }
+
+
+    /**
+     * Decrements the position counter and gets
+     * the character at that positon.
+     * 
+     * @return the character at the previous position
+     */
+    private char prevChar()
+    {
+        pos--;
+        return currentChar();
+    }
+
+
+    /**
+     * Increments the position counter as long as there are
+     * line breaks and gets the character at that positon.
+     * 
+     * @return the character at the next position
+     */
+    private char nextNonLinebreakChar()
+    {
+        while ( nextChar() == '\n' );
+        return currentChar();
+    }
+
+
+    /**
+     * Decrements the position counter as long as there are
+     * line breaks and gets the character at that positon.
+     * 
+     * @return the character at the previous position
+     */
+    private char prevNonLinebreakChar()
+    {
+        while ( prevChar() == '\n' );
+        return currentChar();
+    }
+
+
+    /**
+     * Gets the next token.
+     * 
+     * @return the next token
+     */
+    public LdapFilterToken nextToken()
+    {
+        char c;
+
+        // check for EOF
+        c = nextChar();
+        if ( c == '\u0000' )
+        {
+            return new LdapFilterToken( LdapFilterToken.EOF, "", pos );
+        }
+        else
+        {
+            prevChar();
+        }
+
+        // check for ignorable whitespaces
+        c = nextChar();
+        if ( Character.isWhitespace( c )
+            && ( lastTokenType == LdapFilterToken.RPAR || lastTokenType == LdapFilterToken.AND
+                || lastTokenType == LdapFilterToken.OR || lastTokenType == LdapFilterToken.NOT ) )
+        {
+            StringBuffer sb = new StringBuffer();
+            while ( Character.isWhitespace( c ) )
+            {
+                sb.append( c );
+                c = nextChar();
+            }
+            prevChar();
+            return new LdapFilterToken( LdapFilterToken.WHITESPACE, sb.toString(), pos - sb.length() + 1 );
+        }
+        else
+        {
+            prevChar();
+        }
+
+        // check special characters
+        c = nextChar();
+        switch ( c )
+        {
+            case '(':
+                this.lastTokenType = LdapFilterToken.LPAR;
+                return new LdapFilterToken( this.lastTokenType, "(", pos );
+            case ')':
+                this.lastTokenType = LdapFilterToken.RPAR;
+                return new LdapFilterToken( this.lastTokenType, ")", pos );
+            case '&':
+                if ( lastTokenType == LdapFilterToken.LPAR )
+                {
+                    // if(nextNonWhitespaceChar()=='(') {
+                    // prevNonWhitespaceChar();
+                    this.lastTokenType = LdapFilterToken.AND;
+                    return new LdapFilterToken( this.lastTokenType, "&", pos );
+                    // }
+                    // else {
+                    // prevNonWhitespaceChar();
+                    // }
+                }
+                break;
+            case '|':
+                if ( lastTokenType == LdapFilterToken.LPAR )
+                {
+                    // if(nextNonWhitespaceChar()=='(') {
+                    // prevNonWhitespaceChar();
+                    this.lastTokenType = LdapFilterToken.OR;
+                    return new LdapFilterToken( this.lastTokenType, "|", pos );
+                    // }
+                    // else {
+                    // prevNonWhitespaceChar();
+                    // }
+                }
+                break;
+            case '!':
+                if ( lastTokenType == LdapFilterToken.LPAR )
+                {
+                    // if(nextNonWhitespaceChar()=='(') {
+                    // prevNonWhitespaceChar();
+                    this.lastTokenType = LdapFilterToken.NOT;
+                    return new LdapFilterToken( this.lastTokenType, "!", pos );
+                    // }
+                    // else {
+                    // prevNonWhitespaceChar();
+                    // }
+                }
+                break;
+            case '=':
+                if ( lastTokenType == LdapFilterToken.ATTRIBUTE )
+                {
+                    if ( nextChar() == '*' )
+                    {
+                        char t = nextChar();
+                        if ( t == ')' || t == '\u0000' )
+                        {
+                            prevChar();
+                            this.lastTokenType = LdapFilterToken.PRESENT;
+                            return new LdapFilterToken( this.lastTokenType, "=*", pos - 1 );
+                        }
+                        else
+                        {
+                            prevChar();
+                            prevChar();
+                            this.lastTokenType = LdapFilterToken.EQUAL;
+                            return new LdapFilterToken( this.lastTokenType, "=", pos );
+                        }
+                    }
+                    else
+                    {
+                        prevChar();
+                        this.lastTokenType = LdapFilterToken.EQUAL;
+                        return new LdapFilterToken( this.lastTokenType, "=", pos );
+                    }
+                }
+                else if ( lastTokenType == LdapFilterToken.EXTENSIBLE_EQUALS_COLON )
+                {
+                    this.lastTokenType = LdapFilterToken.EQUAL;
+                    return new LdapFilterToken( this.lastTokenType, "=", pos );
+                }
+                break;
+            case '>':
+                if ( lastTokenType == LdapFilterToken.ATTRIBUTE )
+                {
+                    if ( nextChar() == '=' )
+                    {
+                        this.lastTokenType = LdapFilterToken.GREATER;
+                        return new LdapFilterToken( this.lastTokenType, ">=", pos - 1 );
+                    }
+                    else
+                    {
+                        prevChar();
+                    }
+                }
+                break;
+            case '<':
+                if ( lastTokenType == LdapFilterToken.ATTRIBUTE )
+                {
+                    if ( nextChar() == '=' )
+                    {
+                        this.lastTokenType = LdapFilterToken.LESS;
+                        return new LdapFilterToken( this.lastTokenType, "<=", pos - 1 );
+                    }
+                    else
+                    {
+                        prevChar();
+                    }
+                }
+                break;
+            case '~':
+                if ( lastTokenType == LdapFilterToken.ATTRIBUTE )
+                {
+                    if ( nextChar() == '=' )
+                    {
+                        this.lastTokenType = LdapFilterToken.APROX;
+                        return new LdapFilterToken( this.lastTokenType, "~=", pos - 1 );
+                    }
+                    else
+                    {
+                        prevChar();
+                    }
+                }
+                break;
+            case ':':
+                char t1 = nextChar();
+                char t2 = nextChar();
+                char t3 = nextChar();
+                prevChar();
+                prevChar();
+                prevChar();
+                if ( ( lastTokenType == LdapFilterToken.LPAR || lastTokenType == LdapFilterToken.EXTENSIBLE_ATTRIBUTE )
+                    &&
+                    ( 
+//                        ( t1 == ':' && t2 != '=' )
+//                        ||
+//                        ( ( t1 == 'd' || t1 == 'D' ) && t2 == ':' && t3 == ':' )
+//                        ||
+                        ( ( t1 == 'd' || t1 == 'D' )  && ( t2 == 'n' || t2 == 'N' ) && ( t3 == ':' ) )
+                    )
+                    )
+                {
+                    this.lastTokenType = LdapFilterToken.EXTENSIBLE_DNATTR_COLON;
+                    return new LdapFilterToken( this.lastTokenType, ":", pos );
+                }
+                else if ( ( lastTokenType == LdapFilterToken.EXTENSIBLE_ATTRIBUTE
+                    || lastTokenType == LdapFilterToken.EXTENSIBLE_DNATTR
+                    || lastTokenType == LdapFilterToken.EXTENSIBLE_MATCHINGRULEOID 
+                    || lastTokenType == LdapFilterToken.EXTENSIBLE_MATCHINGRULEOID_COLON )
+                    && t1 == '=' )
+                {
+                    this.lastTokenType = LdapFilterToken.EXTENSIBLE_EQUALS_COLON;
+                    return new LdapFilterToken( this.lastTokenType, ":", pos );
+                }
+                else if ( ( lastTokenType == LdapFilterToken.LPAR
+                    || lastTokenType == LdapFilterToken.EXTENSIBLE_ATTRIBUTE 
+                    || lastTokenType == LdapFilterToken.EXTENSIBLE_DNATTR 
+                    || lastTokenType == LdapFilterToken.EXTENSIBLE_DNATTR_COLON ) )
+                {
+                    this.lastTokenType = LdapFilterToken.EXTENSIBLE_MATCHINGRULEOID_COLON;
+                    return new LdapFilterToken( this.lastTokenType, ":", pos );
+                }
+                break;
+                
+        } // switch
+        prevChar();
+
+        // check attribute or extensible attribute
+        if ( this.lastTokenType == LdapFilterToken.LPAR )
+        {
+            StringBuffer sb = new StringBuffer();
+
+            // first char must be non-whitespace
+            c = nextChar();
+            while ( c != ':' && c != '=' && c != '<' && c != '>' && c != '~' && c != '(' && c != ')' && c != '\u0000'
+                && !Character.isWhitespace( c ) )
+            {
+                sb.append( c );
+                c = nextChar();
+            }
+            prevChar();
+
+            if ( sb.length() > 0 )
+            {
+                boolean isExtensible = ( c == ':' );
+                if(isExtensible)
+                {
+                    this.lastTokenType = LdapFilterToken.EXTENSIBLE_ATTRIBUTE;
+                    return new LdapFilterToken( this.lastTokenType, sb.toString(), pos - sb.length() + 1 );
+                }
+                else
+                {
+                    this.lastTokenType = LdapFilterToken.ATTRIBUTE;
+                    return new LdapFilterToken( this.lastTokenType, sb.toString(), pos - sb.length() + 1 );
+                }
+            }
+        }
+
+        // check value
+        if ( lastTokenType == LdapFilterToken.EQUAL || lastTokenType == LdapFilterToken.GREATER
+            || lastTokenType == LdapFilterToken.LESS || lastTokenType == LdapFilterToken.APROX )
+        {
+
+            StringBuffer sb = new StringBuffer();
+            c = nextNonLinebreakChar();
+            while ( c != '(' && c != ')' && c != '\u0000' )
+            {
+                sb.append( c );
+                c = nextNonLinebreakChar();
+            }
+            prevNonLinebreakChar();
+
+            if ( sb.length() > 0 )
+            {
+                this.lastTokenType = LdapFilterToken.VALUE;
+                return new LdapFilterToken( this.lastTokenType, sb.toString(), pos - sb.length() + 1 );
+            }
+        }
+
+        // check extensible dn
+        if ( lastTokenType == LdapFilterToken.EXTENSIBLE_DNATTR_COLON )
+        {
+            char t1 = nextChar();
+            char t2 = nextChar();
+            char t3 = nextChar();
+            prevChar();
+            if ( ( t1 == 'd' || t1 == 'D' )
+                && ( t2 == 'n' || t2 == 'N' )
+                && ( t3 == ':' || t3 == '\u0000' ) )
+            {
+                this.lastTokenType = LdapFilterToken.EXTENSIBLE_DNATTR;
+                return new LdapFilterToken( this.lastTokenType, ""+t1+t2, pos - 1 );
+            }
+            prevChar();
+            prevChar();
+        }
+        
+        // check extensible matchingrule
+        if ( lastTokenType == LdapFilterToken.EXTENSIBLE_MATCHINGRULEOID_COLON )
+        {
+            StringBuffer sb = new StringBuffer();
+
+            // first char must be non-whitespace
+            c = nextChar();
+            while ( c != ':' && c != '=' && c != '<' && c != '>' && c != '~' && c != '(' && c != ')' && c != '\u0000'
+                && !Character.isWhitespace( c ) )
+            {
+                sb.append( c );
+                c = nextChar();
+            }
+            prevChar();
+
+            if ( sb.length() > 0 )
+            {
+                this.lastTokenType = LdapFilterToken.EXTENSIBLE_MATCHINGRULEOID;
+                return new LdapFilterToken( this.lastTokenType, sb.toString(), pos - sb.length() + 1 );
+            }
+        }
+        
+        // no match
+        StringBuffer sb = new StringBuffer();
+        c = nextChar();
+        while ( c != '(' && c != ')' && c != '\u0000' )
+        {
+            sb.append( c );
+            c = nextChar();
+        }
+        prevChar();
+        // this.lastTokenType = LdapFilterToken.UNKNOWN;
+        // return new LdapFilterToken(this.lastTokenType, sb.toString(),
+        // pos-sb.length());
+        return new LdapFilterToken( LdapFilterToken.UNKNOWN, sb.toString(), pos - sb.length() + 1 );
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterScanner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterToken.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterToken.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterToken.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterToken.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,199 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.core.model.filter.parser;
+
+
+/**
+ * The LdapFilterToken is used to exchange tokens from the scanner to the parser.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapFilterToken implements Comparable
+{
+
+    /** The token identifier for a new filter */
+    public static final int NEW = Integer.MIN_VALUE;
+
+    /** The token identifier for an error token */
+    public static final int ERROR = -2;
+
+    /** The token identifier for end of file */
+    public static final int EOF = -1;
+
+    /** The token identifier for an unknown token */
+    public static final int UNKNOWN = 0;
+
+    /** The token identifier for a whitespace */
+    public static final int WHITESPACE = 1;
+
+    /** The token identifier for the left parenthesis ( */
+    public static final int LPAR = 11;
+
+    /** The token identifier for the right parenthesis ) */
+    public static final int RPAR = 12;
+
+    /** The token identifier for the and operator & */
+    public static final int AND = 21;
+
+    /** The token identifier for the or operator | */
+    public static final int OR = 22;
+
+    /** The token identifier for the not operator ! */
+    public static final int NOT = 23;
+
+    /** The token identifier for the attribute = */
+    public static final int ATTRIBUTE = 31;
+
+    /** The token identifier for the equal filter type = */
+    public static final int EQUAL = 41;
+
+    /** The token identifier for the approx filter type ~= */
+    public static final int APROX = 42;
+
+    /** The token identifier for the greater or equal filter type >= */
+    public static final int GREATER = 43;
+
+    /** The token identifier for the less or equal filter type <= */
+    public static final int LESS = 44;
+
+    /** The token identifier for the present filter type =* */
+    public static final int PRESENT = 45;
+
+    /** The token identifier for a value. */
+    public static final int VALUE = 51;
+
+    /** The token identifier for the asterisk. */
+    public static final int ASTERISK = 52;
+
+    /** The token identifier for the attribute type in extensible filters. */
+    public static final int EXTENSIBLE_ATTRIBUTE = 61;
+
+    /** The token identifier for the colon before the DN flag in extensible filters. */
+    public static final int EXTENSIBLE_DNATTR_COLON = 62;
+
+    /** The token identifier for the DN flag in extensible filters. */
+    public static final int EXTENSIBLE_DNATTR = 63;
+
+    /** The token identifier for the colon before the matching rule OID in extensible filters. */
+    public static final int EXTENSIBLE_MATCHINGRULEOID_COLON = 64;
+
+    /** The token identifier for the matching rule OID in extensible filters. */
+    public static final int EXTENSIBLE_MATCHINGRULEOID = 65;
+
+    /** The token identifier for the colon before the equals in extensible filters. */
+    public static final int EXTENSIBLE_EQUALS_COLON = 66;
+
+    /** The offset. */
+    private int offset;
+
+    /** The type. */
+    private int type;
+
+    /** The value. */
+    private String value;
+
+
+    /**
+     * Creates a new instance of LdapFilterToken.
+     * 
+     * @param type the type
+     * @param value the value
+     * @param offset the offset
+     */
+    public LdapFilterToken( int type, String value, int offset )
+    {
+        this.type = type;
+        this.value = value;
+        this.offset = offset;
+    }
+
+
+    /**
+     * Returns the start position of the token in the original filter
+     * 
+     * @return the start positon of the token
+     */
+    public int getOffset()
+    {
+        return offset;
+    }
+
+
+    /**
+     * Returns the length of the token in the original filter
+     * 
+     * @return the length of the token
+     */
+    public int getLength()
+    {
+        return value.length();
+    }
+
+
+    /**
+     * Gets the token type.
+     * 
+     * @return the token type
+     */
+    public int getType()
+    {
+        return type;
+    }
+
+
+    /**
+     * Gets the value of the token in the original filter.
+     * 
+     * @return the value of the token
+     */
+    public String getValue()
+    {
+        return value;
+    }
+
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return "(" + offset + ") " + "(" + type + ") " + value;
+    }
+
+
+    /**
+     * @see java.lang.Comparable#compareTo(java.lang.Object)
+     */
+    public int compareTo( Object o )
+    {
+        if ( o instanceof LdapFilterToken )
+        {
+            LdapFilterToken token = ( LdapFilterToken ) o;
+            return this.offset - token.offset;
+        }
+        else
+        {
+            throw new ClassCastException( "Not instanceof LapFilterToken: " + o.getClass().getName() );
+        }
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/filter/parser/LdapFilterToken.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message