You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/21 21:08:33 UTC
svn commit: r597198 [2/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...
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifModSpec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifModSpec.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifModSpec.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifModSpec.java Wed Nov 21 12:08:28 2007
@@ -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.studio.ldifparser.model.container;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldifparser.model.LdifPart;
+import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifModSpecSepLine;
+import org.apache.directory.studio.ldifparser.model.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;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifModSpec.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifRecord.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifRecord.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifRecord.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifRecord.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.Iterator;
+
+import org.apache.directory.studio.ldifparser.model.LdifEOFPart;
+import org.apache.directory.studio.ldifparser.model.LdifPart;
+import org.apache.directory.studio.ldifparser.model.lines.LdifCommentLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifDnLine;
+import org.apache.directory.studio.ldifparser.model.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();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifRecord.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifSepContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifSepContainer.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifSepContainer.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifSepContainer.java Wed Nov 21 12:08:28 2007
@@ -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.studio.ldifparser.model.container;
+
+
+import org.apache.directory.studio.ldifparser.model.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;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifSepContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifVersionContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifVersionContainer.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifVersionContainer.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifVersionContainer.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.ldifparser.model.container;
+
+
+import org.apache.directory.studio.ldifparser.model.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;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/container/LdifVersionContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifAttrValLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifAttrValLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifAttrValLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifAttrValLine.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.ldifparser.model.lines;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+import org.apache.directory.studio.ldifparser.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, LdifParserConstants.LINE_SEPARATOR );
+ }
+ }
+
+
+ public static LdifAttrValLine create( String name, byte[] value )
+ {
+ return new LdifAttrValLine( 0, name, "::", LdifUtils.base64encode( value ), LdifParserConstants.LINE_SEPARATOR );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifAttrValLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifChangeTypeLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifChangeTypeLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifChangeTypeLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifChangeTypeLine.java Wed Nov 21 12:08:28 2007
@@ -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.studio.ldifparser.model.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+
+
+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", LdifParserConstants.LINE_SEPARATOR );
+ }
+
+
+ public static LdifChangeTypeLine createAdd()
+ {
+ return new LdifChangeTypeLine( 0, "changetype", ":", "add", LdifParserConstants.LINE_SEPARATOR );
+ }
+
+
+ public static LdifChangeTypeLine createModify()
+ {
+ return new LdifChangeTypeLine( 0, "changetype", ":", "modify", LdifParserConstants.LINE_SEPARATOR );
+ }
+
+
+ public static LdifChangeTypeLine createModDn()
+ {
+ return new LdifChangeTypeLine( 0, "changetype", ":", "moddn", LdifParserConstants.LINE_SEPARATOR );
+ }
+
+
+ public static LdifChangeTypeLine createModRdn()
+ {
+ return new LdifChangeTypeLine( 0, "changetype", ":", "modrdn", LdifParserConstants.LINE_SEPARATOR );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifChangeTypeLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifCommentLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifCommentLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifCommentLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifCommentLine.java Wed Nov 21 12:08:28 2007
@@ -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.studio.ldifparser.model.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+
+
+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, LdifParserConstants.LINE_SEPARATOR );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifCommentLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java Wed Nov 21 12:08:28 2007
@@ -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.studio.ldifparser.model.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+import org.apache.directory.studio.ldifparser.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,
+ LdifParserConstants.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, LdifParserConstants.LINE_SEPARATOR );
+ return controlLine;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDeloldrdnLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDeloldrdnLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDeloldrdnLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDeloldrdnLine.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,118 @@
+/*
+ * 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.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+
+
+public class LdifDeloldrdnLine extends LdifValueLineBase
+{
+
+ private static final long serialVersionUID = 7427736453871426864L;
+
+
+ protected LdifDeloldrdnLine()
+ {
+ }
+
+
+ public LdifDeloldrdnLine( int offset, String rawDeleteOldrdnSpec, String rawValueType, String rawDeleteOldrdn,
+ String rawNewLine )
+ {
+ super( offset, rawDeleteOldrdnSpec, rawValueType, rawDeleteOldrdn, rawNewLine );
+ }
+
+
+ public String getRawDeleteOldrdnSpec()
+ {
+ return super.getRawLineStart();
+ }
+
+
+ public String getUnfoldedDeleteOldrdnSpec()
+ {
+ return super.getUnfoldedLineStart();
+ }
+
+
+ public String getRawDeleteOldrdn()
+ {
+ return super.getRawValue();
+ }
+
+
+ public String getUnfoldedDeleteOldrdn()
+ {
+ return super.getUnfoldedValue();
+ }
+
+
+ public boolean isDeleteOldRdn()
+ {
+ return "1".equals( this.getUnfoldedDeleteOldrdn() );
+ }
+
+
+ public String toRawString()
+ {
+ return super.toRawString();
+ }
+
+
+ public boolean isValid()
+ {
+ if ( !super.isValid() )
+ return false;
+
+ return ( "0".equals( getUnfoldedDeleteOldrdn() ) || "1".equals( getUnfoldedDeleteOldrdn() ) );
+ }
+
+
+ public String getInvalidString()
+ {
+ if ( this.getUnfoldedDeleteOldrdnSpec().length() == 0 )
+ {
+ return "Missing delete old RDN spec 'deleteoldrdn'";
+ }
+ else if ( !"0".equals( getUnfoldedDeleteOldrdn() ) && !"1".equals( getUnfoldedDeleteOldrdn() ) )
+ {
+ return "Invalid value of delete old RDN, must be '0' or '1'";
+ }
+ else
+ {
+ return super.getInvalidString();
+ }
+ }
+
+
+ public static LdifDeloldrdnLine create0()
+ {
+ return new LdifDeloldrdnLine( 0, "deleteoldrdn", ":", "0", LdifParserConstants.LINE_SEPARATOR );
+ }
+
+
+ public static LdifDeloldrdnLine create1()
+ {
+ return new LdifDeloldrdnLine( 0, "deleteoldrdn", ":", "1", LdifParserConstants.LINE_SEPARATOR );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDeloldrdnLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDnLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDnLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDnLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDnLine.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,111 @@
+/*
+ * 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.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+import org.apache.directory.studio.ldifparser.LdifUtils;
+
+
+public class LdifDnLine extends LdifValueLineBase
+{
+
+ private static final long serialVersionUID = 6180172049870560007L;
+
+
+ protected LdifDnLine()
+ {
+ }
+
+
+ public LdifDnLine( int offset, String rawDnSpec, String rawValueType, String rawDn, String rawNewLine )
+ {
+ super( offset, rawDnSpec, rawValueType, rawDn, rawNewLine );
+ }
+
+
+ public String getRawDnSpec()
+ {
+ return super.getRawLineStart();
+ }
+
+
+ public String getUnfoldedDnSpec()
+ {
+ return super.getUnfoldedLineStart();
+ }
+
+
+ public String getRawDn()
+ {
+ return super.getRawValue();
+ }
+
+
+ public String getUnfoldedDn()
+ {
+ return super.getUnfoldedValue();
+ }
+
+
+ public String toRawString()
+ {
+ return super.toRawString();
+ }
+
+
+ public boolean isValid()
+ {
+ return super.isValid();
+ }
+
+
+ public String getInvalidString()
+ {
+ if ( this.getUnfoldedDnSpec().length() == 0 )
+ {
+ return "Missing DN spec 'dn'";
+ }
+ else if ( this.getUnfoldedDn().length() == 0 )
+ {
+ return "Missing DN";
+ }
+ else
+ {
+ return super.getInvalidString();
+ }
+ }
+
+
+ public static LdifDnLine create( String dn )
+ {
+ if ( LdifUtils.mustEncode( dn ) )
+ {
+ return new LdifDnLine( 0, "dn", "::", LdifUtils.base64encode( LdifUtils.utf8encode( dn ) ),
+ LdifParserConstants.LINE_SEPARATOR );
+ }
+ else
+ {
+ return new LdifDnLine( 0, "dn", ":", dn, LdifParserConstants.LINE_SEPARATOR );
+ }
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifDnLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifLineBase.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifLineBase.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifLineBase.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifLineBase.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,196 @@
+/*
+ * 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.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifFormatParameters;
+import org.apache.directory.studio.ldifparser.model.LdifPart;
+
+
+/**
+ * Base class for all lines in a LDIF file.
+ *
+ *
+ */
+public abstract class LdifLineBase implements LdifPart
+{
+
+ private String rawNewLine;
+
+ private int offset;
+
+
+ protected LdifLineBase()
+ {
+ }
+
+
+ protected LdifLineBase( int offset, String rawNewLine )
+ {
+ super();
+ this.rawNewLine = rawNewLine;
+ this.offset = offset;
+ }
+
+
+ public final String getRawNewLine()
+ {
+ return getNonNull( this.rawNewLine );
+ }
+
+
+ public String getUnfoldedNewLine()
+ {
+ return unfold( this.getRawNewLine() );
+ }
+
+
+ public final void adjustOffset( int adjust )
+ {
+ this.offset += adjust;
+ }
+
+
+ public final int getOffset()
+ {
+ return this.offset;
+ }
+
+
+ public final int getLength()
+ {
+ return this.toRawString().length();
+ }
+
+
+ public boolean isValid()
+ {
+ return this.rawNewLine != null;
+ }
+
+
+ public String getInvalidString()
+ {
+ if ( this.rawNewLine == null )
+ {
+ return "Missing new line";
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ public String toRawString()
+ {
+ return this.getRawNewLine();
+ }
+
+
+ public final String toFormattedString( LdifFormatParameters formatParameters )
+ {
+ String raw = toRawString();
+ String unfolded = unfold( raw );
+
+ if ( this instanceof LdifValueLineBase )
+ {
+ if ( unfolded.indexOf( "::" ) > -1 )
+ {
+ unfolded = unfolded.replaceFirst( "::[ ]*", formatParameters.isSpaceAfterColon() ? ":: " : "::" );
+ }
+ else if ( unfolded.indexOf( ":<" ) > -1 )
+ {
+ unfolded = unfolded.replaceFirst( ":<[ ]*", formatParameters.isSpaceAfterColon() ? ":< " : ":<" );
+ }
+ else if ( unfolded.indexOf( ":" ) > -1 )
+ {
+ unfolded = unfolded.replaceFirst( ":[ ]*", formatParameters.isSpaceAfterColon() ? ": " : ":" );
+ }
+ }
+
+ if ( rawNewLine != null )
+ {
+ int index = unfolded.lastIndexOf( rawNewLine );
+ if ( index > -1 )
+ {
+ unfolded = unfolded.substring( 0, unfolded.length() - rawNewLine.length() );
+ unfolded = unfolded + formatParameters.getLineSeparator();
+ }
+ }
+
+ if ( this instanceof LdifValueLineBase )
+ {
+ return fold( unfolded, 0, formatParameters );
+ }
+ else
+ {
+ return unfolded;
+ }
+ }
+
+
+ public final String toString()
+ {
+ String text = toRawString();
+ text = text.replaceAll( "\n", "\\\\n" );
+ text = text.replaceAll( "\r", "\\\\r" );
+ return getClass().getName() + " (" + getOffset() + "," + getLength() + "): '" + text + "'";
+ }
+
+
+ protected static String getNonNull( String s )
+ {
+ return s != null ? s : "";
+ }
+
+
+ protected static String unfold( String s )
+ {
+ s = s.replaceAll( "\n\r ", "" );
+ s = s.replaceAll( "\r\n ", "" );
+ s = s.replaceAll( "\n ", "" );
+ s = s.replaceAll( "\r ", "" );
+ return s;
+ }
+
+
+ protected static String fold( String value, int indent, LdifFormatParameters formatParameters )
+ {
+ StringBuffer formattedLdif = new StringBuffer();
+ int offset = formatParameters.getLineWidth() - indent;
+ int endIndex = 0 + offset;
+ while ( endIndex + formatParameters.getLineSeparator().length() < value.length() )
+ {
+ formattedLdif.append( value.substring( endIndex - offset, endIndex ) );
+ formattedLdif.append( formatParameters.getLineSeparator() );
+ formattedLdif.append( ' ' );
+ offset = formatParameters.getLineWidth() - 1;
+ endIndex += offset;
+ }
+ String rest = value.substring( endIndex - offset, value.length() );
+ formattedLdif.append( rest );
+
+ // return
+ return formattedLdif.toString();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifLineBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecSepLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecSepLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecSepLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecSepLine.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,86 @@
+/*
+ * 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.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+
+
+public class LdifModSpecSepLine extends LdifNonEmptyLineBase
+{
+
+ private static final long serialVersionUID = -6411592502825895865L;
+
+
+ protected LdifModSpecSepLine()
+ {
+ }
+
+
+ public LdifModSpecSepLine( int offset, String rawMinus, String rawNewLine )
+ {
+ super( offset, rawMinus, rawNewLine );
+ }
+
+
+ public String getRawMinus()
+ {
+ return super.getRawLineStart();
+ }
+
+
+ public String getUnfoldedMinus()
+ {
+ return super.getUnfoldedLineStart();
+ }
+
+
+ public String toRawString()
+ {
+ return super.toRawString();
+ }
+
+
+ public boolean isValid()
+ {
+ return super.isValid() && this.getUnfoldedMinus().equals( "-" );
+ }
+
+
+ public String getInvalidString()
+ {
+ if ( !this.getUnfoldedMinus().equals( "-" ) )
+ {
+ return "Missing '-'";
+ }
+ else
+ {
+ return super.getInvalidString();
+ }
+ }
+
+
+ public static LdifModSpecSepLine create()
+ {
+ return new LdifModSpecSepLine( 0, "-", LdifParserConstants.LINE_SEPARATOR );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecSepLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecTypeLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecTypeLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecTypeLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecTypeLine.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,137 @@
+/*
+ * 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.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+
+
+public class LdifModSpecTypeLine extends LdifValueLineBase
+{
+
+ private static final long serialVersionUID = 82623220224991909L;
+
+
+ protected LdifModSpecTypeLine()
+ {
+ }
+
+
+ public LdifModSpecTypeLine( int offset, String rawModType, String rawValueType, String rawAttributeDescription,
+ String rawNewLine )
+ {
+ super( offset, rawModType, rawValueType, rawAttributeDescription, rawNewLine );
+ }
+
+
+ public String getRawModType()
+ {
+ return super.getRawLineStart();
+ }
+
+
+ public String getUnfoldedModType()
+ {
+ return super.getUnfoldedLineStart();
+ }
+
+
+ public String getRawAttributeDescription()
+ {
+ return super.getRawValue();
+ }
+
+
+ public String getUnfoldedAttributeDescription()
+ {
+ return super.getUnfoldedValue();
+ }
+
+
+ public String toRawString()
+ {
+ return super.toRawString();
+ }
+
+
+ public boolean isAdd()
+ {
+ return this.getUnfoldedModType().equals( "add" );
+ }
+
+
+ public boolean isReplace()
+ {
+ return this.getUnfoldedModType().equals( "replace" );
+ }
+
+
+ public boolean isDelete()
+ {
+ return this.getUnfoldedModType().equals( "delete" );
+ }
+
+
+ public boolean isValid()
+ {
+ return super.isValid() && ( this.isAdd() || this.isReplace() || this.isDelete() );
+ }
+
+
+ public String getInvalidString()
+ {
+ if ( this.getUnfoldedModType().length() == 0 )
+ {
+ return "Missing modification type 'add', 'replace' or 'delete'";
+ }
+ else if ( !this.isAdd() && !this.isReplace() && !this.isDelete() )
+ {
+ return "Invalid modification type, expected 'add', 'replace' or 'delete'";
+ }
+ else if ( this.getUnfoldedAttributeDescription().length() == 0 )
+ {
+ return "Missing attribute";
+ }
+ else
+ {
+ return super.getInvalidString();
+ }
+ }
+
+
+ public static LdifModSpecTypeLine createAdd( String attributeName )
+ {
+ return new LdifModSpecTypeLine( 0, "add", ":", attributeName, LdifParserConstants.LINE_SEPARATOR );
+ }
+
+
+ public static LdifModSpecTypeLine createReplace( String attributeName )
+ {
+ return new LdifModSpecTypeLine( 0, "replace", ":", attributeName, LdifParserConstants.LINE_SEPARATOR );
+ }
+
+
+ public static LdifModSpecTypeLine createDelete( String attributeName )
+ {
+ return new LdifModSpecTypeLine( 0, "delete", ":", attributeName, LdifParserConstants.LINE_SEPARATOR );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifModSpecTypeLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewrdnLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewrdnLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewrdnLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewrdnLine.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,112 @@
+/*
+ * 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.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+import org.apache.directory.studio.ldifparser.LdifUtils;
+
+
+public class LdifNewrdnLine extends LdifValueLineBase
+{
+
+ private static final long serialVersionUID = -4393976438427677361L;
+
+
+ protected LdifNewrdnLine()
+ {
+ }
+
+
+ public LdifNewrdnLine( int offset, String rawNewrdnSpec, String rawValueType, String rawNewrdn, String rawNewLine )
+ {
+ super( offset, rawNewrdnSpec, rawValueType, rawNewrdn, rawNewLine );
+ }
+
+
+ public String getRawNewrdnSpec()
+ {
+ return super.getRawLineStart();
+ }
+
+
+ public String getUnfoldedNewrdnSpec()
+ {
+ return super.getUnfoldedLineStart();
+ }
+
+
+ public String getRawNewrdn()
+ {
+ return super.getRawValue();
+ }
+
+
+ public String getUnfoldedNewrdn()
+ {
+ return super.getUnfoldedValue();
+ }
+
+
+ public String toRawString()
+ {
+ return super.toRawString();
+ }
+
+
+ public boolean isValid()
+ {
+ return super.isValid();
+ }
+
+
+ public String getInvalidString()
+ {
+ if ( this.getUnfoldedNewrdnSpec().length() == 0 )
+ {
+ return "Missing new RDN spec 'newrdn'";
+ }
+ else if ( this.getUnfoldedNewrdn().length() == 0 )
+ {
+ return "Missing new RDN";
+ }
+ else
+ {
+ return super.getInvalidString();
+ }
+ }
+
+
+ public static LdifNewrdnLine create( String newrdn )
+ {
+ if ( LdifUtils.mustEncode( newrdn ) )
+ {
+ return new LdifNewrdnLine( 0, "newrdn", "::", LdifUtils.base64encode( LdifUtils.utf8encode( newrdn ) ),
+ LdifParserConstants.LINE_SEPARATOR );
+ }
+ else
+ {
+ return new LdifNewrdnLine( 0, "newrdn", ":", newrdn, LdifParserConstants.LINE_SEPARATOR );
+ }
+
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewrdnLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewsuperiorLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewsuperiorLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewsuperiorLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewsuperiorLine.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,113 @@
+/*
+ * 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.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+import org.apache.directory.studio.ldifparser.LdifUtils;
+
+
+public class LdifNewsuperiorLine extends LdifValueLineBase
+{
+
+ private static final long serialVersionUID = -8614298286815271694L;
+
+
+ protected LdifNewsuperiorLine()
+ {
+ }
+
+
+ public LdifNewsuperiorLine( int offset, String rawNewSuperiorSpec, String rawValueType, String rawNewSuperiorDn,
+ String rawNewLine )
+ {
+ super( offset, rawNewSuperiorSpec, rawValueType, rawNewSuperiorDn, rawNewLine );
+ }
+
+
+ public String getRawNewSuperiorSpec()
+ {
+ return super.getRawLineStart();
+ }
+
+
+ public String getUnfoldedNewSuperiorSpec()
+ {
+ return super.getUnfoldedLineStart();
+ }
+
+
+ public String getRawNewSuperiorDn()
+ {
+ return super.getRawValue();
+ }
+
+
+ public String getUnfoldedNewSuperiorDn()
+ {
+ return super.getUnfoldedValue();
+ }
+
+
+ public String toRawString()
+ {
+ return super.toRawString();
+ }
+
+
+ public boolean isValid()
+ {
+ return super.isValid();
+ }
+
+
+ public String getInvalidString()
+ {
+ if ( this.getUnfoldedNewSuperiorSpec().length() == 0 )
+ {
+ return "Missing new superior spec 'newsuperior'";
+ }
+ else if ( this.getUnfoldedNewSuperiorDn().length() == 0 )
+ {
+ return "Missing new superior DN";
+ }
+ else
+ {
+ return super.getInvalidString();
+ }
+ }
+
+
+ public static LdifNewsuperiorLine create( String newsuperior )
+ {
+ if ( LdifUtils.mustEncode( newsuperior ) )
+ {
+ return new LdifNewsuperiorLine( 0, "newsuperior", "::", LdifUtils.base64encode( LdifUtils
+ .utf8encode( newsuperior ) ), LdifParserConstants.LINE_SEPARATOR );
+ }
+ else
+ {
+ return new LdifNewsuperiorLine( 0, "newsuperior", ":", newsuperior, LdifParserConstants.LINE_SEPARATOR );
+ }
+
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNewsuperiorLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNonEmptyLineBase.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNonEmptyLineBase.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNonEmptyLineBase.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNonEmptyLineBase.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,85 @@
+/*
+ * 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.lines;
+
+
+public abstract class LdifNonEmptyLineBase extends LdifLineBase
+{
+
+ private String rawLineStart;
+
+
+ protected LdifNonEmptyLineBase()
+ {
+ }
+
+
+ public LdifNonEmptyLineBase( int offset, String rawLineStart, String rawNewLine )
+ {
+ super( offset, rawNewLine );
+ this.rawLineStart = rawLineStart;
+ }
+
+
+ public String getRawLineStart()
+ {
+ return getNonNull( this.rawLineStart );
+ }
+
+
+ public String getUnfoldedLineStart()
+ {
+ return unfold( this.getRawLineStart() );
+ }
+
+
+ public boolean isValid()
+ {
+ return super.isValid() && this.rawLineStart != null;
+ }
+
+
+ public String getInvalidString()
+ {
+ if ( this.rawLineStart == null )
+ {
+ return "Missing line start";
+ }
+ else
+ {
+ return super.getInvalidString();
+ }
+ }
+
+
+ public String toRawString()
+ {
+ return this.getRawLineStart() + this.getRawNewLine();
+ }
+
+
+ public boolean isFolded()
+ {
+ String rawString = toRawString();
+ return rawString.indexOf( "\n " ) > -1 || rawString.indexOf( "\r " ) > -1;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifNonEmptyLineBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifSepLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifSepLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifSepLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifSepLine.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.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+
+
+public class LdifSepLine extends LdifLineBase
+{
+
+ private static final long serialVersionUID = 1682910718363816158L;
+
+
+ protected LdifSepLine()
+ {
+ }
+
+
+ public LdifSepLine( int offset, String rawNewLine )
+ {
+ super( offset, rawNewLine );
+ }
+
+
+ public static LdifSepLine create()
+ {
+ return new LdifSepLine( 0, LdifParserConstants.LINE_SEPARATOR );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifSepLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifValueLineBase.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifValueLineBase.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifValueLineBase.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifValueLineBase.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,215 @@
+/*
+ * 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.lines;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import org.apache.directory.studio.ldifparser.LdifUtils;
+
+
+public class LdifValueLineBase extends LdifNonEmptyLineBase
+{
+
+ private static final long serialVersionUID = -7030930374861554147L;
+
+ private String rawValueType;
+
+ private String rawValue;
+
+
+ protected LdifValueLineBase()
+ {
+ }
+
+
+ public LdifValueLineBase( int offset, String rawLineStart, String rawValueType, String rawValue, String rawNewLine )
+ {
+ super( offset, rawLineStart, rawNewLine );
+
+ this.rawValueType = rawValueType;
+ this.rawValue = rawValue;
+ }
+
+
+ public String getRawValueType()
+ {
+ return getNonNull( this.rawValueType );
+ }
+
+
+ public String getUnfoldedValueType()
+ {
+ return unfold( this.getRawValueType() );
+ }
+
+
+ public String getRawValue()
+ {
+ return getNonNull( this.rawValue );
+ }
+
+
+ public String getUnfoldedValue()
+ {
+ return unfold( this.getRawValue() );
+ }
+
+
+ public String toRawString()
+ {
+ return this.getRawLineStart() + this.getRawValueType() + this.getRawValue() + this.getRawNewLine();
+ }
+
+
+ public boolean isValid()
+ {
+ return super.isValid() && this.rawValueType != null && this.rawValue != null;
+ }
+
+
+ public String getInvalidString()
+ {
+ if ( this.rawValueType == null )
+ {
+ return "Missing value type ':', '::' or ':<'";
+ }
+ else if ( this.rawValue == null )
+ {
+ return "Missing value";
+ }
+ else
+ {
+ return super.getInvalidString();
+ }
+ }
+
+
+ /**
+ *
+ * @return the string representation of the value, non-base64, unfolded
+ */
+ public final String getValueAsString()
+ {
+ Object o = getValueAsObject();
+ if ( o instanceof String )
+ {
+ return ( String ) o;
+ }
+ else if ( o instanceof byte[] )
+ {
+ return LdifUtils.utf8decode( ( byte[] ) o );
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+
+ /**
+ *
+ * @return the binary representation of the real value, non-base64,
+ * unfolded
+ */
+ public final byte[] getValueAsBinary()
+ {
+ Object o = getValueAsObject();
+ if ( o instanceof String )
+ {
+ return LdifUtils.utf8encode( ( String ) o );
+ }
+ else if ( o instanceof byte[] )
+ {
+ return ( byte[] ) o;
+ }
+ else
+ {
+ return new byte[0];
+ }
+ }
+
+
+ /**
+ * Returns the real data:
+ * <ul>
+ * <li>The unfolded String if value is a safe value.
+ * </li>
+ * <li>A byte array if value is base64 encoded.
+ * </li>
+ * <li>A byte array if value references an URL.
+ * </li>
+ * </ul>
+ *
+ * @return the real value or null
+ */
+ public final Object getValueAsObject()
+ {
+ if ( this.isValueTypeSafe() )
+ {
+ return this.getUnfoldedValue();
+ }
+ else if ( this.isValueTypeBase64() )
+ {
+ return LdifUtils.base64decodeToByteArray( this.getUnfoldedValue() );
+ }
+ else if ( this.isValueTypeURL() )
+ {
+ try
+ {
+ File file = new File( this.getUnfoldedValue() );
+ byte[] data = new byte[( int ) file.length()];
+ FileInputStream fis = new FileInputStream( file );
+ fis.read( data );
+ return data;
+ }
+ catch ( IOException ioe )
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ public boolean isValueTypeURL()
+ {
+ return this.getUnfoldedValueType().startsWith( ":<" );
+ }
+
+
+ public boolean isValueTypeBase64()
+ {
+ return this.getUnfoldedValueType().startsWith( "::" );
+ }
+
+
+ public boolean isValueTypeSafe()
+ {
+ return this.getUnfoldedValueType().startsWith( ":" ) && !this.isValueTypeBase64() && !this.isValueTypeURL();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifValueLineBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifVersionLine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifVersionLine.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifVersionLine.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifVersionLine.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.ldifparser.model.lines;
+
+
+import org.apache.directory.studio.ldifparser.LdifParserConstants;
+
+
+public class LdifVersionLine extends LdifValueLineBase
+{
+
+ private static final long serialVersionUID = 7302151354496025254L;
+
+
+ protected LdifVersionLine()
+ {
+ }
+
+
+ public LdifVersionLine( int offset, String rawVersionSpec, String rawValueType, String rawVersion, String rawNewLine )
+ {
+ super( offset, rawVersionSpec, rawValueType, rawVersion, rawNewLine );
+ }
+
+
+ public String getRawVersionSpec()
+ {
+ return super.getRawLineStart();
+ }
+
+
+ public String getUnfoldedVersionSpec()
+ {
+ return super.getUnfoldedLineStart();
+ }
+
+
+ public String getRawVersion()
+ {
+ return super.getRawValue();
+ }
+
+
+ public String getUnfoldedVersion()
+ {
+ return super.getUnfoldedValue();
+ }
+
+
+ public String toRawString()
+ {
+ return super.toRawString();
+ }
+
+
+ public boolean isValid()
+ {
+ return super.isValid();
+ }
+
+
+ public String getInvalidString()
+ {
+ if ( this.getUnfoldedVersionSpec().length() == 0 )
+ {
+ return "Missing version spec";
+ }
+ else if ( this.getUnfoldedVersion().length() == 0 )
+ {
+ return "Missing version";
+ }
+ else
+ {
+ return super.getInvalidString();
+ }
+ }
+
+
+ public static LdifVersionLine create()
+ {
+ return new LdifVersionLine( 0, "version", ":", "1", LdifParserConstants.LINE_SEPARATOR );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifVersionLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/DummyLdifContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/DummyLdifContainer.java?rev=597198&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/DummyLdifContainer.java (added)
+++ directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/DummyLdifContainer.java Wed Nov 21 12:08:28 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.parser;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.ldifparser.model.LdifPart;
+import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
+import org.apache.directory.studio.ldifparser.model.lines.LdifCommentLine;
+
+
+public class DummyLdifContainer extends LdifContainer
+{
+
+ private static final long serialVersionUID = -6712132529064161996L;
+
+
+ public DummyLdifContainer( LdifPart part )
+ {
+ super( part );
+ }
+
+
+ public LdifCommentLine[] getComments()
+ {
+ List l = new ArrayList();
+ for ( Iterator it = this.parts.iterator(); it.hasNext(); )
+ {
+ Object o = it.next();
+ if ( o instanceof LdifCommentLine )
+ {
+ l.add( o );
+ }
+ }
+ return ( LdifCommentLine[] ) l.toArray( new LdifCommentLine[l.size()] );
+ }
+
+
+ public boolean isValid()
+ {
+ return false;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/parser/DummyLdifContainer.java
------------------------------------------------------------------------------
svn:eol-style = native