Author: elecharny
Date: Mon May 30 15:19:55 2005
New Revision: 179162
URL: http://svn.apache.org/viewcvs?rev=179162&view=rev
Log:
- deleted the unecessary states (mainly the ones that deals with the following states).
- reformating the code
Modified:
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapResultGrammar.java
Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapResultGrammar.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapResultGrammar.java?rev=179162&r1=179161&r2=179162&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapResultGrammar.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapResultGrammar.java
Mon May 30 15:19:55 2005
@@ -66,7 +66,7 @@
private LdapResultGrammar()
{
name = LdapResultGrammar.class.getName();
- statesEnum = LdapStatesEnum.getInstance();
+ statesEnum = LdapStatesEnum.getInstance();
super.transitions = new GrammarTransition[LdapStatesEnum.LDAP_RESULT_LAST_STATE][256];
@@ -100,7 +100,7 @@
// We have to allocate a LdapResultPOJO now
LdapResultPOJO ldapResult = null;
- ldapResult = new LdapResultPOJO();
+ ldapResult = new LdapResultPOJO();
bindResponse.setLdapResult( ldapResult );
TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -246,16 +246,19 @@
// ...
// matchedDN LDAPDN, (Tag)
// The tag is 0x04. Nothing to do
- super.transitions[LdapStatesEnum.LDAP_RESULT_MATCHED_DN_TAG][0x04] = new GrammarTransition(
- LdapStatesEnum.LDAP_RESULT_MATCHED_DN_TAG, LdapStatesEnum.LDAP_RESULT_MATCHED_DN_LENGTH,
- null );
+ super.transitions[LdapStatesEnum.LDAP_RESULT_MATCHED_DN_TAG][0x04] =
+ new GrammarTransition(
+ LdapStatesEnum.LDAP_RESULT_MATCHED_DN_TAG,
+ LdapStatesEnum.LDAP_RESULT_MATCHED_DN_LENGTH, null );
// LDAPResult --> SEQUENCE {
// ...
// matchedDN LDAPDN, (Length)
// The tag is 0x04. We have to check the Length
- super.transitions[LdapStatesEnum.LDAP_RESULT_MATCHED_DN_LENGTH][0x04] = new GrammarTransition(
- LdapStatesEnum.LDAP_RESULT_MATCHED_DN_LENGTH, LdapStatesEnum.LDAP_RESULT_MATCHED_DN_VALUE,
+ super.transitions[LdapStatesEnum.LDAP_RESULT_MATCHED_DN_LENGTH][0x04] =
+ new GrammarTransition(
+ LdapStatesEnum.LDAP_RESULT_MATCHED_DN_LENGTH,
+ LdapStatesEnum.LDAP_RESULT_MATCHED_DN_VALUE,
new GrammarAction( "Ldap Result Matched DN lentgh control" )
{
public void action( IAsn1Container container ) throws DecoderException
@@ -285,8 +288,10 @@
// ...
// matchedDN LDAPDN, (Value)
// We store the LDAPDN after having checked that it is valid.
- super.transitions[LdapStatesEnum.LDAP_RESULT_MATCHED_DN_VALUE][0x04] = new GrammarTransition(
- LdapStatesEnum.LDAP_RESULT_MATCHED_DN_VALUE, LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_TAG,
+ super.transitions[LdapStatesEnum.LDAP_RESULT_MATCHED_DN_VALUE][0x04] =
+ new GrammarTransition(
+ LdapStatesEnum.LDAP_RESULT_MATCHED_DN_VALUE,
+ LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_TAG,
new GrammarAction( "Store Ldap Result matched DN" )
{
public void action( IAsn1Container container ) throws DecoderException
@@ -313,7 +318,8 @@
// ...
// errorMessage LDAPString, (Tag)
// The tag is 0x04. Nothing to do
- super.transitions[LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_TAG][0x04] = new GrammarTransition(
+ super.transitions[LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_TAG][0x04] =
+ new GrammarTransition(
LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_TAG,
LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_LENGTH, null );
@@ -321,6 +327,7 @@
// ...
// errorMessage LDAPString, (Length)
// The tag is 0x04. We have to check the Length
+ // As the string could be null, we have create an empty error message
super.transitions[LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_LENGTH][0x04] =
new GrammarTransition( LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_LENGTH,
LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_VALUE,
@@ -383,35 +390,24 @@
// referral [3] Referral OPTIONAL } (Tag)
//
// The next state could be one of the following :
- // - 0x80 : a control, like in SearchResultDone, ModifyResponse, AddResponse, DelResponse,
ModifyDNResponse, CompareResponse
// - 0x83 : a referral, in a LdapResult.
- // - 0x87 : a serverSaslCreds, in a BindResponse
// - 0x8A : an extended response
// - GRAMMAR_END : this is implicitly deducted by the fact that we don't have anymore
byte...
//
// We don't deal with all of this values, we just have to treat the 0x83, because
// referral is a part of the LdapResult grammar. In all other cases, we just quit
// the grammar.
- //
- // This is a control. We have to quit the LdapResult grammar
- super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_TAG][0x80] =
- new GrammarTransition( LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_TAG,
- LdapStatesEnum.GRAMMAR_END, null );
+ // As referral is optionnal, we may transoit from a error message state
// This is a referral.
super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_TAG][0x83] =
new GrammarTransition( LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_TAG,
LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_LENGTH, null );
- // This is a serverSaslCreds. We have to quit the LdapResult grammar
- super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_TAG][0x87] =
- new GrammarTransition( LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_TAG,
- LdapStatesEnum.GRAMMAR_END, null );
-
- // This is a extended response. We have to quit the LdapResult grammar
- super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_TAG][0x8A] =
- new GrammarTransition( LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_TAG,
- LdapStatesEnum.GRAMMAR_END, null );
+ // In case we are coming from a error message state
+ super.transitions[LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_VALUE][0x83] =
+ new GrammarTransition( LdapStatesEnum.LDAP_RESULT_ERROR_MESSAGE_VALUE,
+ LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_LENGTH, null );
// LDAPResult --> SEQUENCE {
// ...
@@ -452,13 +448,16 @@
// This is a SEQUENCE, we will have at least one referral, but may be many.
// As this is the tag, we don't have anything to do.
super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_TAG][0x04] = new GrammarTransition(
- LdapStatesEnum.LDAP_RESULT_REFERRAL_TAG, LdapStatesEnum.LDAP_RESULT_REFERRAL_LENGTH,
null );
+ LdapStatesEnum.LDAP_RESULT_REFERRAL_TAG, LdapStatesEnum.LDAP_RESULT_REFERRAL_LENGTH,
+ null );
// Referral ::= SEQUENCE OF LDAPURL (Length)
// This is a SEQUENCE, we will have at least one referral, but may be many.
// We will check the length.
- super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_LENGTH][0x04] = new GrammarTransition(
- LdapStatesEnum.LDAP_RESULT_REFERRAL_LENGTH, LdapStatesEnum.LDAP_RESULT_REFERRAL_VALUE,
+ super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_LENGTH][0x04] =
+ new GrammarTransition(
+ LdapStatesEnum.LDAP_RESULT_REFERRAL_LENGTH,
+ LdapStatesEnum.LDAP_RESULT_REFERRAL_VALUE,
new GrammarAction( "Ldap Result referral length control" )
{
public void action( IAsn1Container container ) throws DecoderException
@@ -489,8 +488,10 @@
// To handle those different cases, we have to transit to a special state, which
// will do this brancing.
// Here, we store the referral in the ldapResult.
- super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_VALUE][0x04] = new GrammarTransition(
- LdapStatesEnum.LDAP_RESULT_REFERRAL_LENGTH, LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG,
+ super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_VALUE][0x04] =
+ new GrammarTransition(
+ LdapStatesEnum.LDAP_RESULT_REFERRAL_LENGTH,
+ LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG,
new GrammarAction( "Store Ldap Result referral" )
{
public void action( IAsn1Container container ) throws DecoderException
@@ -515,28 +516,14 @@
// Referral ::= SEQUENCE OF LDAPURL (Tag)
// We may have another referral, but we could also have something else :
// - 0x04 : a referral, in a LdapResult.
- // - 0x80 : a control, like in SearchResultDone, ModifyResponse, AddResponse, DelResponse,
ModifyDNResponse, CompareResponse
- // - 0x87 : a serverSaslCreds, in a BindResponse
- // - 0x8A : an extended response
- // - GRAMMAR_END : this is implicitly deducted by the fact that we don't have anymore
byte...
+ // - GRAMMAR_END : this is implicitly deducted by the fact that we don't have any
more valid byte...
// Those different cases are handled here.
// This is a referral. We have to transit to its Length state
- super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG][0x04] = new GrammarTransition(
+ super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG][0x04] =
+ new GrammarTransition(
LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG,
LdapStatesEnum.LDAP_RESULT_REFERRAL_SEQUENCE_LENGTH, null );
-
- // This is a control. We have to quit the LdapResult grammar
- super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG][0x80] = new GrammarTransition(
- LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG, LdapStatesEnum.GRAMMAR_END,
null );
-
- // This is a serverSaslCreds. We have to quit the LdapResult grammar
- super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG][0x87] = new GrammarTransition(
- LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG, LdapStatesEnum.GRAMMAR_END,
null );
-
- // This is a extended response. We have to quit the LdapResult grammar
- super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG][0x8A] = new GrammarTransition(
- LdapStatesEnum.LDAP_RESULT_REFERRAL_LOOP_TAG, LdapStatesEnum.GRAMMAR_END,
null );
}
|