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 2012/12/12 14:33:07 UTC
svn commit: r1420665 [5/7] - in /qpid/proton/trunk/proton-j:
contrib/proton-hawtdispatch/src/main/java/org/apache/qpid/proton/hawtdispatch/api/
contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/
proton/src/main/java/org/apache/qpid/proton/amq...
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ModifiedType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Modified.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ModifiedType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ModifiedType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Modified.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Modified.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ModifiedType.java Wed Dec 12 13:32:32 2012
@@ -21,156 +21,123 @@
*/
-package org.apache.qpid.proton.type.messaging;
-import java.util.Map;
-import java.util.List;
-import java.util.AbstractList;
-
+package org.apache.qpid.proton.codec.messaging;
+import java.util.AbstractList;
+import java.util.List;
+import java.util.Map;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Modified;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.*;
+import org.apache.qpid.proton.codec.EncoderImpl;
-public class Modified
- implements DescribedType , org.apache.qpid.proton.type.transport.DeliveryState, Outcome
+public class ModifiedType extends AbstractDescribedType<Modified,List> implements DescribedTypeConstructor<Modified>
{
private static final Object[] DESCRIPTORS =
{
- UnsignedLong.valueOf(0x0000000000000027L), Symbol.valueOf("amqp:modified:list"),
+ UnsignedLong.valueOf(0x0000000000000027L), Symbol.valueOf("amqp:modified:list"),
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000027L);
- private final ModifiedWrapper _wrapper = new ModifiedWrapper();
-
- private Boolean _deliveryFailed;
- private Boolean _undeliverableHere;
- private Map _messageAnnotations;
-
- public Boolean getDeliveryFailed()
- {
- return _deliveryFailed;
- }
- public void setDeliveryFailed(Boolean deliveryFailed)
+ private ModifiedType(EncoderImpl encoder)
{
- _deliveryFailed = deliveryFailed;
+ super(encoder);
}
- public Boolean getUndeliverableHere()
+ public UnsignedLong getDescriptor()
{
- return _undeliverableHere;
+ return DESCRIPTOR;
}
- public void setUndeliverableHere(Boolean undeliverableHere)
+ @Override
+ protected List wrap(Modified val)
{
- _undeliverableHere = undeliverableHere;
+ return new ModifiedWrapper(val);
}
- public Map getMessageAnnotations()
- {
- return _messageAnnotations;
- }
- public void setMessageAnnotations(Map messageAnnotations)
- {
- _messageAnnotations = messageAnnotations;
- }
-
- public Object getDescriptor()
- {
- return DESCRIPTOR;
- }
-
- public Object getDescribed()
- {
- return _wrapper;
- }
-
- public Object get(final int index)
+ public final class ModifiedWrapper extends AbstractList
{
+ private final Modified _impl;
- switch(index)
+ public ModifiedWrapper(Modified impl)
{
- case 0:
- return _deliveryFailed;
- case 1:
- return _undeliverableHere;
- case 2:
- return _messageAnnotations;
+ _impl = impl;
}
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _messageAnnotations != null
- ? 3
- : _undeliverableHere != null
- ? 2
- : _deliveryFailed != null
- ? 1
- : 0;
-
- }
+ public Object get(final int index)
+ {
+ switch(index)
+ {
+ case 0:
+ return _impl.getDeliveryFailed();
+ case 1:
+ return _impl.getUndeliverableHere();
+ case 2:
+ return _impl.getMessageAnnotations();
+ }
- public final class ModifiedWrapper extends AbstractList
- {
+ throw new IllegalStateException("Unknown index " + index);
- @Override
- public Object get(final int index)
- {
- return Modified.this.get(index);
}
- @Override
public int size()
{
- return Modified.this.size();
+ return _impl.getMessageAnnotations() != null
+ ? 3
+ : _impl.getUndeliverableHere() != null
+ ? 2
+ : _impl.getDeliveryFailed() != null
+ ? 1
+ : 0;
+
}
+
}
- private static class ModifiedConstructor implements DescribedTypeConstructor<Modified>
+ public Modified newInstance(Object described)
{
- public Modified newInstance(Object described)
- {
- List l = (List) described;
+ List l = (List) described;
- Modified o = new Modified();
+ Modified o = new Modified();
- switch(3 - l.size())
- {
+ switch(3 - l.size())
+ {
- case 0:
- o.setMessageAnnotations( (Map) l.get( 2 ) );
- case 1:
- o.setUndeliverableHere( (Boolean) l.get( 1 ) );
- case 2:
- o.setDeliveryFailed( (Boolean) l.get( 0 ) );
- }
+ case 0:
+ o.setMessageAnnotations( (Map) l.get( 2 ) );
+ case 1:
+ o.setUndeliverableHere( (Boolean) l.get( 1 ) );
+ case 2:
+ o.setDeliveryFailed( (Boolean) l.get( 0 ) );
+ }
- return o;
- }
+ return o;
+ }
- public Class<Modified> getTypeClass()
- {
- return Modified.class;
- }
+ public Class<Modified> getTypeClass()
+ {
+ return Modified.class;
}
- public static void register(Decoder decoder)
+
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- ModifiedConstructor constructor = new ModifiedConstructor();
+ ModifiedType type = new ModifiedType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
}
\ No newline at end of file
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Properties.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Properties.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Properties.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java Wed Dec 12 13:32:32 2012
@@ -21,19 +21,23 @@
*/
-package org.apache.qpid.proton.type.messaging;
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.AbstractList;
import java.util.Date;
import java.util.List;
-import java.util.AbstractList;
-
-
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Properties;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.*;
+import org.apache.qpid.proton.codec.EncoderImpl;
-public class Properties
- implements DescribedType , Section
+public class PropertiesType extends AbstractDescribedType<Properties,List> implements DescribedTypeConstructor<Properties>
{
private static final Object[] DESCRIPTORS =
{
@@ -41,250 +45,104 @@ public class Properties
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000073L);
- private final PropertiesWrapper _wrapper = new PropertiesWrapper();
-
- private Object _messageId;
- private Binary _userId;
- private String _to;
- private String _subject;
- private String _replyTo;
- private Object _correlationId;
- private Symbol _contentType;
- private Symbol _contentEncoding;
- private Date _absoluteExpiryTime;
- private Date _creationTime;
- private String _groupId;
- private UnsignedInteger _groupSequence;
- private String _replyToGroupId;
-
- public Object getMessageId()
- {
- return _messageId;
- }
-
- public void setMessageId(Object messageId)
- {
- _messageId = messageId;
- }
-
- public Binary getUserId()
- {
- return _userId;
- }
-
- public void setUserId(Binary userId)
- {
- _userId = userId;
- }
-
- public String getTo()
- {
- return _to;
- }
-
- public void setTo(String to)
- {
- _to = to;
- }
-
- public String getSubject()
- {
- return _subject;
- }
-
- public void setSubject(String subject)
- {
- _subject = subject;
- }
- public String getReplyTo()
+ private PropertiesType(EncoderImpl encoder)
{
- return _replyTo;
+ super(encoder);
}
- public void setReplyTo(String replyTo)
- {
- _replyTo = replyTo;
- }
-
- public Object getCorrelationId()
- {
- return _correlationId;
- }
-
- public void setCorrelationId(Object correlationId)
- {
- _correlationId = correlationId;
- }
-
- public Symbol getContentType()
- {
- return _contentType;
- }
-
- public void setContentType(Symbol contentType)
- {
- _contentType = contentType;
- }
-
- public Symbol getContentEncoding()
- {
- return _contentEncoding;
- }
-
- public void setContentEncoding(Symbol contentEncoding)
- {
- _contentEncoding = contentEncoding;
- }
-
- public Date getAbsoluteExpiryTime()
- {
- return _absoluteExpiryTime;
- }
-
- public void setAbsoluteExpiryTime(Date absoluteExpiryTime)
- {
- _absoluteExpiryTime = absoluteExpiryTime;
- }
-
- public Date getCreationTime()
- {
- return _creationTime;
- }
-
- public void setCreationTime(Date creationTime)
- {
- _creationTime = creationTime;
- }
-
- public String getGroupId()
- {
- return _groupId;
- }
-
- public void setGroupId(String groupId)
- {
- _groupId = groupId;
- }
-
- public UnsignedInteger getGroupSequence()
- {
- return _groupSequence;
- }
-
- public void setGroupSequence(UnsignedInteger groupSequence)
- {
- _groupSequence = groupSequence;
- }
-
- public String getReplyToGroupId()
- {
- return _replyToGroupId;
- }
-
- public void setReplyToGroupId(String replyToGroupId)
- {
- _replyToGroupId = replyToGroupId;
- }
-
- public Object getDescriptor()
+ public UnsignedLong getDescriptor()
{
return DESCRIPTOR;
}
- public Object getDescribed()
+ @Override
+ protected List wrap(Properties val)
{
- return _wrapper;
+ return new PropertiesWrapper(val);
}
- public Object get(final int index)
+ private static final class PropertiesWrapper extends AbstractList
{
- switch(index)
+ private Properties _impl;
+
+ public PropertiesWrapper(Properties propertiesType)
{
- case 0:
- return _messageId;
- case 1:
- return _userId;
- case 2:
- return _to;
- case 3:
- return _subject;
- case 4:
- return _replyTo;
- case 5:
- return _correlationId;
- case 6:
- return _contentType;
- case 7:
- return _contentEncoding;
- case 8:
- return _absoluteExpiryTime;
- case 9:
- return _creationTime;
- case 10:
- return _groupId;
- case 11:
- return _groupSequence;
- case 12:
- return _replyToGroupId;
+ _impl = propertiesType;
}
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _replyToGroupId != null
- ? 13
- : _groupSequence != null
- ? 12
- : _groupId != null
- ? 11
- : _creationTime != null
- ? 10
- : _absoluteExpiryTime != null
- ? 9
- : _contentEncoding != null
- ? 8
- : _contentType != null
- ? 7
- : _correlationId != null
- ? 6
- : _replyTo != null
- ? 5
- : _subject != null
- ? 4
- : _to != null
- ? 3
- : _userId != null
- ? 2
- : _messageId != null
- ? 1
- : 0;
-
- }
+ public Object get(final int index)
+ {
+ switch(index)
+ {
+ case 0:
+ return _impl.getMessageId();
+ case 1:
+ return _impl.getUserId();
+ case 2:
+ return _impl.getTo();
+ case 3:
+ return _impl.getSubject();
+ case 4:
+ return _impl.getReplyTo();
+ case 5:
+ return _impl.getCorrelationId();
+ case 6:
+ return _impl.getContentType();
+ case 7:
+ return _impl.getContentEncoding();
+ case 8:
+ return _impl.getAbsoluteExpiryTime();
+ case 9:
+ return _impl.getCreationTime();
+ case 10:
+ return _impl.getGroupId();
+ case 11:
+ return _impl.getGroupSequence();
+ case 12:
+ return _impl.getReplyToGroupId();
+ }
- public final class PropertiesWrapper extends AbstractList
- {
+ throw new IllegalStateException("Unknown index " + index);
- @Override
- public Object get(final int index)
- {
- return Properties.this.get(index);
}
- @Override
public int size()
{
- return Properties.this.size();
+ return _impl.getReplyToGroupId() != null
+ ? 13
+ : _impl.getGroupSequence() != null
+ ? 12
+ : _impl.getGroupId() != null
+ ? 11
+ : _impl.getCreationTime() != null
+ ? 10
+ : _impl.getAbsoluteExpiryTime() != null
+ ? 9
+ : _impl.getContentEncoding() != null
+ ? 8
+ : _impl.getContentType() != null
+ ? 7
+ : _impl.getCorrelationId() != null
+ ? 6
+ : _impl.getReplyTo() != null
+ ? 5
+ : _impl.getSubject() != null
+ ? 4
+ : _impl.getTo() != null
+ ? 3
+ : _impl.getUserId() != null
+ ? 2
+ : _impl.getMessageId() != null
+ ? 1
+ : 0;
+
}
+
}
- private static class PropertiesConstructor implements DescribedTypeConstructor<Properties>
- {
public Properties newInstance(Object described)
{
List l = (List) described;
@@ -331,35 +189,17 @@ public class Properties
{
return Properties.class;
}
- }
- public static void register(Decoder decoder)
+
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- PropertiesConstructor constructor = new PropertiesConstructor();
+ PropertiesType type = new PropertiesType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
- @Override
- public String toString()
- {
- return "Properties{" +
- "messageId=" + _messageId +
- ", userId=" + _userId +
- ", to='" + _to + '\'' +
- ", subject='" + _subject + '\'' +
- ", replyTo='" + _replyTo + '\'' +
- ", correlationId=" + _correlationId +
- ", contentType=" + _contentType +
- ", contentEncoding=" + _contentEncoding +
- ", absoluteExpiryTime=" + _absoluteExpiryTime +
- ", creationTime=" + _creationTime +
- ", groupId='" + _groupId + '\'' +
- ", groupSequence=" + _groupSequence +
- ", replyToGroupId='" + _replyToGroupId + '\'' +
- '}';
- }
}
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ReceivedType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Received.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ReceivedType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ReceivedType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Received.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Received.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ReceivedType.java Wed Dec 12 13:32:32 2012
@@ -21,138 +21,115 @@
*/
-package org.apache.qpid.proton.type.messaging;
-import java.util.List;
-import java.util.AbstractList;
-
+package org.apache.qpid.proton.codec.messaging;
+import java.util.AbstractList;
+import java.util.List;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Received;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.*;
+import org.apache.qpid.proton.codec.EncoderImpl;
-public class Received
- implements DescribedType , org.apache.qpid.proton.type.transport.DeliveryState
+public final class ReceivedType extends AbstractDescribedType<Received,List> implements DescribedTypeConstructor<Received>
{
private static final Object[] DESCRIPTORS =
{
- UnsignedLong.valueOf(0x0000000000000023L), Symbol.valueOf("amqp:received:list"),
+ UnsignedLong.valueOf(0x0000000000000023L), Symbol.valueOf("amqp:received:list"),
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000023L);
- private final ReceivedWrapper _wrapper = new ReceivedWrapper();
-
- private UnsignedInteger _sectionNumber;
- private UnsignedLong _sectionOffset;
- public UnsignedInteger getSectionNumber()
+ private ReceivedType(EncoderImpl encoder)
{
- return _sectionNumber;
+ super(encoder);
}
- public void setSectionNumber(UnsignedInteger sectionNumber)
+ public UnsignedLong getDescriptor()
{
- _sectionNumber = sectionNumber;
+ return DESCRIPTOR;
}
- public UnsignedLong getSectionOffset()
+ @Override
+ protected List wrap(Received val)
{
- return _sectionOffset;
+ return new ReceivedWrapper(val);
}
- public void setSectionOffset(UnsignedLong sectionOffset)
- {
- _sectionOffset = sectionOffset;
- }
-
- public Object getDescriptor()
- {
- return DESCRIPTOR;
- }
- public Object getDescribed()
- {
- return _wrapper;
- }
-
- public Object get(final int index)
+ private static final class ReceivedWrapper extends AbstractList
{
+ private final Received _impl;
- switch(index)
+ private ReceivedWrapper(Received impl)
{
- case 0:
- return _sectionNumber;
- case 1:
- return _sectionOffset;
+ _impl = impl;
}
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _sectionOffset != null
- ? 2
- : _sectionNumber != null
- ? 1
- : 0;
-
- }
+ public Object get(final int index)
+ {
+ switch(index)
+ {
+ case 0:
+ return _impl.getSectionNumber();
+ case 1:
+ return _impl.getSectionOffset();
+ }
- public final class ReceivedWrapper extends AbstractList
- {
+ throw new IllegalStateException("Unknown index " + index);
- @Override
- public Object get(final int index)
- {
- return Received.this.get(index);
}
- @Override
public int size()
{
- return Received.this.size();
+ return _impl.getSectionOffset() != null
+ ? 2
+ : _impl.getSectionOffset() != null
+ ? 1
+ : 0;
+
}
}
- private static class ReceivedConstructor implements DescribedTypeConstructor<Received>
+ public Received newInstance(Object described)
{
- public Received newInstance(Object described)
- {
- List l = (List) described;
+ List l = (List) described;
- Received o = new Received();
+ Received o = new Received();
- switch(2 - l.size())
- {
+ switch(2 - l.size())
+ {
- case 0:
- o.setSectionOffset( (UnsignedLong) l.get( 1 ) );
- case 1:
- o.setSectionNumber( (UnsignedInteger) l.get( 0 ) );
- }
+ case 0:
+ o.setSectionOffset( (UnsignedLong) l.get( 1 ) );
+ case 1:
+ o.setSectionNumber( (UnsignedInteger) l.get( 0 ) );
+ }
- return o;
- }
+ return o;
+ }
- public Class<Received> getTypeClass()
- {
- return Received.class;
- }
+ public Class<Received> getTypeClass()
+ {
+ return Received.class;
}
- public static void register(Decoder decoder)
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- ReceivedConstructor constructor = new ReceivedConstructor();
+ ReceivedType type = new ReceivedType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
}
\ No newline at end of file
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/RejectedType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Rejected.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/RejectedType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/RejectedType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Rejected.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Rejected.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/RejectedType.java Wed Dec 12 13:32:32 2012
@@ -21,121 +21,107 @@
*/
-package org.apache.qpid.proton.type.messaging;
-import java.util.List;
-import java.util.AbstractList;
-
+package org.apache.qpid.proton.codec.messaging;
+import java.util.AbstractList;
+import java.util.List;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Rejected;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.*;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.amqp.transport.ErrorCondition;
-public class Rejected
- implements DescribedType , org.apache.qpid.proton.type.transport.DeliveryState, Outcome
+public class RejectedType extends AbstractDescribedType<Rejected,List> implements DescribedTypeConstructor<Rejected>
{
private static final Object[] DESCRIPTORS =
{
- UnsignedLong.valueOf(0x0000000000000025L), Symbol.valueOf("amqp:rejected:list"),
+ UnsignedLong.valueOf(0x0000000000000025L), Symbol.valueOf("amqp:rejected:list"),
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000025L);
- private final RejectedWrapper _wrapper = new RejectedWrapper();
-
- private List _error;
- public List getError()
+ private RejectedType(EncoderImpl encoder)
{
- return _error;
+ super(encoder);
}
- public void setError(List error)
- {
- _error = error;
- }
-
- public Object getDescriptor()
+ public UnsignedLong getDescriptor()
{
return DESCRIPTOR;
}
- public Object getDescribed()
+ @Override
+ protected List wrap(Rejected val)
{
- return _wrapper;
+ return new RejectedWrapper(val);
}
-
- public Object get(final int index)
+
+
+ private static final class RejectedWrapper extends AbstractList
{
+ private final Rejected _impl;
- switch(index)
+ private RejectedWrapper(Rejected impl)
{
- case 0:
- return _error;
+ _impl = impl;
}
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _error != null
- ? 1
- : 0;
-
- }
+ public Object get(final int index)
+ {
+ switch(index)
+ {
+ case 0:
+ return _impl.getError();
+ }
- public final class RejectedWrapper extends AbstractList
- {
+ throw new IllegalStateException("Unknown index " + index);
- @Override
- public Object get(final int index)
- {
- return Rejected.this.get(index);
}
- @Override
public int size()
{
- return Rejected.this.size();
+ return _impl.getError() != null
+ ? 1
+ : 0;
+
}
}
- private static class RejectedConstructor implements DescribedTypeConstructor<Rejected>
+ public Rejected newInstance(Object described)
{
- public Rejected newInstance(Object described)
- {
- List l = (List) described;
-
- Rejected o = new Rejected();
+ List l = (List) described;
+ Rejected o = new Rejected();
- switch(1 - l.size())
- {
-
- case 0:
- o.setError( (List) l.get( 0 ) );
- }
+ switch(1 - l.size())
+ {
+ case 0:
+ o.setError( (ErrorCondition) l.get( 0 ) );
+ }
- return o;
- }
+ return o;
+ }
- public Class<Rejected> getTypeClass()
- {
- return Rejected.class;
- }
+ public Class<Rejected> getTypeClass()
+ {
+ return Rejected.class;
}
- public static void register(Decoder decoder)
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- RejectedConstructor constructor = new RejectedConstructor();
+ RejectedType type = new RejectedType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
}
\ No newline at end of file
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ReleasedType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Released.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ReleasedType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ReleasedType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Released.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Released.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/ReleasedType.java Wed Dec 12 13:32:32 2012
@@ -21,94 +21,63 @@
*/
-package org.apache.qpid.proton.type.messaging;
-import java.util.List;
-import java.util.AbstractList;
-
+package org.apache.qpid.proton.codec.messaging;
+import java.util.Collections;
+import java.util.List;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Released;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.*;
+import org.apache.qpid.proton.codec.EncoderImpl;
-public class Released
- implements DescribedType , org.apache.qpid.proton.type.transport.DeliveryState, Outcome
+public class ReleasedType extends AbstractDescribedType<Released,List> implements DescribedTypeConstructor<Released>
{
private static final Object[] DESCRIPTORS =
{
- UnsignedLong.valueOf(0x0000000000000026L), Symbol.valueOf("amqp:released:list"),
+ UnsignedLong.valueOf(0x0000000000000026L), Symbol.valueOf("amqp:released:list"),
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000026L);
- private final ReleasedWrapper _wrapper = new ReleasedWrapper();
-
-
- public Object getDescriptor()
- {
- return DESCRIPTOR;
- }
- public Object getDescribed()
+ public ReleasedType(EncoderImpl encoder)
{
- return _wrapper;
+ super(encoder);
}
-
- public Object get(final int index)
- {
-
- throw new IllegalStateException("Unknown index " + index);
+ public UnsignedLong getDescriptor()
+ {
+ return DESCRIPTOR;
}
- public int size()
+ @Override
+ protected List wrap(Released val)
{
- return 0;
-
+ return Collections.EMPTY_LIST;
}
- public final class ReleasedWrapper extends AbstractList
+ public Released newInstance(Object described)
{
-
- @Override
- public Object get(final int index)
- {
- return Released.this.get(index);
- }
-
- @Override
- public int size()
- {
- return Released.this.size();
- }
+ return Released.getInstance();
}
- private static class ReleasedConstructor implements DescribedTypeConstructor<Released>
+ public Class<Released> getTypeClass()
{
- public Released newInstance(Object described)
- {
- List l = (List) described;
-
- Released o = new Released();
-
-
- return o;
- }
-
- public Class<Released> getTypeClass()
- {
- return Released.class;
- }
+ return Released.class;
}
-
- public static void register(Decoder decoder)
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- ReleasedConstructor constructor = new ReleasedConstructor();
+ ReleasedType type = new ReleasedType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
}
\ No newline at end of file
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/SourceType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Source.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/SourceType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/SourceType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Source.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Source.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/SourceType.java Wed Dec 12 13:32:32 2012
@@ -21,23 +21,25 @@
*/
-package org.apache.qpid.proton.type.messaging;
-
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.DescribedType;
-import org.apache.qpid.proton.type.Symbol;
-import org.apache.qpid.proton.type.UnsignedInteger;
-import org.apache.qpid.proton.type.UnsignedLong;
+package org.apache.qpid.proton.codec.messaging;
import java.util.AbstractList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Outcome;
+import org.apache.qpid.proton.amqp.messaging.Source;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DescribedTypeConstructor;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.amqp.messaging.TerminusDurability;
+import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy;
-public class Source
- implements DescribedType , org.apache.qpid.proton.type.transport.Source
+public class SourceType extends AbstractDescribedType<Source,List> implements DescribedTypeConstructor<Source>
{
private static final Object[] DESCRIPTORS =
{
@@ -45,310 +47,171 @@ public class Source
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000028L);
- private final SourceWrapper _wrapper = new SourceWrapper();
-
- private String _address;
- private UnsignedInteger _durable = UnsignedInteger.valueOf(0);
- private Symbol _expiryPolicy = Symbol.valueOf("session-end");
- private UnsignedInteger _timeout = UnsignedInteger.valueOf(0);
- private boolean _dynamic;
- private Map _dynamicNodeProperties;
- private Symbol _distributionMode;
- private Map _filter;
- private Outcome _defaultOutcome;
- private Symbol[] _outcomes;
- private Symbol[] _capabilities;
-
- public String getAddress()
- {
- return _address;
- }
-
- public void setAddress(String address)
- {
- _address = address;
- }
-
- public UnsignedInteger getDurable()
- {
- return _durable;
- }
-
- public void setDurable(UnsignedInteger durable)
- {
- _durable = durable;
- }
-
- public Symbol getExpiryPolicy()
- {
- return _expiryPolicy;
- }
-
- public void setExpiryPolicy(Symbol expiryPolicy)
- {
- _expiryPolicy = expiryPolicy;
- }
- public UnsignedInteger getTimeout()
+ public SourceType(EncoderImpl encoder)
{
- return _timeout;
+ super(encoder);
}
- public void setTimeout(UnsignedInteger timeout)
+ public UnsignedLong getDescriptor()
{
- _timeout = timeout;
- }
-
- public boolean getDynamic()
- {
- return _dynamic;
+ return DESCRIPTOR;
}
- public void setDynamic(boolean dynamic)
+ @Override
+ protected List wrap(Source val)
{
- _dynamic = dynamic;
+ return new SourceWrapper(val);
}
- public Map getDynamicNodeProperties()
- {
- return _dynamicNodeProperties;
- }
- public void setDynamicNodeProperties(Map dynamicNodeProperties)
+ private static final class SourceWrapper extends AbstractList
{
- _dynamicNodeProperties = dynamicNodeProperties;
- }
+ private final Source _impl;
- public Symbol getDistributionMode()
- {
- return _distributionMode;
- }
+ public SourceWrapper(Source impl)
+ {
+ _impl = impl;
+ }
- public void setDistributionMode(Symbol distributionMode)
- {
- _distributionMode = distributionMode;
- }
+ public Object get(final int index)
+ {
- public Map getFilter()
- {
- return _filter;
- }
+ switch(index)
+ {
+ case 0:
+ return _impl.getAddress();
+ case 1:
+ return _impl.getDurable().getValue();
+ case 2:
+ return _impl.getExpiryPolicy().getPolicy();
+ case 3:
+ return _impl.getTimeout();
+ case 4:
+ return _impl.getDynamic();
+ case 5:
+ return _impl.getDynamicNodeProperties();
+ case 6:
+ return _impl.getDistributionMode();
+ case 7:
+ return _impl.getFilter();
+ case 8:
+ return _impl.getDefaultOutcome();
+ case 9:
+ return _impl.getOutcomes();
+ case 10:
+ return _impl.getCapabilities();
+ }
- public void setFilter(Map filter)
- {
- _filter = filter;
- }
+ throw new IllegalStateException("Unknown index " + index);
- public Outcome getDefaultOutcome()
- {
- return _defaultOutcome;
- }
+ }
- public void setDefaultOutcome(Outcome defaultOutcome)
- {
- _defaultOutcome = defaultOutcome;
- }
+ public int size()
+ {
+ return _impl.getCapabilities() != null
+ ? 11
+ : _impl.getOutcomes() != null
+ ? 10
+ : _impl.getDefaultOutcome() != null
+ ? 9
+ : _impl.getFilter() != null
+ ? 8
+ : _impl.getDistributionMode() != null
+ ? 7
+ : _impl.getDynamicNodeProperties() != null
+ ? 6
+ : _impl.getDynamic()
+ ? 5
+ : (_impl.getTimeout() != null && !_impl.getTimeout().equals(UnsignedInteger.ZERO))
+ ? 4
+ : _impl.getExpiryPolicy() != TerminusExpiryPolicy.SESSION_END
+ ? 3
+ : _impl.getDurable() != TerminusDurability.NONE
+ ? 2
+ : _impl.getAddress() != null
+ ? 1
+ : 0;
- public Symbol[] getOutcomes()
- {
- return _outcomes;
- }
+ }
- public void setOutcomes(Symbol... outcomes)
- {
- _outcomes = outcomes;
}
- public Symbol[] getCapabilities()
+ public Source newInstance(Object described)
{
- return _capabilities;
- }
+ List l = (List) described;
- public void setCapabilities(Symbol... capabilities)
- {
- _capabilities = capabilities;
- }
-
- public Object getDescriptor()
- {
- return DESCRIPTOR;
- }
+ Source o = new Source();
- public Object getDescribed()
- {
- return _wrapper;
- }
-
- public Object get(final int index)
- {
- switch(index)
+ switch(11 - l.size())
{
+
case 0:
- return _address;
+ Object val0 = l.get( 10 );
+ if( val0 == null || val0.getClass().isArray() )
+ {
+ o.setCapabilities( (Symbol[]) val0 );
+ }
+ else
+ {
+ o.setCapabilities( (Symbol) val0 );
+ }
case 1:
- return _durable;
+ Object val1 = l.get( 9 );
+ if( val1 == null || val1.getClass().isArray() )
+ {
+ o.setOutcomes( (Symbol[]) val1 );
+ }
+ else
+ {
+ o.setOutcomes( (Symbol) val1 );
+ }
case 2:
- return _expiryPolicy;
+ o.setDefaultOutcome( (Outcome) l.get( 8 ) );
case 3:
- return _timeout;
+ o.setFilter( (Map) l.get( 7 ) );
case 4:
- return _dynamic;
+ o.setDistributionMode( (Symbol) l.get( 6 ) );
case 5:
- return _dynamicNodeProperties;
+ o.setDynamicNodeProperties( (Map) l.get( 5 ) );
case 6:
- return _distributionMode;
+ Boolean dynamic = (Boolean) l.get(4);
+ o.setDynamic(dynamic == null ? false : dynamic);
case 7:
- return _filter;
+ UnsignedInteger timeout = (UnsignedInteger) l.get(3);
+ o.setTimeout(timeout == null ? UnsignedInteger.ZERO : timeout);
case 8:
- return _defaultOutcome;
+ Symbol expiryPolicy = (Symbol) l.get(2);
+ o.setExpiryPolicy(expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : TerminusExpiryPolicy.valueOf(expiryPolicy));
case 9:
- return _outcomes;
+ UnsignedInteger durable = (UnsignedInteger) l.get(1);
+ o.setDurable(durable == null ? TerminusDurability.NONE : TerminusDurability.get(durable));
case 10:
- return _capabilities;
+ o.setAddress( (String) l.get( 0 ) );
}
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _capabilities != null
- ? 11
- : _outcomes != null
- ? 10
- : _defaultOutcome != null
- ? 9
- : _filter != null
- ? 8
- : _distributionMode != null
- ? 7
- : _dynamicNodeProperties != null
- ? 6
- : (_dynamic != false)
- ? 5
- : (_timeout != null && !_timeout.equals(UnsignedInteger.ZERO))
- ? 4
- : (_expiryPolicy != null && !_expiryPolicy.equals(TerminusExpiryPolicy.SESSION_END))
- ? 3
- : (_durable != null && !_durable.equals(TerminusDurability.NONE))
- ? 2
- : _address != null
- ? 1
- : 0;
+ return o;
}
-
- public final class SourceWrapper extends AbstractList
+ public Class<Source> getTypeClass()
{
-
- @Override
- public Object get(final int index)
- {
- return Source.this.get(index);
- }
-
- @Override
- public int size()
- {
- return Source.this.size();
- }
+ return Source.class;
}
- private static class SourceConstructor implements DescribedTypeConstructor<Source>
- {
- public Source newInstance(Object described)
- {
- List l = (List) described;
-
- Source o = new Source();
-
-
- switch(11 - l.size())
- {
-
- case 0:
- Object val0 = l.get( 10 );
- if( val0 == null || val0.getClass().isArray() )
- {
- o.setCapabilities( (Symbol[]) val0 );
- }
- else
- {
- o.setCapabilities( (Symbol) val0 );
- }
- case 1:
- Object val1 = l.get( 9 );
- if( val1 == null || val1.getClass().isArray() )
- {
- o.setOutcomes( (Symbol[]) val1 );
- }
- else
- {
- o.setOutcomes( (Symbol) val1 );
- }
- case 2:
- o.setDefaultOutcome( (Outcome) l.get( 8 ) );
- case 3:
- o.setFilter( (Map) l.get( 7 ) );
- case 4:
- o.setDistributionMode( (Symbol) l.get( 6 ) );
- case 5:
- o.setDynamicNodeProperties( (Map) l.get( 5 ) );
- case 6:
- Boolean dynamic = (Boolean) l.get(4);
- o.setDynamic(dynamic == null ? false : dynamic);
- case 7:
- UnsignedInteger timeout = (UnsignedInteger) l.get(3);
- o.setTimeout(timeout == null ? UnsignedInteger.ZERO : timeout);
- case 8:
- Symbol expiryPolicy = (Symbol) l.get(2);
- o.setExpiryPolicy(expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : expiryPolicy);
- case 9:
- UnsignedInteger durable = (UnsignedInteger) l.get(1);
- o.setDurable(durable == null ? TerminusDurability.NONE : durable);
- case 10:
- o.setAddress( (String) l.get( 0 ) );
- }
- return o;
- }
-
- public Class<Source> getTypeClass()
- {
- return Source.class;
- }
- }
-
-
- public static void register(Decoder decoder)
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- SourceConstructor constructor = new SourceConstructor();
+ SourceType type = new SourceType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
- @Override
- public String toString()
- {
- return "Source{" +
- "address='" + _address + '\'' +
- ", durable=" + _durable +
- ", expiryPolicy=" + _expiryPolicy +
- ", timeout=" + _timeout +
- ", dynamic=" + _dynamic +
- ", dynamicNodeProperties=" + _dynamicNodeProperties +
- ", distributionMode=" + _distributionMode +
- ", filter=" + _filter +
- ", defaultOutcome=" + _defaultOutcome +
- ", outcomes=" + (_outcomes == null ? null : Arrays.asList(_outcomes)) +
- ", capabilities=" + (_capabilities == null ? null : Arrays.asList(_capabilities)) +
- '}';
- }
+
}
\ No newline at end of file
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/TargetType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Target.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/TargetType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/TargetType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Target.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/messaging/Target.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/messaging/TargetType.java Wed Dec 12 13:32:32 2012
@@ -21,23 +21,24 @@
*/
-package org.apache.qpid.proton.type.messaging;
-
-import org.apache.qpid.proton.codec.Decoder;
-import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.DescribedType;
-import org.apache.qpid.proton.type.Symbol;
-import org.apache.qpid.proton.type.UnsignedInteger;
-import org.apache.qpid.proton.type.UnsignedLong;
+package org.apache.qpid.proton.codec.messaging;
import java.util.AbstractList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Target;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DescribedTypeConstructor;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.amqp.messaging.TerminusDurability;
+import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy;
-public class Target
- implements DescribedType , org.apache.qpid.proton.type.transport.Target
+public class TargetType extends AbstractDescribedType<Target,List> implements DescribedTypeConstructor<Target>
{
private static final Object[] DESCRIPTORS =
{
@@ -45,230 +46,137 @@ public class Target
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000029L);
- private final TargetWrapper _wrapper = new TargetWrapper();
-
- private String _address;
- private UnsignedInteger _durable = UnsignedInteger.valueOf(0);
- private Symbol _expiryPolicy = Symbol.valueOf("session-end");
- private UnsignedInteger _timeout = UnsignedInteger.valueOf(0);
- private boolean _dynamic;
- private Map _dynamicNodeProperties;
- private Symbol[] _capabilities;
- public String getAddress()
+ public TargetType(EncoderImpl encoder)
{
- return _address;
+ super(encoder);
}
- public void setAddress(String address)
+ public UnsignedLong getDescriptor()
{
- _address = address;
+ return DESCRIPTOR;
}
- public UnsignedInteger getDurable()
+ @Override
+ protected List wrap(Target val)
{
- return _durable;
+ return new TargetWrapper(val);
}
- public void setDurable(UnsignedInteger durable)
- {
- _durable = durable;
- }
- public Symbol getExpiryPolicy()
+ private static final class TargetWrapper extends AbstractList
{
- return _expiryPolicy;
- }
+ private final Target _impl;
- public void setExpiryPolicy(Symbol expiryPolicy)
- {
- _expiryPolicy = expiryPolicy;
- }
+ public TargetWrapper(Target impl)
+ {
+ _impl = impl;
+ }
- public UnsignedInteger getTimeout()
- {
- return _timeout;
- }
+ public Object get(final int index)
+ {
- public void setTimeout(UnsignedInteger timeout)
- {
- _timeout = timeout;
- }
+ switch(index)
+ {
+ case 0:
+ return _impl.getAddress();
+ case 1:
+ return _impl.getDurable().getValue();
+ case 2:
+ return _impl.getExpiryPolicy().getPolicy();
+ case 3:
+ return _impl.getTimeout();
+ case 4:
+ return _impl.getDynamic();
+ case 5:
+ return _impl.getDynamicNodeProperties();
+ case 6:
+ return _impl.getCapabilities();
+ }
- public boolean getDynamic()
- {
- return _dynamic;
- }
+ throw new IllegalStateException("Unknown index " + index);
- public void setDynamic(boolean dynamic)
- {
- _dynamic = dynamic;
- }
+ }
- public Map getDynamicNodeProperties()
- {
- return _dynamicNodeProperties;
- }
+ public int size()
+ {
+ return _impl.getCapabilities() != null
+ ? 7
+ : _impl.getDynamicNodeProperties() != null
+ ? 6
+ : _impl.getDynamic()
+ ? 5
+ : (_impl.getTimeout() != null && !_impl.getTimeout().equals(UnsignedInteger.ZERO))
+ ? 4
+ : !_impl.getExpiryPolicy().equals(TerminusExpiryPolicy.SESSION_END)
+ ? 3
+ : !_impl.getDurable().equals(TerminusDurability.NONE)
+ ? 2
+ : _impl.getAddress() != null
+ ? 1
+ : 0;
- public void setDynamicNodeProperties(Map dynamicNodeProperties)
- {
- _dynamicNodeProperties = dynamicNodeProperties;
+ }
}
- public Symbol[] getCapabilities()
+ public Target newInstance(Object described)
{
- return _capabilities;
- }
+ List l = (List) described;
- public void setCapabilities(Symbol... capabilities)
- {
- _capabilities = capabilities;
- }
-
- public Object getDescriptor()
- {
- return DESCRIPTOR;
- }
+ Target o = new Target();
- public Object getDescribed()
- {
- return _wrapper;
- }
-
- public Object get(final int index)
- {
- switch(index)
+ switch(7 - l.size())
{
+
case 0:
- return _address;
+ Object val0 = l.get( 6 );
+ if( val0 == null || val0.getClass().isArray() )
+ {
+ o.setCapabilities( (Symbol[]) val0 );
+ }
+ else
+ {
+ o.setCapabilities( (Symbol) val0 );
+ }
case 1:
- return _durable;
+ o.setDynamicNodeProperties( (Map) l.get( 5 ) );
case 2:
- return _expiryPolicy;
+ Boolean dynamic = (Boolean) l.get(4);
+ o.setDynamic(dynamic == null ? false : dynamic);
case 3:
- return _timeout;
+ UnsignedInteger timeout = (UnsignedInteger) l.get(3);
+ o.setTimeout(timeout == null ? UnsignedInteger.ZERO : timeout);
case 4:
- return _dynamic;
+ Symbol expiryPolicy = (Symbol) l.get(2);
+ o.setExpiryPolicy(expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : TerminusExpiryPolicy.valueOf(expiryPolicy));
case 5:
- return _dynamicNodeProperties;
+ UnsignedInteger durable = (UnsignedInteger) l.get(1);
+ o.setDurable(durable == null ? TerminusDurability.NONE : TerminusDurability.get(durable));
case 6:
- return _capabilities;
+ o.setAddress( (String) l.get( 0 ) );
}
- throw new IllegalStateException("Unknown index " + index);
+ return o;
}
- public int size()
- {
- return _capabilities != null
- ? 7
- : _dynamicNodeProperties != null
- ? 6
- : (_dynamic != false)
- ? 5
- : (_timeout != null && !_timeout.equals(UnsignedInteger.ZERO))
- ? 4
- : (_expiryPolicy != null && !_expiryPolicy.equals(TerminusExpiryPolicy.SESSION_END))
- ? 3
- : (_durable != null && !_durable.equals(TerminusDurability.NONE))
- ? 2
- : _address != null
- ? 1
- : 0;
-
- }
-
-
- public final class TargetWrapper extends AbstractList
+ public Class<Target> getTypeClass()
{
-
- @Override
- public Object get(final int index)
- {
- return Target.this.get(index);
- }
-
- @Override
- public int size()
- {
- return Target.this.size();
- }
+ return Target.class;
}
- private static class TargetConstructor implements DescribedTypeConstructor<Target>
- {
- public Target newInstance(Object described)
- {
- List l = (List) described;
-
- Target o = new Target();
- switch(7 - l.size())
- {
-
- case 0:
- Object val0 = l.get( 6 );
- if( val0 == null || val0.getClass().isArray() )
- {
- o.setCapabilities( (Symbol[]) val0 );
- }
- else
- {
- o.setCapabilities( (Symbol) val0 );
- }
- case 1:
- o.setDynamicNodeProperties( (Map) l.get( 5 ) );
- case 2:
- Boolean dynamic = (Boolean) l.get(4);
- o.setDynamic(dynamic == null ? false : dynamic);
- case 3:
- UnsignedInteger timeout = (UnsignedInteger) l.get(3);
- o.setTimeout(timeout == null ? UnsignedInteger.ZERO : timeout);
- case 4:
- Symbol expiryPolicy = (Symbol) l.get(2);
- o.setExpiryPolicy(expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : expiryPolicy);
- case 5:
- UnsignedInteger durable = (UnsignedInteger) l.get(1);
- o.setDurable(durable == null ? TerminusDurability.NONE : durable);
- case 6:
- o.setAddress( (String) l.get( 0 ) );
- }
-
-
- return o;
- }
-
- public Class<Target> getTypeClass()
- {
- return Target.class;
- }
- }
-
-
- public static void register(Decoder decoder)
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- TargetConstructor constructor = new TargetConstructor();
+ TargetType type = new TargetType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
- @Override
- public String toString()
- {
- return "Target{" +
- "address='" + _address + '\'' +
- ", durable=" + _durable +
- ", expiryPolicy=" + _expiryPolicy +
- ", timeout=" + _timeout +
- ", dynamic=" + _dynamic +
- ", dynamicNodeProperties=" + _dynamicNodeProperties +
- ", capabilities=" + (_capabilities == null ? null : Arrays.asList(_capabilities)) +
- '}';
- }
}
\ No newline at end of file
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslChallengeType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslChallenge.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslChallengeType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslChallengeType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslChallenge.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslChallenge.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslChallengeType.java Wed Dec 12 13:32:32 2012
@@ -21,19 +21,23 @@
*/
-package org.apache.qpid.proton.type.security;
-import java.util.List;
-import java.util.AbstractList;
-
+package org.apache.qpid.proton.codec.security;
+import java.util.AbstractList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.security.SaslChallenge;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
import org.apache.qpid.proton.codec.DecodeException;
import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.*;
+import org.apache.qpid.proton.codec.EncoderImpl;
-public class SaslChallenge
- implements DescribedType , SaslFrameBody
+public class SaslChallengeType extends AbstractDescribedType<SaslChallenge,List> implements DescribedTypeConstructor<SaslChallenge>
{
private static final Object[] DESCRIPTORS =
{
@@ -41,121 +45,59 @@ public class SaslChallenge
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000042L);
- private final SaslChallengeWrapper _wrapper = new SaslChallengeWrapper();
-
- private Binary _challenge;
- public Binary getChallenge()
+ private SaslChallengeType(EncoderImpl encoder)
{
- return _challenge;
- }
-
- public void setChallenge(Binary challenge)
- {
- if( challenge == null )
- {
- throw new NullPointerException("the challenge field is mandatory");
- }
-
- _challenge = challenge;
+ super(encoder);
}
- public Object getDescriptor()
+ public UnsignedLong getDescriptor()
{
return DESCRIPTOR;
}
- public Object getDescribed()
- {
- return _wrapper;
- }
-
- public Object get(final int index)
- {
-
- switch(index)
- {
- case 0:
- return _challenge;
- }
-
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
+ @Override
+ protected List wrap(SaslChallenge val)
{
- return 1;
-
+ return Collections.singletonList(val.getChallenge());
}
- public <E> void invoke(SaslFrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleChallenge(this, payload, context);
- }
- public final class SaslChallengeWrapper extends AbstractList
+ public SaslChallenge newInstance(Object described)
{
+ List l = (List) described;
- @Override
- public Object get(final int index)
- {
- return SaslChallenge.this.get(index);
- }
+ SaslChallenge o = new SaslChallenge();
- @Override
- public int size()
+ if(l.isEmpty())
{
- return SaslChallenge.this.size();
+ throw new DecodeException("The challenge field cannot be omitted");
}
- }
-
- private static class SaslChallengeConstructor implements DescribedTypeConstructor<SaslChallenge>
- {
- public SaslChallenge newInstance(Object described)
- {
- List l = (List) described;
-
- SaslChallenge o = new SaslChallenge();
- if(l.size() <= 0)
- {
- throw new DecodeException("The challenge field cannot be omitted");
- }
+ o.setChallenge( (Binary) l.get( 0 ) );
- switch(1 - l.size())
- {
- case 0:
- o.setChallenge( (Binary) l.get( 0 ) );
- }
+ return o;
+ }
- return o;
- }
-
- public Class<SaslChallenge> getTypeClass()
- {
- return SaslChallenge.class;
- }
+ public Class<SaslChallenge> getTypeClass()
+ {
+ return SaslChallenge.class;
}
- public static void register(Decoder decoder)
+
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- SaslChallengeConstructor constructor = new SaslChallengeConstructor();
+ SaslChallengeType type = new SaslChallengeType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
- @Override
- public String toString()
- {
- return "SaslChallenge{" +
- "challenge=" + _challenge +
- '}';
- }
+
}
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslInitType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslInit.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslInitType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslInitType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslInit.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslInit.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslInitType.java Wed Dec 12 13:32:32 2012
@@ -21,19 +21,22 @@
*/
-package org.apache.qpid.proton.type.security;
-import java.util.List;
-import java.util.AbstractList;
-
+package org.apache.qpid.proton.codec.security;
+import java.util.AbstractList;
+import java.util.List;
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.security.SaslInit;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
import org.apache.qpid.proton.codec.DecodeException;
import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.*;
+import org.apache.qpid.proton.codec.EncoderImpl;
-public class SaslInit
- implements DescribedType , SaslFrameBody
+public class SaslInitType extends AbstractDescribedType<SaslInit,List> implements DescribedTypeConstructor<SaslInit>
{
private static final Object[] DESCRIPTORS =
{
@@ -41,157 +44,102 @@ public class SaslInit
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000041L);
- private final SaslInitWrapper _wrapper = new SaslInitWrapper();
- private Symbol _mechanism;
- private Binary _initialResponse;
- private String _hostname;
-
- public Symbol getMechanism()
+ private SaslInitType(EncoderImpl encoder)
{
- return _mechanism;
+ super(encoder);
}
- public void setMechanism(Symbol mechanism)
+ public UnsignedLong getDescriptor()
{
- if( mechanism == null )
- {
- throw new NullPointerException("the mechanism field is mandatory");
- }
-
- _mechanism = mechanism;
- }
-
- public Binary getInitialResponse()
- {
- return _initialResponse;
- }
-
- public void setInitialResponse(Binary initialResponse)
- {
- _initialResponse = initialResponse;
- }
-
- public String getHostname()
- {
- return _hostname;
+ return DESCRIPTOR;
}
- public void setHostname(String hostname)
+ @Override
+ protected List wrap(SaslInit val)
{
- _hostname = hostname;
+ return new SaslInitWrapper(val);
}
- public Object getDescriptor()
- {
- return DESCRIPTOR;
- }
- public Object getDescribed()
+ public static class SaslInitWrapper extends AbstractList
{
- return _wrapper;
- }
- public Object get(final int index)
- {
+ private SaslInit _saslInit;
- switch(index)
+ public SaslInitWrapper(SaslInit saslInit)
{
- case 0:
- return _mechanism;
- case 1:
- return _initialResponse;
- case 2:
- return _hostname;
+ _saslInit = saslInit;
}
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _hostname != null
- ? 3
- : _initialResponse != null
- ? 2
- : 1;
-
- }
-
- @Override
- public String toString()
- {
- return "SaslInit{" +
- "mechanism=" + _mechanism +
- ", initialResponse=" + _initialResponse +
- ", hostname=" + (_hostname == null ? "null":'\''+ _hostname + '\'') +
- '}';
- }
-
- public <E> void invoke(SaslFrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleInit(this, payload, context);
- }
+ public Object get(final int index)
+ {
+ switch(index)
+ {
+ case 0:
+ return _saslInit.getMechanism();
+ case 1:
+ return _saslInit.getInitialResponse();
+ case 2:
+ return _saslInit.getHostname();
+ }
- public final class SaslInitWrapper extends AbstractList
- {
+ throw new IllegalStateException("Unknown index " + index);
- @Override
- public Object get(final int index)
- {
- return SaslInit.this.get(index);
}
- @Override
public int size()
{
- return SaslInit.this.size();
+ return _saslInit.getHostname() != null
+ ? 3
+ : _saslInit.getInitialResponse() != null
+ ? 2
+ : 1;
+
}
}
- private static class SaslInitConstructor implements DescribedTypeConstructor<SaslInit>
+ public SaslInit newInstance(Object described)
{
- public SaslInit newInstance(Object described)
- {
- List l = (List) described;
+ List l = (List) described;
- SaslInit o = new SaslInit();
+ SaslInit o = new SaslInit();
- if(l.size() <= 0)
- {
- throw new DecodeException("The mechanism field cannot be omitted");
- }
+ if(l.size() <= 0)
+ {
+ throw new DecodeException("The mechanism field cannot be omitted");
+ }
- switch(3 - l.size())
- {
+ switch(3 - l.size())
+ {
- case 0:
- o.setHostname( (String) l.get( 2 ) );
- case 1:
- o.setInitialResponse( (Binary) l.get( 1 ) );
- case 2:
- o.setMechanism( (Symbol) l.get( 0 ) );
- }
+ case 0:
+ o.setHostname( (String) l.get( 2 ) );
+ case 1:
+ o.setInitialResponse( (Binary) l.get( 1 ) );
+ case 2:
+ o.setMechanism( (Symbol) l.get( 0 ) );
+ }
- return o;
- }
+ return o;
+ }
- public Class<SaslInit> getTypeClass()
- {
- return SaslInit.class;
- }
+ public Class<SaslInit> getTypeClass()
+ {
+ return SaslInit.class;
}
- public static void register(Decoder decoder)
+
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- SaslInitConstructor constructor = new SaslInitConstructor();
+ SaslInitType type = new SaslInitType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
}
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslMechanismsType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslMechanisms.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslMechanismsType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslMechanismsType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslMechanisms.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslMechanisms.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslMechanismsType.java Wed Dec 12 13:32:32 2012
@@ -21,22 +21,21 @@
*/
-package org.apache.qpid.proton.type.security;
+package org.apache.qpid.proton.codec.security;
-import java.util.AbstractList;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.security.SaslMechanisms;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
import org.apache.qpid.proton.codec.DecodeException;
import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.Binary;
-import org.apache.qpid.proton.type.DescribedType;
-import org.apache.qpid.proton.type.Symbol;
-import org.apache.qpid.proton.type.UnsignedLong;
+import org.apache.qpid.proton.codec.EncoderImpl;
-public class SaslMechanisms
- implements DescribedType , SaslFrameBody
+public class SaslMechanismsType extends AbstractDescribedType<SaslMechanisms,List> implements DescribedTypeConstructor<SaslMechanisms>
{
private static final Object[] DESCRIPTORS =
{
@@ -44,130 +43,63 @@ public class SaslMechanisms
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000040L);
- private final SaslMechanismsWrapper _wrapper = new SaslMechanismsWrapper();
- private Symbol[] _saslServerMechanisms;
-
- public Symbol[] getSaslServerMechanisms()
+ private SaslMechanismsType(EncoderImpl encoder)
{
- return _saslServerMechanisms;
- }
-
- public void setSaslServerMechanisms(Symbol... saslServerMechanisms)
- {
- if( saslServerMechanisms == null )
- {
- throw new NullPointerException("the sasl-server-mechanisms field is mandatory");
- }
-
- _saslServerMechanisms = saslServerMechanisms;
+ super(encoder);
}
- public Object getDescriptor()
+ public UnsignedLong getDescriptor()
{
return DESCRIPTOR;
}
- public Object getDescribed()
+ @Override
+ protected List wrap(SaslMechanisms val)
{
- return _wrapper;
+ return Collections.singletonList(val.getSaslServerMechanisms());
}
- public Object get(final int index)
+ public SaslMechanisms newInstance(Object described)
{
+ List l = (List) described;
- switch(index)
+ SaslMechanisms o = new SaslMechanisms();
+
+ if(l.isEmpty())
{
- case 0:
- return _saslServerMechanisms;
+ throw new DecodeException("The sasl-server-mechanisms field cannot be omitted");
}
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return 1;
-
- }
-
- public <E> void invoke(SaslFrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleMechanisms(this, payload, context);
- }
-
-
- public final class SaslMechanismsWrapper extends AbstractList
- {
-
- @Override
- public Object get(final int index)
+ Object val0 = l.get( 0 );
+ if( val0 == null || val0.getClass().isArray() )
{
- return SaslMechanisms.this.get(index);
+ o.setSaslServerMechanisms( (Symbol[]) val0 );
}
-
- @Override
- public int size()
+ else
{
- return SaslMechanisms.this.size();
+ o.setSaslServerMechanisms( (Symbol) val0 );
}
+
+ return o;
}
- private static class SaslMechanismsConstructor implements DescribedTypeConstructor<SaslMechanisms>
+ public Class<SaslMechanisms> getTypeClass()
{
- public SaslMechanisms newInstance(Object described)
- {
- List l = (List) described;
-
- SaslMechanisms o = new SaslMechanisms();
-
- if(l.size() <= 0)
- {
- throw new DecodeException("The sasl-server-mechanisms field cannot be omitted");
- }
-
- switch(1 - l.size())
- {
-
- case 0:
- Object val0 = l.get( 0 );
- if( val0 == null || val0.getClass().isArray() )
- {
- o.setSaslServerMechanisms( (Symbol[]) val0 );
- }
- else
- {
- o.setSaslServerMechanisms( (Symbol) val0 );
- }
- }
-
-
- return o;
- }
-
- public Class<SaslMechanisms> getTypeClass()
- {
- return SaslMechanisms.class;
- }
+ return SaslMechanisms.class;
}
- public static void register(Decoder decoder)
+
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- SaslMechanismsConstructor constructor = new SaslMechanismsConstructor();
+ SaslMechanismsType type = new SaslMechanismsType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
- @Override
- public String toString()
- {
- return "SaslMechanisms{" +
- "saslServerMechanisms=" + (_saslServerMechanisms == null ? null : Arrays.asList(_saslServerMechanisms))
- +
- '}';
- }
+
}
Copied: qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslOutcomeType.java (from r1418272, qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslOutcome.java)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslOutcomeType.java?p2=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslOutcomeType.java&p1=qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslOutcome.java&r1=1418272&r2=1420665&rev=1420665&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/type/security/SaslOutcome.java (original)
+++ qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/codec/security/SaslOutcomeType.java Wed Dec 12 13:32:32 2012
@@ -21,19 +21,24 @@
*/
-package org.apache.qpid.proton.type.security;
-import java.util.List;
-import java.util.AbstractList;
-
+package org.apache.qpid.proton.codec.security;
+import java.util.AbstractList;
+import java.util.List;
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedByte;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.security.SaslCode;
+import org.apache.qpid.proton.amqp.security.SaslOutcome;
+import org.apache.qpid.proton.codec.AbstractDescribedType;
import org.apache.qpid.proton.codec.DecodeException;
import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
-import org.apache.qpid.proton.type.*;
+import org.apache.qpid.proton.codec.EncoderImpl;
-public class SaslOutcome
- implements DescribedType , SaslFrameBody
+public class SaslOutcomeType extends AbstractDescribedType<SaslOutcome,List> implements DescribedTypeConstructor<SaslOutcome>
{
private static final Object[] DESCRIPTORS =
{
@@ -41,139 +46,95 @@ public class SaslOutcome
};
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000044L);
- private final SaslOutcomeWrapper _wrapper = new SaslOutcomeWrapper();
-
- private UnsignedByte _code;
- private Binary _additionalData;
-
- public UnsignedByte getCode()
- {
- return _code;
- }
-
- public void setCode(UnsignedByte code)
- {
- if( code == null )
- {
- throw new NullPointerException("the code field is mandatory");
- }
-
- _code = code;
- }
- public Binary getAdditionalData()
+ private SaslOutcomeType(EncoderImpl encoder)
{
- return _additionalData;
+ super(encoder);
}
- public void setAdditionalData(Binary additionalData)
- {
- _additionalData = additionalData;
- }
-
- public Object getDescriptor()
+ public UnsignedLong getDescriptor()
{
return DESCRIPTOR;
}
- public Object getDescribed()
+ @Override
+ protected List wrap(SaslOutcome val)
{
- return _wrapper;
+ return new SaslOutcomeWrapper(val);
}
- public Object get(final int index)
+
+ public static final class SaslOutcomeWrapper extends AbstractList
{
+ private final SaslOutcome _impl;
- switch(index)
+ public SaslOutcomeWrapper(SaslOutcome impl)
{
- case 0:
- return _code;
- case 1:
- return _additionalData;
+ _impl = impl;
}
- throw new IllegalStateException("Unknown index " + index);
-
- }
-
- public int size()
- {
- return _additionalData != null
- ? 2
- : 1;
-
- }
-
- @Override
- public String toString()
- {
- return "SaslOutcome{" +
- "_code=" + _code +
- ", _additionalData=" + _additionalData +
- '}';
- }
- public <E> void invoke(SaslFrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleOutcome(this, payload, context);
- }
+ public Object get(final int index)
+ {
+ switch(index)
+ {
+ case 0:
+ return _impl.getCode().getValue();
+ case 1:
+ return _impl.getAdditionalData();
+ }
- public final class SaslOutcomeWrapper extends AbstractList
- {
+ throw new IllegalStateException("Unknown index " + index);
- @Override
- public Object get(final int index)
- {
- return SaslOutcome.this.get(index);
}
- @Override
public int size()
{
- return SaslOutcome.this.size();
+ return _impl.getAdditionalData() != null
+ ? 2
+ : 1;
}
}
- private static class SaslOutcomeConstructor implements DescribedTypeConstructor<SaslOutcome>
+ public SaslOutcome newInstance(Object described)
{
- public SaslOutcome newInstance(Object described)
- {
- List l = (List) described;
+ List l = (List) described;
- SaslOutcome o = new SaslOutcome();
+ SaslOutcome o = new SaslOutcome();
- if(l.size() <= 0)
- {
- throw new DecodeException("The code field cannot be omitted");
- }
+ if(l.isEmpty())
+ {
+ throw new DecodeException("The code field cannot be omitted");
+ }
- switch(2 - l.size())
- {
+ switch(2 - l.size())
+ {
- case 0:
- o.setAdditionalData( (Binary) l.get( 1 ) );
- case 1:
- o.setCode( (UnsignedByte) l.get( 0 ) );
- }
+ case 0:
+ o.setAdditionalData( (Binary) l.get( 1 ) );
+ case 1:
+ o.setCode(SaslCode.valueOf((UnsignedByte) l.get(0)));
+ }
- return o;
- }
+ return o;
+ }
- public Class<SaslOutcome> getTypeClass()
- {
- return SaslOutcome.class;
- }
+ public Class<SaslOutcome> getTypeClass()
+ {
+ return SaslOutcome.class;
}
- public static void register(Decoder decoder)
+
+ public static void register(Decoder decoder, EncoderImpl encoder)
{
- SaslOutcomeConstructor constructor = new SaslOutcomeConstructor();
+ SaslOutcomeType type = new SaslOutcomeType(encoder);
for(Object descriptor : DESCRIPTORS)
{
- decoder.register(descriptor, constructor);
+ decoder.register(descriptor, type);
}
+ encoder.register(type);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org