directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r597198 [1/3] - in /directory/sandbox/felixk: ./ studio-ldif-parser/ studio-ldif-parser/META-INF/ studio-ldif-parser/src/ studio-ldif-parser/src/main/ studio-ldif-parser/src/main/java/ studio-ldif-parser/src/main/java/org/ studio-ldif-parse...
Date Wed, 21 Nov 2007 20:08:33 GMT
Author: felixk
Date: Wed Nov 21 12:08:28 2007
New Revision: 597198

URL: http://svn.apache.org/viewvc?rev=597198&view=rev
Log:
Completely missed the ldif-parser up to now

Added:
    directory/sandbox/felixk/studio-ldif-parser/   (with props)
    directory/sandbox/felixk/studio-ldif-parser/META-INF/
    directory/sandbox/felixk/studio-ldif-parser/META-INF/MANIFEST.MF   (with props)
    directory/sandbox/felixk/studio-ldif-parser/pom.xml   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/
    directory/sandbox/felixk/studio-ldif-parser/src/main/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifFormatParameters.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifParserConstants.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifUtils.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEOFPart.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEnumeration.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifFile.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifInvalidPart.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifPart.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeAddRecord.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeDeleteRecord.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModDnRecord.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeRecord.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifCommentContainer.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContainer.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContentRecord.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifEOFContainer.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifInvalidContainer.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifModSpec.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifRecord.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifSepContainer.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifVersionContainer.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifAttrValLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifChangeTypeLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifCommentLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDeloldrdnLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDnLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifLineBase.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecSepLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecTypeLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewrdnLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewsuperiorLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNonEmptyLineBase.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifSepLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifValueLineBase.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifVersionLine.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/DummyLdifContainer.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifParser.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifScanner.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/LdifToken.java   (with props)
    directory/sandbox/felixk/studio-ldif-parser/src/test/
    directory/sandbox/felixk/studio-ldif-parser/src/test/java/
Modified:
    directory/sandbox/felixk/pom.xml

Modified: directory/sandbox/felixk/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/pom.xml?rev=597198&r1=597197&r2=597198&view=diff
==============================================================================
--- directory/sandbox/felixk/pom.xml (original)
+++ directory/sandbox/felixk/pom.xml Wed Nov 21 12:08:28 2007
@@ -96,6 +96,7 @@
         <ldifeditor.help.version>1.0.1</ldifeditor.help.version>
         <ldifeditor.feature.version>1.0.1</ldifeditor.feature.version>
         <ldifeditor.version>1.0.1</ldifeditor.version>
+        <ldifparser.version>1.0.1</ldifparser.version>
         <ldapbrowser.ui.version>1.0.1</ldapbrowser.ui.version>
         <ldapbrowser.help.version>1.0.1</ldapbrowser.help.version>
         <ldapbrowser.feature.version>1.0.1</ldapbrowser.feature.version>
@@ -779,6 +780,7 @@
         <module>studio-rcp</module>
         <module>studio-rcp-feature</module>
         <module>studio-rcp-help</module>
+        <module>studio-ldif-parser</module>
         <module>studio-ldifeditor</module>
         <module>studio-ldifeditor-feature</module>
         <module>studio-ldifeditor-help</module>

Propchange: directory/sandbox/felixk/studio-ldif-parser/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Nov 21 12:08:28 2007
@@ -0,0 +1,4 @@
+.classpath
+.project
+target
+.settings

Added: directory/sandbox/felixk/studio-ldif-parser/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/META-INF/MANIFEST.MF?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/META-INF/MANIFEST.MF (added)
+++ directory/sandbox/felixk/studio-ldif-parser/META-INF/MANIFEST.MF Wed Nov 21 12:08:28 2007
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Apache Directory Studio LDIF Parser
+Bundle-SymbolicName: org.apache.directory.studio.ldifparser;singleton:=true
+Bundle-Version: 1.0.1
+Bundle-Localization: plugin
+Bundle-Vendor: The Apache Software Foundation
+Export-Package: 
+ org.apache.directory.studio.ldifparser,
+ org.apache.directory.studio.ldifparser.model,
+ org.apache.directory.studio.ldifparser.model.container,
+ org.apache.directory.studio.ldifparser.model.lines,
+ org.apache.directory.studio.ldifparser.parser
+Bundle-ClassPath: .,
+ commons-codec-1.3.jar

Propchange: directory/sandbox/felixk/studio-ldif-parser/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/pom.xml?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/pom.xml (added)
+++ directory/sandbox/felixk/studio-ldif-parser/pom.xml Wed Nov 21 12:08:28 2007
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.
+-->
+<!--
+    @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+    @version $Id: pom.xml 353 2007-10-28 14:59:35Z felix $
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.directory.studio</groupId>
+        <artifactId>parent</artifactId>
+        <version>1.0.2-SNAPSHOT</version>
+    </parent>
+    <artifactId>${groupId}.ldifparser</artifactId>
+    <version>${ldifparser.version}</version>
+    <name>Apache Directory Studio LDIF Parser</name>
+    <packaging>jar</packaging>
+
+    <description></description>
+
+    <!-- Set path for local repository -->
+    <properties>
+        <local-repo>${project.basedir}/../local-repository</local-repo>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-eclipse-plugin</artifactId>
+                <configuration>
+                    <pde>true</pde>
+                    <buildcommands>
+                        <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+                        <buildcommand>org.eclipse.pde.ManifestBuilder</buildcommand>
+                        <buildcommand>org.eclipse.pde.SchemaBuilder</buildcommand>
+                    </buildcommands>
+                    <projectnatures>
+                        <projectnature>org.eclipse.pde.PluginNature</projectnature>
+                        <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+                    </projectnatures>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifestFile>META-INF/MANIFEST.MF</manifestFile>
+                        <addMavenDescriptor>false</addMavenDescriptor>
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+        </dependency>
+    </dependencies>
+</project>

Propchange: directory/sandbox/felixk/studio-ldif-parser/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifFormatParameters.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifFormatParameters.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifFormatParameters.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifFormatParameters.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,95 @@
+/*
+ *  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.ldifparser;
+
+
+
+
+public class LdifFormatParameters
+{
+
+    /** The default LDIF format parameters */
+    public static final LdifFormatParameters DEFAULT = new LdifFormatParameters();
+
+    private boolean spaceAfterColon;
+    private int lineWidth;
+    private String lineSeparator;
+
+
+    /**
+     * Creates a new instance of LdifFormatParameters with the following parameters:
+     * <ul>
+     * <li>Space after colon
+     * <li>Line width 78
+     * <li>The system specific line separator
+     * </ul>
+     */
+    private LdifFormatParameters()
+    {
+        this.spaceAfterColon = true;
+        this.lineWidth = LdifParserConstants.LINE_WIDTH;
+        this.lineSeparator = LdifParserConstants.LINE_SEPARATOR;
+    }
+
+
+    public LdifFormatParameters( boolean spaceAfterColon, int lineWidth, String lineSeparator )
+    {
+        this.spaceAfterColon = spaceAfterColon;
+        this.lineWidth = lineWidth;
+        this.lineSeparator = lineSeparator;
+    }
+
+
+    public boolean isSpaceAfterColon()
+    {
+        return spaceAfterColon;
+    }
+
+
+    public void setSpaceAfterColon( boolean spaceAfterColon )
+    {
+        this.spaceAfterColon = spaceAfterColon;
+    }
+
+
+    public int getLineWidth()
+    {
+        return lineWidth;
+    }
+
+
+    public void setLineWidth( int lineWidth )
+    {
+        this.lineWidth = lineWidth;
+    }
+
+
+    public String getLineSeparator()
+    {
+        return lineSeparator;
+    }
+
+
+    public void setLineSeparator( String lineSeparator )
+    {
+        this.lineSeparator = lineSeparator;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifFormatParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifParserConstants.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifParserConstants.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifParserConstants.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifParserConstants.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,40 @@
+/*
+ *  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.ldifparser;
+
+
+/**
+ * Constants for the LDIF Parser.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface LdifParserConstants
+{
+
+    /** The system specific line separator. */
+    public static final String LINE_SEPARATOR = System.getProperty( "line.separator" ); //$NON-NLS-1$
+    
+    /** The default line width, value is 78. */
+    public static final int LINE_WIDTH = 78;
+
+    
+}

Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifParserConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifUtils.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifUtils.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifUtils.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,207 @@
+/*
+ *  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.ldifparser;
+
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.Hex;
+
+
+/**
+ * Utilities for LDAP related encoding and decoding.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdifUtils
+{
+
+
+    /**
+     * Encodes the given string to UTF-8
+     *
+     * @param s the string to encode
+     *
+     * @return the byte[] the encoded value
+     */
+    public static byte[] utf8encode( String s )
+    {
+        try
+        {
+            return s.getBytes( "UTF-8" );
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            return s.getBytes();
+        }
+    }
+
+
+    /**
+     * Encodes the given string into URL format.
+     *
+     * @param s the string to encode
+     *
+     * @return the string the URL encoded string
+     */
+    public static String urlEncode( String s )
+    {
+        try
+        {
+            return URLEncoder.encode( s, "UTF-8" );
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            return s;
+        }
+    }
+
+
+    /**
+     * Encodes the given byte array using BASE-64 encoding.
+     *
+     * @param b the b the byte array to encode
+     *
+     * @return the BASE-64 encoded string
+     */
+    public static String base64encode( byte[] b )
+    {
+        return utf8decode( Base64.encodeBase64( b ) );
+    }
+
+
+    /**
+     * Encodes the given byte array to a sequence of
+     * its hex values.
+     *
+     * @param data the data to encode
+     * @return the HEX encoded string
+     */
+    public static String hexEncode( byte[] data )
+    {
+        if ( data == null )
+            return null;
+
+        char[] c = Hex.encodeHex( data );
+        String s = new String( c );
+        return s;
+
+        // StringBuffer sb = new StringBuffer(data.length*3);
+        // for(int i=0; i<data.length; i++) {
+        // int b = (int)data[i];
+        // if(b<0) b=256+b;
+        // String s = Integer.toHexString(b)/*.toUpperCase()*/;
+        // if(s.length() ==1) s = "0" + s; //$NON-NLS-1$
+        // sb.append(s);
+        // if(i+1 < data.length)
+        // sb.append(' ');
+        // }
+        // return(sb.toString());
+    }
+
+
+    /**
+     * Decodes the given UTF-8 byte array to an string.
+     *
+     * @param b the b the byte array to decode
+     *
+     * @return the decoded string
+     */
+    public static String utf8decode( byte[] b )
+    {
+        try
+        {
+            return new String( b, "UTF-8" );
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            return new String( b );
+        }
+    }
+
+
+    /**
+     * Decodes the given BASE-64 encoded string to its
+     * bytes presentation.
+     *
+     * @param s the s the BASE-64 encoded string
+     *
+     * @return the byte[] the decoded byte array
+     */
+    public static byte[] base64decodeToByteArray( String s )
+    {
+        return Base64.decodeBase64( utf8encode( s ) );
+    }
+
+
+    /**
+     * Checks if the given distinguished name must be encoded.
+     *
+     * @param dn the dn to check
+     *
+     * @return true, if must encode DN
+     */
+    public static boolean mustEncodeDN( String dn )
+    {
+        return mustEncode( dn );
+    }
+
+
+    /**
+     * Checks if the given string must be encoded to be
+     * used in an LDIF.
+     *
+     * @param value the value to check
+     *
+     * @return true, if must encode
+     */
+    public static boolean mustEncode( String value )
+    {
+        if ( value == null || value.length() < 1 )
+        {
+            return false;
+        }
+
+        if ( value.startsWith( " " ) || value.startsWith( ":" ) || value.startsWith( "<" ) )
+        {
+            return true;
+        }
+        if ( value.endsWith( " " ) )
+        {
+            return true;
+        }
+
+        for ( int i = 0; i < value.length(); i++ )
+        {
+            if ( value.charAt( i ) == '\r' || value.charAt( i ) == '\n' || value.charAt( i ) == '\u0000'
+                || value.charAt( i ) > '\u007F' )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/LdifUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEOFPart.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEOFPart.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEOFPart.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEOFPart.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,95 @@
+/*
+ *  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.ldifparser.model;
+
+import org.apache.directory.studio.ldifparser.LdifFormatParameters;
+
+
+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( LdifFormatParameters formatParameters )
+    {
+        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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEOFPart.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEnumeration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEnumeration.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEnumeration.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifEnumeration.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,44 @@
+/*
+ *  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.ldifparser.model;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
+
+
+public interface LdifEnumeration
+{
+
+    /**
+     * @return true if this enumeration has more elements.
+     */
+    public boolean hasNext() throws Exception;
+
+
+    /**
+     * 
+     * @return the next LDIF container or null if hasNext() returns false.
+     */
+    public LdifContainer next() throws Exception;
+
+}

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

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifFile.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifFile.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifFile.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifFile.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,433 @@
+/*
+ *  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.ldifparser.model;
+
+
+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.ldifparser.LdifFormatParameters;
+import org.apache.directory.studio.ldifparser.model.container.LdifChangeRecord;
+import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
+import org.apache.directory.studio.ldifparser.model.container.LdifContentRecord;
+import org.apache.directory.studio.ldifparser.model.container.LdifModSpec;
+import org.apache.directory.studio.ldifparser.model.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( LdifFormatParameters formatParameters )
+    {
+        StringBuffer sb = new StringBuffer();
+
+        LdifContainer[] containers = this.getContainers();
+        for ( int i = 0; i < containers.length; i++ )
+        {
+            sb.append( containers[i].toFormattedString( formatParameters ) );
+        }
+
+        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 (org.apache.directory.studio.ldifparser.model.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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifFile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifInvalidPart.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifInvalidPart.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifInvalidPart.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifInvalidPart.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,98 @@
+/*
+ *  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.ldifparser.model;
+
+import org.apache.directory.studio.ldifparser.LdifFormatParameters;
+
+
+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( LdifFormatParameters formatParameters )
+    {
+        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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifInvalidPart.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifPart.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifPart.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifPart.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/LdifPart.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,52 @@
+/*
+ *  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.ldifparser.model;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.studio.ldifparser.LdifFormatParameters;
+
+
+public interface LdifPart extends Serializable
+{
+
+    public int getOffset();
+
+
+    public int getLength();
+
+
+    public boolean isValid();
+
+
+    public String getInvalidString();
+
+
+    public String toRawString();
+
+
+    public String toFormattedString( LdifFormatParameters formatParameters );
+
+
+    public void adjustOffset( int adjust );
+
+}

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

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeAddRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeAddRecord.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeAddRecord.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeAddRecord.java Wed Nov 21 12:08:28 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.ldifparser.model.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifChangeTypeLine;
+import org.apache.directory.studio.ldifparser.model.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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeAddRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeDeleteRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeDeleteRecord.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeDeleteRecord.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeDeleteRecord.java Wed Nov 21 12:08:28 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.ldifparser.model.container;
+
+
+import org.apache.directory.studio.ldifparser.model.lines.LdifChangeTypeLine;
+import org.apache.directory.studio.ldifparser.model.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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeDeleteRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModDnRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModDnRecord.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModDnRecord.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModDnRecord.java Wed Nov 21 12:08:28 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.ldifparser.model.container;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.studio.ldifparser.model.lines.LdifChangeTypeLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifDeloldrdnLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifDnLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifNewrdnLine;
+import org.apache.directory.studio.ldifparser.model.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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModDnRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java Wed Nov 21 12:08:28 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.ldifparser.model.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldifparser.model.lines.LdifChangeTypeLine;
+import org.apache.directory.studio.ldifparser.model.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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeModifyRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeRecord.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeRecord.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeRecord.java Wed Nov 21 12:08:28 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.ldifparser.model.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldifparser.model.lines.LdifChangeTypeLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifControlLine;
+import org.apache.directory.studio.ldifparser.model.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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifChangeRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifCommentContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifCommentContainer.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifCommentContainer.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifCommentContainer.java Wed Nov 21 12:08:28 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.ldifparser.model.container;
+
+
+import org.apache.directory.studio.ldifparser.model.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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifCommentContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContainer.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContainer.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContainer.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,201 @@
+/*
+ *  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.ldifparser.model.container;
+
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldifparser.LdifFormatParameters;
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+import org.apache.directory.studio.ldifparser.model.LdifInvalidPart;
+import org.apache.directory.studio.ldifparser.model.LdifPart;
+import org.apache.directory.studio.ldifparser.model.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 (org.apache.directory.studio.ldifparser.model.LdifPart[] ) this.parts.toArray( new LdifPart[parts.size()] );
+    }
+
+
+    public final String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( getClass().getName() );
+        sb.append( ":" );
+        sb.append( LdifParserConstants.LINE_SEPARATOR );
+
+        LdifPart[] parts = this.getParts();
+        for ( int i = 0; i < parts.length; i++ )
+        {
+            sb.append( "    " );
+            sb.append( parts[i].toString() );
+            sb.append( LdifParserConstants.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( LdifFormatParameters formatParameters )
+    {
+        StringBuffer sb = new StringBuffer();
+
+        LdifPart[] parts = this.getParts();
+        for ( int i = 0; i < parts.length; i++ )
+        {
+            sb.append( parts[i].toFormattedString( formatParameters ) );
+        }
+
+        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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContentRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContentRecord.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContentRecord.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContentRecord.java Wed Nov 21 12:08:28 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.ldifparser.model.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
+import org.apache.directory.studio.ldifparser.model.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-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifContentRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifEOFContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifEOFContainer.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifEOFContainer.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifEOFContainer.java Wed Nov 21 12:08:28 2007
@@ -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.studio.ldifparser.model.container;
+
+
+import org.apache.directory.studio.ldifparser.model.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;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifEOFContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifInvalidContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifInvalidContainer.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifInvalidContainer.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifInvalidContainer.java Wed Nov 21 12:08:28 2007
@@ -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.studio.ldifparser.model.container;
+
+
+import org.apache.directory.studio.ldifparser.model.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;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifInvalidContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message