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 2010/05/14 23:02:31 UTC
svn commit: r944466 - in
/directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec:
Asn1CodecDecoder.java Asn1CodecEncoder.java
Author: elecharny
Date: Fri May 14 21:02:31 2010
New Revision: 944466
URL: http://svn.apache.org/viewvc?rev=944466&view=rev
Log:
Minor refactoring to remove checkstyle warnings.
Modified:
directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecDecoder.java
directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecEncoder.java
Modified: directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecDecoder.java?rev=944466&r1=944465&r2=944466&view=diff
==============================================================================
--- directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecDecoder.java (original)
+++ directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecDecoder.java Fri May 14 21:02:31 2010
@@ -6,16 +6,16 @@
* to you 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.asn1.codec;
@@ -29,24 +29,35 @@ import org.apache.mina.filter.codec.Prot
/**
- * Adapts {@link StatefulDecoder} to MINA <tt>ProtocolDecoder</tt>
- *
+ * Adapts {@link StatefulDecoder} to MINA <tt>ProtocolDecoder</tt>.
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
- * @version $Rev$, $Date$,
+ * @version $Rev$, $Date$,
*/
public class Asn1CodecDecoder extends ProtocolDecoderAdapter
{
+ /** The stateful decoder */
private final StatefulDecoder decoder;
+
+ /** The associated callback */
private final DecoderCallbackImpl callback = new DecoderCallbackImpl();
+ /**
+ * Creates a new instance of Asn1CodecDecoder.
+ *
+ * @param decoder The associated decoder
+ */
public Asn1CodecDecoder( StatefulDecoder decoder )
{
- decoder.setCallback( callback );
this.decoder = decoder;
+ this.decoder.setCallback( callback );
}
+ /**
+ * {@inheritDoc}
+ */
public void decode( IoSession session, IoBuffer in, ProtocolDecoderOutput out ) throws DecoderException
{
callback.decOut = out;
Modified: directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecEncoder.java?rev=944466&r1=944465&r2=944466&view=diff
==============================================================================
--- directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecEncoder.java (original)
+++ directory/shared/trunk/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecEncoder.java Fri May 14 21:02:31 2010
@@ -6,16 +6,16 @@
* to you 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.asn1.codec;
@@ -34,24 +34,35 @@ import org.apache.mina.filter.codec.Prot
/**
- * Adapts {@link StatefulEncoder} to MINA <tt>ProtocolEncoder</tt>
- *
+ * Adapts {@link StatefulEncoder} to MINA <tt>ProtocolEncoder</tt>.
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
- * @version $Rev$, $Date$,
+ * @version $Rev$, $Date$,
*/
public class Asn1CodecEncoder implements ProtocolEncoder
{
+ /** The associated encoder */
private final StatefulEncoder encoder;
+
+ /** The encoder callback */
private final EncoderCallbackImpl callback = new EncoderCallbackImpl();
+ /**
+ * Creates a new instance of Asn1CodecEncoder.
+ *
+ * @param encoder The associacted encoder
+ */
public Asn1CodecEncoder( StatefulEncoder encoder )
{
- encoder.setCallback( callback );
this.encoder = encoder;
+ this.encoder.setCallback( callback );
}
+ /**
+ * {@inheritDoc}
+ */
public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws EncoderException
{
callback.encOut = out;
@@ -59,27 +70,38 @@ public class Asn1CodecEncoder implements
}
+ /**
+ * {@inheritDoc}
+ */
public void dispose( IoSession session ) throws Exception
{
}
+ /**
+ * A Callback implementation.
+ */
private class EncoderCallbackImpl implements EncoderCallback
{
+ /** The queue in which the encoded message is written */
private ProtocolEncoderOutput encOut;
+ /**
+ * {@inheritDoc}
+ */
public void encodeOccurred( StatefulEncoder codec, Object encoded )
{
- if( encoded instanceof java.nio.ByteBuffer )
+ if ( encoded instanceof java.nio.ByteBuffer )
{
java.nio.ByteBuffer buf = ( java.nio.ByteBuffer ) encoded;
IoBuffer wrappedBuf = IoBuffer.wrap( buf );
encOut.write( wrappedBuf );
}
- else if( encoded instanceof Object[] )
+ else if ( encoded instanceof Object[] )
{
Object[] bufArray = ( Object[] ) encoded;
+
for ( Object buf : bufArray )
{
this.encodeOccurred( codec, buf );
@@ -87,33 +109,35 @@ public class Asn1CodecEncoder implements
encOut.mergeAll();
}
- else if( encoded instanceof Iterator )
+ else if ( encoded instanceof Iterator )
{
Iterator it = ( Iterator ) encoded;
- while( it.hasNext() )
+
+ while ( it.hasNext() )
{
this.encodeOccurred( codec, it.next() );
}
-
+
encOut.mergeAll();
}
- else if( encoded instanceof Collection )
+ else if ( encoded instanceof Collection )
{
for ( Object o : ( ( Collection ) encoded ) )
{
this.encodeOccurred( codec, o );
}
-
+
encOut.mergeAll();
}
- else if( encoded instanceof Enumeration )
+ else if ( encoded instanceof Enumeration )
{
Enumeration e = ( Enumeration ) encoded;
- while( e.hasMoreElements() )
+
+ while ( e.hasMoreElements() )
{
this.encodeOccurred( codec, e.nextElement() );
}
-
+
encOut.mergeAll();
}
else