directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r348987 - in /directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec: StoredProcedureContainer.java StoredProcedureEnum.java StoredProcedureGrammar.java
Date Fri, 25 Nov 2005 17:30:22 GMT
Author: elecharny
Date: Fri Nov 25 09:30:16 2005
New Revision: 348987

URL: http://svn.apache.org/viewcvs?rev=348987&view=rev
Log:
created the first brew of StoredProcedure codec

Added:
    directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureContainer.java
    directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureEnum.java
    directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureGrammar.java

Added: directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureContainer.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureContainer.java?rev=348987&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureContainer.java
(added)
+++ directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureContainer.java
Fri Nov 25 09:30:16 2005
@@ -0,0 +1,87 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.ldap.server.storedprocs.codec;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.asn1new.ber.AbstractContainer;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1.codec.util.StringUtils;
+import org.apache.ldap.server.storedprocs.StoredProcedurePojo;
+
+
+/**
+ *  
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureContainer extends AbstractContainer implements IAsn1Container
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The pojo */
+    private StoredProcedurePojo storedProcedurePojo;
+    
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     */
+    public StoredProcedureContainer()
+    {
+        super( );
+        currentGrammar = 0;
+        grammars = new IGrammar[1];
+        grammarStack = new IGrammar[1];
+        stateStack = new int[1];
+        nbGrammars = 0;
+
+        grammars[StoredProcedureEnum.STORED_PROCEDURE_GRAMMAR] = StoredProcedureGrammar.getInstance();

+
+        grammarStack[currentGrammar] = grammars[StoredProcedureEnum.STORED_PROCEDURE_GRAMMAR];
+        
+        states = StoredProcedureEnum.getInstance();
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+    /**
+     * @return Returns the ldapMessage.
+     */
+    public StoredProcedurePojo getStoredProcedurePojo()
+    {
+
+        return storedProcedurePojo;
+    }
+
+    /**
+     * Set a ldapMessage Object into the container. It will be completed
+     * by the ldapDecoder .
+     *
+     * @param ldapMessage The ldapMessage to set.
+     */
+    public void setStoredProcedurePojo( StoredProcedurePojo storedProcedurePojo )
+    {
+        this.storedProcedurePojo = storedProcedurePojo;
+    }
+    
+    public void clean()
+    {
+    	super.clean();
+    	
+    	storedProcedurePojo = null;
+    }
+}

Added: directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureEnum.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureEnum.java?rev=348987&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureEnum.java
(added)
+++ directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureEnum.java
Fri Nov 25 09:30:16 2005
@@ -0,0 +1,208 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.ldap.server.storedprocs.codec;
+
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ber.grammar.IStates;
+
+
+/**
+ * This class store the Ldap grammar's constants.
+ * It is also used for debugging purpose
+ * 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureEnum implements IStates
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    //=========================================================================
+    // StoredProcedure
+    //=========================================================================
+    /** StoredProcedure Tag */
+    public static int STORED_PROCEDURE_TAG = 0;
+
+    /** StoredProcedure Value */
+    public static int STORED_PROCEDURE_VALUE = 1;
+
+    // Language ---------------------------------------------------------------
+    /** Language Tag */
+    public static int LANGUAGE_TAG = 2;
+
+    /** Language Value */
+    public static int LANGUAGE_VALUE = 3;
+
+    // Procedure --------------------------------------------------------------
+    /** Procedure Tag */
+    public static int PROCEDURE_TAG = 4;
+
+    /** Procedure Value */
+    public static int PROCEDURE_VALUE = 5;
+
+    // Parameters -------------------------------------------------------------
+    /** Parameters Tag */
+    public static int PARAMETERS_TAG = 6;
+
+    /** Parameters Value */
+    public static int PARAMETERS_VALUE = 7;
+
+    // Parameter type ---------------------------------------------------------
+    /** Parameter type Tag */
+    public static int PARAMETER_TYPE_TAG = 8;
+
+    /** Parameter type Value */
+    public static int PARAMETER_TYPE_VALUE = 9;
+
+    // Parameters value -------------------------------------------------------
+    /** Parameter value Tag */
+    public static int PARAMETER_VALUE_TAG = 10;
+
+    /** Parameter value Value */
+    public static int PARAMETER_VALUE_VALUE = 11;
+    
+    public static int LAST_STORED_PROCEDURE_STATE = 12;
+    
+    //=========================================================================
+    // Grammars declaration.
+    //=========================================================================
+    /** Ldap Message Grammar */
+    public static final int STORED_PROCEDURE_GRAMMAR_SWITCH = 0x0100;
+
+    /** LdapMessage grammar number */
+    public static final int STORED_PROCEDURE_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[]
+        {
+            "STORED_PROCEDURE_GRAMMAR_SWITCH", 
+        };
+
+    //=========================================================================
+    // States debug strings 
+    //=========================================================================
+    /** A string representation of all the states */
+    private static String[] StoredProcedureString =
+        new String[]
+        {
+        	"STORED_PROCEDURE_TAG",
+        	"STORED_PROCEDURE_VALUE",
+        	"LANGUAGE_TAG",
+        	"LANGUAGE_VALUE",
+        	"PROCEDURE_TAG",
+        	"PROCEDURE_VALUE",
+        	"PARAMETERS_TAG",
+        	"PARAMETERS_VALUE",
+        	"PARAMETER_TYPE_TAG",
+        	"PARAMETER_TYPE_VALUE",
+        	"PARAMETER_VALUE_TAG",
+        	"PARAMETER_VALUE_VALUE"
+        };
+
+    /** The instance */
+    private static StoredProcedureEnum instance = new StoredProcedureEnum();
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * This is a private constructor. This class is a singleton
+     *
+     */
+    private StoredProcedureEnum()
+    {
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get an instance of this class
+     * @return An instance on this class
+     */
+    public static IStates getInstance()
+    {
+        return instance;
+    }
+    
+    /**
+     * Get the grammar name
+     * @param The grammar code
+     * @return The grammar name
+     */
+    public String getGrammarName(int grammar)
+    {
+        switch (grammar)
+        {
+            case STORED_PROCEDURE_GRAMMAR            : return "STORED_PROCEDURE_GRAMMAR";
+
+        	default                              : return "UNKNOWN";
+        }
+    }
+
+    /**
+     * Get the grammar name
+     * @param The grammar class
+     * @return The grammar name
+     */
+    public String getGrammarName(IGrammar grammar)
+    {
+        if (grammar instanceof StoredProcedureGrammar)
+        {
+            return "STORED_PROCEDURE_GRAMMAR";
+        }
+        else 
+        {
+            return "UNKNOWN GRAMMAR";
+        }
+    }
+
+    /**
+     * Get the string representing the state
+     * 
+     * @param grammar The current grammar being used
+     * @param state The state number
+     * @return The String representing the state
+     */
+    public String getState( int grammar, 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 STORED_PROCEDURE_GRAMMAR :
+                    return ( ( state == GRAMMAR_END ) ? "STORED_PROCEDURE_END_STATE" : StoredProcedureString[state]
);
+
+                default :
+                    return "UNKNOWN";
+            }
+        }
+    }
+}

Added: directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureGrammar.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureGrammar.java?rev=348987&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureGrammar.java
(added)
+++ directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureGrammar.java
Fri Nov 25 09:30:16 2005
@@ -0,0 +1,370 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.ldap.server.storedprocs.codec;
+
+import javax.naming.InvalidNameException;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.AbstractGrammar;
+import org.apache.asn1new.ber.grammar.GrammarAction;
+import org.apache.asn1new.ber.grammar.GrammarTransition;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ber.tlv.TLV;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1.codec.util.StringUtils;
+import org.apache.ldap.server.storedprocs.StoredProcedurePojo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the SearchResultEntry LDAP message. All the actions are declared
in this
+ * class. As it is a singleton, these declaration are only done once.
+ * 
+ * We have to deal with empty elements, as stated by rfc 2251 :
+ * 
+ * -- implementors should note that the PartialAttributeList may
+ * -- have zero elements (if none of the attributes of that entry
+ * -- were requested, or could be returned), and that the vals set
+ * -- may also have zero elements (if types only was requested, or
+ * -- all values were excluded from the result.)
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureGrammar extends AbstractGrammar implements IGrammar
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoredProcedureGrammar.class
);
+
+    /** The instance of grammar. SearchResultEntryGrammar is a singleton */
+    private static IGrammar instance = new StoredProcedureGrammar();
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new SearchResultEntryGrammar object.
+     */
+    private StoredProcedureGrammar()
+    {
+        name       = StoredProcedureGrammar.class.getName();
+        statesEnum = StoredProcedureEnum.getInstance();
+
+        // Create the transitions table
+        super.transitions = new GrammarTransition[StoredProcedureEnum.LAST_STORED_PROCEDURE_STATE][256];
+
+        //============================================================================================
+        // StoredProcedure Message
+        //============================================================================================
+        // StoredProcedure ::= SEQUENCE { (Tag)
+        //   ...
+        // Nothing to do.
+        super.transitions[StoredProcedureEnum.STORED_PROCEDURE_TAG][UniversalTag.SEQUENCE_TAG]
= new GrammarTransition(
+        		StoredProcedureEnum.STORED_PROCEDURE_TAG, StoredProcedureEnum.STORED_PROCEDURE_VALUE,
+                null );
+
+        // StoredProcedure ::= SEQUENCE { (Value)
+        //   ...
+        // Nothing to do.
+        super.transitions[StoredProcedureEnum.STORED_PROCEDURE_VALUE][UniversalTag.SEQUENCE_TAG]
= new GrammarTransition(
+        		StoredProcedureEnum.STORED_PROCEDURE_VALUE,
+        		StoredProcedureEnum.LANGUAGE_TAG, null );
+
+        //    language OCTETSTRING, (Tag)
+        //    ...
+        // Nothing to do
+        super.transitions[StoredProcedureEnum.LANGUAGE_TAG][UniversalTag.OCTET_STRING_TAG]
=
+            new GrammarTransition(
+            		StoredProcedureEnum.LANGUAGE_TAG,
+            		StoredProcedureEnum.LANGUAGE_VALUE, null );
+
+        //    language OCTETSTRING, (Tag)
+        //    ...
+        // Store the language.
+        super.transitions[StoredProcedureEnum.LANGUAGE_VALUE][UniversalTag.OCTET_STRING_TAG]
=
+            new GrammarTransition(
+            		StoredProcedureEnum.LANGUAGE_VALUE,
+            		StoredProcedureEnum.PROCEDURE_TAG,
+                new GrammarAction( "Create the pojo" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer
)
+                            container;
+
+                        TLV                  tlv                  =
+                        	storedProcedureContainer.getCurrentTLV();
+
+                        // Store the value.
+                        if ( tlv.getLength().getLength() == 0 )
+                        {
+                        	// This is supposed to be Java
+                            StoredProcedurePojo storedProcedurePojo = new StoredProcedurePojo();
+                        }
+                        else
+                        {
+                        	String language = StringUtils.toUtf8( tlv.getValue().getData() );
+                            
+                        	if ( "java".compareToIgnoreCase( language ) == 0 )
+                        	{
+                        		StoredProcedurePojo storedProcedurePojo = new StoredProcedurePojo();
+                        	}
+                        	else
+                        	{
+                                log.error( "The language " + StringUtils.dumpBytes( tlv.getValue().getData()
) + " is invalid" );
+                                throw new DecoderException( "The language " + StringUtils.dumpBytes(
tlv.getValue().getData() ) + " is invalid" );
+                        	}
+                        }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Language found : java " );
+                        }
+                    }
+                } );
+
+/*
+        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
+        //    attributes      PartialAttributeList }
+        // PartialAttributeList ::= *SEQUENCE* OF SEQUENCE { (Tag)
+        //    ...
+        // Nothing to do
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTES_TAG][UniversalTag.SEQUENCE_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTES_TAG,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTES_VALUE, null );
+
+        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
+        //    attributes      PartialAttributeList }
+        // PartialAttributeList ::= *SEQUENCE* OF SEQUENCE { (Tag)
+        //    ...
+        // We may have many attributes. Nothing to do
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTES_VALUE][UniversalTag.SEQUENCE_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTES_VALUE,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_PARTIAL_ATTRIBUTE_LIST_TAG, null );
+
+        // PartialAttributeList ::= SEQUENCE OF *SEQUENCE* { (Tag)
+        //    ...
+        // Nothing to do
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_PARTIAL_ATTRIBUTE_LIST_TAG][UniversalTag.SEQUENCE_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_PARTIAL_ATTRIBUTE_LIST_TAG,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_PARTIAL_ATTRIBUTE_LIST_VALUE, null );
+
+        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
+        //    attributes      PartialAttributeList }
+        // PartialAttributeList ::= SEQUENCE OF *SEQUENCE* { (Tag)
+        //    ...
+        // Loop.
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_OR_LIST_TAG][UniversalTag.SEQUENCE_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_OR_LIST_TAG,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_PARTIAL_ATTRIBUTE_LIST_VALUE, null );
+
+        // PartialAttributeList ::= SEQUENCE OF *SEQUENCE* { (Value)
+        //    ...
+        // We may have many attributes. We also have to store a previously decoded AttributeValue
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_PARTIAL_ATTRIBUTE_LIST_VALUE][UniversalTag.SEQUENCE_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_PARTIAL_ATTRIBUTE_LIST_VALUE,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_TYPE_TAG,
+                new GrammarAction( "Store attributeValue" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage          ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        SearchResultEntry    searchResultEntry    =
+                            ldapMessage.getSearchResultEntry();
+
+                        searchResultEntry.addPartialAttributeList();
+                    }
+                } );
+
+        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+        //    type    AttributeDescription, (Tag)
+        //    ...
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_TYPE_TAG][UniversalTag.OCTET_STRING_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_TYPE_TAG,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_TYPE_VALUE, null );
+
+        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+        //    type    AttributeDescription, (Value)
+        //    ...
+        // Store the attribute's name.
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_TYPE_VALUE][UniversalTag.OCTET_STRING_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_TYPE_VALUE,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_VALS_TAG,
+                new GrammarAction( "Store search result entry object name Value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage          ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        SearchResultEntry    searchResultEntry    =
+                            ldapMessage.getSearchResultEntry();
+
+                        TLV                  tlv                  =
+                            ldapMessageContainer.getCurrentTLV();
+
+                        LdapString type = LdapString.EMPTY_STRING;
+
+                        // Store the name
+                        if ( tlv.getLength().getLength() == 0 )
+                        {
+                            searchResultEntry.addAttributeValues( type );
+                        }
+                        else
+                        {
+                            try
+                            {
+                                type = new LdapString( tlv.getValue().getData() );
+                                searchResultEntry.addAttributeValues( type );
+                            }
+                            catch ( LdapStringEncodingException lsee )
+                            {
+                                log.error( "Invalid attribute type : " + StringUtils.dumpBytes(
tlv.getValue().getData() ) );
+                                throw new DecoderException( "The attribute type is invalid
: " + lsee.getMessage() );
+                            }
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Attribute type : " + type );
+                        }
+                    }
+                } );
+
+        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+        //    ...
+        //    vals    *SET OF* AttributeValue} (Tag)
+        // Nothing to do
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_VALS_TAG][UniversalTag.SET_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_VALS_TAG,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_VALS_VALUE, null );
+
+        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+        //    ...
+        //    vals    *SET OF* AttributeValue} (Value)
+        // We may have many values. Nothing to do
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_VALS_VALUE][UniversalTag.SET_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_VALS_VALUE,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_TAG, null );
+
+        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+        //    ...
+        //    vals    SET OF *AttributeValue*} (Tag)
+        // Nothing to do
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_TAG][UniversalTag.OCTET_STRING_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_TAG,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_VALUE, null );
+
+        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+        //    ...
+        //    vals    SET OF *AttributeValue*} (Tag)
+        // The loop.
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_OR_LIST_TAG][UniversalTag.OCTET_STRING_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_OR_LIST_TAG,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_VALUE, null );
+
+        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+        //    ...
+        //    vals    SET OF *AttributeValue*} (Value)
+        // We may have many values. Store the current one in the current Attribute Value
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_VALUE][UniversalTag.OCTET_STRING_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_VALUE,
+                LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTE_VALUE_OR_LIST_TAG,
+                new GrammarAction( "Store Attribute Value value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage          ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        SearchResultEntry    searchResultEntry    =
+                            ldapMessage.getSearchResultEntry();
+
+                        TLV                  tlv                  =
+                            ldapMessageContainer.getCurrentTLV();
+
+                        // Store the value
+                        Object value = null;
+                        
+                        if ( tlv.getLength().getLength() == 0 )
+                        {
+                            searchResultEntry.addAttributeValue( "" );
+                        }
+                        else
+                        {
+                            if (ldapMessageContainer.isBinary( searchResultEntry.getCurrentAttributeValueType()
) )
+                            {
+                                value = tlv.getValue().getData();
+                                
+                                if ( log.isDebugEnabled() )
+                                {
+                                    log.debug( "Attribute value " + StringUtils.dumpBytes(
(byte[])value ) );
+                                }
+                            }
+                            else
+                            {
+                                value = StringUtils.toUtf8( tlv.getValue().getData() );
+
+                                if ( log.isDebugEnabled() )
+                                {
+                                    log.debug( "Attribute value " + value );
+                                }
+                            }
+
+                            searchResultEntry.addAttributeValue( value );
+                        }
+                    }
+                } );
+*/
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the instance of this grammar
+     *
+     * @return An instance on the SearchResultEntry Grammar
+     */
+    public static IGrammar getInstance()
+    {
+        return instance;
+    }
+}



Mime
View raw message