You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tr...@apache.org on 2007/11/12 03:42:07 UTC

svn commit: r594010 - /mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/

Author: trustin
Date: Sun Nov 11 18:42:05 2007
New Revision: 594010

URL: http://svn.apache.org/viewvc?rev=594010&view=rev
Log:
* Replaced CRLF with CrLf to conform with our naming rules
* Added IntegerDecodingState
* Added ShortIntegerDecodingState
* Added SingleByteDecodingState

Added:
    mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ConsumeToCrLfDecodingState.java
      - copied, changed from r593878, mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ConsumeToCRLFDecodingState.java
    mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/CrLfDecodingState.java
      - copied, changed from r593878, mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/CRLFDecodingState.java
    mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/IntegerDecodingState.java   (with props)
    mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ShortIntegerDecodingState.java   (with props)
    mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/SingleByteDecodingState.java   (with props)
Removed:
    mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/CRLFDecodingState.java
    mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ConsumeToCRLFDecodingState.java

Copied: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ConsumeToCrLfDecodingState.java (from r593878, mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ConsumeToCRLFDecodingState.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ConsumeToCrLfDecodingState.java?p2=mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ConsumeToCrLfDecodingState.java&p1=mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ConsumeToCRLFDecodingState.java&r1=593878&r2=594010&rev=594010&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ConsumeToCRLFDecodingState.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ConsumeToCrLfDecodingState.java Sun Nov 11 18:42:05 2007
@@ -29,7 +29,7 @@
  * @author The Apache MINA Project (dev@mina.apache.org)
  * @version $Rev$, $Date$
  */
-public abstract class ConsumeToCRLFDecodingState implements DecodingState {
+public abstract class ConsumeToCrLfDecodingState implements DecodingState {
 
     /**
      * Carriage return character
@@ -48,7 +48,7 @@
     /**
      * Creates a new instance.
      */
-    public ConsumeToCRLFDecodingState() {
+    public ConsumeToCrLfDecodingState() {
     }
 
     public DecodingState decode(IoBuffer in, ProtocolDecoderOutput out)

Copied: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/CrLfDecodingState.java (from r593878, mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/CRLFDecodingState.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/CrLfDecodingState.java?p2=mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/CrLfDecodingState.java&p1=mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/CRLFDecodingState.java&r1=593878&r2=594010&rev=594010&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/CRLFDecodingState.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/CrLfDecodingState.java Sun Nov 11 18:42:05 2007
@@ -35,7 +35,7 @@
  * @author The Apache MINA Project (dev@mina.apache.org)
  * @version $Rev$, $Date$
  */
-public abstract class CRLFDecodingState implements DecodingState {
+public abstract class CrLfDecodingState implements DecodingState {
     /**
      * Carriage return character
      */

Added: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/IntegerDecodingState.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/IntegerDecodingState.java?rev=594010&view=auto
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/IntegerDecodingState.java (added)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/IntegerDecodingState.java Sun Nov 11 18:42:05 2007
@@ -0,0 +1,68 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  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.
+ *
+ */
+package org.apache.mina.filter.codec.statemachine;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+/**
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ */
+public abstract class IntegerDecodingState implements DecodingState {
+    
+    private int firstByte;
+    private int secondByte;
+    private int thirdByte;
+    private int counter;
+
+    public IntegerDecodingState() {
+    }
+
+    public DecodingState decode(IoBuffer in, ProtocolDecoderOutput out)
+            throws Exception {
+        while (in.hasRemaining()) {
+            switch (counter) {
+            case 0:
+                firstByte = in.getUnsigned();
+                break;
+            case 1:
+                secondByte = in.getUnsigned();
+                break;
+            case 2:
+                thirdByte = in.getUnsigned();
+                break;
+            case 3:
+                counter = 0;
+                return finishDecode(
+                        (firstByte << 24) | (secondByte << 16) | (thirdByte << 8) | in.getUnsigned(),
+                        out);
+            default:
+                throw new InternalError();
+            }
+            counter ++;
+        }
+
+        return this;
+    }
+
+    protected abstract DecodingState finishDecode(int value,
+            ProtocolDecoderOutput out) throws Exception;
+}

Propchange: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/IntegerDecodingState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/IntegerDecodingState.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ShortIntegerDecodingState.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ShortIntegerDecodingState.java?rev=594010&view=auto
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ShortIntegerDecodingState.java (added)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ShortIntegerDecodingState.java Sun Nov 11 18:42:05 2007
@@ -0,0 +1,59 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  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.
+ *
+ */
+package org.apache.mina.filter.codec.statemachine;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+/**
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ */
+public abstract class ShortIntegerDecodingState implements DecodingState {
+    
+    private int highByte;
+    private int counter;
+    
+    public ShortIntegerDecodingState() {
+    }
+
+    public DecodingState decode(IoBuffer in, ProtocolDecoderOutput out)
+            throws Exception {
+        
+        while (in.hasRemaining()) {
+            switch (counter) {
+            case 0:
+                highByte = in.getUnsigned();
+                break;
+            case 1:
+                counter = 0;
+                return finishDecode((short) ((highByte << 8) | in.getUnsigned()), out);
+            default:
+                throw new InternalError();
+            }
+
+            counter ++;
+        }
+        return this;
+    }
+
+    protected abstract DecodingState finishDecode(short value,
+            ProtocolDecoderOutput out) throws Exception;
+}

Propchange: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ShortIntegerDecodingState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/ShortIntegerDecodingState.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/SingleByteDecodingState.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/SingleByteDecodingState.java?rev=594010&view=auto
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/SingleByteDecodingState.java (added)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/SingleByteDecodingState.java Sun Nov 11 18:42:05 2007
@@ -0,0 +1,45 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  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.
+ *
+ */
+package org.apache.mina.filter.codec.statemachine;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+/**
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ */
+public abstract class SingleByteDecodingState implements DecodingState {
+
+    public SingleByteDecodingState() {
+    }
+
+    public DecodingState decode(IoBuffer in, ProtocolDecoderOutput out)
+            throws Exception {
+        if (in.hasRemaining()) {
+            return finishDecode(in.get(), out);
+        } else {
+            return this;
+        }
+    }
+
+    protected abstract DecodingState finishDecode(byte b,
+            ProtocolDecoderOutput out) throws Exception;
+}

Propchange: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/SingleByteDecodingState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/core/src/main/java/org/apache/mina/filter/codec/statemachine/SingleByteDecodingState.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date