You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/05 17:52:07 UTC

svn commit: r592082 [13/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...

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,518 @@
+/*
+ *  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.impl;
+
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent;
+import org.apache.directory.studio.ldapbrowser.core.internal.search.LdapSearchPageScoreComputer;
+import org.apache.directory.studio.ldapbrowser.core.model.Control;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
+import org.apache.directory.studio.ldapbrowser.core.model.URL;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.AliasDereferencingMethod;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.ReferralHandlingMethod;
+import org.eclipse.search.ui.ISearchPageScoreComputer;
+
+
+/**
+ * Default implementation of ISearch.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Search implements ISearch
+{
+
+    /** The serialVersionUID. */
+    private static final long serialVersionUID = -3482673086666351174L;
+
+    /** The connection. */
+    private IBrowserConnection connection;
+
+    /** The search results. */
+    private ISearchResult[] searchResults;
+
+    /** The search parameter. */
+    private SearchParameter searchParameter;
+
+    /** The count limit exceeded flag. */
+    private boolean countLimitExceeded;
+
+
+    /**
+     * Creates a new search with the following parameters:
+     * <ul>
+     * <li>searchName: current date
+     * <li>connection: null
+     * <li>empty search base
+     * <li>default filter (objectClass=*)
+     * <li>no returning attributes
+     * <li>search scope one level
+     * <li>no count limit
+     * <li>no time limit
+     * <li>never dereference aliases
+     * <li>ignore referrals
+     * <li>no initialization of hasChildren flag
+     * <li>no initialization of isAlias and isReferral flag
+     * <li>no controls
+     * <li>
+     * </ul>
+     */
+    public Search()
+    {
+        this(
+            new SimpleDateFormat( "yyyy-MM-dd HH-mm-ss" ).format( new Date() ), //$NON-NLS-1$
+            null, EMPTY_SEARCH_BASE, FILTER_TRUE, NO_ATTRIBUTES, SearchScope.ONELEVEL, 0, 0,
+            AliasDereferencingMethod.NEVER, ReferralHandlingMethod.IGNORE, false, false, null );
+    }
+
+
+    /**
+     * Creates a new Search with the given connection and search parameters.
+     *
+     * @param conn the connection
+     * @param searchParameter the search parameters
+     */
+    public Search( IBrowserConnection conn, SearchParameter searchParameter )
+    {
+        this.connection = conn;
+        this.searchResults = null;
+        this.searchParameter = searchParameter;
+        this.countLimitExceeded = false;
+    }
+
+
+    /**
+     * Creates a new search with the given search parameters
+     *
+     * @param searchName
+     *                the name of the search
+     * @param conn
+     *                the connection of the search
+     * @param searchBase
+     *                the base DN of the search, a null search base will be
+     *                transformed to an empty DN.
+     * @param filter
+     *                the filter to use, null or empty filters will be
+     *                transformed to (objectClass=*)
+     * @param returningAttributes
+     *                the attributes to return, an empty array indicates none,
+     *                null will be transformed to '*' (all user attributes)
+     * @param scope
+     *                the search scope
+     * @param countLimit
+     *                the count limit, 0 indicates no limit
+     * @param timeLimit
+     *                the time limit in ms, 0 indicates no limit
+     * @param aliasesDereferencingMethod
+     *                the aliases dereferencing method
+     * @param referralsHandlingMethod
+     *                the referrals handling method
+     * @param initHasChildrenFlag
+     *                the init hasChildren flag
+     * @param initAliasAndReferralsFlag
+     *                the init isAlias and isReferral flag
+     * @param controls
+     *                the controls
+     */
+    public Search( String searchName, IBrowserConnection conn, LdapDN searchBase, String filter,
+        String[] returningAttributes, SearchScope scope, int countLimit, int timeLimit,
+        AliasDereferencingMethod aliasesDereferencingMethod, ReferralHandlingMethod referralsHandlingMethod,
+        boolean initHasChildrenFlag, boolean initAliasAndReferralsFlag, Control[] controls )
+    {
+        this.connection = conn;
+        this.searchResults = null;
+        this.countLimitExceeded = false;
+
+        this.searchParameter = new SearchParameter();
+        this.searchParameter.setName( searchName );
+        this.searchParameter.setSearchBase( searchBase );
+        this.searchParameter.setFilter( filter );
+        this.searchParameter.setReturningAttributes( returningAttributes );
+        this.searchParameter.setScope( scope );
+        this.searchParameter.setTimeLimit( timeLimit );
+        this.searchParameter.setCountLimit( countLimit );
+        this.searchParameter.setAliasesDereferencingMethod( aliasesDereferencingMethod );
+        this.searchParameter.setReferralsHandlingMethod( referralsHandlingMethod );
+        this.searchParameter.setInitHasChildrenFlag( initHasChildrenFlag );
+        this.searchParameter.setInitAliasAndReferralFlag( initAliasAndReferralsFlag );
+        this.searchParameter.setControls( controls );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public URL getUrl()
+    {
+        return new URL( this );
+    }
+
+
+    /**
+     * Fires a search update event if the search name is set.
+     *
+     * @param detail the SearchUpdateEvent detail
+     */
+    private void fireSearchUpdated( SearchUpdateEvent.EventDetail detail )
+    {
+        if ( getName() != null && !"".equals( getName() ) ) { //$NON-NLS-1$
+            EventRegistry.fireSearchUpdated( new SearchUpdateEvent( this, detail ), this );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isInitHasChildrenFlag()
+    {
+        return searchParameter.isInitHasChildrenFlag();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isInitAliasAndReferralFlag()
+    {
+        return searchParameter.isInitAliasAndReferralFlag();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Control[] getControls()
+    {
+        return searchParameter.getControls();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getCountLimit()
+    {
+        return searchParameter.getCountLimit();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setCountLimit( int countLimit )
+    {
+        searchParameter.setCountLimit( countLimit );
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getFilter()
+    {
+        return searchParameter.getFilter();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setFilter( String filter )
+    {
+        searchParameter.setFilter( filter );
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getReturningAttributes()
+    {
+        return searchParameter.getReturningAttributes();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setReturningAttributes( String[] returningAttributes )
+    {
+        searchParameter.setReturningAttributes( returningAttributes );
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SearchScope getScope()
+    {
+        return searchParameter.getScope();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setScope( SearchScope scope )
+    {
+        searchParameter.setScope( scope );
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public AliasDereferencingMethod getAliasesDereferencingMethod()
+    {
+        return searchParameter.getAliasesDereferencingMethod();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setAliasesDereferencingMethod( AliasDereferencingMethod aliasesDereferencingMethod )
+    {
+        searchParameter.setAliasesDereferencingMethod( aliasesDereferencingMethod );
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ReferralHandlingMethod getReferralsHandlingMethod()
+    {
+        return searchParameter.getReferralsHandlingMethod();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setReferralsHandlingMethod( ReferralHandlingMethod referralsHandlingMethod )
+    {
+        searchParameter.setReferralsHandlingMethod( referralsHandlingMethod );
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public LdapDN getSearchBase()
+    {
+        return searchParameter.getSearchBase();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSearchBase( LdapDN searchBase )
+    {
+        searchParameter.setSearchBase( searchBase );
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getTimeLimit()
+    {
+        return searchParameter.getTimeLimit();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setTimeLimit( int timeLimit )
+    {
+        searchParameter.setTimeLimit( timeLimit );
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName()
+    {
+        return searchParameter.getName();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setName( String searchName )
+    {
+        searchParameter.setName( searchName );
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_RENAMED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ISearchResult[] getSearchResults()
+    {
+        return searchResults;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSearchResults( ISearchResult[] searchResults )
+    {
+        this.searchResults = searchResults;
+        if ( searchResults != null )
+        {
+            fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PERFORMED );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isCountLimitExceeded()
+    {
+        return countLimitExceeded;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setCountLimitExceeded( boolean countLimitExceeded )
+    {
+        this.countLimitExceeded = countLimitExceeded;
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PERFORMED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IBrowserConnection getBrowserConnection()
+    {
+        return connection;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setBrowserConnection( IBrowserConnection connection )
+    {
+        this.connection = connection;
+        searchParameter.setCountLimit( connection.getCountLimit() );
+        searchParameter.setTimeLimit( connection.getTimeLimit() );
+        searchParameter.setAliasesDereferencingMethod( connection.getAliasesDereferencingMethod() );
+        searchParameter.setReferralsHandlingMethod( connection.getReferralsHandlingMethod() );
+        fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+        return getName() + " (" + getBrowserConnection() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object clone()
+    {
+        return new Search( getName(), getBrowserConnection(), getSearchBase(), getFilter(), getReturningAttributes(),
+            getScope(), getCountLimit(), getTimeLimit(), getAliasesDereferencingMethod(), getReferralsHandlingMethod(),
+            isInitHasChildrenFlag(), isInitAliasAndReferralFlag(), getControls() );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SearchParameter getSearchParameter()
+    {
+        return searchParameter;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSearchParameter( SearchParameter searchParameter )
+    {
+        this.searchParameter = searchParameter;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public Object getAdapter( Class adapter )
+    {
+        Class<?> clazz = ( Class<?> ) adapter;
+        if ( clazz.isAssignableFrom( ISearchPageScoreComputer.class ) )
+        {
+            return new LdapSearchPageScoreComputer();
+        }
+        if ( clazz.isAssignableFrom( Connection.class ) )
+        {
+            return getBrowserConnection().getConnection();
+        }
+        if ( clazz.isAssignableFrom( IBrowserConnection.class ) )
+        {
+            return getBrowserConnection();
+        }
+        if ( clazz.isAssignableFrom( ISearch.class ) )
+        {
+            return this;
+        }
+
+        return null;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/SearchResult.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/SearchResult.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/SearchResult.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/SearchResult.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,171 @@
+/*
+ *  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.impl;
+
+
+import java.util.ArrayList;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.ldapbrowser.core.internal.search.LdapSearchPageScoreComputer;
+import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.eclipse.search.ui.ISearchPageScoreComputer;
+
+
+/**
+ * Default implementation of ISearchResult.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchResult implements ISearchResult
+{
+
+    private static final long serialVersionUID = -5658803569872619432L;
+
+    /** The search. */
+    private ISearch search;
+
+    /** The entry. */
+    private IEntry entry;
+
+
+    protected SearchResult()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of SearchResult.
+     * 
+     * @param entry the entry
+     * @param search the search
+     */
+    public SearchResult( IEntry entry, ISearch search )
+    {
+        this.entry = entry;
+        this.search = search;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public LdapDN getDn()
+    {
+        return entry.getDn();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IAttribute[] getAttributes()
+    {
+        ArrayList<IAttribute> attributeList = new ArrayList<IAttribute>();
+        for ( int i = 0; i < search.getReturningAttributes().length; i++ )
+        {
+            if ( entry.getAttribute( search.getReturningAttributes()[i] ) != null )
+            {
+                attributeList.add( entry.getAttribute( search.getReturningAttributes()[i] ) );
+            }
+        }
+        return attributeList.toArray( new IAttribute[attributeList.size()] );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IAttribute getAttribute( String attributeDescription )
+    {
+        return entry.getAttribute( attributeDescription );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public AttributeHierarchy getAttributeWithSubtypes( String attributeDescription )
+    {
+        return entry.getAttributeWithSubtypes( attributeDescription );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IEntry getEntry()
+    {
+        return entry;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public Object getAdapter( Class adapter )
+    {
+        Class<?> clazz = ( Class<?> ) adapter;
+        if ( clazz.isAssignableFrom( ISearchPageScoreComputer.class ) )
+        {
+            return new LdapSearchPageScoreComputer();
+        }
+        if ( clazz.isAssignableFrom( Connection.class ) )
+        {
+            return search.getBrowserConnection().getConnection();
+        }
+        if ( clazz.isAssignableFrom( IBrowserConnection.class ) )
+        {
+            return search.getBrowserConnection();
+        }
+        if ( clazz.isAssignableFrom( IEntry.class ) )
+        {
+            return getEntry();
+        }
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ISearch getSearch()
+    {
+        return search;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSearch( ISearch search )
+    {
+        this.search = search;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Value.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Value.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Value.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Value.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,322 @@
+/*
+ *  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.impl;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.ldapbrowser.core.internal.search.LdapSearchPageScoreComputer;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.utils.LdifUtils;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+import org.eclipse.search.ui.ISearchPageScoreComputer;
+
+
+/**
+ * Default implementation of IValue.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Value implements IValue
+{
+
+    /** The serialVersionUID. */
+    private static final long serialVersionUID = -9039209604742682740L;
+
+    /** The attribute this value belongs to */
+    private IAttribute attribute;
+
+    /** The raw value, either a String or a byte[] */
+    private Object rawValue;
+
+
+    /**
+     * Creates a new instance of Value.
+     *
+     * @param attribute the attribute this value belongs to 
+     * @param rawValue the raw value, either a String or a byte[]
+     */
+    public Value( IAttribute attribute, Object rawValue )
+    {
+        this.init( attribute, rawValue );
+        assert rawValue != null;
+    }
+
+
+    /**
+     * Creates a new instance of Value with an empty value.
+     *
+     * @param attribute the attribute this value belongs to
+     */
+    public Value( IAttribute attribute )
+    {
+        this.init( attribute, null );
+    }
+
+
+    /**
+     * Initializes this Value.
+     *
+     * @param attribute the attribute this value belongs to 
+     * @param rawValue the raw value, either a String or a byte[] or null 
+     */
+    private void init( IAttribute attribute, Object rawValue )
+    {
+        assert attribute != null;
+
+        this.attribute = attribute;
+
+        if ( rawValue == null )
+        {
+            if ( attribute.isString() )
+            {
+                this.rawValue = IValue.EMPTY_STRING_VALUE;
+            }
+            else
+            {
+                this.rawValue = IValue.EMPTY_BINARY_VALUE;
+            }
+        }
+        else
+        {
+            this.rawValue = rawValue;
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IAttribute getAttribute()
+    {
+        return attribute;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object getRawValue()
+    {
+        return rawValue;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getStringValue()
+    {
+
+        if ( rawValue == EMPTY_STRING_VALUE )
+        {
+            return EMPTY_STRING_VALUE.getStringValue();
+        }
+        else if ( rawValue == EMPTY_BINARY_VALUE )
+        {
+            return EMPTY_BINARY_VALUE.getStringValue();
+        }
+        else if ( rawValue instanceof String )
+        {
+            return ( String ) rawValue;
+        }
+        else if ( rawValue instanceof byte[] )
+        {
+            return LdifUtils.utf8decode( ( byte[] ) rawValue );
+        }
+        else
+        {
+            return "UNKNOWN";
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public byte[] getBinaryValue()
+    {
+        if ( rawValue == EMPTY_STRING_VALUE )
+        {
+            return EMPTY_STRING_VALUE.getBinaryValue();
+        }
+        else if ( rawValue == EMPTY_BINARY_VALUE )
+        {
+            return EMPTY_BINARY_VALUE.getBinaryValue();
+        }
+        else if ( rawValue instanceof byte[] )
+        {
+            return ( byte[] ) rawValue;
+        }
+        else if ( rawValue instanceof String )
+        {
+            return LdifUtils.utf8encode( ( String ) rawValue );
+        }
+        else
+        {
+            return LdifUtils.utf8encode( "UNKNOWN" );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isString()
+    {
+        return rawValue == EMPTY_STRING_VALUE || attribute.isString();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isBinary()
+    {
+        return rawValue == EMPTY_BINARY_VALUE || attribute.isBinary();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEmpty()
+    {
+        return rawValue == EMPTY_STRING_VALUE || rawValue == EMPTY_BINARY_VALUE;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean equals( Object o )
+    {
+        // check argument
+        if ( o == null || !( o instanceof IValue ) )
+        {
+            return false;
+        }
+        IValue vc = ( IValue ) o;
+
+        // compare attributes
+        if ( !vc.getAttribute().equals( this.getAttribute() ) )
+        {
+            return false;
+        }
+
+        // compare values
+        if ( this.isEmpty() && vc.isEmpty() )
+        {
+            return true;
+        }
+        else if ( this.isBinary() && vc.isBinary() )
+        {
+            return Utils.equals( this.getBinaryValue(), vc.getBinaryValue() );
+        }
+        else if ( this.isString() && vc.isString() )
+        {
+            return ( this.getStringValue().equals( vc.getStringValue() ) );
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int hashCode()
+    {
+        return rawValue.hashCode();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+        return attribute + ":" + ( isString() ? getStringValue() : "BINARY" ); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public Object getAdapter( Class adapter )
+    {
+        Class<?> clazz = ( Class<?> ) adapter;
+        if ( clazz.isAssignableFrom( ISearchPageScoreComputer.class ) )
+        {
+            return new LdapSearchPageScoreComputer();
+        }
+        if ( clazz.isAssignableFrom( Connection.class ) )
+        {
+            return getAttribute().getEntry().getBrowserConnection().getConnection();
+        }
+        if ( clazz.isAssignableFrom( IBrowserConnection.class ) )
+        {
+            return getAttribute().getEntry().getBrowserConnection();
+        }
+        if ( clazz.isAssignableFrom( IEntry.class ) )
+        {
+            return getAttribute().getEntry();
+        }
+        if ( clazz.isAssignableFrom( IAttribute.class ) )
+        {
+            return getAttribute();
+        }
+        if ( clazz.isAssignableFrom( IValue.class ) )
+        {
+            return this;
+        }
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isRdnPart()
+    {
+        Iterator<AttributeTypeAndValue> atavIterator = getAttribute().getEntry().getRdn().iterator();
+        while(atavIterator.hasNext())
+        {
+            AttributeTypeAndValue atav = atavIterator.next();
+            if ( getAttribute().getDescription().equals( atav.getUpType() )
+                && getStringValue().equals( atav.getUpValue() ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifEOFPart.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifEOFPart.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifEOFPart.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifEOFPart.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,93 @@
+/*
+ *  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.ldif;
+
+
+public final class LdifEOFPart implements LdifPart
+{
+
+    private static final long serialVersionUID = -8527682569842893613L;
+
+    private int offset;
+
+
+    protected LdifEOFPart()
+    {
+    }
+
+
+    public LdifEOFPart( int offset )
+    {
+        this.offset = offset;
+    }
+
+
+    public final int getOffset()
+    {
+        return this.offset;
+    }
+
+
+    public final int getLength()
+    {
+        return 0;
+    }
+
+
+    public final String toRawString()
+    {
+        return "";
+    }
+
+
+    public final String toFormattedString()
+    {
+        return "";
+    }
+
+
+    public final String toString()
+    {
+        String text = toRawString();
+        text = text.replaceAll( "\n", "\\\\n" );
+        text = text.replaceAll( "\r", "\\\\r" );
+        return getClass().getName() + " (" + getOffset() + "," + getLength() + "): '" + text + "'";
+    }
+
+
+    public final boolean isValid()
+    {
+        return true;
+    }
+
+
+    public final String getInvalidString()
+    {
+        return "";
+    }
+
+
+    public final void adjustOffset( int adjust )
+    {
+        this.offset += adjust;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifEnumeration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifEnumeration.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifEnumeration.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifEnumeration.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,54 @@
+/*
+ *  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.ldif;
+
+
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.ldapbrowser.core.model.ConnectionException;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContainer;
+
+
+public interface LdifEnumeration
+{
+
+    /**
+     * 
+     * @param monitor
+     *                The monitor to check for cancellation. Don't report
+     *                errors to the monitor, throw an ConnectionException
+     *                instead.
+     * @throws ConnectionException
+     */
+    public boolean hasNext( StudioProgressMonitor monitor ) throws ConnectionException;
+
+
+    /**
+     * 
+     * @param monitor
+     *                The monitor to check for cancellation. Don't report
+     *                errors to the monitor, throw an ConnectionException
+     *                instead.
+     * @return the next LDIF container or null if hasNext() returns false;
+     * @throws ConnectionException
+     */
+    public LdifContainer next( StudioProgressMonitor monitor ) throws ConnectionException;
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifFile.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifFile.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifFile.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifFile.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,432 @@
+/*
+ *  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.ldif;
+
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifChangeRecord;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContentRecord;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifModSpec;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifRecord;
+
+
+public class LdifFile implements Serializable
+{
+
+    private static final long serialVersionUID = 846864138240517008L;
+
+    private List containerList;
+
+
+    public LdifFile()
+    {
+        super();
+        this.containerList = new ArrayList( 1 );
+    }
+
+
+    public boolean isContentType()
+    {
+        for ( Iterator it = this.containerList.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifRecord )
+            {
+                return o instanceof LdifContentRecord;
+            }
+        }
+        return false;
+    }
+
+
+    public boolean isChangeType()
+    {
+        for ( Iterator it = this.containerList.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifRecord )
+            {
+                return o instanceof LdifChangeRecord;
+            }
+        }
+        return false;
+    }
+
+
+    public void addContainer( LdifContainer container )
+    {
+        this.containerList.add( container );
+    }
+
+
+    /**
+     * 
+     * @return all container, includes version, comments, records and
+     *         unknown
+     */
+    public LdifContainer[] getContainers()
+    {
+        return ( LdifContainer[] ) this.containerList.toArray( new LdifContainer[this.containerList.size()] );
+    }
+
+
+    /**
+     * 
+     * @return only records (even invalid), no version, comments, and
+     *         unknown
+     */
+    public LdifRecord[] getRecords()
+    {
+        List l = new ArrayList();
+        for ( Iterator it = this.containerList.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifRecord )
+            {
+                l.add( o );
+            }
+        }
+        return ( LdifRecord[] ) l.toArray( new LdifRecord[l.size()] );
+    }
+
+
+    /**
+     * 
+     * @return the last container or null
+     */
+    public LdifContainer getLastContainer()
+    {
+        if ( this.containerList.isEmpty() )
+        {
+            return null;
+        }
+        else
+        {
+            return ( LdifContainer ) this.containerList.get( this.containerList.size() - 1 );
+        }
+    }
+
+
+    public String toRawString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        LdifContainer[] containers = this.getContainers();
+        for ( int i = 0; i < containers.length; i++ )
+        {
+            sb.append( containers[i].toRawString() );
+        }
+
+        return sb.toString();
+    }
+
+
+    public String toFormattedString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        LdifContainer[] containers = this.getContainers();
+        for ( int i = 0; i < containers.length; i++ )
+        {
+            sb.append( containers[i].toFormattedString() );
+        }
+
+        return sb.toString();
+    }
+
+
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        LdifContainer[] containers = this.getContainers();
+        for ( int i = 0; i < containers.length; i++ )
+        {
+            sb.append( containers[i].toString() );
+        }
+
+        return sb.toString();
+    }
+
+
+    public static LdifContainer getContainer( LdifFile model, int offset )
+    {
+        if ( model == null || offset < 0 )
+            return null;
+
+        LdifContainer container = null;
+        LdifContainer[] containers = model.getContainers();
+        if ( containers.length > 0 )
+        {
+            for ( int i = 0; i < containers.length; i++ )
+            {
+                if ( containers[i].getOffset() <= offset
+                    && offset < containers[i].getOffset() + containers[i].getLength() )
+                {
+                    container = containers[i];
+                    break;
+                }
+            }
+        }
+        return container;
+    }
+
+
+    public static LdifModSpec getInnerContainer( LdifContainer container, int offset )
+    {
+        if ( container == null || offset < container.getOffset()
+            || offset > container.getOffset() + container.getLength() )
+            return null;
+
+        LdifModSpec innerContainer = null;
+        LdifPart[] parts = container.getParts();
+        if ( parts.length > 0 )
+        {
+            int partIndex = -1;
+
+            for ( int i = 0; i < parts.length; i++ )
+            {
+                int start = parts[i].getOffset();
+                int end = parts[i].getOffset() + parts[i].getLength();
+                if ( start <= offset && offset < end )
+                {
+                    partIndex = i;
+                    break;
+                }
+            }
+
+            if ( partIndex > -1 )
+            {
+                if ( parts[partIndex] instanceof LdifModSpec )
+                {
+                    innerContainer = ( LdifModSpec ) parts[partIndex];
+                }
+            }
+        }
+        return innerContainer;
+    }
+
+
+    public static LdifContainer[] getContainers( LdifFile model, int offset, int length )
+    {
+        if ( model == null || offset < 0 )
+            return null;
+
+        ArrayList containerList = new ArrayList();
+
+        LdifContainer[] containers = model.getContainers();
+        if ( containers.length > 0 )
+        {
+            for ( int i = 0; i < containers.length; i++ )
+            {
+                if ( offset < containers[i].getOffset() + containers[i].getLength()
+                    && offset + length > containers[i].getOffset() )
+                {
+                    containerList.add( containers[i] );
+                }
+            }
+        }
+
+        return ( LdifContainer[] ) containerList.toArray( new LdifContainer[containerList.size()] );
+    }
+
+
+    public static LdifPart[] getParts( LdifFile model, int offset, int length )
+    {
+        if ( model == null || offset < 0 )
+            return null;
+
+        LdifContainer[] containers = model.getContainers();
+        return getParts( containers, offset, length );
+
+    }
+
+
+    public static LdifPart[] getParts( LdifContainer[] containers, int offset, int length )
+    {
+        if ( containers == null || offset < 0 )
+            return null;
+
+        ArrayList partList = new ArrayList();
+
+        for ( int i = 0; i < containers.length; i++ )
+        {
+            if ( offset < containers[i].getOffset() + containers[i].getLength()
+                && offset + length >= containers[i].getOffset() )
+            {
+                LdifPart[] parts = containers[i].getParts();
+                if ( parts.length > 0 )
+                {
+                    for ( int p = 0; p < parts.length; p++ )
+                    {
+                        if ( offset < parts[p].getOffset() + parts[p].getLength()
+                            && offset + length >= parts[p].getOffset() )
+                        {
+                            LdifPart part = parts[p];
+
+                            if ( part instanceof LdifModSpec )
+                            {
+                                LdifModSpec spec = ( LdifModSpec ) part;
+                                partList.addAll( Arrays.asList( getParts( new LdifContainer[]
+                                    { spec }, offset, length ) ) );
+                            }
+                            else
+                            {
+                                if ( part instanceof LdifInvalidPart && p > 0 )
+                                {
+                                    part = parts[p - 1];
+                                }
+
+                                partList.add( part );
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return ( LdifPart[] ) partList.toArray( new LdifPart[partList.size()] );
+    }
+
+
+    public static LdifPart getContainerContent( LdifContainer container, int offset )
+    {
+        if ( container == null || offset < container.getOffset()
+            || offset > container.getOffset() + container.getLength() )
+            return null;
+
+        LdifPart part = null;
+        LdifPart[] parts = container.getParts();
+        if ( parts.length > 0 )
+        {
+            int partIndex = -1;
+
+            for ( int i = 0; i < parts.length; i++ )
+            {
+                int start = parts[i].getOffset();
+                int end = parts[i].getOffset() + parts[i].getLength();
+                if ( start <= offset && offset < end )
+                {
+                    partIndex = i;
+                    break;
+                }
+            }
+
+            if ( partIndex > -1 )
+            {
+                part = parts[partIndex];
+                if ( part instanceof LdifModSpec )
+                {
+                    part = getContainerContent( ( LdifModSpec ) part, offset );
+                }
+                // if(part instanceof LdifInvalidPart && partIndex > 0) {
+                // partIndex--;
+                // part = parts[partIndex];
+                // }
+            }
+        }
+        return part;
+    }
+
+
+    // public static LdifPart getPart(LdifContainer container, int offset) {
+    // if(container == null || offset < 0)
+    // return null;
+    //		
+    // LdifPart part = null;
+    // LdifPart[] parts = container.getParts();
+    // if(parts.length > 0) {
+    // int partIndex = -1;
+    //			
+    // for (int i=0; i<parts.length; i++) {
+    // int start = parts[i].getOffset();
+    // int end = parts[i].getOffset()+parts[i].getLength();
+    // if(start <= offset && offset < end) {
+    // partIndex = i;
+    // break;
+    // }
+    // }
+    //			
+    // if(partIndex > -1) {
+    // part = parts[partIndex];
+    //
+    // if(part instanceof LdifUnknownPart && partIndex > 0) {
+    // partIndex--;
+    // part = parts[partIndex];
+    // }
+    //				
+    // if(part instanceof LdifContainer) {
+    // part = getPart((LdifContainer)part, offset);
+    // }
+    // }
+    // }
+    // return part;
+    // }
+
+    public void replace( LdifContainer[] oldContainers, LdifContainer[] newContainers )
+    {
+
+        // find index
+        int index = 0;
+        if ( oldContainers.length > 0 )
+        {
+            index = this.containerList.indexOf( oldContainers[0] );
+        }
+
+        // remove old containers
+        int removeLength = 0;
+        int removeOffset = 0;
+        if ( oldContainers.length > 0 )
+        {
+            removeOffset = oldContainers[0].getOffset();
+            for ( int i = 0; i < oldContainers.length; i++ )
+            {
+                this.containerList.remove( index );
+                removeLength += oldContainers[i].getLength();
+            }
+        }
+
+        // add new containers
+        int insertLength = 0;
+        for ( int i = 0; i < newContainers.length; i++ )
+        {
+            newContainers[i].adjustOffset( removeOffset );
+            insertLength += newContainers[i].getLength();
+            this.containerList.add( index + i, newContainers[i] );
+        }
+
+        // adjust offset of folling containers
+        int adjust = insertLength - removeLength;
+        for ( int i = index + newContainers.length; i < this.containerList.size(); i++ )
+        {
+            LdifContainer container = ( LdifContainer ) this.containerList.get( i );
+            container.adjustOffset( adjust );
+        }
+
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifInvalidPart.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifInvalidPart.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifInvalidPart.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifInvalidPart.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,96 @@
+/*
+ *  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.ldif;
+
+
+public final class LdifInvalidPart implements LdifPart
+{
+
+    private static final long serialVersionUID = 3107136058896890735L;
+
+    private int offset;
+
+    private String unknown;
+
+
+    protected LdifInvalidPart()
+    {
+    }
+
+
+    public LdifInvalidPart( int offset, String unknown )
+    {
+        this.offset = offset;
+        this.unknown = unknown;
+    }
+
+
+    public final int getOffset()
+    {
+        return this.offset;
+    }
+
+
+    public final int getLength()
+    {
+        return this.toRawString().length();
+    }
+
+
+    public final String toRawString()
+    {
+        return this.unknown;
+    }
+
+
+    public final String toFormattedString()
+    {
+        return this.unknown;
+    }
+
+
+    public final String toString()
+    {
+        String text = toRawString();
+        text = text.replaceAll( "\n", "\\\\n" );
+        text = text.replaceAll( "\r", "\\\\r" );
+        return getClass().getName() + " (" + getOffset() + "," + getLength() + "): '" + text + "'";
+    }
+
+
+    public final boolean isValid()
+    {
+        return false;
+    }
+
+
+    public String getInvalidString()
+    {
+        return "Unexpected Token";
+    }
+
+
+    public final void adjustOffset( int adjust )
+    {
+        this.offset += adjust;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifPart.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifPart.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifPart.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/LdifPart.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,50 @@
+/*
+ *  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.ldif;
+
+
+import java.io.Serializable;
+
+
+public interface LdifPart extends Serializable
+{
+
+    public int getOffset();
+
+
+    public int getLength();
+
+
+    public boolean isValid();
+
+
+    public String getInvalidString();
+
+
+    public String toRawString();
+
+
+    public String toFormattedString();
+
+
+    public void adjustOffset( int adjust );
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeAddRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeAddRecord.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeAddRecord.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeAddRecord.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,90 @@
+/*
+ *  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.ldif.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifAttrValLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifDnLine;
+
+
+public class LdifChangeAddRecord extends LdifChangeRecord
+{
+
+    private static final long serialVersionUID = -8976783000053951136L;
+
+
+    protected LdifChangeAddRecord()
+    {
+    }
+
+
+    public LdifChangeAddRecord( LdifDnLine dn )
+    {
+        super( dn );
+    }
+
+
+    public void addAttrVal( LdifAttrValLine attrVal )
+    {
+        if ( attrVal == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( attrVal );
+    }
+
+
+    public LdifAttrValLine[] getAttrVals()
+    {
+        List l = new ArrayList();
+        for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifAttrValLine )
+            {
+                l.add( o );
+            }
+        }
+        return ( LdifAttrValLine[] ) l.toArray( new LdifAttrValLine[l.size()] );
+    }
+
+
+    public static LdifChangeAddRecord create( String dn )
+    {
+        LdifChangeAddRecord record = new LdifChangeAddRecord( LdifDnLine.create( dn ) );
+        record.setChangeType( LdifChangeTypeLine.createAdd() );
+        return record;
+    }
+
+
+    public boolean isValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+        return getAttrVals().length > 0;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeDeleteRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeDeleteRecord.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeDeleteRecord.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeDeleteRecord.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,63 @@
+/*
+ *  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.ldif.container;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifDnLine;
+
+
+public class LdifChangeDeleteRecord extends LdifChangeRecord
+{
+
+    private static final long serialVersionUID = -1597258565782701577L;
+
+
+    protected LdifChangeDeleteRecord()
+    {
+    }
+
+
+    public LdifChangeDeleteRecord( LdifDnLine dn )
+    {
+        super( dn );
+    }
+
+
+    public static LdifChangeDeleteRecord create( String dn )
+    {
+        LdifChangeDeleteRecord record = new LdifChangeDeleteRecord( LdifDnLine.create( dn ) );
+        record.setChangeType( LdifChangeTypeLine.createDelete() );
+        return record;
+    }
+
+
+    public boolean isValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+
+        return this.getChangeTypeLine() != null && this.getSepLine() != null;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeModDnRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeModDnRecord.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeModDnRecord.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeModDnRecord.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,154 @@
+/*
+ *  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.ldif.container;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifDeloldrdnLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifDnLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifNewrdnLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifNewsuperiorLine;
+
+
+public class LdifChangeModDnRecord extends LdifChangeRecord
+{
+
+    private static final long serialVersionUID = 4439094400671169207L;
+
+
+    protected LdifChangeModDnRecord()
+    {
+    }
+
+
+    public LdifChangeModDnRecord( LdifDnLine dn )
+    {
+        super( dn );
+    }
+
+
+    public void setNewrdn( LdifNewrdnLine newrdn )
+    {
+        if ( newrdn == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( newrdn );
+    }
+
+
+    public void setDeloldrdn( LdifDeloldrdnLine deloldrdn )
+    {
+        if ( deloldrdn == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( deloldrdn );
+    }
+
+
+    public void setNewsuperior( LdifNewsuperiorLine newsuperior )
+    {
+        if ( newsuperior == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( newsuperior );
+    }
+
+
+    public LdifNewrdnLine getNewrdnLine()
+    {
+        for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifNewrdnLine )
+            {
+                return ( LdifNewrdnLine ) o;
+            }
+        }
+
+        return null;
+    }
+
+
+    public LdifDeloldrdnLine getDeloldrdnLine()
+    {
+        for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifDeloldrdnLine )
+            {
+                return ( LdifDeloldrdnLine ) o;
+            }
+        }
+
+        return null;
+    }
+
+
+    public LdifNewsuperiorLine getNewsuperiorLine()
+    {
+        for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifNewsuperiorLine )
+            {
+                return ( LdifNewsuperiorLine ) o;
+            }
+        }
+
+        return null;
+    }
+
+
+    public static LdifChangeModDnRecord create( String dn )
+    {
+        LdifChangeModDnRecord record = new LdifChangeModDnRecord( LdifDnLine.create( dn ) );
+        record.setChangeType( LdifChangeTypeLine.createModDn() );
+        return record;
+    }
+
+
+    public boolean isValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+
+        return this.getNewrdnLine() != null && this.getDeloldrdnLine() != null;
+    }
+
+
+    public String getInvalidString()
+    {
+        if ( this.getNewrdnLine() == null )
+        {
+            return "Missing new RDN";
+        }
+        else if ( this.getDeloldrdnLine() == null )
+        {
+            return "Missing delete old RDN";
+        }
+        else
+        {
+            return super.getInvalidString();
+        }
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeModifyRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeModifyRecord.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeModifyRecord.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeModifyRecord.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,90 @@
+/*
+ *  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.ldif.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifDnLine;
+
+
+public class LdifChangeModifyRecord extends LdifChangeRecord
+{
+
+    private static final long serialVersionUID = 6971543260694585796L;
+
+
+    protected LdifChangeModifyRecord()
+    {
+    }
+
+
+    public LdifChangeModifyRecord( LdifDnLine dn )
+    {
+        super( dn );
+    }
+
+
+    public void addModSpec( LdifModSpec modSpec )
+    {
+        if ( modSpec == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( modSpec );
+    }
+
+
+    public LdifModSpec[] getModSpecs()
+    {
+        List l = new ArrayList();
+        for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifModSpec )
+            {
+                l.add( o );
+            }
+        }
+        return ( LdifModSpec[] ) l.toArray( new LdifModSpec[l.size()] );
+    }
+
+
+    public static LdifChangeModifyRecord create( String dn )
+    {
+        LdifChangeModifyRecord record = new LdifChangeModifyRecord( LdifDnLine.create( dn ) );
+        record.setChangeType( LdifChangeTypeLine.createModify() );
+        return record;
+    }
+
+
+    public boolean isValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+
+        return this.getModSpecs().length > 0;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeRecord.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeRecord.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifChangeRecord.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,123 @@
+/*
+ *  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.ldif.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifControlLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifDnLine;
+
+
+public class LdifChangeRecord extends LdifRecord
+{
+
+    private static final long serialVersionUID = 2995003778589275697L;
+
+
+    protected LdifChangeRecord()
+    {
+    }
+
+
+    public LdifChangeRecord( LdifDnLine dn )
+    {
+        super( dn );
+    }
+
+
+    public void addControl( LdifControlLine controlLine )
+    {
+        if ( controlLine == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( controlLine );
+    }
+
+
+    public void setChangeType( LdifChangeTypeLine changeTypeLine )
+    {
+        if ( changeTypeLine == null )
+            throw new IllegalArgumentException( "null argument" );
+        if ( getChangeTypeLine() != null )
+            throw new IllegalArgumentException( "changetype is already set" );
+        this.parts.add( changeTypeLine );
+    }
+
+
+    public LdifControlLine[] getControls()
+    {
+        List l = new ArrayList();
+        for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifControlLine )
+            {
+                l.add( o );
+            }
+        }
+        return ( LdifControlLine[] ) l.toArray( new LdifControlLine[l.size()] );
+    }
+
+
+    public LdifChangeTypeLine getChangeTypeLine()
+    {
+        for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifChangeTypeLine )
+            {
+                return ( LdifChangeTypeLine ) o;
+            }
+        }
+
+        return null;
+    }
+
+
+    protected boolean isAbstractValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+        return getChangeTypeLine() != null;
+    }
+
+
+    public boolean isValid()
+    {
+        return this.isAbstractValid();
+    }
+
+
+    public String getInvalidString()
+    {
+
+        if ( getChangeTypeLine() == null )
+            return "Missing changetype line";
+
+        return super.getInvalidString();
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifCommentContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifCommentContainer.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifCommentContainer.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifCommentContainer.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,64 @@
+/*
+ *  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.ldif.container;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifCommentLine;
+
+
+public class LdifCommentContainer extends LdifContainer
+{
+
+    private static final long serialVersionUID = 5193234573866495240L;
+
+
+    protected LdifCommentContainer()
+    {
+    }
+
+
+    public LdifCommentContainer( LdifCommentLine comment )
+    {
+        super( comment );
+    }
+
+
+    public void addComment( LdifCommentLine comment )
+    {
+        if ( comment == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( comment );
+    }
+
+
+    public boolean isValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+
+        // return getLastPart() instanceof LdifCommentLine &&
+        // getLastPart().isValid();
+        return true;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifContainer.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifContainer.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifContainer.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,200 @@
+/*
+ *  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.ldif.container;
+
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.LdifInvalidPart;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.LdifPart;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifLineBase;
+
+
+public abstract class LdifContainer implements Serializable
+{
+
+    protected List parts;
+
+
+    protected LdifContainer()
+    {
+    }
+
+
+    protected LdifContainer( LdifPart part )
+    {
+        this.parts = new ArrayList( 1 );
+        if ( part == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( part );
+    }
+
+
+    public final int getOffset()
+    {
+        return ( ( LdifPart ) this.parts.get( 0 ) ).getOffset();
+    }
+
+
+    public final int getLength()
+    {
+        LdifPart lastPart = this.getLastPart();
+        return lastPart.getOffset() + lastPart.getLength() - getOffset();
+    }
+
+
+    public final void addInvalid( LdifInvalidPart invalid )
+    {
+        if ( invalid == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( invalid );
+    }
+
+
+    public final LdifPart getLastPart()
+    {
+        return ( LdifPart ) parts.get( parts.size() - 1 );
+    }
+
+
+    public final LdifPart[] getParts()
+    {
+        return ( LdifPart[] ) this.parts.toArray( new LdifPart[parts.size()] );
+    }
+
+
+    public final String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( getClass().getName() );
+        sb.append( ":" );
+        sb.append( BrowserCoreConstants.LINE_SEPARATOR );
+
+        LdifPart[] parts = this.getParts();
+        for ( int i = 0; i < parts.length; i++ )
+        {
+            sb.append( "    " );
+            sb.append( parts[i].toString() );
+            sb.append( BrowserCoreConstants.LINE_SEPARATOR );
+        }
+
+        return sb.toString();
+    }
+
+
+    public final String toRawString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        LdifPart[] parts = this.getParts();
+        for ( int i = 0; i < parts.length; i++ )
+        {
+            sb.append( parts[i].toRawString() );
+        }
+
+        return sb.toString();
+    }
+
+
+    public final String toFormattedString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        LdifPart[] parts = this.getParts();
+        for ( int i = 0; i < parts.length; i++ )
+        {
+            sb.append( parts[i].toFormattedString() );
+        }
+
+        return sb.toString();
+    }
+
+
+    public abstract boolean isValid();
+
+
+    /**
+     * true if
+     * <ul>
+     * <li>at least one line
+     * <li>no LdifUnknownPart
+     * <li>all parts are valid
+     * </ul>
+     */
+    protected boolean isAbstractValid()
+    {
+        if ( this.parts.isEmpty() )
+            return false;
+
+        boolean containsLine = false;
+        LdifPart[] parts = this.getParts();
+        for ( int i = 0; i < parts.length; i++ )
+        {
+            if ( parts[i] instanceof LdifInvalidPart )
+            {
+                return false;
+            }
+            if ( !parts[i].isValid() )
+            {
+                return false;
+            }
+            if ( parts[i] instanceof LdifLineBase )
+            {
+                containsLine = true;
+            }
+        }
+        return containsLine;
+    }
+
+
+    public String getInvalidString()
+    {
+        if ( this.parts.isEmpty() )
+            return "Empty Container";
+
+        LdifPart[] parts = this.getParts();
+        for ( int i = 0; i < parts.length; i++ )
+        {
+            if ( !parts[i].isValid() )
+            {
+                return parts[i].getInvalidString();
+            }
+        }
+
+        return null;
+    }
+
+
+    public final void adjustOffset( int adjust )
+    {
+        for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+        {
+            LdifPart part = ( LdifPart ) it.next();
+            part.adjustOffset( adjust );
+        }
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifContentRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifContentRecord.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifContentRecord.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ldif/container/LdifContentRecord.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,97 @@
+/*
+ *  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.ldif.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifAttrValLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifDnLine;
+
+
+public class LdifContentRecord extends LdifRecord
+{
+
+    private static final long serialVersionUID = -1410857864284794069L;
+
+
+    protected LdifContentRecord()
+    {
+    }
+
+
+    public LdifContentRecord( LdifDnLine dn )
+    {
+        super( dn );
+    }
+
+
+    public void addAttrVal( LdifAttrValLine attrVal )
+    {
+        if ( attrVal == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( attrVal );
+    }
+
+
+    public LdifAttrValLine[] getAttrVals()
+    {
+        List l = new ArrayList();
+        for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifAttrValLine )
+            {
+                l.add( o );
+            }
+        }
+        return ( LdifAttrValLine[] ) l.toArray( new LdifAttrValLine[l.size()] );
+    }
+
+
+    public static LdifContentRecord create( String dn )
+    {
+        return new LdifContentRecord( LdifDnLine.create( dn ) );
+    }
+
+
+    public boolean isValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+        return getAttrVals().length > 0;
+
+    }
+
+
+    public String getInvalidString()
+    {
+        if ( !( getAttrVals().length > 0 ) )
+            return "Record must contain attribute value lines";
+        else
+            return super.getInvalidString();
+    }
+
+}

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