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 2005/06/22 07:25:41 UTC
svn commit: r191767 -
/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultEntryGrammar.java
Author: elecharny
Date: Tue Jun 21 22:25:40 2005
New Revision: 191767
URL: http://svn.apache.org/viewcvs?rev=191767&view=rev
Log:
Deleted the useless LENGTH transitions
Added:
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultEntryGrammar.java
Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultEntryGrammar.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultEntryGrammar.java?rev=191767&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultEntryGrammar.java (added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultEntryGrammar.java Tue Jun 21 22:25:40 2005
@@ -0,0 +1,157 @@
+/*
+ * 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.asn1.ldap.codec.grammars;
+
+import org.apache.asn1.DecoderException;
+import org.apache.asn1.ber.containers.IAsn1Container;
+import org.apache.asn1.ber.grammar.AbstractGrammar;
+import org.apache.asn1.ber.grammar.GrammarAction;
+import org.apache.asn1.ber.grammar.GrammarTransition;
+import org.apache.asn1.ber.grammar.IGrammar;
+import org.apache.asn1.ber.tlv.TLV;
+import org.apache.asn1.ldap.codec.LdapMessageContainer;
+import org.apache.asn1.ldap.codec.primitives.LdapDN;
+import org.apache.asn1.ldap.pojo.LdapMessage;
+import org.apache.asn1.ldap.pojo.SearchResultEntry;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * 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 SearchResultEntryGrammar extends AbstractGrammar implements IGrammar
+{
+ //~ Static fields/initializers -----------------------------------------------------------------
+
+ /** The logger */
+ private static final Logger log = Logger.getLogger( SearchResultEntryGrammar.class );
+
+ /** Logging speed up */
+ private static final boolean DEBUG = log.isDebugEnabled();
+
+ /** The instance of grammar. SearchResultEntryGrammar is a singleton */
+ private static IGrammar instance = new SearchResultEntryGrammar();
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ /**
+ * Creates a new SearchResultEntryGrammar object.
+ */
+ private SearchResultEntryGrammar()
+ {
+ name = SearchResultEntryGrammar.class.getName();
+ statesEnum = LdapStatesEnum.getInstance();
+
+ // Intitialisation
+ super.transitions = new GrammarTransition[LdapStatesEnum.LAST_SEARCH_RESULT_ENTRY_STATE][256];
+
+ //============================================================================================
+ // SearchResultEntry Message
+ //============================================================================================
+ // LdapMessage ::= ... SearchResultEntry ...
+ // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { (Tag)
+ // Nothing to do.
+ super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_TAG][0x64] = new GrammarTransition(
+ LdapStatesEnum.SEARCH_RESULT_ENTRY_TAG, LdapStatesEnum.SEARCH_RESULT_ENTRY_VALUE, null );
+
+ // LdapMessage ::= ... SearchResultEntry ...
+ // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { (Value)
+ // Nothing to do.
+ super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_VALUE][0x64] = new GrammarTransition(
+ LdapStatesEnum.SEARCH_RESULT_ENTRY_VALUE, LdapStatesEnum.SEARCH_RESULT_ENTRY_OBJECT_NAME_TAG,
+ new GrammarAction( "Init SearchResultEntry" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+ // Now, we can allocate the SearchResultEntry Object
+ // And we associate it to the ldapMessage Object
+ ldapMessage.setProtocolOP( new SearchResultEntry() );
+ }
+ } );
+
+ // LdapMessage ::= ... SearchResultEntry ...
+ // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
+ // objectName LDAPDN, (Tag)
+ // ...
+ // Nothing to do
+ super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_OBJECT_NAME_TAG][0x04] = new GrammarTransition(
+ LdapStatesEnum.SEARCH_RESULT_ENTRY_OBJECT_NAME_TAG, LdapStatesEnum.SEARCH_RESULT_ENTRY_OBJECT_NAME_VALUE, null );
+
+ // LdapMessage ::= ... SearchResultEntry ...
+ // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
+ // objectName LDAPDN, (Value)
+ // ...
+ // Store the object name.
+ super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_OBJECT_NAME_VALUE][0x04] = new GrammarTransition(
+ LdapStatesEnum.SEARCH_RESULT_ENTRY_OBJECT_NAME_VALUE, LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTES_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();
+
+ // Store the value.
+ searchResultEntry.setObjectName( new LdapDN( tlv.getValue().getData() ) );
+ }
+ } );
+
+ // 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_TAG][0x30] = new GrammarTransition(
+ LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTES_TAG, LdapStatesEnum.SEARCH_RESULT_ENTRY_ATTRIBUTES_VALUE, null );
+
+
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ /**
+ * Get the instance of this grammar
+ *
+ * @return An instance on the SearchResultEntry Grammar
+ */
+ public static IGrammar getInstance()
+ {
+ return instance;
+ }
+}