directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1072218 - in /directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl: CancelGrammar.java CancelStatesEnum.java CertGenerationGrammar.java CertGenerationStatesEnum.java
Date Sat, 19 Feb 2011 00:47:05 GMT
Author: akarasulu
Date: Sat Feb 19 00:47:05 2011
New Revision: 1072218

URL: http://svn.apache.org/viewvc?rev=1072218&view=rev
Log:
some generics cleanup

Modified:
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelGrammar.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelStatesEnum.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationGrammar.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationStatesEnum.java

Modified: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelGrammar.java?rev=1072218&r1=1072217&r2=1072218&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelGrammar.java
(original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelGrammar.java
Sat Feb 19 00:47:05 2011
@@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class CancelGrammar extends AbstractGrammar
+public final class CancelGrammar extends AbstractGrammar<CancelContainer>
 {
     /** The logger */
     static final Logger LOG = LoggerFactory.getLogger( CancelGrammar.class );
@@ -59,12 +59,13 @@ public final class CancelGrammar extends
     static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
     /** The instance of grammar. CancelGrammar is a singleton */
-    private static Grammar instance = new CancelGrammar();
+    private static Grammar<CancelContainer> instance = new CancelGrammar();
 
 
     /**
      * Creates a new GracefulDisconnectGrammar object.
      */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     private CancelGrammar()
     {
         setName( CancelGrammar.class.getName() );
@@ -80,11 +81,10 @@ public final class CancelGrammar extends
          * Creates the Cancel object
          */
         super.transitions[CancelStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= 
-            new GrammarTransition( CancelStatesEnum.START_STATE,
+            new GrammarTransition<CancelContainer>( CancelStatesEnum.START_STATE,
                                     CancelStatesEnum.CANCEL_SEQUENCE_STATE, 
                                     UniversalTag.SEQUENCE.getValue(),
-                new GrammarAction(
-                "Init Cancel" )
+                new GrammarAction( "Init Cancel" )
             {
                 public void action( Asn1Container container )
                 {
@@ -104,7 +104,7 @@ public final class CancelGrammar extends
          * Set the cancelId value into the Cancel object.    
          */
         super.transitions[CancelStatesEnum.CANCEL_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= 
-            new GrammarTransition( CancelStatesEnum.CANCEL_SEQUENCE_STATE,
+            new GrammarTransition<CancelContainer>( CancelStatesEnum.CANCEL_SEQUENCE_STATE,
                                     CancelStatesEnum.CANCEL_ID_STATE, 
                                     UniversalTag.INTEGER.getValue(), 
                 new GrammarAction( "Stores CancelId" )
@@ -142,7 +142,7 @@ public final class CancelGrammar extends
      * 
      * @return An instance on this grammar
      */
-    public static Grammar getInstance()
+    public static Grammar<CancelContainer> getInstance()
     {
         return instance;
     }

Modified: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelStatesEnum.java?rev=1072218&r1=1072217&r2=1072218&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelStatesEnum.java
(original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelStatesEnum.java
Sat Feb 19 00:47:05 2011
@@ -71,14 +71,9 @@ public enum CancelStatesEnum implements 
      * @param grammar The grammar class
      * @return The grammar name
      */
-    public String getGrammarName( Grammar grammar )
+    public String getGrammarName( Grammar<CancelContainer> grammar )
     {
-        if ( grammar instanceof CancelGrammar )
-        {
-            return "CANCEL_GRAMMAR";
-        }
-
-        return "UNKNOWN GRAMMAR";
+        return "CANCEL_GRAMMAR";
     }
 
 

Modified: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationGrammar.java?rev=1072218&r1=1072217&r2=1072218&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationGrammar.java
(original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationGrammar.java
Sat Feb 19 00:47:05 2011
@@ -20,7 +20,6 @@
 package org.apache.directory.shared.ldap.extras.extended.ads_impl;
 
 
-import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
@@ -53,7 +52,7 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 
-public class CertGenerationGrammar extends AbstractGrammar
+public class CertGenerationGrammar extends AbstractGrammar<CertGenerationContainer>
 {
 
     /** logger */
@@ -63,9 +62,10 @@ public class CertGenerationGrammar exten
     static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
     /** The instance of grammar. CertGenerationObjectGrammar is a singleton */
-    private static Grammar instance = new CertGenerationGrammar();
+    private static Grammar<CertGenerationContainer> instance = new CertGenerationGrammar();
 
 
+    @SuppressWarnings("unchecked")
     public CertGenerationGrammar()
     {
         setName( CertGenerationGrammar.class.getName() );
@@ -81,15 +81,15 @@ public class CertGenerationGrammar exten
          *     
          * Creates the CertGenerationObject object
          */
-        super.transitions[CertGenerationStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= new GrammarTransition(
+        super.transitions[CertGenerationStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= 
+            new GrammarTransition<CertGenerationContainer>(
             CertGenerationStatesEnum.START_STATE, CertGenerationStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE,
-            UniversalTag.SEQUENCE.getValue(), new GrammarAction( "Init CertGenerationObject"
)
+            UniversalTag.SEQUENCE.getValue(), new GrammarAction<CertGenerationContainer>(
"Init CertGenerationObject" )
             {
-                public void action( Asn1Container container )
+                public void action( CertGenerationContainer container )
                 {
-                    CertGenerationContainer certGenContainer = ( CertGenerationContainer
) container;
                     CertGenerationObject certGenerationObject = new CertGenerationObject();
-                    certGenContainer.setCertGenerationObject( certGenerationObject );
+                    container.setCertGenerationObject( certGenerationObject );
                 }
             } );
 
@@ -102,14 +102,14 @@ public class CertGenerationGrammar exten
          *     
          * Set the targetDN value into the CertGenerationObject instance.
          */
-        super.transitions[CertGenerationStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= new GrammarTransition(
-            CertGenerationStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE, CertGenerationStatesEnum.TARGETDN_STATE,
-            UniversalTag.OCTET_STRING.getValue(), new GrammarAction( "Set Cert Generation
target Dn value" )
+        super.transitions[CertGenerationStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= 
+            new GrammarTransition<CertGenerationContainer>( CertGenerationStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE,

+                CertGenerationStatesEnum.TARGETDN_STATE, UniversalTag.OCTET_STRING.getValue(),

+                new GrammarAction<CertGenerationContainer>( "Set Cert Generation target
Dn value" )
             {
-                public void action( Asn1Container container ) throws DecoderException
+                public void action( CertGenerationContainer container ) throws DecoderException
                 {
-                    CertGenerationContainer certGenContainer = ( CertGenerationContainer
) container;
-                    Value value = certGenContainer.getCurrentTLV().getValue();
+                    Value value = container.getCurrentTLV().getValue();
 
                     String targetDN = Strings.utf8ToString(value.getData());
 
@@ -127,7 +127,7 @@ public class CertGenerationGrammar exten
                             throw new DecoderException( msg );
                         }
                         
-                        certGenContainer.getCertGenerationObject().setTargetDN( targetDN
);
+                        container.getCertGenerationObject().setTargetDN( targetDN );
                     }
                     else
                     {
@@ -148,14 +148,14 @@ public class CertGenerationGrammar exten
          *     
          * Set the issuerDN value into the CertGenerationObject instance.
          */
-        super.transitions[CertGenerationStatesEnum.TARGETDN_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= new GrammarTransition(
-            CertGenerationStatesEnum.TARGETDN_STATE, CertGenerationStatesEnum.ISSUER_STATE,
UniversalTag.OCTET_STRING.getValue(),
-            new GrammarAction( "Set Cert Generation issuer Dn value" )
+        super.transitions[CertGenerationStatesEnum.TARGETDN_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= 
+            new GrammarTransition<CertGenerationContainer>( CertGenerationStatesEnum.TARGETDN_STATE,

+                CertGenerationStatesEnum.ISSUER_STATE, UniversalTag.OCTET_STRING.getValue(),
+                new GrammarAction<CertGenerationContainer>( "Set Cert Generation issuer
Dn value" )
             {
-                public void action( Asn1Container container ) throws DecoderException
+                public void action( CertGenerationContainer container ) throws DecoderException
                 {
-                    CertGenerationContainer certGenContainer = ( CertGenerationContainer
) container;
-                    Value value = certGenContainer.getCurrentTLV().getValue();
+                    Value value = container.getCurrentTLV().getValue();
 
                     String issuerDN = Strings.utf8ToString(value.getData());
 
@@ -173,7 +173,7 @@ public class CertGenerationGrammar exten
                             throw new DecoderException( msg );
                         }
                         
-                        certGenContainer.getCertGenerationObject().setIssuerDN( issuerDN
);
+                        container.getCertGenerationObject().setIssuerDN( issuerDN );
                     }
                 }
             } );
@@ -188,14 +188,14 @@ public class CertGenerationGrammar exten
          *     
          * Set the subjectDN value into the CertGenerationObject instance.
          */
-        super.transitions[CertGenerationStatesEnum.ISSUER_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= new GrammarTransition(
-            CertGenerationStatesEnum.ISSUER_STATE, CertGenerationStatesEnum.SUBJECT_STATE,
UniversalTag.OCTET_STRING.getValue(),
-            new GrammarAction( "Set Cert Generation subject Dn value" )
+        super.transitions[CertGenerationStatesEnum.ISSUER_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= 
+            new GrammarTransition<CertGenerationContainer>( CertGenerationStatesEnum.ISSUER_STATE,

+                CertGenerationStatesEnum.SUBJECT_STATE, UniversalTag.OCTET_STRING.getValue(),
+            new GrammarAction<CertGenerationContainer>( "Set Cert Generation subject
Dn value" )
             {
-                public void action( Asn1Container container ) throws DecoderException
+                public void action( CertGenerationContainer container ) throws DecoderException
                 {
-                    CertGenerationContainer certGenContainer = ( CertGenerationContainer
) container;
-                    Value value = certGenContainer.getCurrentTLV().getValue();
+                    Value value = container.getCurrentTLV().getValue();
 
                     String subjectDN = Strings.utf8ToString(value.getData());
 
@@ -213,7 +213,7 @@ public class CertGenerationGrammar exten
                             throw new DecoderException( msg );
                         }
 
-                        certGenContainer.getCertGenerationObject().setSubjectDN( subjectDN
);
+                        container.getCertGenerationObject().setSubjectDN( subjectDN );
                     }
                     else
                     {
@@ -233,14 +233,15 @@ public class CertGenerationGrammar exten
          *     
          * Set the key algorithm value into the CertGenerationObject instance.
          */
-        super.transitions[CertGenerationStatesEnum.SUBJECT_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= new GrammarTransition(
-            CertGenerationStatesEnum.SUBJECT_STATE, CertGenerationStatesEnum.KEY_ALGORITHM_STATE,
-            UniversalTag.OCTET_STRING.getValue(), new GrammarAction( "Set Cert Generation
key algorithm value" )
+        super.transitions[CertGenerationStatesEnum.SUBJECT_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= 
+            new GrammarTransition<CertGenerationContainer>( CertGenerationStatesEnum.SUBJECT_STATE,

+                CertGenerationStatesEnum.KEY_ALGORITHM_STATE,
+                UniversalTag.OCTET_STRING.getValue(), 
+                new GrammarAction<CertGenerationContainer>( "Set Cert Generation key
algorithm value" )
             {
-                public void action( Asn1Container container ) throws DecoderException
+                public void action( CertGenerationContainer container ) throws DecoderException
                 {
-                    CertGenerationContainer certGenContainer = ( CertGenerationContainer
) container;
-                    Value value = certGenContainer.getCurrentTLV().getValue();
+                    Value value = container.getCurrentTLV().getValue();
 
                     String keyAlgorithm = Strings.utf8ToString(value.getData());
 
@@ -251,10 +252,10 @@ public class CertGenerationGrammar exten
 
                     if ( keyAlgorithm != null && ( keyAlgorithm.trim().length() >
0 ) )
                     {
-                        certGenContainer.getCertGenerationObject().setKeyAlgorithm( keyAlgorithm
);
+                        container.getCertGenerationObject().setKeyAlgorithm( keyAlgorithm
);
                     }
 
-                    certGenContainer.setGrammarEndAllowed( true );
+                    container.setGrammarEndAllowed( true );
                 }
             } );
 
@@ -266,7 +267,7 @@ public class CertGenerationGrammar exten
      * 
      * @return An instance on this grammar
      */
-    public static Grammar getInstance()
+    public static Grammar<CertGenerationContainer> getInstance()
     {
         return instance;
     }

Modified: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationStatesEnum.java?rev=1072218&r1=1072217&r2=1072218&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationStatesEnum.java
(original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationStatesEnum.java
Sat Feb 19 00:47:05 2011
@@ -62,14 +62,9 @@ public enum CertGenerationStatesEnum imp
      * @param grammar The grammar class
      * @return The grammar name
      */
-    public String getGrammarName( Grammar grammar )
+    public String getGrammarName( Grammar<CertGenerationContainer> grammar )
     {
-        if ( grammar instanceof CertGenerationGrammar )
-        {
-            return "CERT_GENERATION_GRAMMER";
-        }
-        
-        return "UNKNOWN GRAMMAR";
+        return "CERT_GENERATION_GRAMMER";
     }
 
     



Mime
View raw message