You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2013/03/17 19:03:43 UTC

svn commit: r1457505 [7/14] - in /qpid/trunk/qpid/java: amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/ amqp-1-0-client/example/src/main/java/org/apache/qpid/amqp_1_0/client/ amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/c...

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueHandler.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueHandler.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueHandler.java Sun Mar 17 18:03:37 2013
@@ -1,159 +1,159 @@
-/*
- *
- * 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.qpid.amqp_1_0.codec;
-
-import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
-import org.apache.qpid.amqp_1_0.type.transport.AmqpError;
-import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-
-public class ValueHandler implements DescribedTypeConstructorRegistry.Source
-{
-    private static final byte DESCRIBED_TYPE = (byte)0;
-
-    private final DescribedTypeConstructorRegistry _describedTypeConstructorRegistry;
-
-
-    private static final TypeConstructor[][] TYPE_CONSTRUCTORS =
-            {
-                    {},
-                    {},
-                    {},
-                    {},
-                    { NullTypeConstructor.getInstance(),   BooleanConstructor.getTrueInstance(),
-                      BooleanConstructor.getFalseInstance(), ZeroUIntConstructor.getInstance(),
-                      ZeroULongConstructor.getInstance(),  ZeroListConstructor.getInstance()       },
-                    { UByteTypeConstructor.getInstance(),  ByteTypeConstructor.getInstance(),
-                      SmallUIntConstructor.getInstance(),  SmallULongConstructor.getInstance(),
-                      SmallIntConstructor.getInstance(),   SmallLongConstructor.getInstance(),
-                      BooleanConstructor.getByteInstance()},
-                    { UShortTypeConstructor.getInstance(), ShortTypeConstructor.getInstance()      },
-                    { UIntTypeConstructor.getInstance(),   IntTypeConstructor.getInstance(),
-                      FloatTypeConstructor.getInstance(),  CharTypeConstructor.getInstance(),
-                      DecimalConstructor.getDecimal32Instance()},
-                    { ULongTypeConstructor.getInstance(),  LongTypeConstructor.getInstance(),
-                      DoubleTypeConstructor.getInstance(), TimestampTypeConstructor.getInstance(),
-                      DecimalConstructor.getDecimal64Instance()},
-                    { null,                                null,
-                      null,                                null,
-                      DecimalConstructor.getDecimal128Instance(), null,
-                      null,                                null,
-                      UUIDTypeConstructor.getInstance()                                            },
-                    { BinaryTypeConstructor.getInstance(1),
-                      StringTypeConstructor.getInstance(1, Charset.forName("UTF8")),
-                      StringTypeConstructor.getInstance(1, Charset.forName("UTF16")),
-                      SymbolTypeConstructor.getInstance(1)                                         },
-                    { BinaryTypeConstructor.getInstance(4),
-                      StringTypeConstructor.getInstance(4, Charset.forName("UTF8")),
-                      StringTypeConstructor.getInstance(4, Charset.forName("UTF16")),
-                      SymbolTypeConstructor.getInstance(4)                                         },
-                    { CompoundTypeConstructor.getInstance(1, CompoundTypeConstructor.LIST_ASSEMBLER_FACTORY),
-                      CompoundTypeConstructor.getInstance(1, CompoundTypeConstructor.MAP_ASSEMBLER_FACTORY)  },
-                    { CompoundTypeConstructor.getInstance(4, CompoundTypeConstructor.LIST_ASSEMBLER_FACTORY),
-                      CompoundTypeConstructor.getInstance(4, CompoundTypeConstructor.MAP_ASSEMBLER_FACTORY)  },
-                    {
-                      ArrayTypeConstructor.getOneByteSizeTypeConstructor()
-                    },
-                    {
-                      ArrayTypeConstructor.getFourByteSizeTypeConstructor()
-                    }
-            };
-
-
-    public ValueHandler(DescribedTypeConstructorRegistry registry)
-    {
-        _describedTypeConstructorRegistry = registry;
-    }
-
-    public Object parse(final ByteBuffer in) throws AmqpErrorException
-    {
-        TypeConstructor constructor = readConstructor(in);
-        return constructor.construct(in, this);
-    }
-
-
-    public TypeConstructor readConstructor(ByteBuffer in) throws AmqpErrorException
-    {
-        if(!in.hasRemaining())
-        {
-            throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data - expected type, no data remaining");
-        }
-        byte formatCode = in.get();
-
-        if(formatCode == DESCRIBED_TYPE)
-        {
-            Object descriptor = parse(in);
-            DescribedTypeConstructor describedTypeConstructor = _describedTypeConstructorRegistry.getConstructor(descriptor);
-            if(describedTypeConstructor==null)
-            {
-                describedTypeConstructor=new DefaultDescribedTypeConstructor(descriptor);
-            }
-            TypeConstructor typeConstructor = readConstructor(in);
-
-            return describedTypeConstructor.construct(typeConstructor);
-
-        }
-        else
-        {
-            int subCategory = (formatCode >> 4) & 0x0F;
-            int subtype =  formatCode & 0x0F;
-
-            TypeConstructor tc;
-            try
-            {
-                tc = TYPE_CONSTRUCTORS[subCategory][subtype];
-            }
-            catch(IndexOutOfBoundsException e)
-            {
-                tc = null;
-            }
-
-            if(tc == null)
-            {
-                throw new AmqpErrorException(ConnectionError.FRAMING_ERROR,"Unknown type format-code 0x%02x", formatCode);
-            }
-
-            return tc;
-        }
-    }
-
-
-
-
-
-    @Override
-    public String toString()
-    {
-        return "ValueHandler{" +
-              ", _describedTypeConstructorRegistry=" + _describedTypeConstructorRegistry +
-               '}';
-    }
-
-
-    public DescribedTypeConstructorRegistry getDescribedTypeRegistry()
-    {
-        return _describedTypeConstructorRegistry;
-    }
-
-
-}
+/*
+ *
+ * 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.qpid.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.transport.AmqpError;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+public class ValueHandler implements DescribedTypeConstructorRegistry.Source
+{
+    private static final byte DESCRIBED_TYPE = (byte)0;
+
+    private final DescribedTypeConstructorRegistry _describedTypeConstructorRegistry;
+
+
+    private static final TypeConstructor[][] TYPE_CONSTRUCTORS =
+            {
+                    {},
+                    {},
+                    {},
+                    {},
+                    { NullTypeConstructor.getInstance(),   BooleanConstructor.getTrueInstance(),
+                      BooleanConstructor.getFalseInstance(), ZeroUIntConstructor.getInstance(),
+                      ZeroULongConstructor.getInstance(),  ZeroListConstructor.getInstance()       },
+                    { UByteTypeConstructor.getInstance(),  ByteTypeConstructor.getInstance(),
+                      SmallUIntConstructor.getInstance(),  SmallULongConstructor.getInstance(),
+                      SmallIntConstructor.getInstance(),   SmallLongConstructor.getInstance(),
+                      BooleanConstructor.getByteInstance()},
+                    { UShortTypeConstructor.getInstance(), ShortTypeConstructor.getInstance()      },
+                    { UIntTypeConstructor.getInstance(),   IntTypeConstructor.getInstance(),
+                      FloatTypeConstructor.getInstance(),  CharTypeConstructor.getInstance(),
+                      DecimalConstructor.getDecimal32Instance()},
+                    { ULongTypeConstructor.getInstance(),  LongTypeConstructor.getInstance(),
+                      DoubleTypeConstructor.getInstance(), TimestampTypeConstructor.getInstance(),
+                      DecimalConstructor.getDecimal64Instance()},
+                    { null,                                null,
+                      null,                                null,
+                      DecimalConstructor.getDecimal128Instance(), null,
+                      null,                                null,
+                      UUIDTypeConstructor.getInstance()                                            },
+                    { BinaryTypeConstructor.getInstance(1),
+                      StringTypeConstructor.getInstance(1, Charset.forName("UTF8")),
+                      StringTypeConstructor.getInstance(1, Charset.forName("UTF16")),
+                      SymbolTypeConstructor.getInstance(1)                                         },
+                    { BinaryTypeConstructor.getInstance(4),
+                      StringTypeConstructor.getInstance(4, Charset.forName("UTF8")),
+                      StringTypeConstructor.getInstance(4, Charset.forName("UTF16")),
+                      SymbolTypeConstructor.getInstance(4)                                         },
+                    { CompoundTypeConstructor.getInstance(1, CompoundTypeConstructor.LIST_ASSEMBLER_FACTORY),
+                      CompoundTypeConstructor.getInstance(1, CompoundTypeConstructor.MAP_ASSEMBLER_FACTORY)  },
+                    { CompoundTypeConstructor.getInstance(4, CompoundTypeConstructor.LIST_ASSEMBLER_FACTORY),
+                      CompoundTypeConstructor.getInstance(4, CompoundTypeConstructor.MAP_ASSEMBLER_FACTORY)  },
+                    {
+                      ArrayTypeConstructor.getOneByteSizeTypeConstructor()
+                    },
+                    {
+                      ArrayTypeConstructor.getFourByteSizeTypeConstructor()
+                    }
+            };
+
+
+    public ValueHandler(DescribedTypeConstructorRegistry registry)
+    {
+        _describedTypeConstructorRegistry = registry;
+    }
+
+    public Object parse(final ByteBuffer in) throws AmqpErrorException
+    {
+        TypeConstructor constructor = readConstructor(in);
+        return constructor.construct(in, this);
+    }
+
+
+    public TypeConstructor readConstructor(ByteBuffer in) throws AmqpErrorException
+    {
+        if(!in.hasRemaining())
+        {
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data - expected type, no data remaining");
+        }
+        byte formatCode = in.get();
+
+        if(formatCode == DESCRIBED_TYPE)
+        {
+            Object descriptor = parse(in);
+            DescribedTypeConstructor describedTypeConstructor = _describedTypeConstructorRegistry.getConstructor(descriptor);
+            if(describedTypeConstructor==null)
+            {
+                describedTypeConstructor=new DefaultDescribedTypeConstructor(descriptor);
+            }
+            TypeConstructor typeConstructor = readConstructor(in);
+
+            return describedTypeConstructor.construct(typeConstructor);
+
+        }
+        else
+        {
+            int subCategory = (formatCode >> 4) & 0x0F;
+            int subtype =  formatCode & 0x0F;
+
+            TypeConstructor tc;
+            try
+            {
+                tc = TYPE_CONSTRUCTORS[subCategory][subtype];
+            }
+            catch(IndexOutOfBoundsException e)
+            {
+                tc = null;
+            }
+
+            if(tc == null)
+            {
+                throw new AmqpErrorException(ConnectionError.FRAMING_ERROR,"Unknown type format-code 0x%02x", formatCode);
+            }
+
+            return tc;
+        }
+    }
+
+
+
+
+
+    @Override
+    public String toString()
+    {
+        return "ValueHandler{" +
+              ", _describedTypeConstructorRegistry=" + _describedTypeConstructorRegistry +
+               '}';
+    }
+
+
+    public DescribedTypeConstructorRegistry getDescribedTypeRegistry()
+    {
+        return _describedTypeConstructorRegistry;
+    }
+
+
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueProducingProtocolHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueProducingProtocolHandler.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueProducingProtocolHandler.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueProducingProtocolHandler.java Sun Mar 17 18:03:37 2013
@@ -1,31 +1,31 @@
-/*
- *
- * 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.qpid.amqp_1_0.codec;
-
-import org.apache.qpid.amqp_1_0.type.transport.Error;
-
-public interface ValueProducingProtocolHandler extends ProtocolHandler
-{
-    Object getValue();
-    public boolean hasError();
-    public Error getError();
-
-}
+/*
+ *
+ * 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.qpid.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+public interface ValueProducingProtocolHandler extends ProtocolHandler
+{
+    Object getValue();
+    public boolean hasError();
+    public Error getError();
+
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueProducingProtocolHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueWriter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueWriter.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueWriter.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueWriter.java Sun Mar 17 18:03:37 2013
@@ -1,58 +1,58 @@
-/*
- *
- * 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.qpid.amqp_1_0.codec;
-
-import java.nio.ByteBuffer;
-import java.util.Map;
-
-public interface ValueWriter<T extends Object>
-{
-
-
-
-    public static interface Factory<V extends Object>
-    {
-        ValueWriter<V> newInstance(Registry registry);
-    }
-
-    public static interface Registry
-    {
-        public static interface Source
-        {
-            public Registry getDescribedTypeRegistry();
-        }
-
-        <V extends Object> ValueWriter<V> getValueWriter(V value);
-        <V extends Object> ValueWriter<V> getValueWriter(V value, Map<Class, ValueWriter> localCache);
-        <V extends Object> ValueWriter<V> register(Class<V> clazz, ValueWriter.Factory<V> writer);
-
-    }
-
-
-    int writeToBuffer(ByteBuffer buffer);
-
-    void setValue(T frameBody);
-
-    boolean isComplete();
-
-    boolean isCacheable();
-}
+/*
+ *
+ * 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.qpid.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+import java.util.Map;
+
+public interface ValueWriter<T extends Object>
+{
+
+
+
+    public static interface Factory<V extends Object>
+    {
+        ValueWriter<V> newInstance(Registry registry);
+    }
+
+    public static interface Registry
+    {
+        public static interface Source
+        {
+            public Registry getDescribedTypeRegistry();
+        }
+
+        <V extends Object> ValueWriter<V> getValueWriter(V value);
+        <V extends Object> ValueWriter<V> getValueWriter(V value, Map<Class, ValueWriter> localCache);
+        <V extends Object> ValueWriter<V> register(Class<V> clazz, ValueWriter.Factory<V> writer);
+
+    }
+
+
+    int writeToBuffer(ByteBuffer buffer);
+
+    void setValue(T frameBody);
+
+    boolean isComplete();
+
+    boolean isCacheable();
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthTypeConstructor.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthTypeConstructor.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthTypeConstructor.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthTypeConstructor.java Sun Mar 17 18:03:37 2013
@@ -1,48 +1,48 @@
-/*
- *
- * 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.qpid.amqp_1_0.codec;
-
-import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
-
-import java.nio.ByteBuffer;
-
-public abstract class VariableWidthTypeConstructor implements TypeConstructor
-{
-    protected int _size;
-
-    public VariableWidthTypeConstructor(int size)
-    {
-        _size = size;
-    }
-
-    public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
-    {
-        return construct(in, false, handler);
-    }
-
-    public int getSize()
-    {
-        return _size;
-    }
-
-    public abstract Object construct(ByteBuffer in, boolean isCopy, ValueHandler handler) throws AmqpErrorException;
-
-}
+/*
+ *
+ * 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.qpid.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+
+import java.nio.ByteBuffer;
+
+public abstract class VariableWidthTypeConstructor implements TypeConstructor
+{
+    protected int _size;
+
+    public VariableWidthTypeConstructor(int size)
+    {
+        _size = size;
+    }
+
+    public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+    {
+        return construct(in, false, handler);
+    }
+
+    public int getSize()
+    {
+        return _size;
+    }
+
+    public abstract Object construct(ByteBuffer in, boolean isCopy, ValueHandler handler) throws AmqpErrorException;
+
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthTypeConstructor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthWriter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthWriter.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthWriter.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthWriter.java Sun Mar 17 18:03:37 2013
@@ -1,169 +1,169 @@
-/*
- *
- * 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.qpid.amqp_1_0.codec;
-
-import java.nio.ByteBuffer;
-
-public abstract class VariableWidthWriter<V> implements ValueWriter<V>
-{
-    private int _written;
-    private int _size;
-
-    public int writeToBuffer(ByteBuffer buffer)
-    {
-
-        int written = _written;
-        final int length = getLength();
-        boolean singleOctetSize = _size == 1;
-        if(singleOctetSize)
-        {
-            switch(written)
-            {
-                case 0:
-                    if(buffer.hasRemaining())
-                    {
-                        buffer.put(getSingleOctetEncodingCode());
-                    }
-                    else
-                    {
-                        break;
-                    }
-                case 1:
-                    if(buffer.hasRemaining())
-                    {
-                        buffer.put((byte)length);
-                        written = 2;
-                    }
-                    else
-                    {
-                        written = 1;
-                        break;
-                    }
-                default:
-
-                    final int toWrite = 2 + length - written;
-                    if(buffer.remaining() >= toWrite)
-                    {
-                        writeBytes(buffer, written-2,toWrite);
-                        written = length + 2;
-                        clearValue();
-                    }
-                    else
-                    {
-                        final int remaining = buffer.remaining();
-
-                        writeBytes(buffer, written-2, remaining);
-                        written += remaining;
-                    }
-
-            }
-        }
-        else
-        {
-
-            int remaining = buffer.remaining();
-
-            switch(written)
-            {
-
-                case 0:
-                    if(buffer.hasRemaining())
-                    {
-                        buffer.put(getFourOctetEncodingCode());
-                        remaining--;
-                        written = 1;
-                    }
-                    else
-                    {
-                        break;
-                    }
-                case 1:
-                    if(remaining >= 4)
-                    {
-                        buffer.putInt(length);
-                        remaining-=4;
-                        written+=4;
-                    }
-                case 2:
-                case 3:
-                    if(remaining >= 2 && written <= 3)
-                    {
-                        buffer.putShort((short)((length >> ((3-written)<<3)) & 0xFFFF ));
-                        remaining -= 2;
-                        written += 2;
-                    }
-                case 4:
-                    if(remaining >=1 && written <=4)
-                    {
-                        buffer.put((byte)((length>> ((4-written)<<3)) & 0xFF ));
-                        written++;
-                    }
-
-                default:
-
-                    final int toWrite = 5 + length - written;
-                    if(buffer.remaining() >= toWrite)
-                    {
-                        writeBytes(buffer, written-5,toWrite);
-                        written = length + 5;
-                        clearValue();
-                    }
-                    else if(buffer.hasRemaining())
-                    {
-                        written += buffer.remaining();
-                        writeBytes(buffer, written-5, buffer.remaining());
-                    }
-
-            }
-
-        }
-
-        _written = written;
-        return 1 + _size + length;
-    }
-
-    protected abstract void clearValue();
-
-    protected abstract boolean hasValue();
-
-    protected abstract byte getFourOctetEncodingCode();
-
-    protected abstract byte getSingleOctetEncodingCode();
-
-    public void setValue(V value)
-    {
-        _written = 0;
-        _size = (getLength() & 0xFFFFFF00) == 0 ? 1 : 4;
-    }
-
-    protected abstract int getLength();
-
-    protected abstract void writeBytes(ByteBuffer buf, int offset, int length);
-
-
-    public boolean isComplete()
-    {
-        return !hasValue() || _written == getLength() + _size + 1;
-    }
-
-
-}
+/*
+ *
+ * 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.qpid.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public abstract class VariableWidthWriter<V> implements ValueWriter<V>
+{
+    private int _written;
+    private int _size;
+
+    public int writeToBuffer(ByteBuffer buffer)
+    {
+
+        int written = _written;
+        final int length = getLength();
+        boolean singleOctetSize = _size == 1;
+        if(singleOctetSize)
+        {
+            switch(written)
+            {
+                case 0:
+                    if(buffer.hasRemaining())
+                    {
+                        buffer.put(getSingleOctetEncodingCode());
+                    }
+                    else
+                    {
+                        break;
+                    }
+                case 1:
+                    if(buffer.hasRemaining())
+                    {
+                        buffer.put((byte)length);
+                        written = 2;
+                    }
+                    else
+                    {
+                        written = 1;
+                        break;
+                    }
+                default:
+
+                    final int toWrite = 2 + length - written;
+                    if(buffer.remaining() >= toWrite)
+                    {
+                        writeBytes(buffer, written-2,toWrite);
+                        written = length + 2;
+                        clearValue();
+                    }
+                    else
+                    {
+                        final int remaining = buffer.remaining();
+
+                        writeBytes(buffer, written-2, remaining);
+                        written += remaining;
+                    }
+
+            }
+        }
+        else
+        {
+
+            int remaining = buffer.remaining();
+
+            switch(written)
+            {
+
+                case 0:
+                    if(buffer.hasRemaining())
+                    {
+                        buffer.put(getFourOctetEncodingCode());
+                        remaining--;
+                        written = 1;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                case 1:
+                    if(remaining >= 4)
+                    {
+                        buffer.putInt(length);
+                        remaining-=4;
+                        written+=4;
+                    }
+                case 2:
+                case 3:
+                    if(remaining >= 2 && written <= 3)
+                    {
+                        buffer.putShort((short)((length >> ((3-written)<<3)) & 0xFFFF ));
+                        remaining -= 2;
+                        written += 2;
+                    }
+                case 4:
+                    if(remaining >=1 && written <=4)
+                    {
+                        buffer.put((byte)((length>> ((4-written)<<3)) & 0xFF ));
+                        written++;
+                    }
+
+                default:
+
+                    final int toWrite = 5 + length - written;
+                    if(buffer.remaining() >= toWrite)
+                    {
+                        writeBytes(buffer, written-5,toWrite);
+                        written = length + 5;
+                        clearValue();
+                    }
+                    else if(buffer.hasRemaining())
+                    {
+                        written += buffer.remaining();
+                        writeBytes(buffer, written-5, buffer.remaining());
+                    }
+
+            }
+
+        }
+
+        _written = written;
+        return 1 + _size + length;
+    }
+
+    protected abstract void clearValue();
+
+    protected abstract boolean hasValue();
+
+    protected abstract byte getFourOctetEncodingCode();
+
+    protected abstract byte getSingleOctetEncodingCode();
+
+    public void setValue(V value)
+    {
+        _written = 0;
+        _size = (getLength() & 0xFFFFFF00) == 0 ? 1 : 4;
+    }
+
+    protected abstract int getLength();
+
+    protected abstract void writeBytes(ByteBuffer buf, int offset, int length);
+
+
+    public boolean isComplete()
+    {
+        return !hasValue() || _written == getLength() + _size + 1;
+    }
+
+
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/WrapperTypeValueWriter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/WrapperTypeValueWriter.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/WrapperTypeValueWriter.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/WrapperTypeValueWriter.java Sun Mar 17 18:03:37 2013
@@ -1,55 +1,55 @@
-/*
- *
- * 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.qpid.amqp_1_0.codec;
-
-import org.apache.qpid.amqp_1_0.type.WrapperType;
-
-public class WrapperTypeValueWriter extends DelegatingValueWriter<WrapperType>
-{
-    public WrapperTypeValueWriter(final Registry registry)
-    {
-        super(registry);
-    }
-
-    @Override
-    protected Object getUnderlyingValue(final WrapperType wrapperType)
-    {
-        return wrapperType.getValue();
-    }
-
-    private static Factory FACTORY = new Factory()
-    {
-
-        public ValueWriter newInstance(Registry registry)
-        {
-            return new WrapperTypeValueWriter(registry);
-        }
-    };
-
-    public boolean isCacheable()
-    {
-        return true;
-    }
-
-    public static void register(Registry registry, Class<? extends WrapperType> clazz)
-    {
-        registry.register(clazz, FACTORY);
-    }}
+/*
+ *
+ * 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.qpid.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.WrapperType;
+
+public class WrapperTypeValueWriter extends DelegatingValueWriter<WrapperType>
+{
+    public WrapperTypeValueWriter(final Registry registry)
+    {
+        super(registry);
+    }
+
+    @Override
+    protected Object getUnderlyingValue(final WrapperType wrapperType)
+    {
+        return wrapperType.getValue();
+    }
+
+    private static Factory FACTORY = new Factory()
+    {
+
+        public ValueWriter newInstance(Registry registry)
+        {
+            return new WrapperTypeValueWriter(registry);
+        }
+    };
+
+    public boolean isCacheable()
+    {
+        return true;
+    }
+
+    public static void register(Registry registry, Class<? extends WrapperType> clazz)
+    {
+        registry.register(clazz, FACTORY);
+    }}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/WrapperTypeValueWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroListConstructor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroUIntConstructor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroULongConstructor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQFrame.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQFrame.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQFrame.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQFrame.java Sun Mar 17 18:03:37 2013
@@ -1,76 +1,76 @@
-/*
- *
- * 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.qpid.amqp_1_0.framing;
-
-import org.apache.qpid.amqp_1_0.type.Binary;
-import org.apache.qpid.amqp_1_0.type.FrameBody;
-
-import java.nio.ByteBuffer;
-
-public abstract class AMQFrame<T>
-{
-    private T _frameBody;
-    private ByteBuffer _payload;
-
-    AMQFrame(T frameBody)
-    {
-        _frameBody = frameBody;
-    }
-
-    protected AMQFrame(T frameBody, ByteBuffer payload)
-    {
-        _frameBody = frameBody;
-        _payload = payload;
-    }
-
-    public ByteBuffer getPayload()
-    {
-        return _payload;
-    }
-
-    public static TransportFrame createAMQFrame(short channel, FrameBody frameBody)
-    {
-        return createAMQFrame(channel, frameBody, null);
-    }
-
-    public static TransportFrame createAMQFrame(short channel, FrameBody frameBody, ByteBuffer payload)
-    {
-        return new TransportFrame(channel, frameBody, payload);
-    }
-
-    abstract public short getChannel();
-
-    abstract public byte getFrameType();
-
-    public T getFrameBody()
-    {
-        return _frameBody;
-    }
-
-    @Override
-    public String toString()
-    {
-        return "AMQFrame{" +
-               "frameBody=" + _frameBody +
-               '}';
-    }
-}
+/*
+ *
+ * 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.qpid.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.type.Binary;
+import org.apache.qpid.amqp_1_0.type.FrameBody;
+
+import java.nio.ByteBuffer;
+
+public abstract class AMQFrame<T>
+{
+    private T _frameBody;
+    private ByteBuffer _payload;
+
+    AMQFrame(T frameBody)
+    {
+        _frameBody = frameBody;
+    }
+
+    protected AMQFrame(T frameBody, ByteBuffer payload)
+    {
+        _frameBody = frameBody;
+        _payload = payload;
+    }
+
+    public ByteBuffer getPayload()
+    {
+        return _payload;
+    }
+
+    public static TransportFrame createAMQFrame(short channel, FrameBody frameBody)
+    {
+        return createAMQFrame(channel, frameBody, null);
+    }
+
+    public static TransportFrame createAMQFrame(short channel, FrameBody frameBody, ByteBuffer payload)
+    {
+        return new TransportFrame(channel, frameBody, payload);
+    }
+
+    abstract public short getChannel();
+
+    abstract public byte getFrameType();
+
+    public T getFrameBody()
+    {
+        return _frameBody;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "AMQFrame{" +
+               "frameBody=" + _frameBody +
+               '}';
+    }
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQFrame.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQPProtocolHeaderHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQPProtocolHeaderHandler.java?rev=1457505&r1=1457504&r2=1457505&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQPProtocolHeaderHandler.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQPProtocolHeaderHandler.java Sun Mar 17 18:03:37 2013
@@ -1,85 +1,85 @@
-/*
- *
- * 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.qpid.amqp_1_0.framing;
-
-import org.apache.qpid.amqp_1_0.codec.ProtocolHandler;
-import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
-
-import java.nio.ByteBuffer;
-
-public class AMQPProtocolHeaderHandler implements ProtocolHandler
-{
-    private ConnectionEndpoint _connection;
-    private static final byte MAJOR_VERSION = (byte) 1;
-    private static final byte MINOR_VERSION = (byte) 0;
-
-    enum State {
-        AWAITING_MAJOR,
-        AWAITING_MINOR,
-        AWAITING_REVISION,
-        ERROR
-    }
-
-    private State _state = State.AWAITING_MAJOR;
-
-    public AMQPProtocolHeaderHandler(final ConnectionEndpoint connection)
-    {
-        _connection = connection;
-    }
-
-    public ProtocolHandler parse(final ByteBuffer in)
-    {
-        while(in.hasRemaining() && _state != State.ERROR)
-        {
-            switch(_state)
-            {
-                case AWAITING_MAJOR:
-                    _state = in.get() == MAJOR_VERSION ? State.AWAITING_MINOR : State.ERROR;
-                    if(!in.hasRemaining())
-                    {
-                        break;
-                    }
-                case AWAITING_MINOR:
-                    _state = in.get() == MINOR_VERSION ? State.AWAITING_MINOR : State.ERROR;
-                    if(!in.hasRemaining())
-                    {
-                        break;
-                    }
-                case AWAITING_REVISION:
-                    byte revision = in.get();
-                    _connection.protocolHeaderReceived(MAJOR_VERSION, MINOR_VERSION, revision);
-                    ProtocolHandler handler = new FrameHandler(_connection);
-                    return handler.parse(in);
-            }
-        }
-        if(_state == State.ERROR)
-        {
-            _connection.invalidHeaderReceived();
-        }
-        return this;
-
-    }
-
-    public boolean isDone()
-    {
-        return _state != State.ERROR && !_connection.closedForInput();
-    }
-}
+/*
+ *
+ * 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.qpid.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.codec.ProtocolHandler;
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+import java.nio.ByteBuffer;
+
+public class AMQPProtocolHeaderHandler implements ProtocolHandler
+{
+    private ConnectionEndpoint _connection;
+    private static final byte MAJOR_VERSION = (byte) 1;
+    private static final byte MINOR_VERSION = (byte) 0;
+
+    enum State {
+        AWAITING_MAJOR,
+        AWAITING_MINOR,
+        AWAITING_REVISION,
+        ERROR
+    }
+
+    private State _state = State.AWAITING_MAJOR;
+
+    public AMQPProtocolHeaderHandler(final ConnectionEndpoint connection)
+    {
+        _connection = connection;
+    }
+
+    public ProtocolHandler parse(final ByteBuffer in)
+    {
+        while(in.hasRemaining() && _state != State.ERROR)
+        {
+            switch(_state)
+            {
+                case AWAITING_MAJOR:
+                    _state = in.get() == MAJOR_VERSION ? State.AWAITING_MINOR : State.ERROR;
+                    if(!in.hasRemaining())
+                    {
+                        break;
+                    }
+                case AWAITING_MINOR:
+                    _state = in.get() == MINOR_VERSION ? State.AWAITING_MINOR : State.ERROR;
+                    if(!in.hasRemaining())
+                    {
+                        break;
+                    }
+                case AWAITING_REVISION:
+                    byte revision = in.get();
+                    _connection.protocolHeaderReceived(MAJOR_VERSION, MINOR_VERSION, revision);
+                    ProtocolHandler handler = new FrameHandler(_connection);
+                    return handler.parse(in);
+            }
+        }
+        if(_state == State.ERROR)
+        {
+            _connection.invalidHeaderReceived();
+        }
+        return this;
+
+    }
+
+    public boolean isDone()
+    {
+        return _state != State.ERROR && !_connection.closedForInput();
+    }
+}

Propchange: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQPProtocolHeaderHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org