directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r488355 [2/10] - in /directory/sandbox/pamarcelot/ldapstudio: ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/ ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/filter/ ldapstudio-browse...
Date Mon, 18 Dec 2006 17:32:09 GMT
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifFile.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifFile.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifFile.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifFile.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.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.ldapstudio.browser.core.model.ldif.container.LdifChangeRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContentRecord;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifModSpec;
+import org.apache.directory.ldapstudio.browser.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 );
+        }
+
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifInvalidPart.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifInvalidPart.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifInvalidPart.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifInvalidPart.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.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;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifPart.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifPart.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifPart.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/LdifPart.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.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 );
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeAddRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeAddRecord.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeAddRecord.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeAddRecord.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifAttrValLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.ldapstudio.browser.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;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeDeleteRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeDeleteRecord.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeDeleteRecord.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeDeleteRecord.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.container;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.ldapstudio.browser.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;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeModDnRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeModDnRecord.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeModDnRecord.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeModDnRecord.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.container;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifDeloldrdnLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifDnLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifNewrdnLine;
+import org.apache.directory.ldapstudio.browser.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();
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeModifyRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeModifyRecord.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeModifyRecord.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeModifyRecord.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.ldapstudio.browser.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;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeRecord.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeRecord.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifChangeRecord.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifChangeTypeLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifControlLine;
+import org.apache.directory.ldapstudio.browser.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();
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifCommentContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifCommentContainer.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifCommentContainer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifCommentContainer.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.container;
+
+
+import org.apache.directory.ldapstudio.browser.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;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifContainer.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifContainer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifContainer.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.container;
+
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifInvalidPart;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifPart;
+import org.apache.directory.ldapstudio.browser.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 );
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifContentRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifContentRecord.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifContentRecord.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifContentRecord.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifAttrValLine;
+import org.apache.directory.ldapstudio.browser.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();
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifEOFContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifEOFContainer.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifEOFContainer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifEOFContainer.java Mon Dec 18 09:32:03 2006
@@ -0,0 +1,49 @@
+/*
+ *  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.ldapstudio.browser.core.model.ldif.container;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifEOFPart;
+
+
+public class LdifEOFContainer extends LdifContainer
+{
+
+    private static final long serialVersionUID = -570235244832982061L;
+
+
+    protected LdifEOFContainer()
+    {
+    }
+
+
+    public LdifEOFContainer( LdifEOFPart eofPart )
+    {
+        super( eofPart );
+    }
+
+
+    public boolean isValid()
+    {
+        return getLastPart() instanceof LdifEOFPart;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifInvalidContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifInvalidContainer.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifInvalidContainer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifInvalidContainer.java Mon Dec 18 09:32:03 2006
@@ -0,0 +1,49 @@
+/*
+ *  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.ldapstudio.browser.core.model.ldif.container;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifInvalidPart;
+
+
+public class LdifInvalidContainer extends LdifContainer
+{
+
+    private static final long serialVersionUID = -6967822536130425931L;
+
+
+    protected LdifInvalidContainer()
+    {
+    }
+
+
+    public LdifInvalidContainer( LdifInvalidPart invalid )
+    {
+        super( invalid );
+    }
+
+
+    public boolean isValid()
+    {
+        return false;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifModSpec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifModSpec.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifModSpec.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifModSpec.java Mon Dec 18 09:32:03 2006
@@ -0,0 +1,208 @@
+/*
+ *  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.ldapstudio.browser.core.model.ldif.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifPart;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifAttrValLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifModSpecSepLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifModSpecTypeLine;
+
+
+public class LdifModSpec extends LdifContainer implements LdifPart
+{
+
+    private static final long serialVersionUID = 6708749639253050273L;
+
+
+    protected LdifModSpec()
+    {
+    }
+
+
+    public LdifModSpec( LdifModSpecTypeLine modSpecTypeLine )
+    {
+        super( modSpecTypeLine );
+    }
+
+
+    public void addAttrVal( LdifAttrValLine attrVal )
+    {
+        if ( attrVal == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( attrVal );
+    }
+
+
+    public void finish( LdifModSpecSepLine modSpecSepLine )
+    {
+        if ( modSpecSepLine == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( modSpecSepLine );
+    }
+
+
+    public LdifModSpecTypeLine getModSpecType()
+    {
+        return ( LdifModSpecTypeLine ) this.parts.get( 0 );
+    }
+
+
+    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 LdifModSpecSepLine getModSpecSep()
+    {
+        if ( getLastPart() instanceof LdifModSpecSepLine )
+        {
+            return ( LdifModSpecSepLine ) getLastPart();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    public boolean isAdd()
+    {
+        return this.getModSpecType().isAdd();
+    }
+
+
+    public boolean isReplace()
+    {
+        return this.getModSpecType().isReplace();
+    }
+
+
+    public boolean isDelete()
+    {
+        return this.getModSpecType().isDelete();
+    }
+
+
+    public static LdifModSpec createAdd( String attributeName )
+    {
+        return new LdifModSpec( LdifModSpecTypeLine.createAdd( attributeName ) );
+    }
+
+
+    public static LdifModSpec createReplace( String attributeName )
+    {
+        return new LdifModSpec( LdifModSpecTypeLine.createReplace( attributeName ) );
+    }
+
+
+    public static LdifModSpec createDelete( String attributeName )
+    {
+        return new LdifModSpec( LdifModSpecTypeLine.createDelete( attributeName ) );
+    }
+
+
+    public boolean isValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+
+        if ( this.getModSpecType() == null )
+        {
+            return false;
+        }
+
+        LdifAttrValLine[] attrVals = this.getAttrVals();
+        if ( attrVals.length > 0 )
+        {
+            String att = this.getModSpecType().getUnfoldedAttributeDescription();
+            for ( int i = 0; i < attrVals.length; i++ )
+            {
+                if ( !att.equals( attrVals[i].getUnfoldedAttributeDescription() ) )
+                {
+                    return false;
+                }
+            }
+        }
+
+        if ( isAdd() )
+        {
+            return attrVals.length > 0;
+        }
+        else if ( isDelete() )
+        {
+            return true;
+        }
+        else if ( isReplace() )
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    public String getInvalidString()
+    {
+        if ( this.getModSpecType() == null )
+        {
+            return "Missing mod spec line ";
+        }
+        else if ( isAdd() && this.getAttrVals().length == 0 )
+        {
+            return "Modification must contain attribute value lines ";
+        }
+
+        LdifAttrValLine[] attrVals = this.getAttrVals();
+        if ( attrVals.length > 0 )
+        {
+            String att = this.getModSpecType().getUnfoldedAttributeDescription();
+            for ( int i = 0; i < attrVals.length; i++ )
+            {
+                if ( !att.equals( attrVals[i].getUnfoldedAttributeDescription() ) )
+                {
+                    return "Attribute descriptions don't match";
+                }
+            }
+        }
+
+        return null;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifRecord.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifRecord.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifRecord.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.container;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifEOFPart;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifPart;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifCommentLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifDnLine;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifSepLine;
+
+
+public abstract class LdifRecord extends LdifContainer
+{
+
+    protected LdifRecord()
+    {
+    }
+
+
+    protected LdifRecord( LdifDnLine dn )
+    {
+        super( dn );
+    }
+
+
+    public void addComment( LdifCommentLine comment )
+    {
+        if ( comment == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( comment );
+    }
+
+
+    public void finish( LdifSepLine sep )
+    {
+        if ( sep == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( sep );
+    }
+
+
+    public void finish( LdifEOFPart eof )
+    {
+        if ( eof == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( eof );
+    }
+
+
+    public LdifDnLine getDnLine()
+    {
+        return ( LdifDnLine ) this.parts.get( 0 );
+    }
+
+
+    public LdifSepLine getSepLine()
+    {
+        for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+        {
+            Object o = it.next();
+            if ( o instanceof LdifSepLine )
+            {
+                return ( LdifSepLine ) o;
+            }
+        }
+
+        return null;
+    }
+
+
+    public String getInvalidString()
+    {
+        LdifDnLine dnLine = getDnLine();
+        LdifSepLine sepLine = getSepLine();
+
+        if ( dnLine == null )
+            return "Record must start with DN";
+        else if ( !dnLine.isValid() )
+            return dnLine.getInvalidString();
+
+        if ( sepLine == null )
+            return "Record must end with an empty line";
+        else if ( !sepLine.isValid() )
+            return sepLine.getInvalidString();
+
+        return super.getInvalidString();
+    }
+
+
+    protected boolean isAbstractValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+
+        LdifPart lastPart = getLastPart();
+        return this.getDnLine().isValid() && ( lastPart instanceof LdifSepLine || lastPart instanceof LdifEOFPart )
+            && lastPart.isValid();
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifSepContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifSepContainer.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifSepContainer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifSepContainer.java Mon Dec 18 09:32:03 2006
@@ -0,0 +1,62 @@
+/*
+ *  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.ldapstudio.browser.core.model.ldif.container;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifSepLine;
+
+
+public class LdifSepContainer extends LdifContainer
+{
+
+    private static final long serialVersionUID = 479360761136440710L;
+
+
+    protected LdifSepContainer()
+    {
+    }
+
+
+    public LdifSepContainer( LdifSepLine sep )
+    {
+        super( sep );
+    }
+
+
+    public void addSep( LdifSepLine sep )
+    {
+        if ( sep == null )
+            throw new IllegalArgumentException( "null argument" );
+        this.parts.add( sep );
+    }
+
+
+    public boolean isValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifVersionContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifVersionContainer.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifVersionContainer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/container/LdifVersionContainer.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.container;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifVersionLine;
+
+
+public class LdifVersionContainer extends LdifContainer
+{
+
+    private static final long serialVersionUID = -6373331266642629348L;
+
+
+    protected LdifVersionContainer()
+    {
+    }
+
+
+    public LdifVersionContainer( LdifVersionLine versionLine )
+    {
+        super( versionLine );
+    }
+
+
+    public boolean isValid()
+    {
+        if ( !super.isAbstractValid() )
+        {
+            return false;
+        }
+
+        return getLastPart() instanceof LdifVersionLine;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifAttrValLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifAttrValLine.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifAttrValLine.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifAttrValLine.java Mon Dec 18 09:32:03 2006
@@ -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.ldapstudio.browser.core.model.ldif.lines;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
+
+
+public class LdifAttrValLine extends LdifValueLineBase implements Serializable
+{
+
+    private static final long serialVersionUID = 2818131653565822685L;
+
+
+    protected LdifAttrValLine()
+    {
+    }
+
+
+    public LdifAttrValLine( int offset, String attributeDescripton, String valueType, String value, String newLine )
+    {
+        super( offset, attributeDescripton, valueType, value, newLine );
+    }
+
+
+    public String getRawAttributeDescription()
+    {
+        return super.getRawLineStart();
+    }
+
+
+    public String getUnfoldedAttributeDescription()
+    {
+        return super.getUnfoldedLineStart();
+    }
+
+
+    public boolean isValid()
+    {
+        return super.isValid();
+    }
+
+
+    public String getInvalidString()
+    {
+        if ( this.getUnfoldedAttributeDescription().length() == 0 )
+        {
+            return "Missing attribute name";
+        }
+        else
+        {
+            return super.getInvalidString();
+        }
+    }
+
+
+    public static LdifAttrValLine create( String name, String value )
+    {
+        if ( LdifUtils.mustEncode( value ) )
+        {
+            return create( name, LdifUtils.utf8encode( value ) );
+        }
+        else
+        {
+            return new LdifAttrValLine( 0, name, ":", value, BrowserCoreConstants.LINE_SEPARATOR );
+        }
+    }
+
+
+    public static LdifAttrValLine create( String name, byte[] value )
+    {
+        return new LdifAttrValLine( 0, name, "::", LdifUtils.base64encode( value ), BrowserCoreConstants.LINE_SEPARATOR );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifChangeTypeLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifChangeTypeLine.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifChangeTypeLine.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifChangeTypeLine.java Mon Dec 18 09:32:03 2006
@@ -0,0 +1,151 @@
+/*
+ *  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.ldapstudio.browser.core.model.ldif.lines;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+
+
+public class LdifChangeTypeLine extends LdifValueLineBase
+{
+
+    private static final long serialVersionUID = 8613980677301250589L;
+
+
+    protected LdifChangeTypeLine()
+    {
+    }
+
+
+    public LdifChangeTypeLine( int offset, String rawChangeTypeSpec, String rawValueType, String rawChangeType,
+        String rawNewLine )
+    {
+        super( offset, rawChangeTypeSpec, rawValueType, rawChangeType, rawNewLine );
+    }
+
+
+    public String getRawChangeTypeSpec()
+    {
+        return super.getRawLineStart();
+    }
+
+
+    public String getUnfoldedChangeTypeSpec()
+    {
+        return super.getUnfoldedLineStart();
+    }
+
+
+    public String getRawChangeType()
+    {
+        return super.getRawValue();
+    }
+
+
+    public String getUnfoldedChangeType()
+    {
+        return super.getUnfoldedValue();
+    }
+
+
+    public String toRawString()
+    {
+        return super.toRawString();
+    }
+
+
+    public boolean isAdd()
+    {
+        return this.getUnfoldedChangeType().equals( "add" );
+    }
+
+
+    public boolean isDelete()
+    {
+        return this.getUnfoldedChangeType().equals( "delete" );
+    }
+
+
+    public boolean isModify()
+    {
+        return this.getUnfoldedChangeType().equals( "modify" );
+    }
+
+
+    public boolean isModDn()
+    {
+        return this.getUnfoldedChangeType().equals( "moddn" ) || this.getUnfoldedChangeType().equals( "modrdn" );
+    }
+
+
+    public boolean isValid()
+    {
+        return super.isValid();
+    }
+
+
+    public String getInvalidString()
+    {
+        if ( this.getUnfoldedChangeTypeSpec().length() == 0 )
+        {
+            return "Missing spec 'changetype'";
+        }
+        else if ( this.getUnfoldedChangeType().length() == 0 )
+        {
+            return "Missing changetype";
+        }
+        else
+        {
+            return super.getInvalidString();
+        }
+    }
+
+
+    public static LdifChangeTypeLine createDelete()
+    {
+        return new LdifChangeTypeLine( 0, "changetype", ":", "delete", BrowserCoreConstants.LINE_SEPARATOR );
+    }
+
+
+    public static LdifChangeTypeLine createAdd()
+    {
+        return new LdifChangeTypeLine( 0, "changetype", ":", "add", BrowserCoreConstants.LINE_SEPARATOR );
+    }
+
+
+    public static LdifChangeTypeLine createModify()
+    {
+        return new LdifChangeTypeLine( 0, "changetype", ":", "modify", BrowserCoreConstants.LINE_SEPARATOR );
+    }
+
+
+    public static LdifChangeTypeLine createModDn()
+    {
+        return new LdifChangeTypeLine( 0, "changetype", ":", "moddn", BrowserCoreConstants.LINE_SEPARATOR );
+    }
+
+
+    public static LdifChangeTypeLine createModRdn()
+    {
+        return new LdifChangeTypeLine( 0, "changetype", ":", "modrdn", BrowserCoreConstants.LINE_SEPARATOR );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifCommentLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifCommentLine.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifCommentLine.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifCommentLine.java Mon Dec 18 09:32:03 2006
@@ -0,0 +1,79 @@
+/*
+ *  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.ldapstudio.browser.core.model.ldif.lines;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+
+
+public class LdifCommentLine extends LdifNonEmptyLineBase
+{
+
+    private static final long serialVersionUID = -4810053047583328865L;
+
+
+    protected LdifCommentLine()
+    {
+    }
+
+
+    public LdifCommentLine( int offset, String rawComment, String rawNewLine )
+    {
+        super( offset, rawComment, rawNewLine );
+    }
+
+
+    public String getRawComment()
+    {
+        return super.getRawLineStart();
+    }
+
+
+    public String getUnfoldedComment()
+    {
+        return super.getUnfoldedLineStart();
+    }
+
+
+    public String toRawString()
+    {
+        return super.toRawString();
+    }
+
+
+    public boolean isValid()
+    {
+        return super.isValid();
+    }
+
+
+    public String getInvalidString()
+    {
+        return super.getInvalidString();
+    }
+
+
+    public static LdifCommentLine create( String comment )
+    {
+        return new LdifCommentLine( 0, comment, BrowserCoreConstants.LINE_SEPARATOR );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifControlLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifControlLine.java?view=auto&rev=488355
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifControlLine.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ldif/lines/LdifControlLine.java Mon Dec 18 09:32:03 2006
@@ -0,0 +1,249 @@
+/*
+ *  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.ldapstudio.browser.core.model.ldif.lines;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
+
+
+public class LdifControlLine extends LdifValueLineBase
+{
+
+    private static final long serialVersionUID = -3961159214439218610L;
+
+    private String rawCriticality;
+
+    private String rawControlValueType;
+
+    private String rawControlValue;
+
+
+    protected LdifControlLine()
+    {
+    }
+
+
+    public LdifControlLine( int offset, String rawControlSpec, String rawControlType, String rawOid,
+        String rawCriticality, String rawControlValueType, String rawControlValue, String rawNewLine )
+    {
+        super( offset, rawControlSpec, rawControlType, rawOid, rawNewLine );
+        this.rawCriticality = rawCriticality;
+        this.rawControlValueType = rawControlValueType;
+        this.rawControlValue = rawControlValue;
+    }
+
+
+    public String getRawControlSpec()
+    {
+        return super.getRawLineStart();
+    }
+
+
+    public String getUnfoldedControlSpec()
+    {
+        return super.getUnfoldedLineStart();
+    }
+
+
+    public String getRawControlType()
+    {
+        return super.getRawValueType();
+    }
+
+
+    public String getUnfoldedControlType()
+    {
+        return super.getUnfoldedValueType();
+    }
+
+
+    public String getRawOid()
+    {
+        return super.getRawValue();
+    }
+
+
+    public String getUnfoldedOid()
+    {
+        return super.getUnfoldedValue();
+    }
+
+
+    public String getRawCriticality()
+    {
+        return getNonNull( this.rawCriticality );
+    }
+
+
+    public String getUnfoldedCriticality()
+    {
+        return unfold( this.getRawCriticality() );
+    }
+
+
+    public boolean isCritical()
+    {
+        return this.getUnfoldedCriticality().endsWith( "true" );
+    }
+
+
+    public String getRawControlValueType()
+    {
+        return getNonNull( this.rawControlValueType );
+    }
+
+
+    public String getUnfoldedControlValueType()
+    {
+        return unfold( this.getRawControlValueType() );
+    }
+
+
+    public String getRawControlValue()
+    {
+        return getNonNull( this.rawControlValue );
+    }
+
+
+    public String getUnfoldedControlValue()
+    {
+        return unfold( this.getRawControlValue() );
+    }
+
+
+    public String toRawString()
+    {
+        return this.getRawControlSpec() + this.getRawControlType() + this.getRawOid() + this.getRawCriticality()
+            + this.getRawControlValueType() + this.getRawControlValue() + this.getRawNewLine();
+    }
+
+
+    public boolean isValid()
+    {
+        return this.getUnfoldedControlSpec().length() > 0
+            && this.getUnfoldedControlType().length() > 0
+            && this.getUnfoldedOid().length() > 0
+            && ( this.rawCriticality == null || this.getUnfoldedCriticality().endsWith( "true" ) || this
+                .getUnfoldedCriticality().endsWith( "false" ) )
+            && ( ( this.rawControlValueType == null && this.rawControlValue == null ) || ( this.rawControlValueType != null && this.rawControlValue != null ) )
+            && this.getUnfoldedNewLine().length() > 0;
+    }
+
+
+    public String getInvalidString()
+    {
+        if ( this.getUnfoldedControlSpec().length() == 0 )
+        {
+            return "Missing 'control'";
+        }
+        else if ( this.getUnfoldedOid().length() == 0 )
+        {
+            return "Missing OID";
+        }
+        else if ( ( this.rawCriticality != null && !this.getUnfoldedCriticality().endsWith( "true" ) && !this
+            .getUnfoldedCriticality().endsWith( "false" ) ) )
+        {
+            return "Invalid criticality, must be 'true' or 'false'";
+        }
+        else
+        {
+            return super.getInvalidString();
+        }
+    }
+
+
+    /**
+     * 
+     * @return the binary representation of the control value, may be null
+     */
+    public final byte[] getControlValueAsBinary()
+    {
+        Object o = getControlValueAsObject();
+        if ( o instanceof String )
+        {
+            return LdifUtils.utf8encode( ( String ) o );
+        }
+        else if ( o instanceof byte[] )
+        {
+            return ( byte[] ) o;
+        }
+        else
+        {
+            return new byte[0];
+        }
+    }
+
+
+    public final Object getControlValueAsObject()
+    {
+        if ( this.isControlValueTypeSafe() )
+        {
+            return this.getUnfoldedControlValue();
+        }
+        else if ( this.isControlValueTypeBase64() )
+        {
+            return LdifUtils.base64decodeToByteArray( this.getUnfoldedControlValue() );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    public boolean isControlValueTypeBase64()
+    {
+        return this.getUnfoldedControlValueType().startsWith( "::" );
+    }
+
+
+    public boolean isControlValueTypeSafe()
+    {
+        return this.getUnfoldedControlValueType().startsWith( ":" ) && !this.isControlValueTypeBase64();
+    }
+
+
+    public static LdifControlLine create( String oid, String criticality, String controlValue )
+    {
+        if ( LdifUtils.mustEncode( controlValue ) )
+        {
+            return create( oid, criticality, LdifUtils.utf8encode( controlValue ) );
+        }
+        else
+        {
+            LdifControlLine controlLine = new LdifControlLine( 0, "control", ":", oid, criticality,
+                controlValue != null ? ":" : null, controlValue != null ? controlValue : null,
+                BrowserCoreConstants.LINE_SEPARATOR );
+            return controlLine;
+        }
+    }
+
+
+    public static LdifControlLine create( String oid, String criticality, byte[] controlValue )
+    {
+        LdifControlLine controlLine = new LdifControlLine( 0, "control", ":", oid, criticality, controlValue != null
+            && controlValue.length > 0 ? "::" : null, controlValue != null && controlValue.length > 0 ? LdifUtils
+            .base64encode( controlValue ) : null, BrowserCoreConstants.LINE_SEPARATOR );
+        return controlLine;
+    }
+
+}



Mime
View raw message