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/06/18 10:23:58 UTC

svn commit: r1494067 [2/2] - in /qpid/proton/trunk: proton-c/bindings/java/src/main/java/org/apache/qpid/proton/codec/jni/ proton-j/proton-api/src/main/resources/ proton-j/proton/src/main/java/org/apache/qpid/proton/codec/ proton-j/proton/src/main/java...

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Decimal32Element.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Decimal32Element.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Decimal32Element.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Decimal32Element.java Tue Jun 18 08:23:57 2013
@@ -0,0 +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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.amqp.Decimal32;
+import org.apache.qpid.proton.codec.Data;
+
+class Decimal32Element extends AtomicElement<Decimal32>
+{
+
+    private final Decimal32 _value;
+
+    Decimal32Element(Element parent, Element prev, Decimal32 d)
+    {
+        super(parent, prev);
+        _value = d;
+    }
+
+    @Override
+    public int size()
+    {
+        return isElementOfArray() ? 4 : 5;
+    }
+
+    @Override
+    public Decimal32 getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.DECIMAL32;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(b.remaining()>=size)
+        {
+            if(size == 5)
+            {
+                b.put((byte)0x74);
+            }
+            b.putInt(_value.getBits());
+            return size;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Decimal64Element.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Decimal64Element.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Decimal64Element.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Decimal64Element.java Tue Jun 18 08:23:57 2013
@@ -0,0 +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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.amqp.Decimal64;
+import org.apache.qpid.proton.codec.Data;
+
+class Decimal64Element extends AtomicElement<Decimal64>
+{
+
+    private final Decimal64 _value;
+
+    Decimal64Element(Element parent, Element prev, Decimal64 d)
+    {
+        super(parent, prev);
+        _value = d;
+    }
+
+    @Override
+    public int size()
+    {
+        return isElementOfArray() ? 8 : 9;
+    }
+
+    @Override
+    public Decimal64 getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.DECIMAL64;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(b.remaining()>=size)
+        {
+            if(size == 9)
+            {
+                b.put((byte)0x84);
+            }
+            b.putLong(_value.getBits());
+            return size;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,160 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+import java.util.AbstractSequentialList;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.codec.Data;
+
+class DescribedTypeElement extends AbstractElement<DescribedType>
+{
+    private Element _first;
+
+    DescribedTypeElement(Element parent, Element prev)
+    {
+        super(parent, prev);
+    }
+
+
+
+
+    @Override
+    public int size()
+    {
+        int count = 0;
+        int size = 0;
+        Element elt = _first;
+        while(elt != null)
+        {
+            count++;
+            size += elt.size();
+            elt = elt.next();
+        }
+
+        if(isElementOfArray())
+        {
+            throw new IllegalArgumentException("Cannot add described type members to an array");
+        }
+        else if(count > 2)
+        {
+            throw new IllegalArgumentException("Too many elements in described type");
+        }
+        else if(count == 0)
+        {
+            size = 3;
+        }
+        else if(count == 1)
+        {
+            size += 2;
+        }
+        else
+        {
+            size+=1;
+        }
+
+        return size;
+    }
+
+    @Override
+    public DescribedType getValue()
+    {
+        final Object descriptor = _first == null ? null : _first.getValue();
+        Element second = _first == null ? null : _first.next();
+        final Object described = second == null ? null : second.getValue();
+        return new DescribedTypeImpl(descriptor,described);
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.DESCRIBED;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int encodedSize = size();
+
+        if(encodedSize > b.remaining())
+        {
+            return 0;
+        }
+        else
+        {
+            b.put((byte) 0);
+            if(_first == null)
+            {
+                b.put((byte)0x40);
+                b.put((byte)0x40);
+            }
+            else
+            {
+                _first.encode(b);
+                if(_first.next() == null)
+                {
+                    b.put((byte)0x40);
+                }
+                else
+                {
+                    _first.next().encode(b);
+                }
+            }
+        }
+        return encodedSize;
+    }
+
+    @Override
+    public boolean canEnter()
+    {
+        return true;
+    }
+
+    @Override
+    public Element child()
+    {
+        return _first;
+    }
+
+    @Override
+    public Element checkChild(Element element)
+    {
+        if(element.prev() != _first)
+        {
+            throw new IllegalArgumentException("Described Type may only have two elements");
+        }
+        return element;
+
+    }
+
+    @Override
+    public Element addChild(Element element)
+    {
+        _first = element;
+        return element;
+    }
+
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeImpl.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeImpl.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeImpl.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DescribedTypeImpl.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import org.apache.qpid.proton.amqp.DescribedType;
+
+class DescribedTypeImpl implements DescribedType
+{
+    private final Object _descriptor;
+    private final Object _described;
+
+    public DescribedTypeImpl(final Object descriptor, final Object described)
+    {
+        _descriptor = descriptor;
+        _described = described;
+    }
+
+    @Override
+    public Object getDescriptor()
+    {
+        return _descriptor;
+    }
+
+    @Override
+    public Object getDescribed()
+    {
+        return _described;
+    }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        if (this == o)
+        {
+            return true;
+        }
+        if (o == null || ! (o instanceof DescribedType))
+        {
+            return false;
+        }
+
+        DescribedType that = (DescribedType) o;
+
+        if (_described != null ? !_described.equals(that.getDescribed()) : that.getDescribed() != null)
+        {
+            return false;
+        }
+        if (_descriptor != null ? !_descriptor.equals(that.getDescriptor()) : that.getDescriptor() != null)
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int result = _descriptor != null ? _descriptor.hashCode() : 0;
+        result = 31 * result + (_described != null ? _described.hashCode() : 0);
+        return result;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "{"  + _descriptor +
+               ": " + _described +
+               '}';
+    }
+}
\ No newline at end of file

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DoubleElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DoubleElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DoubleElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/DoubleElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.codec.Data;
+
+class DoubleElement extends AtomicElement<Double>
+{
+
+    private final double _value;
+
+    DoubleElement(Element parent, Element prev, double d)
+    {
+        super(parent, prev);
+        _value = d;
+    }
+
+    @Override
+    public int size()
+    {
+        return isElementOfArray() ? 8 : 9;
+    }
+
+    @Override
+    public Double getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.DOUBLE;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(b.remaining()>=size)
+        {
+            if(size == 9)
+            {
+                b.put((byte)0x82);
+            }
+            b.putDouble(_value);
+            return size;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Element.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Element.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Element.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/Element.java Tue Jun 18 08:23:57 2013
@@ -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.qpid.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.codec.Data;
+
+interface Element<T>
+{
+    int size();
+    T getValue();
+    Data.DataType getDataType();
+    int encode(ByteBuffer b);
+    Element next();
+    Element prev();
+    Element child();
+    Element parent();
+    void setNext(Element elt);
+
+    Element addChild(Element element);
+
+    Element checkChild(Element element);
+
+    boolean canEnter();
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/FloatElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/FloatElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/FloatElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/FloatElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.codec.Data;
+
+class FloatElement extends AtomicElement<Float>
+{
+
+    private final float _value;
+
+    FloatElement(Element parent, Element prev, float f)
+    {
+        super(parent, prev);
+        _value = f;
+    }
+
+    @Override
+    public int size()
+    {
+        return isElementOfArray() ? 4 : 5;
+    }
+
+    @Override
+    public Float getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.FLOAT;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(b.remaining()>=size)
+        {
+            if(size == 5)
+            {
+                b.put((byte)0x72);
+            }
+            b.putFloat(_value);
+            return size;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/IntegerElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/IntegerElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/IntegerElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/IntegerElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,106 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.codec.Data;
+
+class IntegerElement extends AtomicElement<Integer>
+{
+
+    private final int _value;
+
+    IntegerElement(Element parent, Element prev, int i)
+    {
+        super(parent, prev);
+        _value = i;
+    }
+
+    @Override
+    public int size()
+    {
+        if(isElementOfArray())
+        {
+            final ArrayElement parent = (ArrayElement) parent();
+            if(parent.constructorType() == ArrayElement.SMALL)
+            {
+                if(-128 <= _value && _value <= 127)
+                {
+                    return 1;
+                }
+                else
+                {
+                    parent.setConstructorType(ArrayElement.LARGE);
+                    return 4;
+                }
+            }
+            else
+            {
+                return 4;
+            }
+        }
+        else
+        {
+            return (-128 <= _value && _value <= 127) ? 2 : 5;
+        }
+
+    }
+
+    @Override
+    public Integer getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.INT;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(size <= b.remaining())
+        {
+            switch(size)
+            {
+                case 2:
+                    b.put((byte)0x54);
+                case 1:
+                    b.put((byte)_value);
+                    break;
+
+                case 5:
+                    b.put((byte)0x71);
+                case 4:
+                    b.putInt(_value);
+
+            }
+
+            return size;
+        }
+        return 0;
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/ListElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/ListElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/ListElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/ListElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,222 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+import java.util.*;
+
+import org.apache.qpid.proton.codec.Data;
+
+class ListElement extends AbstractElement<List<Object>>
+{
+    private Element _first;
+
+    ListElement(Element parent, Element prev)
+    {
+        super(parent, prev);
+    }
+
+    public int count()
+    {
+        int count = 0;
+        Element elt = _first;
+        while(elt != null)
+        {
+            count++;
+            elt = elt.next();
+        }
+        return count;
+    }
+
+
+    @Override
+    public int size()
+    {
+        int count = 0;
+        int size = 0;
+        Element elt = _first;
+        while(elt != null)
+        {
+            count++;
+            size += elt.size();
+            elt = elt.next();
+        }
+        if(isElementOfArray())
+        {
+            ArrayElement parent = (ArrayElement) parent();
+            if(parent.constructorType() == ArrayElement.TINY)
+            {
+                if(count != 0)
+                {
+                    parent.setConstructorType(ArrayElement.ConstructorType.SMALL);
+                    size += 2;
+                }
+            }
+            else if(parent.constructorType() == ArrayElement.SMALL)
+            {
+                if(count > 255 || size > 254)
+                {
+                    parent.setConstructorType(ArrayElement.ConstructorType.LARGE);
+                    size += 8;
+                }
+                else
+                {
+                    size += 2;
+                }
+            }
+            size += 8;
+
+        }
+        else
+        {
+            if(count == 0)
+            {
+                size = 1;
+            }
+            else if(count <= 255 && size <= 254)
+            {
+                size += 3;
+            }
+            else
+            {
+                size+=9;
+            }
+        }
+
+        return size;
+    }
+
+    @Override
+    public List<Object> getValue()
+    {
+        List<Object> list = new ArrayList<Object>();
+        Element elt = _first;
+        while(elt != null)
+        {
+            list.add(elt.getValue());
+            elt = elt.next();
+        }
+
+        return Collections.unmodifiableList(list);
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.LIST;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int encodedSize = size();
+
+        int count = 0;
+        int size = 0;
+        Element elt = _first;
+        while(elt != null)
+        {
+            count++;
+            size += elt.size();
+            elt = elt.next();
+        }
+
+        if(encodedSize > b.remaining())
+        {
+            return 0;
+        }
+        else
+        {
+            if(isElementOfArray())
+            {
+                switch(((ArrayElement)parent()).constructorType())
+                {
+                    case TINY:
+                        break;
+                    case SMALL:
+                        b.put((byte)(size+1));
+                        b.put((byte)count);
+                        break;
+                    case LARGE:
+                        b.putInt((size+4));
+                        b.putInt(count);
+                }
+            }
+            else
+            {
+                if(count == 0)
+                {
+                    b.put((byte)0x45);
+                }
+                else if(size <= 254 && count <=255)
+                {
+                    b.put((byte)0xc0);
+                    b.put((byte)(size+1));
+                    b.put((byte)count);
+                }
+                else
+                {
+                    b.put((byte)0xd0);
+                    b.putInt((size+4));
+                    b.putInt(count);
+                }
+
+            }
+
+            elt = _first;
+            while(elt != null)
+            {
+                elt.encode(b);
+                elt = elt.next();
+            }
+
+            return encodedSize;
+        }
+    }
+
+    @Override
+    public boolean canEnter()
+    {
+        return true;
+    }
+
+    @Override
+    public Element child()
+    {
+        // TODO
+        return _first;
+    }
+
+    @Override
+    public Element checkChild(Element element)
+    {
+        return element;
+    }
+
+    @Override
+    public Element addChild(Element element)
+    {
+        _first = element;
+        return element;
+    }
+
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/LongElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/LongElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/LongElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/LongElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,103 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.codec.Data;
+
+class LongElement extends AtomicElement<Long>
+{
+
+    private final long _value;
+
+    LongElement(Element parent, Element prev, long l)
+    {
+        super(parent, prev);
+        _value = l;
+    }
+
+    @Override
+    public int size()
+    {
+        if(isElementOfArray())
+        {
+            final ArrayElement parent = (ArrayElement) parent();
+
+            if(parent.constructorType() == ArrayElement.SMALL)
+            {
+                if(-128l <= _value && _value <= 127l)
+                {
+                    return 1;
+                }
+                else
+                {
+                    parent.setConstructorType(ArrayElement.LARGE);
+                }
+            }
+
+            return 8;
+
+        }
+        else
+        {
+            return (-128l <= _value && _value <= 127l) ? 2 : 9;
+        }
+
+    }
+
+    @Override
+    public Long getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.LONG;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(size > b.remaining())
+        {
+            return 0;
+        }
+        switch(size)
+        {
+            case 2:
+                b.put((byte)0x55);
+            case 1:
+                b.put((byte)_value);
+                break;
+            case 9:
+                b.put((byte)0x81);
+            case 8:
+                b.putLong(_value);
+
+        }
+        return size;
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/MapElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/MapElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/MapElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/MapElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,215 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+import java.util.*;
+
+import org.apache.qpid.proton.codec.Data;
+
+class MapElement extends AbstractElement<Map<Object,Object>>
+{
+    private Element _first;
+
+    MapElement(Element parent, Element prev)
+    {
+        super(parent, prev);
+    }
+
+
+    public int count()
+    {
+        int count = 0;
+        Element elt = _first;
+        while(elt != null)
+        {
+            count++;
+            elt = elt.next();
+        }
+        return count;
+    }
+
+    @Override
+    public int size()
+    {
+        int count = 0;
+        int size = 0;
+        Element elt = _first;
+        while(elt != null)
+        {
+            count++;
+            size += elt.size();
+            elt = elt.next();
+        }
+        if(isElementOfArray())
+        {
+            ArrayElement parent = (ArrayElement) parent();
+
+            if(parent.constructorType() == ArrayElement.SMALL)
+            {
+                if(count > 255 || size > 254)
+                {
+                    parent.setConstructorType(ArrayElement.ConstructorType.LARGE);
+                    size += 8;
+                }
+                else
+                {
+                    size += 2;
+                }
+            }
+            size += 8;
+
+        }
+        else
+        {
+            if(count <= 255 && size <= 254)
+            {
+                size += 3;
+            }
+            else
+            {
+                size+=9;
+            }
+        }
+
+        return size;
+    }
+
+    @Override
+    public Map<Object,Object> getValue()
+    {
+        LinkedHashMap<Object,Object> map = new LinkedHashMap<Object,Object>();
+        Element elt = _first;
+        while(elt != null)
+        {
+            Object key = elt.getValue();
+            Object value;
+            elt = elt.next();
+            if(elt != null)
+            {
+                value = elt.getValue();
+                elt = elt.next();
+            }
+            else
+            {
+                value = null;
+            }
+            map.put(key,value);
+        }
+
+        return Collections.unmodifiableMap(map);
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.MAP;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int encodedSize = size();
+
+        int count = 0;
+        int size = 0;
+        Element elt = _first;
+        while(elt != null)
+        {
+            count++;
+            size += elt.size();
+            elt = elt.next();
+        }
+
+        if(encodedSize > b.remaining())
+        {
+            return 0;
+        }
+        else
+        {
+            if(isElementOfArray())
+            {
+                switch(((ArrayElement)parent()).constructorType())
+                {
+                    case SMALL:
+                        b.put((byte)(size+1));
+                        b.put((byte)count);
+                        break;
+                    case LARGE:
+                        b.putInt((size+4));
+                        b.putInt(count);
+                }
+            }
+            else
+            {
+                if(size <= 254 && count <=255)
+                {
+                    b.put((byte)0xc1);
+                    b.put((byte)(size+1));
+                    b.put((byte)count);
+                }
+                else
+                {
+                    b.put((byte)0xd1);
+                    b.putInt((size+4));
+                    b.putInt(count);
+                }
+
+            }
+
+            elt = _first;
+            while(elt != null)
+            {
+                elt.encode(b);
+                elt = elt.next();
+            }
+
+            return encodedSize;
+        }
+    }
+
+    @Override
+    public boolean canEnter()
+    {
+        return true;
+    }
+
+    @Override
+    public Element child()
+    {
+        return _first;
+    }
+
+    @Override
+    public Element checkChild(Element element)
+    {
+        return element;
+    }
+
+    @Override
+    public Element addChild(Element element)
+    {
+        _first = element;
+        return element;
+    }
+
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/NullElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/NullElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/NullElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/NullElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.codec.Data;
+
+class NullElement extends AtomicElement<Void>
+{
+    NullElement(Element parent, Element prev)
+    {
+        super(parent, prev);
+    }
+
+    @Override
+    public int size()
+    {
+        return isElementOfArray() ? 0 : 1;
+    }
+
+    @Override
+    public Void getValue()
+    {
+        return null;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.NULL;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        if(b.hasRemaining() && !isElementOfArray())
+        {
+            b.put((byte)0x40);
+            return 1;
+        }
+        return 0;
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/ShortElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/ShortElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/ShortElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/ShortElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.codec.Data;
+
+class ShortElement extends AtomicElement<Short>
+{
+
+    private final short _value;
+
+    ShortElement(Element parent, Element prev, short s)
+    {
+        super(parent, prev);
+        _value = s;
+    }
+
+    @Override
+    public int size()
+    {
+        return isElementOfArray() ? 2 : 3;
+    }
+
+    @Override
+    public Short getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.SHORT;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        if(isElementOfArray())
+        {
+            if(b.remaining() >= 2)
+            {
+                b.putShort(_value);
+                return 2;
+            }
+        }
+        else
+        {
+            if(b.remaining()>=3)
+            {
+                b.put((byte)0x61);
+                b.putShort(_value);
+                return 3;
+            }
+        }
+        return 0;
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/StringElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/StringElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/StringElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/StringElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,136 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.codec.Data;
+
+class StringElement extends AtomicElement<String>
+{
+
+    private static final Charset UTF_8 = Charset.forName("UTF-8");
+    private final String _value;
+
+    StringElement(Element parent, Element prev, String s)
+    {
+        super(parent, prev);
+        _value = s;
+    }
+
+    @Override
+    public int size()
+    {
+        final int length = _value.getBytes(UTF_8).length;
+
+        return size(length);
+    }
+
+    private int size(int length)
+    {
+        if(isElementOfArray())
+        {
+            final ArrayElement parent = (ArrayElement) parent();
+
+            if(parent.constructorType() == ArrayElement.SMALL)
+            {
+                if(length > 255)
+                {
+                    parent.setConstructorType(ArrayElement.LARGE);
+                    return 4+length;
+                }
+                else
+                {
+                    return 1+length;
+                }
+            }
+            else
+            {
+                return 4+length;
+            }
+        }
+        else
+        {
+            if(length >255)
+            {
+                return 5 + length;
+            }
+            else
+            {
+                return 2 + length;
+            }
+        }
+    }
+
+    @Override
+    public String getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.STRING;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        final byte[] bytes = _value.getBytes(UTF_8);
+        final int length = bytes.length;
+
+        int size = size(length);
+        if(b.remaining()<size)
+        {
+            return 0;
+        }
+        if(isElementOfArray())
+        {
+            final ArrayElement parent = (ArrayElement) parent();
+
+            if(parent.constructorType() == ArrayElement.SMALL)
+            {
+                b.put((byte)length);
+            }
+            else
+            {
+                b.putInt(length);
+            }
+        }
+        else if(length<=255)
+        {
+            b.put((byte)0xa1);
+            b.put((byte)length);
+        }
+        else
+        {
+            b.put((byte)0xb1);
+            b.put((byte)length);
+        }
+        b.put(bytes);
+        return size;
+
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/SymbolElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/SymbolElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/SymbolElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/SymbolElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,129 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.codec.Data;
+
+class SymbolElement extends AtomicElement<Symbol>
+{
+
+    private static final Charset ASCII = Charset.forName("US-ASCII");
+    private final Symbol _value;
+
+    SymbolElement(Element parent, Element prev, Symbol s)
+    {
+        super(parent, prev);
+        _value = s;
+    }
+
+    @Override
+    public int size()
+    {
+        final int length = _value.length();
+
+        if(isElementOfArray())
+        {
+            final ArrayElement parent = (ArrayElement) parent();
+
+            if(parent.constructorType() == ArrayElement.SMALL)
+            {
+                if(length > 255)
+                {
+                    parent.setConstructorType(ArrayElement.LARGE);
+                    return 4+length;
+                }
+                else
+                {
+                    return 1+length;
+                }
+            }
+            else
+            {
+                return 4+length;
+            }
+        }
+        else
+        {
+            if(length >255)
+            {
+                return 5 + length;
+            }
+            else
+            {
+                return 2 + length;
+            }
+        }
+    }
+
+    @Override
+    public Symbol getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.SYMBOL;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(b.remaining()<size)
+        {
+            return 0;
+        }
+        if(isElementOfArray())
+        {
+            final ArrayElement parent = (ArrayElement) parent();
+
+            if(parent.constructorType() == ArrayElement.SMALL)
+            {
+                b.put((byte)_value.length());
+            }
+            else
+            {
+                b.putInt(_value.length());
+            }
+        }
+        else if(_value.length()<=255)
+        {
+            b.put((byte)0xa3);
+            b.put((byte)_value.length());
+        }
+        else
+        {
+            b.put((byte)0xb3);
+            b.put((byte)_value.length());
+        }
+        b.put(_value.toString().getBytes(ASCII));
+        return size;
+
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/TimestampElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/TimestampElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/TimestampElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/TimestampElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+import java.util.Date;
+
+import org.apache.qpid.proton.codec.Data;
+
+class TimestampElement extends AtomicElement<Date>
+{
+
+    private final Date _value;
+
+    TimestampElement(Element parent, Element prev, Date d)
+    {
+        super(parent, prev);
+        _value = d;
+    }
+
+    @Override
+    public int size()
+    {
+        return isElementOfArray() ? 8 : 9;
+    }
+
+    @Override
+    public Date getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.TIMESTAMP;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(size > b.remaining())
+        {
+            return 0;
+        }
+        if(size == 9)
+        {
+            b.put((byte)0x83);
+        }
+        b.putLong(_value.getTime());
+
+        return size;
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UUIDElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UUIDElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UUIDElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UUIDElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+import java.util.UUID;
+
+import org.apache.qpid.proton.codec.Data;
+
+class UUIDElement extends AtomicElement<UUID>
+{
+
+    private final UUID _value;
+
+    UUIDElement(Element parent, Element prev, UUID u)
+    {
+        super(parent, prev);
+        _value = u;
+    }
+
+    @Override
+    public int size()
+    {
+        return isElementOfArray() ? 16 : 17;
+    }
+
+    @Override
+    public UUID getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.UUID;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(b.remaining()>=size)
+        {
+            if(size == 17)
+            {
+                b.put((byte)0x98);
+            }
+            b.putLong(_value.getMostSignificantBits());
+            b.putLong(_value.getLeastSignificantBits());
+            return size;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedByteElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedByteElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedByteElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedByteElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.amqp.UnsignedByte;
+import org.apache.qpid.proton.codec.Data;
+
+class UnsignedByteElement extends AtomicElement<UnsignedByte>
+{
+
+    private final UnsignedByte _value;
+
+    UnsignedByteElement(Element parent, Element prev, UnsignedByte ub)
+    {
+        super(parent, prev);
+        _value = ub;
+    }
+
+    @Override
+    public int size()
+    {
+        return isElementOfArray() ? 1 : 2;
+    }
+
+    @Override
+    public UnsignedByte getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.UBYTE;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        if(isElementOfArray())
+        {
+            if(b.hasRemaining())
+            {
+                b.put(_value.byteValue());
+                return 1;
+            }
+        }
+        else
+        {
+            if(b.remaining()>=2)
+            {
+                b.put((byte)0x50);
+                b.put(_value.byteValue());
+                return 2;
+            }
+        }
+        return 0;
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedIntegerElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedIntegerElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedIntegerElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedIntegerElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,125 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.apache.qpid.proton.codec.Data;
+
+class UnsignedIntegerElement extends AtomicElement<UnsignedInteger>
+{
+
+    private final UnsignedInteger _value;
+
+    UnsignedIntegerElement(Element parent, Element prev, UnsignedInteger i)
+    {
+        super(parent, prev);
+        _value = i;
+    }
+
+    @Override
+    public int size()
+    {
+        if(isElementOfArray())
+        {
+            final ArrayElement parent = (ArrayElement) parent();
+            if(parent.constructorType() == ArrayElement.TINY)
+            {
+                if(_value.intValue() == 0)
+                {
+                    return 0;
+                }
+                else
+                {
+                    parent.setConstructorType(ArrayElement.SMALL);
+                }
+            }
+
+            if(parent.constructorType() == ArrayElement.SMALL)
+            {
+                if(0 <= _value.intValue() && _value.intValue() <= 255)
+                {
+                    return 1;
+                }
+                else
+                {
+                    parent.setConstructorType(ArrayElement.LARGE);
+                }
+            }
+
+            return 4;
+
+        }
+        else
+        {
+            return 0 == _value.intValue() ? 1 : (1 <= _value.intValue() && _value.intValue() <= 255) ? 2 : 5;
+        }
+
+    }
+
+    @Override
+    public UnsignedInteger getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.UINT;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(size > b.remaining())
+        {
+            return 0;
+        }
+        switch(size)
+        {
+            case 1:
+                if(isElementOfArray())
+                {
+                    b.put((byte)_value.intValue());
+                }
+                else
+                {
+                    b.put((byte)0x43);
+                }
+                break;
+            case 2:
+                b.put((byte)0x52);
+                b.put((byte)_value.intValue());
+                break;
+            case 5:
+                b.put((byte)0x70);
+            case 4:
+                b.putInt(_value.intValue());
+
+        }
+
+        return size;
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedLongElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedLongElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedLongElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedLongElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,125 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.codec.Data;
+
+class UnsignedLongElement extends AtomicElement<UnsignedLong>
+{
+
+    private final UnsignedLong _value;
+
+    UnsignedLongElement(Element parent, Element prev, UnsignedLong ul)
+    {
+        super(parent, prev);
+        _value = ul;
+    }
+
+    @Override
+    public int size()
+    {
+        if(isElementOfArray())
+        {
+            final ArrayElement parent = (ArrayElement) parent();
+            if(parent.constructorType() == ArrayElement.TINY)
+            {
+                if(_value.longValue() == 0l)
+                {
+                    return 0;
+                }
+                else
+                {
+                    parent.setConstructorType(ArrayElement.SMALL);
+                }
+            }
+
+            if(parent.constructorType() == ArrayElement.SMALL)
+            {
+                if(0l <= _value.longValue() && _value.longValue() <= 255l)
+                {
+                    return 1;
+                }
+                else
+                {
+                    parent.setConstructorType(ArrayElement.LARGE);
+                }
+            }
+
+            return 8;
+
+        }
+        else
+        {
+            return 0l == _value.longValue() ? 1 : (1l <= _value.longValue() && _value.longValue() <= 255l) ? 2 : 9;
+        }
+
+    }
+
+    @Override
+    public UnsignedLong getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.ULONG;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        int size = size();
+        if(size > b.remaining())
+        {
+            return 0;
+        }
+        switch(size)
+        {
+            case 1:
+                if(isElementOfArray())
+                {
+                    b.put((byte)_value.longValue());
+                }
+                else
+                {
+                    b.put((byte)0x44);
+                }
+                break;
+            case 2:
+                b.put((byte)0x53);
+                b.put((byte)_value.longValue());
+                break;
+            case 9:
+                b.put((byte)0x80);
+            case 8:
+                b.putLong(_value.longValue());
+
+        }
+
+        return size;
+    }
+}

Added: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedShortElement.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedShortElement.java?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedShortElement.java (added)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/impl/UnsignedShortElement.java Tue Jun 18 08:23:57 2013
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.proton.codec.impl;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.amqp.UnsignedShort;
+import org.apache.qpid.proton.codec.Data;
+
+class UnsignedShortElement extends AtomicElement<UnsignedShort>
+{
+
+    private final UnsignedShort _value;
+
+    UnsignedShortElement(Element parent, Element prev, UnsignedShort ub)
+    {
+        super(parent, prev);
+        _value = ub;
+    }
+
+    @Override
+    public int size()
+    {
+        return isElementOfArray() ? 2 : 3;
+    }
+
+    @Override
+    public UnsignedShort getValue()
+    {
+        return _value;
+    }
+
+    @Override
+    public Data.DataType getDataType()
+    {
+        return Data.DataType.USHORT;
+    }
+
+    @Override
+    public int encode(ByteBuffer b)
+    {
+        if(isElementOfArray())
+        {
+            if(b.remaining()>=2)
+            {
+                b.putShort(_value.shortValue());
+                return 2;
+            }
+        }
+        else
+        {
+            if(b.remaining()>=3)
+            {
+                b.put((byte)0x60);
+                b.putShort(_value.shortValue());
+                return 3;
+            }
+        }
+        return 0;
+    }
+}

Modified: qpid/proton/trunk/tests/java/org/apache/qpid/proton/JythonTest.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/java/org/apache/qpid/proton/JythonTest.java?rev=1494067&r1=1494066&r2=1494067&view=diff
==============================================================================
--- qpid/proton/trunk/tests/java/org/apache/qpid/proton/JythonTest.java (original)
+++ qpid/proton/trunk/tests/java/org/apache/qpid/proton/JythonTest.java Tue Jun 18 08:23:57 2013
@@ -48,11 +48,13 @@ public class JythonTest
     private static final String PROTON_JYTHON_TEST_ROOT = "protonJythonTestRoot";
     private static final String PROTON_JYTHON_TEST_SCRIPT = "protonJythonTestScript";
     private static final String PROTON_JYTHON_TESTS_XML_OUTPUT_DIRECTORY = "protonJythonTestXmlOutputDirectory";
+    private static final String PROTON_JYTHON_IGNORE_FILE = "protonJythonIgnoreFile";
 
     /** Name of the junit style xml report to be written by the python test script */
     private static final String XML_REPORT_NAME = "TEST-jython-test-results.xml";
 
     public static final String TEST_PATTERN_SYSTEM_PROPERTY = "proton.pythontest.pattern";
+    public static final String IGNORE_FILE_SYSTEM_PROPERTY = "proton.pythontest.ignore_file";
 
     /** The number of times to run the test, or forever if zero */
     public static final String TEST_INVOCATIONS_SYSTEM_PROPERTY = "proton.pythontest.invocations";
@@ -65,8 +67,9 @@ public class JythonTest
         String testScript = getJythonTestScript();
         String testRoot = getJythonTestRoot();
         String xmlReportFile = getOptionalXmlReportFilename();
+        String ignoreFile = getOptionalIgnoreFile();
 
-        PythonInterpreter interp = createInterpreterWithArgs(xmlReportFile);
+        PythonInterpreter interp = createInterpreterWithArgs(xmlReportFile, ignoreFile);
         interp.getSystemState().path.insert(0, new PyString(testRoot));
 
         LOGGER.info("About to call Jython test script: '" + testScript
@@ -116,7 +119,7 @@ public class JythonTest
         }
     }
 
-    private PythonInterpreter createInterpreterWithArgs(String xmlReportFile)
+    private PythonInterpreter createInterpreterWithArgs(String xmlReportFile, String ignoreFile)
     {
         PySystemState systemState = new PySystemState();
 
@@ -126,6 +129,17 @@ public class JythonTest
             systemState.argv.append(new PyString(xmlReportFile));
         }
 
+        if(ignoreFile == null)
+        {
+            ignoreFile = System.getProperty(IGNORE_FILE_SYSTEM_PROPERTY);
+        }
+
+        if(ignoreFile != null)
+        {
+            systemState.argv.append(new PyString("-I"));
+            systemState.argv.append(new PyString(ignoreFile));
+        }
+
         String testPattern = System.getProperty(TEST_PATTERN_SYSTEM_PROPERTY);
         if(testPattern != null)
         {
@@ -164,6 +178,26 @@ public class JythonTest
         return testRoot.getAbsolutePath();
     }
 
+    private String getOptionalIgnoreFile()
+    {
+        String ignoreFile = System.getProperty(PROTON_JYTHON_IGNORE_FILE);
+
+        if(ignoreFile != null)
+        {
+            File f = new File(ignoreFile);
+            if(f.exists() && f.canRead())
+            {
+                return ignoreFile;
+            }
+            else
+            {
+                LOGGER.info(PROTON_JYTHON_IGNORE_FILE + " system property set to " + ignoreFile + " but this cannot be read.");
+            }
+        }
+        return null;
+        
+    }
+
     private String getOptionalXmlReportFilename()
     {
         String xmlOutputDirString = System.getProperty(PROTON_JYTHON_TESTS_XML_OUTPUT_DIRECTORY);

Added: qpid/proton/trunk/tests/java/pythonTests.ignore
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/java/pythonTests.ignore?rev=1494067&view=auto
==============================================================================
--- qpid/proton/trunk/tests/java/pythonTests.ignore (added)
+++ qpid/proton/trunk/tests/java/pythonTests.ignore Tue Jun 18 08:23:57 2013
@@ -0,0 +1,3 @@
+proton_tests.soak.*
+proton_tests.ssl.SslTest.test_defaults_messenger_app
+proton_tests.ssl.SslTest.test_server_authentication_messenger_app

Modified: qpid/proton/trunk/tests/pom.xml
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/pom.xml?rev=1494067&r1=1494066&r2=1494067&view=diff
==============================================================================
--- qpid/proton/trunk/tests/pom.xml (original)
+++ qpid/proton/trunk/tests/pom.xml Tue Jun 18 08:23:57 2013
@@ -57,6 +57,7 @@ directory &lt;basedir&gt;/build/proton-c
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <systemPropertyVariables>
+            <protonJythonIgnoreFile>${basedir}/java/pythonTests.ignore</protonJythonIgnoreFile>
             <protonJythonTestRoot>${basedir}/python</protonJythonTestRoot>
             <protonJythonTestScript>${basedir}/python/proton-test</protonJythonTestScript>
             <protonJythonTestXmlOutputDirectory>${testReportOutputDirectory}</protonJythonTestXmlOutputDirectory>

Modified: qpid/proton/trunk/tests/python/proton_tests/interop.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/python/proton_tests/interop.py?rev=1494067&r1=1494066&r2=1494067&view=diff
==============================================================================
--- qpid/proton/trunk/tests/python/proton_tests/interop.py (original)
+++ qpid/proton/trunk/tests/python/proton_tests/interop.py Tue Jun 18 08:23:57 2013
@@ -53,8 +53,6 @@ class InteropTest(common.Test):
             n = self.data.decode(buffer)
             buffer = buffer[n:]
         self.data.rewind()
-        # Test the round-trip re-encoding gives the same result.
-        assert encoded == self.data.encode()
 
     def decode_data_file(self, name): self.decode_data(self.get_data(name))
 



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