You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/10/02 01:07:49 UTC
svn commit: r451836 [9/11] - in /directory/branches/shared/0.9.5/ldap/src:
main/java/org/apache/directory/shared/ldap/codec/
main/java/org/apache/directory/shared/ldap/codec/abandon/
main/java/org/apache/directory/shared/ldap/codec/actions/ main/java/o...
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java Sun Oct 1 16:07:44 2006
@@ -25,18 +25,26 @@
import java.util.ArrayList;
import java.util.Iterator;
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
import org.apache.directory.shared.asn1.ber.tlv.Value;
import org.apache.directory.shared.asn1.codec.EncoderException;
import org.apache.directory.shared.ldap.codec.LdapConstants;
-import org.apache.directory.shared.ldap.codec.util.LdapString;
+import org.apache.directory.shared.ldap.util.StringTools;
/**
- * A Object that stores the substring filter. A substring filter follow this
- * grammar : substring = attr "=" ([initial] any [final] | (initial [any]
- * [final) | ([initial] [any] final) initial = value any = "*" *(value "*")
+ * A Object that stores the substring filter.
+ *
+ * A substring filter follow this
+ * grammar :
+ *
+ * substring = attr "=" ( ([initial] any [final] |
+ * (initial [any] [final) |
+ * ([initial] [any] final) )
+ *
+ * initial = value
+ * any = "*" *(value "*")
* final = value
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -47,25 +55,30 @@
// ----------------------------------------------------------------------------
/** The substring filter type (an attributeDescription) */
- private LdapString type;
+ private String type;
+
+ /** The type length */
+ private transient int typeLength;
/**
* This member is used to control the length of the three parts of the
- * substring filter *
+ * substring filter
*/
private transient int substringsLength;
/** The initial filter */
- private LdapString initialSubstrings;
+ private String initialSubstrings;
/** The any filter. It's a list of LdapString */
private ArrayList anySubstrings;
/** The final filter */
- private LdapString finalSubstrings;
+ private String finalSubstrings;
+ /** Temporary storage for substringsFilter length */
private transient int substringsFilterLength;
+ /** Temporary storage for substringsFilter sequence length */
private transient int substringsFilterSequenceLength;
@@ -96,10 +109,9 @@
/**
* Add a internal substring
*
- * @param anySubstrings
- * The anySubstrings to set.
+ * @param anySubstrings The anySubstrings to set.
*/
- public void addAnySubstrings( LdapString anySubstrings )
+ public void addAnySubstrings( String anySubstrings )
{
this.anySubstrings.add( anySubstrings );
}
@@ -110,7 +122,7 @@
*
* @return Returns the finalSubstrings.
*/
- public LdapString getFinalSubstrings()
+ public String getFinalSubstrings()
{
return finalSubstrings;
}
@@ -119,10 +131,9 @@
/**
* Set the final substring
*
- * @param finalSubstrings
- * The finalSubstrings to set.
+ * @param finalSubstrings The finalSubstrings to set.
*/
- public void setFinalSubstrings( LdapString finalSubstrings )
+ public void setFinalSubstrings( String finalSubstrings )
{
this.finalSubstrings = finalSubstrings;
}
@@ -133,7 +144,7 @@
*
* @return Returns the initialSubstrings.
*/
- public LdapString getInitialSubstrings()
+ public String getInitialSubstrings()
{
return initialSubstrings;
}
@@ -142,10 +153,9 @@
/**
* Set the initial substring
*
- * @param initialSubstrings
- * The initialSubstrings to set.
+ * @param initialSubstrings The initialSubstrings to set.
*/
- public void setInitialSubstrings( LdapString initialSubstrings )
+ public void setInitialSubstrings( String initialSubstrings )
{
this.initialSubstrings = initialSubstrings;
}
@@ -156,7 +166,7 @@
*
* @return Returns the type.
*/
- public LdapString getType()
+ public String getType()
{
return type;
}
@@ -165,10 +175,9 @@
/**
* Set the attribute to match
*
- * @param type
- * The type to set.
+ * @param type The type to set.
*/
- public void setType( LdapString type )
+ public void setType( String type )
{
this.type = type;
}
@@ -184,8 +193,7 @@
/**
- * @param substringsLength
- * The substringsLength to set.
+ * @param substringsLength The substringsLength to set.
*/
public void setSubstringsLength( int substringsLength )
{
@@ -194,21 +202,36 @@
/**
- * Compute the SubstringFilter length SubstringFilter : 0xA4 L1 | +--> 0x04
- * L2 type +--> 0x30 L3 | [+--> 0x80 L4 initial] [+--> 0x81 L5-1 any] [+-->
- * 0x81 L5-2 any] [+--> ... [+--> 0x81 L5-i any] [+--> ... [+--> 0x81 L5-n
- * any] [+--> 0x82 L6 final]
+ * Compute the SubstringFilter length
+ *
+ * SubstringFilter :
+ * 0xA4 L1
+ * |
+ * +--> 0x04 L2 type
+ * +--> 0x30 L3
+ * |
+ * [+--> 0x80 L4 initial]
+ * [+--> 0x81 L5-1 any]
+ * [+--> 0x81 L5-2 any]
+ * [+--> ...
+ * [+--> 0x81 L5-i any]
+ * [+--> ...
+ * [+--> 0x81 L5-n any]
+ * [+--> 0x82 L6 final]
*/
public int computeLength()
{
// The type
- substringsFilterLength = 1 + Length.getNbBytes( type.getNbBytes() ) + type.getNbBytes();
+ typeLength = StringTools.getBytesUtf8( type ).length;
+
+ substringsFilterLength = 1 + TLV.getNbBytes( typeLength ) + typeLength;
substringsFilterSequenceLength = 0;
if ( initialSubstrings != null )
{
- substringsFilterSequenceLength += 1 + Length.getNbBytes( initialSubstrings.getNbBytes() )
- + initialSubstrings.getNbBytes();
+ int initialLength = StringTools.getBytesUtf8( initialSubstrings ).length;
+ substringsFilterSequenceLength += 1 + TLV.getNbBytes( initialLength )
+ + initialLength;
}
if ( anySubstrings != null )
@@ -217,32 +240,44 @@
while ( anyIterator.hasNext() )
{
- LdapString any = ( LdapString ) anyIterator.next();
- substringsFilterSequenceLength += 1 + Length.getNbBytes( any.getNbBytes() ) + any.getNbBytes();
+ String any = ( String ) anyIterator.next();
+ int anyLength = StringTools.getBytesUtf8( any ).length;
+ substringsFilterSequenceLength += 1 + TLV.getNbBytes( anyLength ) + anyLength;
}
}
if ( finalSubstrings != null )
{
- substringsFilterSequenceLength += 1 + Length.getNbBytes( finalSubstrings.getNbBytes() )
- + finalSubstrings.getNbBytes();
+ int finalLength = StringTools.getBytesUtf8( finalSubstrings ).length;
+ substringsFilterSequenceLength += 1 + TLV.getNbBytes( finalLength )
+ + finalLength;
}
- substringsFilterLength += 1 + Length.getNbBytes( substringsFilterSequenceLength )
+ substringsFilterLength += 1 + TLV.getNbBytes( substringsFilterSequenceLength )
+ substringsFilterSequenceLength;
- return 1 + Length.getNbBytes( substringsFilterLength ) + substringsFilterLength;
+ return 1 + TLV.getNbBytes( substringsFilterLength ) + substringsFilterLength;
}
/**
- * Encode the Substrings Filter to a PDU. Substrings Filter : 0xA4 LL 0x30
- * LL substringsFilter 0x04 LL type 0x30 LL substrings sequence | 0x80 LL
- * initial | / [0x81 LL any]* |/ [0x82 LL final] +--[0x81 LL any]+ \ [0x82
- * LL final] \ 0x82 LL final
+ * Encode the Substrings Filter to a PDU.
+ *
+ * Substrings Filter :
+ *
+ * 0xA4 LL
+ * 0x30 LL substringsFilter
+ * 0x04 LL type
+ * 0x30 LL substrings sequence
+ * | 0x80 LL initial
+ * | / [0x81 LL any]*
+ * |/ [0x82 LL final]
+ * +--[0x81 LL any]+
+ * \ [0x82 LL final]
+ * \
+ * 0x82 LL final
*
- * @param buffer
- * The buffer where to put the PDU
+ * @param buffer The buffer where to put the PDU
* @return The PDU.
*/
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -256,14 +291,14 @@
{
// The SubstringFilter Tag
buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_TAG );
- buffer.put( Length.getBytes( substringsFilterLength ) );
+ buffer.put( TLV.getBytes( substringsFilterLength ) );
// The type
Value.encode( buffer, type.getBytes() );
// The SubstringSequenceFilter Tag
buffer.put( UniversalTag.SEQUENCE_TAG );
- buffer.put( Length.getBytes( substringsFilterSequenceLength ) );
+ buffer.put( TLV.getBytes( substringsFilterSequenceLength ) );
if ( ( initialSubstrings == null ) && ( ( anySubstrings == null ) || ( anySubstrings.size() == 0 ) )
&& ( finalSubstrings == null ) )
@@ -274,9 +309,10 @@
// The initial substring
if ( initialSubstrings != null )
{
+ byte[] initialBytes = StringTools.getBytesUtf8( initialSubstrings );
buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_INITIAL_TAG );
- buffer.put( Length.getBytes( initialSubstrings.getNbBytes() ) );
- buffer.put( initialSubstrings.getBytes() );
+ buffer.put( TLV.getBytes( initialBytes.length ) );
+ buffer.put( initialBytes );
}
// The any substrings
@@ -286,19 +322,21 @@
while ( anyIterator.hasNext() )
{
- LdapString any = ( LdapString ) anyIterator.next();
+ String any = ( String ) anyIterator.next();
+ byte[] anyBytes = StringTools.getBytesUtf8( any );
buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_ANY_TAG );
- buffer.put( Length.getBytes( any.getNbBytes() ) );
- buffer.put( any.getBytes() );
+ buffer.put( TLV.getBytes( anyBytes.length ) );
+ buffer.put( anyBytes );
}
}
// The final substring
if ( finalSubstrings != null )
{
+ byte[] finalBytes = StringTools.getBytesUtf8( finalSubstrings );
buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_FINAL_TAG );
- buffer.put( Length.getBytes( finalSubstrings.getNbBytes() ) );
- buffer.put( finalSubstrings.getBytes() );
+ buffer.put( TLV.getBytes( finalBytes.length ) );
+ buffer.put( finalBytes );
}
}
catch ( BufferOverflowException boe )
@@ -333,7 +371,7 @@
while ( anyIterator.hasNext() )
{
- sb.append( ( LdapString ) anyIterator.next() ).append( '*' );
+ sb.append( ( String ) anyIterator.next() ).append( '*' );
}
}
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java Sun Oct 1 16:07:44 2006
@@ -55,7 +55,7 @@
public static final ChangeType MODIFY = new ChangeType( "MODIFY", MODIFY_VALUE );
public static final ChangeType MODDN = new ChangeType( "MODDN", MODDN_VALUE );
-
+
private final String label;
private final int value;
@@ -76,18 +76,16 @@
public String toString()
{
- return ( label );
+ return label;
}
/**
* Gets the changeType enumeration type for an integer value.
*
- * @param value
- * the value to get the enumeration for
+ * @param value the value to get the enumeration for
* @return the enueration type for the value if the value is valid
- * @throws IllegalArgumentException
- * if the value is undefined
+ * @throws IllegalArgumentException if the value is undefined
*/
public static ChangeType getChangeType( int value )
{
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java Sun Oct 1 16:07:44 2006
@@ -23,7 +23,7 @@
import java.nio.ByteBuffer;
import org.apache.directory.shared.asn1.Asn1Object;
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
import org.apache.directory.shared.asn1.ber.tlv.Value;
import org.apache.directory.shared.asn1.codec.EncoderException;
@@ -77,7 +77,6 @@
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
*/
public class EntryChangeControl extends Asn1Object
{
@@ -87,17 +86,24 @@
private int changeNumber = UNDEFINED_CHANGE_NUMBER;
+ /** The previous DN */
private LdapDN previousDn = null;
- private byte[] previousDnBytes = null;
+ /** A temporary storage for the previous DN */
+ private transient byte[] previousDnBytes = null;
+ /** The entry change global length */
private transient int eccSeqLength;
/**
- * Compute the EnryChangeControl length 0x30 L1 | +--> 0x0A 0x0(1-4)
- * [1|2|4|8] (changeType) +--> 0x04 L2 previousDN +--> 0x02 0x0(1-4)
- * [0..2^31-1] (changeNumber)
+ * Compute the EntryChangeControl length
+ *
+ * 0x30 L1
+ * |
+ * +--> 0x0A 0x0(1-4) [1|2|4|8] (changeType)
+ * [+--> 0x04 L2 previousDN]
+ * [+--> 0x02 0x0(1-4) [0..2^31-1] (changeNumber)]
*/
public int computeLength()
{
@@ -109,7 +115,7 @@
if ( previousDn != null )
{
previousDnBytes = StringTools.getBytesUtf8( previousDn.getUpName() );
- previousDnLength = 1 + Length.getNbBytes( previousDnBytes.length ) + previousDnBytes.length;
+ previousDnLength = 1 + TLV.getNbBytes( previousDnBytes.length ) + previousDnBytes.length;
}
if ( changeNumber != UNDEFINED_CHANGE_NUMBER )
@@ -119,25 +125,23 @@
eccSeqLength = changeTypesLength + previousDnLength + changeNumberLength;
- return 1 + Length.getNbBytes( eccSeqLength ) + eccSeqLength;
+ return 1 + TLV.getNbBytes( eccSeqLength ) + eccSeqLength;
}
/**
* Encodes the entry change control.
*
- * @param buffer
- * The encoded sink
+ * @param buffer The encoded sink
* @return A ByteBuffer that contains the encoded PDU
- * @throws EncoderException
- * If anything goes wrong.
+ * @throws EncoderException If anything goes wrong.
*/
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
// Allocate the bytes buffer.
ByteBuffer bb = ByteBuffer.allocate( computeLength() );
bb.put( UniversalTag.SEQUENCE_TAG );
- bb.put( Length.getBytes( eccSeqLength ) );
+ bb.put( TLV.getBytes( eccSeqLength ) );
bb.put( UniversalTag.ENUMERATED_TAG );
bb.put( ( byte ) 1 );
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlContainer.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlContainer.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlContainer.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlContainer.java Sun Oct 1 16:07:44 2006
@@ -22,7 +22,6 @@
import org.apache.directory.shared.asn1.ber.AbstractContainer;
import org.apache.directory.shared.asn1.ber.IAsn1Container;
-import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
/**
@@ -41,14 +40,8 @@
public EntryChangeControlContainer()
{
super();
- currentGrammar = 0;
- grammars = new IGrammar[EntryChangeControlStatesEnum.NB_GRAMMARS];
- grammarStack = new IGrammar[1];
stateStack = new int[1];
- nbGrammars = 0;
-
- grammars[EntryChangeControlStatesEnum.EC_GRAMMAR] = EntryChangeControlGrammar.getInstance();
- grammarStack[currentGrammar] = grammars[EntryChangeControlStatesEnum.EC_GRAMMAR];
+ grammar = EntryChangeControlGrammar.getInstance();
states = EntryChangeControlStatesEnum.getInstance();
}
@@ -66,15 +59,16 @@
* Set a EntryChangeControl Object into the container. It will be completed
* by the ldapDecoder.
*
- * @param control
- * the EntryChangeControl to set.
+ * @param control the EntryChangeControl to set.
*/
public void setEntryChangeControl( EntryChangeControl control )
{
this.control = control;
}
-
+ /**
+ * Clean the container
+ */
public void clean()
{
super.clean();
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlDecoder.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlDecoder.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlDecoder.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlDecoder.java Sun Oct 1 16:07:44 2006
@@ -37,17 +37,31 @@
*/
public class EntryChangeControlDecoder extends Asn1Decoder implements ControlDecoder
{
+ /** The entry change OID */
private final static String CONTROL_TYPE_OID = "2.16.840.1.113730.3.4.7";
+ /** An instance of this decoder */
private static final Asn1Decoder decoder = new Asn1Decoder();
-
+ /**
+ * @return The Entry Change controm OID
+ */
public String getControlType()
{
return CONTROL_TYPE_OID;
}
-
+ /**
+ * Decode the entry change control
+ *
+ * @param controlBytes The bytes array which contains the encoded entry change
+ *
+ * @return A valid EntryChange object
+ *
+ * @throws DecoderException If the decoding found an error
+ * @throws NamingException It will never be throw by this method
+ */
+
public Asn1Object decode( byte[] controlBytes ) throws DecoderException, NamingException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlGrammar.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlGrammar.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlGrammar.java Sun Oct 1 16:07:44 2006
@@ -68,23 +68,17 @@
super.transitions = new GrammarTransition[EntryChangeControlStatesEnum.LAST_EC_STATE][256];
// ============================================================================================
- // Entry Change Control
+ // Transition from start state to Entry Change sequence
// ============================================================================================
- // EntryChangeNotification ::= SEQUENCE { (Tag)
- // ...
- // Nothing to do
- super.transitions[EntryChangeControlStatesEnum.EC_SEQUENCE_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
- EntryChangeControlStatesEnum.EC_SEQUENCE_TAG, EntryChangeControlStatesEnum.EC_SEQUENCE_VALUE, null );
-
- // ============================================================================================
- // Entry Change Control
- // ============================================================================================
- // EntryChangeNotification ::= SEQUENCE { (Value)
- // ...
+ // EntryChangeNotification ::= SEQUENCE {
+ // ...
+ //
// Initialization of the structure
- super.transitions[EntryChangeControlStatesEnum.EC_SEQUENCE_VALUE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
- EntryChangeControlStatesEnum.EC_SEQUENCE_VALUE, EntryChangeControlStatesEnum.CHANGE_TYPE_TAG,
- new GrammarAction( "Init EntryChangeControl" )
+ super.transitions[EntryChangeControlStatesEnum.START_STATE][UniversalTag.SEQUENCE_TAG] =
+ new GrammarTransition( EntryChangeControlStatesEnum.START_STATE,
+ EntryChangeControlStatesEnum.EC_SEQUENCE_STATE,
+ UniversalTag.SEQUENCE_TAG,
+ new GrammarAction( "Init EntryChangeControl" )
{
public void action( IAsn1Container container )
{
@@ -95,27 +89,18 @@
} );
// ============================================================================================
- // Change Type
- // ============================================================================================
- // EntryChangeNotification ::= SEQUENCE {
- // changeType ENUMERATED { (Tag) },
- // ...
- //
- // Nothing to do
- super.transitions[EntryChangeControlStatesEnum.CHANGE_TYPE_TAG][UniversalTag.ENUMERATED_TAG] = new GrammarTransition(
- EntryChangeControlStatesEnum.CHANGE_TYPE_TAG, EntryChangeControlStatesEnum.CHANGE_TYPE_VALUE, null );
-
- // ============================================================================================
- // Change Type
+ // transition from Entry Change sequence to Change Type
// ============================================================================================
// EntryChangeNotification ::= SEQUENCE {
- // changeType ENUMERATED { (Value) },
- // ...
+ // changeType ENUMERATED {
+ // ...
//
// Evaluates the changeType
-
- // Action associated with the ChangeType transition
- GrammarAction setChangeTypeAction = new GrammarAction( "Set EntryChangeControl changeType" )
+ super.transitions[EntryChangeControlStatesEnum.EC_SEQUENCE_STATE][UniversalTag.ENUMERATED_TAG] =
+ new GrammarTransition( EntryChangeControlStatesEnum.EC_SEQUENCE_STATE,
+ EntryChangeControlStatesEnum.CHANGE_TYPE_STATE,
+ UniversalTag.ENUMERATED_TAG,
+ new GrammarAction( "Set EntryChangeControl changeType" )
{
public void action( IAsn1Container container ) throws DecoderException
{
@@ -158,39 +143,23 @@
throw new DecoderException( msg );
}
}
- };
-
- // ChangeType Transition
- super.transitions[EntryChangeControlStatesEnum.CHANGE_TYPE_VALUE][UniversalTag.ENUMERATED_TAG] = new GrammarTransition(
- EntryChangeControlStatesEnum.CHANGE_TYPE_VALUE,
- EntryChangeControlStatesEnum.CHANGE_NUMBER_OR_PREVIOUS_DN_TAG, setChangeTypeAction );
+ } );
// ============================================================================================
- // Previous DN (We have a OCTET_STRING Tag)
+ // Transition from Change Type to Previous DN
// ============================================================================================
// EntryChangeNotification ::= SEQUENCE {
- // ...
- // previousDN LDAPDN OPTIONAL, (Tag)
- // ...
- //
- // Nothing to do
- super.transitions[EntryChangeControlStatesEnum.CHANGE_NUMBER_OR_PREVIOUS_DN_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
- EntryChangeControlStatesEnum.CHANGE_NUMBER_OR_PREVIOUS_DN_TAG,
- EntryChangeControlStatesEnum.PREVIOUS_DN_VALUE, null );
-
- // ============================================================================================
- // Previous DN
- // ============================================================================================
- // EntryChangeNotification ::= SEQUENCE {
- // ...
- // previousDN LDAPDN OPTIONAL, (Value)
- // ...
+ // ...
+ // previousDN LDAPDN OPTIONAL,
+ // ...
//
// Set the previousDN into the structure. We first check that it's a
// valid DN
-
- // Action associated with the PreviousDN transition
- GrammarAction setPreviousDnAction = new GrammarAction( "Set EntryChangeControl previousDN" )
+ super.transitions[EntryChangeControlStatesEnum.CHANGE_TYPE_STATE][UniversalTag.OCTET_STRING_TAG] =
+ new GrammarTransition( EntryChangeControlStatesEnum.CHANGE_TYPE_STATE,
+ EntryChangeControlStatesEnum.PREVIOUS_DN_STATE,
+ UniversalTag.OCTET_STRING_TAG,
+ new GrammarAction( "Set EntryChangeControl previousDN" )
{
public void action( IAsn1Container container ) throws DecoderException
{
@@ -229,47 +198,7 @@
entryChangeContainer.grammarEndAllowed( true );
}
}
- };
-
- // PreviousDN transition
- super.transitions[EntryChangeControlStatesEnum.PREVIOUS_DN_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
- EntryChangeControlStatesEnum.PREVIOUS_DN_VALUE, EntryChangeControlStatesEnum.CHANGE_NUMBER_TAG,
- setPreviousDnAction );
-
- // ============================================================================================
- // Change Number from Change Type
- // ============================================================================================
- // EntryChangeNotification ::= SEQUENCE {
- // ...
- // changeNumber INTEGER OPTIONAL (Tag)
- // }
- //
- // Nothing to do
- super.transitions[EntryChangeControlStatesEnum.CHANGE_NUMBER_OR_PREVIOUS_DN_TAG][UniversalTag.INTEGER_TAG] = new GrammarTransition(
- EntryChangeControlStatesEnum.CHANGE_NUMBER_OR_PREVIOUS_DN_TAG,
- EntryChangeControlStatesEnum.CHANGE_NUMBER_VALUE, null );
-
- // ============================================================================================
- // Change Number from PreviousDN
- // ============================================================================================
- // EntryChangeNotification ::= SEQUENCE {
- // ...
- // changeNumber INTEGER OPTIONAL (Tag)
- // }
- //
- // Nothing to do
- super.transitions[EntryChangeControlStatesEnum.CHANGE_NUMBER_TAG][UniversalTag.INTEGER_TAG] = new GrammarTransition(
- EntryChangeControlStatesEnum.CHANGE_NUMBER_TAG, EntryChangeControlStatesEnum.CHANGE_NUMBER_VALUE, null );
-
- // ============================================================================================
- // Change Number
- // ============================================================================================
- // EntryChangeNotification ::= SEQUENCE {
- // ...
- // changeNumber INTEGER OPTIONAL (Value)
- // }
- //
- // Set the changeNumber into the structure
+ } );
// Change Number action
GrammarAction setChangeNumberAction = new GrammarAction( "Set EntryChangeControl changeNumber" )
@@ -302,10 +231,35 @@
}
};
- // Transition
- super.transitions[EntryChangeControlStatesEnum.CHANGE_NUMBER_VALUE][UniversalTag.INTEGER_TAG] = new GrammarTransition(
- EntryChangeControlStatesEnum.CHANGE_NUMBER_VALUE, EntryChangeControlStatesEnum.GRAMMAR_END,
- setChangeNumberAction );
+ // ============================================================================================
+ // Transition from Previous DN to Change Number
+ // ============================================================================================
+ // EntryChangeNotification ::= SEQUENCE {
+ // ...
+ // changeNumber INTEGER OPTIONAL
+ // }
+ //
+ // Set the changeNumber into the structure
+ super.transitions[EntryChangeControlStatesEnum.PREVIOUS_DN_STATE][UniversalTag.INTEGER_TAG] =
+ new GrammarTransition( EntryChangeControlStatesEnum.PREVIOUS_DN_STATE,
+ EntryChangeControlStatesEnum.CHANGE_NUMBER_STATE,
+ UniversalTag.INTEGER_TAG,
+ setChangeNumberAction );
+
+ // ============================================================================================
+ // Transition from Previous DN to Change Number
+ // ============================================================================================
+ // EntryChangeNotification ::= SEQUENCE {
+ // ...
+ // changeNumber INTEGER OPTIONAL
+ // }
+ //
+ // Set the changeNumber into the structure
+ super.transitions[EntryChangeControlStatesEnum.CHANGE_TYPE_STATE][UniversalTag.INTEGER_TAG] =
+ new GrammarTransition( EntryChangeControlStatesEnum.CHANGE_TYPE_STATE,
+ EntryChangeControlStatesEnum.CHANGE_NUMBER_STATE,
+ UniversalTag.INTEGER_TAG,
+ setChangeNumberAction );
}
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlStatesEnum.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlStatesEnum.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlStatesEnum.java Sun Oct 1 16:07:44 2006
@@ -40,58 +40,35 @@
// =========================================================================
/** Sequence Tag */
- public static int EC_SEQUENCE_TAG = 0;
+ public static int START_STATE = 0;
- /** Sequence Value */
- public static int EC_SEQUENCE_VALUE = 1;
+ /** Sequence */
+ public static int EC_SEQUENCE_STATE = 1;
- /** changeType Tag */
- public static int CHANGE_TYPE_TAG = 2;
+ /** changeType */
+ public static int CHANGE_TYPE_STATE = 2;
- /** changeType Value */
- public static int CHANGE_TYPE_VALUE = 3;
+ /** previousDN */
+ public static int PREVIOUS_DN_STATE = 3;
- /** previousDN Tag */
- public static int CHANGE_NUMBER_OR_PREVIOUS_DN_TAG = 4;
-
- /** previousDN Value */
- public static int PREVIOUS_DN_VALUE = 5;
-
- /** changeNumber Tag */
- public static int CHANGE_NUMBER_TAG = 6;
-
- /** changeNumber Value */
- public static int CHANGE_NUMBER_VALUE = 7;
+ /** changeNumber */
+ public static int CHANGE_NUMBER_STATE = 4;
/** terminal state */
- public static int LAST_EC_STATE = 8;
-
- // =========================================================================
- // Grammars declaration.
- // =========================================================================
- /** Entry change grammar */
- public static final int EC_GRAMMAR_SWITCH = 0x0100;
-
- /** Entry change grammar number */
- public static final int EC_GRAMMAR = 0;
-
- /** The total number of grammars used */
- public static final int NB_GRAMMARS = 1;
-
- // =========================================================================
- // Grammar switches debug strings
- // =========================================================================
- /** A string representation of grammars */
- private static String[] GrammarSwitchString = new String[]
- { "EC_GRAMMAR_SWITCH" };
+ public static int LAST_EC_STATE = 5;
// =========================================================================
// States debug strings
// =========================================================================
/** A string representation of all the states */
private static String[] EcString = new String[]
- { "EC_SEQUENCE_TAG", "EC_SEQUENCE_VALUE", "CHANGE_TYPE_TAG", "CHANGE_TYPE_VALUE",
- "CHANGE_NUMBER_OR_PREVIOUS_DN_TAG", "PREVIOUS_DN_VALUE", "CHANGE_NUMBER_TAG", "CHANGE_NUMBER_VALUE" };
+ {
+ "START_STATE",
+ "EC_SEQUENCE_STATE",
+ "CHANGE_TYPE_STATE",
+ "PREVIOUS_DN_STATE",
+ "CHANGE_NUMBER_STATE"
+ };
/** The instance */
private static EntryChangeControlStatesEnum instance = new EntryChangeControlStatesEnum();
@@ -125,27 +102,19 @@
/**
* Get the grammar name
*
- * @param grammar
- * The grammar code
+ * @param grammar The grammar code
* @return The grammar name
*/
public String getGrammarName( int grammar )
{
- switch ( grammar )
- {
- case EC_GRAMMAR:
- return "EC_GRAMMAR";
- default:
- return "UNKNOWN";
- }
+ return "EC_GRAMMAR";
}
/**
* Get the grammar name
*
- * @param grammar
- * The grammar class
+ * @param grammar The grammar class
* @return The grammar name
*/
public String getGrammarName( IGrammar grammar )
@@ -162,32 +131,11 @@
/**
* Get the string representing the state
*
- * @param grammar
- * The current grammar being used
- * @param state
- * The state number
+ * @param state The state number
* @return The String representing the state
*/
- public String getState( int grammar, int state )
+ public String getState( int state )
{
-
- if ( ( state & GRAMMAR_SWITCH_MASK ) != 0 )
- {
- return ( state == END_STATE ) ? "END_STATE"
- : GrammarSwitchString[( ( state & GRAMMAR_SWITCH_MASK ) >> 8 ) - 1];
- }
- else
- {
-
- switch ( grammar )
- {
-
- case EC_GRAMMAR:
- return ( ( state == GRAMMAR_END ) ? "EC_END_STATE" : EcString[state] );
-
- default:
- return "UNKNOWN";
- }
- }
+ return ( ( state == GRAMMAR_END ) ? "EC_END_STATE" : EcString[state] );
}
}
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControl.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControl.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControl.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControl.java Sun Oct 1 16:07:44 2006
@@ -23,12 +23,17 @@
import java.nio.ByteBuffer;
import org.apache.directory.shared.asn1.Asn1Object;
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
import org.apache.directory.shared.asn1.ber.tlv.Value;
import org.apache.directory.shared.asn1.codec.EncoderException;
+/**
+ * A persistence search object
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
public class PSearchControl extends Asn1Object
{
/**
@@ -46,33 +51,30 @@
/**
* As changes are made to the server, the effected entries MUST be returned
- * to the client if they match the standard search cri- teria and if the
+ * to the client if they match the standard search criteria and if the
* operation that caused the change is included in the changeTypes field.
* The changeTypes field is the logical OR of one or more of these values:
- * add (1), delete (2), modify (4), modDN (8).
+ * add (1),
+ * delete (2),
+ * modify (4),
+ * modDN (8).
*/
private int changeTypes;
+
+ /** Definition of the change types */
+ public static final int CHANGE_TYPE_ADD = 1;
+ public static final int CHANGE_TYPE_DELETE = 2;
+ public static final int CHANGE_TYPE_MODIFY = 4;
+ public static final int CHANGE_TYPE_MODDN = 8;
+
+ /** Min and Max values for the possible combined change types */
+ public static final int CHANGE_TYPES_MIN = CHANGE_TYPE_ADD;
+ public static final int CHANGE_TYPES_MAX = CHANGE_TYPE_ADD | CHANGE_TYPE_DELETE | CHANGE_TYPE_MODIFY | CHANGE_TYPE_MODDN;
+ /** A temporary storage for a psearch length */
private transient int psearchSeqLength;
- /**
- * Compute the PSearchControl length 0x30 L1 | +--> 0x02 0x0(1-4)
- * [0..2^31-1] (changeTypes) +--> 0x01 0x01 [0x00 | 0xFF] (changeOnly) +-->
- * 0x01 0x01 [0x00 | 0xFF] (returnRCs)
- */
- public int computeLength()
- {
- int changeTypesLength = 1 + 1 + Value.getNbBytes( changeTypes );
- int changesOnlyLength = 1 + 1 + 1;
- int returnRCsLength = 1 + 1 + 1;
-
- psearchSeqLength = changeTypesLength + changesOnlyLength + returnRCsLength;
-
- return 1 + Length.getNbBytes( psearchSeqLength ) + psearchSeqLength;
- }
-
-
public void setChangesOnly( boolean changesOnly )
{
this.changesOnly = changesOnly;
@@ -108,22 +110,39 @@
return changeTypes;
}
+ /**
+ * Compute the PSearchControl length
+ * 0x30 L1
+ * |
+ * +--> 0x02 0x0(1-4) [0..2^31-1] (changeTypes)
+ * +--> 0x01 0x01 [0x00 | 0xFF] (changeOnly)
+ * +--> 0x01 0x01 [0x00 | 0xFF] (returnRCs)
+ */
+ public int computeLength()
+ {
+ int changeTypesLength = 1 + 1 + Value.getNbBytes( changeTypes );
+ int changesOnlyLength = 1 + 1 + 1;
+ int returnRCsLength = 1 + 1 + 1;
+
+ psearchSeqLength = changeTypesLength + changesOnlyLength + returnRCsLength;
+
+ return 1 + TLV.getNbBytes( psearchSeqLength ) + psearchSeqLength;
+ }
+
/**
* Encodes the persistent search control.
*
- * @param buffer
- * The encoded sink
+ * @param buffer The encoded sink
* @return A ByteBuffer that contains the encoded PDU
- * @throws EncoderException
- * If anything goes wrong.
+ * @throws EncoderException If anything goes wrong.
*/
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
// Allocate the bytes buffer.
ByteBuffer bb = ByteBuffer.allocate( computeLength() );
bb.put( UniversalTag.SEQUENCE_TAG );
- bb.put( Length.getBytes( psearchSeqLength ) );
+ bb.put( TLV.getBytes( psearchSeqLength ) );
Value.encode( bb, changeTypes );
Value.encode( bb, changesOnly );
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlContainer.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlContainer.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlContainer.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlContainer.java Sun Oct 1 16:07:44 2006
@@ -22,7 +22,6 @@
import org.apache.directory.shared.asn1.ber.AbstractContainer;
import org.apache.directory.shared.asn1.ber.IAsn1Container;
-import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
/**
@@ -41,14 +40,8 @@
public PSearchControlContainer()
{
super();
- currentGrammar = 0;
- grammars = new IGrammar[PSearchControlStatesEnum.NB_GRAMMARS];
- grammarStack = new IGrammar[1];
stateStack = new int[1];
- nbGrammars = 0;
-
- grammars[PSearchControlStatesEnum.PSEARCH_GRAMMAR] = PSearchControlGrammar.getInstance();
- grammarStack[currentGrammar] = grammars[PSearchControlStatesEnum.PSEARCH_GRAMMAR];
+ grammar = PSearchControlGrammar.getInstance();
states = PSearchControlStatesEnum.getInstance();
}
@@ -67,15 +60,16 @@
* Set a PSearchControl Object into the container. It will be completed by
* the ldapDecoder.
*
- * @param control
- * the PSearchControl to set.
+ * @param control the PSearchControl to set.
*/
public void setPSearchControl( PSearchControl control )
{
this.control = control;
}
-
+ /**
+ * Clean the container
+ */
public void clean()
{
super.clean();
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlDecoder.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlDecoder.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlDecoder.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlDecoder.java Sun Oct 1 16:07:44 2006
@@ -37,17 +37,32 @@
*/
public class PSearchControlDecoder extends Asn1Decoder implements ControlDecoder
{
+ /** The persistence search OID */
private final static String CONTROL_TYPE_OID = "2.16.840.1.113730.3.4.3";
+ /** An instance of this decoder */
private static final Asn1Decoder decoder = new Asn1Decoder();
-
+ /**
+ * Return the persistence search OID
+ *
+ * @see org.apache.directory.shared.ldap.codec.ControlDecoder#getControlType()
+ */
public String getControlType()
{
return CONTROL_TYPE_OID;
}
-
+ /**
+ * Decode the persistence search control
+ *
+ * @param controlBytes The bytes array which contains the encoded persistence search
+ *
+ * @return A valid PersistenceSearch object
+ *
+ * @throws DecoderException If the decoding found an error
+ * @throws NamingException It will never be throw by this method
+ */
public Asn1Object decode( byte[] controlBytes ) throws DecoderException, NamingException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlGrammar.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlGrammar.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlGrammar.java Sun Oct 1 16:07:44 2006
@@ -32,7 +32,6 @@
import org.apache.directory.shared.asn1.util.BooleanDecoderException;
import org.apache.directory.shared.asn1.util.IntegerDecoder;
import org.apache.directory.shared.asn1.util.IntegerDecoderException;
-import org.apache.directory.shared.ldap.codec.LdapStatesEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,6 +40,20 @@
* This class implements the PSearchControl. All the actions are declared in
* this class. As it is a singleton, these declaration are only done once.
*
+ * The decoded grammar is the following :
+ *
+ * PersistenceSearch ::= SEQUENCE {
+ * changeTypes INTEGER, -- an OR combinaison of 0, 1, 2 and 4 --
+ * changeOnly BOOLEAN,
+ * returnECs BOOLEAN
+ * }
+ *
+ * The changeTypes field is the logical OR of one or more of these values:
+ * add (1),
+ * delete (2),
+ * modify (4),
+ * modDN (8).
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PSearchControlGrammar extends AbstractGrammar implements IGrammar
@@ -66,12 +79,18 @@
// Create the transitions table
super.transitions = new GrammarTransition[PSearchControlStatesEnum.LAST_PSEARCH_STATE][256];
- super.transitions[PSearchControlStatesEnum.PSEARCH_SEQUENCE_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
- PSearchControlStatesEnum.PSEARCH_SEQUENCE_TAG, PSearchControlStatesEnum.PSEARCH_SEQUENCE_VALUE, null );
-
- super.transitions[PSearchControlStatesEnum.PSEARCH_SEQUENCE_VALUE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
- PSearchControlStatesEnum.PSEARCH_SEQUENCE_VALUE, PSearchControlStatesEnum.CHANGE_TYPES_TAG,
- new GrammarAction( "Init PSearchControl" )
+ /**
+ * Transition from initial state to Psearch sequence
+ * PSearch ::= SEQUENCE OF {
+ * ...
+ *
+ * Initialize the persistence search object
+ */
+ super.transitions[PSearchControlStatesEnum.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE_TAG] =
+ new GrammarTransition( PSearchControlStatesEnum.INIT_GRAMMAR_STATE,
+ PSearchControlStatesEnum.PSEARCH_SEQUENCE_STATE,
+ UniversalTag.SEQUENCE_TAG,
+ new GrammarAction( "Init PSearchControl" )
{
public void action( IAsn1Container container )
{
@@ -81,12 +100,18 @@
}
} );
- super.transitions[PSearchControlStatesEnum.CHANGE_TYPES_TAG][UniversalTag.INTEGER_TAG] = new GrammarTransition(
- PSearchControlStatesEnum.CHANGE_TYPES_TAG, PSearchControlStatesEnum.CHANGE_TYPES_VALUE, null );
- super.transitions[PSearchControlStatesEnum.CHANGE_TYPES_VALUE][UniversalTag.INTEGER_TAG] = new GrammarTransition(
- PSearchControlStatesEnum.CHANGE_TYPES_VALUE, PSearchControlStatesEnum.CHANGES_ONLY_TAG, new GrammarAction(
- "Set PSearchControl changeTypes" )
+ /**
+ * Transition from Psearch sequence to Change types
+ * PSearch ::= SEQUENCE OF {
+ * changeTypes INTEGER, -- an OR combinaison of 0, 1, 2 and 4 --
+ * ...
+ *
+ * Stores the change types value
+ */
+ super.transitions[PSearchControlStatesEnum.PSEARCH_SEQUENCE_STATE][UniversalTag.INTEGER_TAG] =
+ new GrammarTransition( PSearchControlStatesEnum.PSEARCH_SEQUENCE_STATE, PSearchControlStatesEnum.CHANGE_TYPES_STATE, UniversalTag.INTEGER_TAG,
+ new GrammarAction( "Set PSearchControl changeTypes" )
{
public void action( IAsn1Container container ) throws DecoderException
{
@@ -95,8 +120,9 @@
try
{
- int changeTypes = IntegerDecoder.parse( value );
-
+ // Check that the value is into the allowed interval
+ int changeTypes = IntegerDecoder.parse( value, PSearchControl.CHANGE_TYPES_MIN, PSearchControl.CHANGE_TYPES_MAX );
+
if ( IS_DEBUG )
{
log.debug( "changeTypes = " + changeTypes );
@@ -113,12 +139,18 @@
}
} );
- super.transitions[PSearchControlStatesEnum.CHANGES_ONLY_TAG][UniversalTag.BOOLEAN_TAG] = new GrammarTransition(
- PSearchControlStatesEnum.CHANGES_ONLY_TAG, PSearchControlStatesEnum.CHANGES_ONLY_VALUE, null );
-
- super.transitions[PSearchControlStatesEnum.CHANGES_ONLY_VALUE][UniversalTag.BOOLEAN_TAG] = new GrammarTransition(
- PSearchControlStatesEnum.CHANGES_ONLY_VALUE, PSearchControlStatesEnum.RETURN_ECS_TAG, new GrammarAction(
- "Set PSearchControl changesOnly" )
+ /**
+ * Transition from Change types to Changes only
+ * PSearch ::= SEQUENCE OF {
+ * ...
+ * changeOnly BOOLEAN,
+ * ...
+ *
+ * Stores the change only flag
+ */
+ super.transitions[PSearchControlStatesEnum.CHANGE_TYPES_STATE][UniversalTag.BOOLEAN_TAG] =
+ new GrammarTransition( PSearchControlStatesEnum.CHANGE_TYPES_STATE, PSearchControlStatesEnum.CHANGES_ONLY_STATE, UniversalTag.BOOLEAN_TAG,
+ new GrammarAction( "Set PSearchControl changesOnly" )
{
public void action( IAsn1Container container ) throws DecoderException
{
@@ -145,12 +177,18 @@
}
} );
- super.transitions[PSearchControlStatesEnum.RETURN_ECS_TAG][UniversalTag.BOOLEAN_TAG] = new GrammarTransition(
- PSearchControlStatesEnum.RETURN_ECS_TAG, PSearchControlStatesEnum.RETURN_ECS_VALUE, null );
-
- super.transitions[PSearchControlStatesEnum.RETURN_ECS_VALUE][UniversalTag.BOOLEAN_TAG] = new GrammarTransition(
- PSearchControlStatesEnum.RETURN_ECS_VALUE, LdapStatesEnum.GRAMMAR_END, new GrammarAction(
- "Set PSearchControl returnECs" )
+ /**
+ * Transition from Change types to Changes only
+ * PSearch ::= SEQUENCE OF {
+ * ...
+ * returnECs BOOLEAN
+ * }
+ *
+ * Stores the return ECs flag
+ */
+ super.transitions[PSearchControlStatesEnum.CHANGES_ONLY_STATE][UniversalTag.BOOLEAN_TAG] =
+ new GrammarTransition( PSearchControlStatesEnum.CHANGES_ONLY_STATE, PSearchControlStatesEnum.RETURN_ECS_STATE, UniversalTag.BOOLEAN_TAG,
+ new GrammarAction( "Set PSearchControl returnECs" )
{
public void action( IAsn1Container container ) throws DecoderException
{
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlStatesEnum.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlStatesEnum.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlStatesEnum.java Sun Oct 1 16:07:44 2006
@@ -38,60 +38,36 @@
// =========================================================================
// Persistent search control grammar states
// =========================================================================
-
- /** Sequence Tag */
- public static int PSEARCH_SEQUENCE_TAG = 0;
+ /** Initial state */
+ public static final int START_STATE = 0;
/** Sequence Value */
- public static int PSEARCH_SEQUENCE_VALUE = 1;
-
- /** changeTypes Tag */
- public static int CHANGE_TYPES_TAG = 2;
+ public static int PSEARCH_SEQUENCE_STATE = 1;
/** changeTypes Value */
- public static int CHANGE_TYPES_VALUE = 3;
-
- /** changesOnly Tag */
- public static int CHANGES_ONLY_TAG = 4;
-
+ public static int CHANGE_TYPES_STATE = 3;
+
/** changesOnly Value */
- public static int CHANGES_ONLY_VALUE = 5;
-
- /** returnECs Tag */
- public static int RETURN_ECS_TAG = 6;
+ public static int CHANGES_ONLY_STATE = 5;
/** returnECs Value */
- public static int RETURN_ECS_VALUE = 7;
+ public static int RETURN_ECS_STATE = 7;
/** terminal state */
public static int LAST_PSEARCH_STATE = 8;
// =========================================================================
- // Grammars declaration.
- // =========================================================================
- /** PSsearch grammar */
- public static final int PSEARCH_GRAMMAR_SWITCH = 0x0100;
-
- /** PSearch grammar number */
- public static final int PSEARCH_GRAMMAR = 0;
-
- /** The total number of grammars used */
- public static final int NB_GRAMMARS = 1;
-
- // =========================================================================
- // Grammar switches debug strings
- // =========================================================================
- /** A string representation of grammars */
- private static String[] GrammarSwitchString = new String[]
- { "PSEARCH_GRAMMAR_SWITCH" };
-
- // =========================================================================
// States debug strings
// =========================================================================
/** A string representation of all the states */
private static String[] PSearchString = new String[]
- { "PSEARCH_SEQUENCE_TAG", "PSEARCH_SEQUENCE_VALUE", "CHANGE_TYPES_TAG", "CHANGE_TYPES_VALUE",
- "CHANGES_ONLY_TAG", "CHANGES_ONLY_VALUE", "RETURN_ECS_TAG", "RETURN_ECS_VALUE" };
+ {
+ "START_STATE",
+ "PSEARCH_SEQUENCE_VALUE",
+ "CHANGE_TYPES_STATE",
+ "CHANGES_ONLY_STATE",
+ "RETURN_ECS_STATE"
+ };
/** The instance */
private static PSearchControlStatesEnum instance = new PSearchControlStatesEnum();
@@ -125,27 +101,19 @@
/**
* Get the grammar name
*
- * @param grammar
- * The grammar code
+ * @param grammar The grammar code
* @return The grammar name
*/
public String getGrammarName( int grammar )
{
- switch ( grammar )
- {
- case PSEARCH_GRAMMAR:
- return "PSEARCH_GRAMMAR";
- default:
- return "UNKNOWN";
- }
+ return "PSEARCH_GRAMMAR";
}
/**
* Get the grammar name
*
- * @param grammar
- * The grammar class
+ * @param grammar The grammar class
* @return The grammar name
*/
public String getGrammarName( IGrammar grammar )
@@ -162,32 +130,11 @@
/**
* Get the string representing the state
*
- * @param grammar
- * The current grammar being used
- * @param state
- * The state number
+ * @param state The state number
* @return The String representing the state
*/
- public String getState( int grammar, int state )
+ public String getState( int state )
{
-
- if ( ( state & GRAMMAR_SWITCH_MASK ) != 0 )
- {
- return ( state == END_STATE ) ? "END_STATE"
- : GrammarSwitchString[( ( state & GRAMMAR_SWITCH_MASK ) >> 8 ) - 1];
- }
- else
- {
-
- switch ( grammar )
- {
-
- case PSEARCH_GRAMMAR:
- return ( ( state == GRAMMAR_END ) ? "PSEARCH_END_STATE" : PSearchString[state] );
-
- default:
- return "UNKNOWN";
- }
- }
+ return ( ( state == GRAMMAR_END ) ? "PSEARCH_END_STATE" : PSearchString[state] );
}
}
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControl.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControl.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControl.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControl.java Sun Oct 1 16:07:44 2006
@@ -28,7 +28,7 @@
/**
- * A searchRequest control.
+ * A searchRequest control : SubEntry
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
@@ -52,8 +52,7 @@
/**
* Set the visibility flag
*
- * @param visibility
- * The visibility flag : true or false
+ * @param visibility The visibility flag : true or false
*/
public void setVisibility( boolean visibility )
{
@@ -73,11 +72,9 @@
/**
* Encodes the subEntry control.
*
- * @param buffer
- * The encoded sink
+ * @param buffer The encoded sink
* @return A ByteBuffer that contains the encoded PDU
- * @throws EncoderException
- * If anything goes wrong.
+ * @throws EncoderException If anything goes wrong.
*/
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlContainer.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlContainer.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlContainer.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlContainer.java Sun Oct 1 16:07:44 2006
@@ -22,7 +22,6 @@
import org.apache.directory.shared.asn1.ber.AbstractContainer;
import org.apache.directory.shared.asn1.ber.IAsn1Container;
-import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
/**
@@ -35,20 +34,13 @@
/**
- * Creates a new SubEntryControlContainer object. We will store one grammar,
- * it's enough ...
+ * Creates a new SubEntryControlContainer object.
*/
public SubEntryControlContainer()
{
super();
- currentGrammar = 0;
- grammars = new IGrammar[SubEntryControlStatesEnum.NB_GRAMMARS];
- grammarStack = new IGrammar[1];
stateStack = new int[1];
- nbGrammars = 0;
-
- grammars[SubEntryControlStatesEnum.SUB_ENTRY_GRAMMAR] = SubEntryControlGrammar.getInstance();
- grammarStack[currentGrammar] = grammars[SubEntryControlStatesEnum.SUB_ENTRY_GRAMMAR];
+ grammar = SubEntryControlGrammar.getInstance();
states = SubEntryControlStatesEnum.getInstance();
}
@@ -58,7 +50,6 @@
*/
public SubEntryControl getSubEntryControl()
{
-
return control;
}
@@ -67,15 +58,16 @@
* Set a SubEntryControl Object into the container. It will be completed by
* the ldapDecoder.
*
- * @param control
- * the SubEntryControl to set.
+ * @param control the SubEntryControl to set.
*/
public void setSubEntryControl( SubEntryControl control )
{
this.control = control;
}
-
+ /**
+ * Clean the current container
+ */
public void clean()
{
super.clean();
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlDecoder.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlDecoder.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlDecoder.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlDecoder.java Sun Oct 1 16:07:44 2006
@@ -37,17 +37,30 @@
*/
public class SubEntryControlDecoder extends Asn1Decoder implements ControlDecoder
{
+ /** The sub entry OID */
private final static String CONTROL_TYPE_OID = "1.3.6.1.4.1.4203.1.10.1";
+ /** The sub entry decoder */
private static final Asn1Decoder decoder = new Asn1Decoder();
-
+ /**
+ * @return the sub entry OID
+ */
public String getControlType()
{
return CONTROL_TYPE_OID;
}
-
+ /**
+ * Decode the sub entry control
+ *
+ * @param controlBytes The bytes array which contains the encoded sub entry
+ *
+ * @return A valid SubEntry object
+ *
+ * @throws DecoderException If the decoding found an error
+ * @throws NamingException It will never be throw by this method
+ */
public Asn1Object decode( byte[] controlBytes ) throws DecoderException, NamingException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlGrammar.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlGrammar.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlGrammar.java Sun Oct 1 16:07:44 2006
@@ -62,13 +62,9 @@
// Create the transitions table
super.transitions = new GrammarTransition[SubEntryControlStatesEnum.LAST_SUB_ENTRY_STATE][256];
- super.transitions[SubEntryControlStatesEnum.SUB_ENTRY_VISIBILITY_TAG][UniversalTag.BOOLEAN_TAG] = new GrammarTransition(
- SubEntryControlStatesEnum.SUB_ENTRY_VISIBILITY_TAG, SubEntryControlStatesEnum.SUB_ENTRY_VISIBILITY_VALUE,
- null );
-
- super.transitions[SubEntryControlStatesEnum.SUB_ENTRY_VISIBILITY_VALUE][UniversalTag.BOOLEAN_TAG] = new GrammarTransition(
- SubEntryControlStatesEnum.SUB_ENTRY_VISIBILITY_VALUE, SubEntryControlStatesEnum.GRAMMAR_END,
- new GrammarAction( "SubEntryControl visibility" )
+ super.transitions[SubEntryControlStatesEnum.START_STATE][UniversalTag.BOOLEAN_TAG] =
+ new GrammarTransition( SubEntryControlStatesEnum.START_STATE, SubEntryControlStatesEnum.SUB_ENTRY_VISIBILITY_STATE, UniversalTag.BOOLEAN_TAG,
+ new GrammarAction( "SubEntryControl visibility" )
{
public void action( IAsn1Container container ) throws DecoderException
{
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlStatesEnum.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlStatesEnum.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlStatesEnum.java Sun Oct 1 16:07:44 2006
@@ -39,40 +39,24 @@
// Sub entry control grammar states
// =========================================================================
- /** Visibility Tag */
- public static int SUB_ENTRY_VISIBILITY_TAG = 0;
+ /** Starting state */
+ public static int START_STATE = 0;
/** Visibility Value */
- public static int SUB_ENTRY_VISIBILITY_VALUE = 1;
+ public static int SUB_ENTRY_VISIBILITY_STATE = 1;
/** terminal state */
public static int LAST_SUB_ENTRY_STATE = 2;
// =========================================================================
- // Grammars declaration.
- // =========================================================================
- /** PSsearch grammar */
- public static final int SUB_ENTRY_GRAMMAR_SWITCH = 0x0100;
-
- /** PSearch grammar number */
- public static final int SUB_ENTRY_GRAMMAR = 0;
-
- /** The total number of grammars used */
- public static final int NB_GRAMMARS = 1;
-
- // =========================================================================
- // Grammar switches debug strings
- // =========================================================================
- /** A string representation of grammars */
- private static String[] GrammarSwitchString = new String[]
- { "SUB_ENTRY_GRAMMAR_SWITCH" };
-
- // =========================================================================
// States debug strings
// =========================================================================
/** A string representation of all the states */
private static String[] SubEntryString = new String[]
- { "SUB_ENTRY_VISIBILITY_TAG", "SUB_ENTRY_VISIBILITY_VALUE", };
+ {
+ "START_STATE",
+ "SUB_ENTRY_VISIBILITY_STATE"
+ };
/** The instance */
private static SubEntryControlStatesEnum instance = new SubEntryControlStatesEnum();
@@ -106,27 +90,19 @@
/**
* Get the grammar name
*
- * @param grammar
- * The grammar code
+ * @param grammar The grammar code
* @return The grammar name
*/
public String getGrammarName( int grammar )
{
- switch ( grammar )
- {
- case SUB_ENTRY_GRAMMAR:
- return "SUB_ENTRY_GRAMMAR";
- default:
- return "UNKNOWN";
- }
+ return "SUB_ENTRY_GRAMMAR";
}
/**
* Get the grammar name
*
- * @param grammar
- * The grammar class
+ * @param grammar The grammar class
* @return The grammar name
*/
public String getGrammarName( IGrammar grammar )
@@ -143,32 +119,11 @@
/**
* Get the string representing the state
*
- * @param grammar
- * The current grammar being used
- * @param state
- * The state number
+ * @param state The state number
* @return The String representing the state
*/
- public String getState( int grammar, int state )
+ public String getState( int state )
{
-
- if ( ( state & GRAMMAR_SWITCH_MASK ) != 0 )
- {
- return ( state == END_STATE ) ? "END_STATE"
- : GrammarSwitchString[( ( state & GRAMMAR_SWITCH_MASK ) >> 8 ) - 1];
- }
- else
- {
-
- switch ( grammar )
- {
-
- case SUB_ENTRY_GRAMMAR:
- return ( ( state == GRAMMAR_END ) ? "SUB_ENTRY_END_STATE" : SubEntryString[state] );
-
- default:
- return "UNKNOWN";
- }
- }
+ return ( ( state == GRAMMAR_END ) ? "SUB_ENTRY_END_STATE" : SubEntryString[state] );
}
}
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequest.java Sun Oct 1 16:07:44 2006
@@ -29,8 +29,12 @@
/**
- * A UnBindRequest ldapObject. Its syntax is : UnbindRequest ::= [APPLICATION 2]
- * NULL This ldapObject is empty.
+ * A UnBindRequest ldapObject.
+ *
+ * Its syntax is :
+ * UnbindRequest ::= [APPLICATION 2] NULL
+ *
+ * This ldapObject is empty.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -66,7 +70,10 @@
/**
- * Compute the UnBindRequest length UnBindRequest : 0x42 00
+ * Compute the UnBindRequest length
+ *
+ * UnBindRequest :
+ * 0x42 00
*/
public int computeLength()
{
@@ -77,8 +84,7 @@
/**
* Encode the UnbindRequest message to a PDU.
*
- * @param buffer
- * The buffer where to put the PDU
+ * @param buffer The buffer where to put the PDU
* @return The PDU.
*/
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java Sun Oct 1 16:07:44 2006
@@ -21,7 +21,6 @@
import org.apache.directory.shared.asn1.codec.DecoderException;
-import org.apache.directory.shared.ldap.codec.util.LdapString;
import org.apache.directory.shared.ldap.filter.FilterParserImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -42,19 +41,28 @@
/**
- * Decodes a LdapUrl, and checks that it complies with the RFC 2255. The grammar
- * is the following : ldapurl = scheme "://" [hostport] ["/" [dn ["?"
- * [attributes] ["?" [scope] ["?" [filter] ["?" extensions]]]]]] scheme = "ldap"
- * attributes = attrdesc *("," attrdesc) scope = "base" / "one" / "sub" dn =
- * LdapDN hostport = hostport from Section 5 of RFC 1738 attrdesc =
- * AttributeDescription from Section 4.1.5 of RFC 2251 filter = filter from
- * Section 4 of RFC 2254 extensions = extension *("," extension) extension =
- * ["!"] extype ["=" exvalue] extype = token / xtoken exvalue = LDAPString token =
- * oid from section 4.1 of RFC 2252 xtoken = ("X-" / "x-") token
+ * Decodes a LdapUrl, and checks that it complies with
+ * the RFC 2255. The grammar is the following :
+ * ldapurl = scheme "://" [hostport] ["/"
+ * [dn ["?" [attributes] ["?" [scope]
+ * ["?" [filter] ["?" extensions]]]]]]
+ * scheme = "ldap"
+ * attributes = attrdesc *("," attrdesc)
+ * scope = "base" / "one" / "sub"
+ * dn = LdapDN
+ * hostport = hostport from Section 5 of RFC 1738
+ * attrdesc = AttributeDescription from Section 4.1.5 of RFC 2251
+ * filter = filter from Section 4 of RFC 2254
+ * extensions = extension *("," extension)
+ * extension = ["!"] extype ["=" exvalue]
+ * extype = token / xtoken
+ * exvalue = LDAPString
+ * token = oid from section 4.1 of RFC 2252
+ * xtoken = ("X-" / "x-") token
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class LdapURL extends LdapString
+public class LdapURL
{
// ~ Static fields/initializers
// -----------------------------------------------------------------
@@ -95,7 +103,12 @@
/** The criticals extensions */
private HashMap criticalExtensions;
+ /** Stores the LdapURL as a String */
+ private String string;
+ /** Stores the LdapURL as a byte array */
+ private byte[] bytes;
+
// ~ Constructors
// -------------------------------------------------------------------------------
@@ -115,7 +128,11 @@
criticalExtensions = new HashMap();
}
-
+ /**
+ * Parse a LdapURL
+ * @param chars The chars containing the URL
+ * @throws LdapURLEncodingException If the URL is invalid
+ */
public void parse( char[] chars ) throws LdapURLEncodingException
{
host = null;
@@ -277,13 +294,11 @@
/**
* Create a new LdapURL from a String after having parsed it.
*
- * @param string
- * TheString that contains the LDAPURL
+ * @param string TheString that contains the LDAPURL
* @return A MutableString containing the LDAPURL
- * @throws DecoderException
- * If the String does not comply with RFC 2255
+ * @throws DecoderException If the String does not comply with RFC 2255
*/
- public LdapURL(String string) throws LdapURLEncodingException
+ public LdapURL( String string ) throws LdapURLEncodingException
{
if ( string == null )
{
@@ -306,11 +321,9 @@
/**
* Create a new LdapURL after having parsed it.
*
- * @param bytes
- * The byte buffer that contains the LDAPURL
+ * @param bytes The byte buffer that contains the LDAPURL
* @return A MutableString containing the LDAPURL
- * @throws DecoderException
- * If the byte array does not comply with RFC 2255
+ * @throws DecoderException If the byte array does not comply with RFC 2255
*/
public LdapURL(byte[] bytes) throws LdapURLEncodingException
{
@@ -350,10 +363,8 @@
* <digits> "." <digits>
* </p>
*
- * @param chars
- * The buffer to parse
- * @param pos
- * The current position in the byte buffer
+ * @param chars The buffer to parse
+ * @param pos The current position in the byte buffer
* @return The new position in the byte buffer, or -1 if the rule does not
* apply to the byte buffer TODO check that the topLabel is valid
* (it must start with an alpha)
@@ -508,10 +519,8 @@
* </p>
* The port must be between 0 and 65535.
*
- * @param chars
- * The buffer to parse
- * @param pos
- * The current position in the byte buffer
+ * @param chars The buffer to parse
+ * @param pos The current position in the byte buffer
* @return The new position in the byte buffer, or -1 if the rule does not
* apply to the byte buffer
*/
@@ -549,10 +558,8 @@
* <hostport> ::= <host> ':' <port>
* </p>
*
- * @param chars
- * The char array to parse
- * @param pos
- * The current position in the byte buffer
+ * @param chars The char array to parse
+ * @param pos The current position in the byte buffer
* @return The new position in the byte buffer, or -1 if the rule does not
* apply to the byte buffer
*/
@@ -589,14 +596,10 @@
* characters to a string. If the specified charset is not supported,
* default system encoding is used.
*
- * @param data
- * the byte array to be encoded
- * @param offset
- * the index of the first byte to encode
- * @param length
- * the number of bytes to encode
- * @param charset
- * the desired character encoding
+ * @param data the byte array to be encoded
+ * @param offset the index of the first byte to encode
+ * @param length the number of bytes to encode
+ * @param charset the desired character encoding
* @return The result of the conversion.
* @since 3.0
*/
@@ -628,10 +631,8 @@
* characters to a string. If the specified charset is not supported,
* default system encoding is used.
*
- * @param data
- * the byte array to be encoded
- * @param charset
- * the desired character encoding
+ * @param data the byte array to be encoded
+ * @param charset the desired character encoding
* @return The result of the conversion.
* @since 3.0
*/
@@ -644,8 +645,7 @@
/**
* Converts the specified string to byte array of ASCII characters.
*
- * @param data
- * the string to be encoded
+ * @param data the string to be encoded
* @return The string as a byte array.
* @since 3.0
*/
@@ -673,11 +673,9 @@
* array of original bytes. Escaped characters are converted back to their
* original representation.
*
- * @param bytes
- * array of URL safe characters
+ * @param bytes array of URL safe characters
* @return array of original bytes
- * @throws DecoderException
- * Thrown if URL decoding is unsuccessful
+ * @throws DecoderException Thrown if URL decoding is unsuccessful
*/
private static final byte[] decodeUrl( byte[] bytes ) throws UrlDecoderException
{
@@ -729,11 +727,9 @@
* From commons-httpclients. Unescape and decode a given string regarded as
* an escaped string with the default protocol charset.
*
- * @param escaped
- * a string
+ * @param escaped a string
* @return the unescaped string
- * @throws URIException
- * if the string cannot be decoded (invalid)
+ * @throws URIException if the string cannot be decoded (invalid)
* @see URI#getDefaultProtocolCharset
*/
private static String decode( String escaped ) throws URIException
@@ -754,10 +750,8 @@
* Parse a string and check that it complies with RFC 2253. Here, we will
* just call the LdapDN parser to do the job.
*
- * @param chars
- * The char array to be checked
- * @param pos
- * the starting position
+ * @param chars The char array to be checked
+ * @param pos the starting position
* @return -1 if the char array does not contains a DN
*/
private int parseDN( char[] chars, int pos )
@@ -790,10 +784,8 @@
/**
* Parse the attributes part
*
- * @param chars
- * The char array to be checked
- * @param pos
- * the starting position
+ * @param chars The char array to be checked
+ * @param pos the starting position
* @return -1 if the char array does not contains attributes
*/
private int parseAttributes( char[] chars, int pos )
@@ -900,10 +892,8 @@
/**
* Parse the filter part. We will use the FilterParserImpl class
*
- * @param chars
- * The char array to be checked
- * @param pos
- * the starting position
+ * @param chars The char array to be checked
+ * @param pos the starting position
* @return -1 if the char array does not contains a filter
*/
private int parseFilter( char[] chars, int pos )
@@ -941,10 +931,8 @@
/**
* Parse the scope part.
*
- * @param chars
- * The char array to be checked
- * @param pos
- * the starting position
+ * @param chars The char array to be checked
+ * @param pos the starting position
* @return -1 if the char array does not contains a scope
*/
private int parseScope( char[] chars, int pos )
@@ -1018,14 +1006,14 @@
/**
- * Parse extensions and critical extensions. The grammar is : extensions ::=
- * extension [ ',' extension ]* extension ::= [ '!' ] ( token | ( 'x-' |
- * 'X-' ) token ) ) [ '=' exvalue ]
+ * Parse extensions and critical extensions.
*
- * @param char
- * The char array to be checked
- * @param pos
- * the starting position
+ * The grammar is :
+ * extensions ::= extension [ ',' extension ]*
+ * extension ::= [ '!' ] ( token | ( 'x-' | 'X-' ) token ) ) [ '=' exvalue ]
+ *
+ * @param char The char array to be checked
+ * @param pos the starting position
* @return -1 if the char array does not contains valid extensions or
* critical extensions
*/
@@ -1153,15 +1141,16 @@
/**
- * Encode a String to avoid special characters *NOTE* : this is an ugly
- * function, just needed because the RFC 2255 is VERY unclear about the way
- * LDAP searches are to be encoded. Some references to RFC 1738 are made,
- * but they are really useless and inadequat.
+ * Encode a String to avoid special characters
+ *
+ * *NOTE* : this is an ugly function, just needed because the RFC 2255
+ * is VERY unclear about the way LDAP searches are to be encoded.
*
- * @param string
- * The String to encode
- * @param doubleEncode
- * Set if we need to encode the comma
+ * Some references to RFC 1738 are made, but they are really useless
+ * and inadequat.
+ *
+ * @param string The String to encode
+ * @param doubleEncode Set if we need to encode the comma
* @return An encoded string
*/
private String urlEncode( String string, boolean doubleEncode )
@@ -1423,5 +1412,29 @@
public String getScheme()
{
return scheme;
+ }
+
+ /**
+ * @return the number of bytes for this LdapURL
+ */
+ public int getNbBytes()
+ {
+ return ( bytes != null ? bytes.length : 0 );
+ }
+
+ /**
+ * @return the bytes representing this LdapURL
+ */
+ public byte[] getBytes()
+ {
+ return bytes;
+ }
+
+ /**
+ * @return the LdapURL as a String
+ */
+ public String getString()
+ {
+ return string;
}
}
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java Sun Oct 1 16:07:44 2006
@@ -1413,6 +1413,8 @@
}
}
+ isFirstLine = false;
+
// We will read the first line which is not a comment
switch ( line.charAt( 0 ) )
{
@@ -1421,8 +1423,6 @@
break;
case ' ':
- isFirstLine = false;
-
if ( insideComment )
{
continue;
@@ -1441,8 +1441,6 @@
break;
default:
- isFirstLine = false;
-
// We have found a new entry
// First, stores the previous one if any.
if ( sb.length() != 0 )
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AbstractMessage.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AbstractMessage.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AbstractMessage.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AbstractMessage.java Sun Oct 1 16:07:44 2006
@@ -19,8 +19,10 @@
*/
package org.apache.directory.shared.ldap.message;
-
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
/**
@@ -34,7 +36,7 @@
static final long serialVersionUID = 7601738291101182094L;
/** Map of message controls using OID Strings for keys and Control values */
- private final Map controls;
+ private Map controls;
/** The session unique message sequence identifier */
private final int id;
@@ -88,6 +90,13 @@
return Collections.unmodifiableMap( controls );
}
+ /**
+ * Initialize the controls list
+ */
+ public void initControls()
+ {
+ controls = new HashMap();
+ }
/**
* Adds a control to this Message.
@@ -203,12 +212,14 @@
}
Map controls = msg.getControls();
+
if ( controls.size() != this.controls.size() )
{
return false;
}
Iterator list = this.controls.keySet().iterator();
+
while ( list.hasNext() )
{
if ( !controls.containsKey( list.next() ) )