@Override public ExactSubjectFilter construct(Object underlying) throws AmqpErrorException { if(underlying instanceof String) { return new ExactSubjectFilter((String)underlying); } else { final String msg = String.format("Cannot decode 'apache.org:legacy-amqp-direct-binding' from '%s'", underlying == null ? null : underlying.getClass().getSimpleName()); throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg); } }
private ListenableFuture<? extends LinkEndpoint<S, T>> rejectLink(final Session_1_0 session, Throwable t) { if (t instanceof AmqpErrorException) { _linkEndpoint = new ErrantLinkEndpoint<>(this, session, ((AmqpErrorException) t).getError()); } else { _linkEndpoint = new ErrantLinkEndpoint<>(this, session, new Error(AmqpError.INTERNAL_ERROR, t.getMessage())); } return Futures.immediateFuture(_linkEndpoint); }
@Override public Footer construct(Object underlying) throws AmqpErrorException { if(underlying instanceof Map) { return new Footer((Map)underlying); } else { final String msg = String.format("Cannot decode 'footer' from '%s'", underlying == null ? null : underlying.getClass().getSimpleName()); throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg); } }
@Override public Data construct(Object underlying) throws AmqpErrorException { if(underlying instanceof Binary) { return new Data((Binary)underlying); } else { final String msg = String.format("Cannot decode 'data' from '%s'", underlying == null ? null : underlying.getClass().getSimpleName()); throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg); } }
frameParsingError = ex.getError();
@Override public DeliveryAnnotations construct(Object underlying) throws AmqpErrorException { if(underlying instanceof Map) { return new DeliveryAnnotations((Map)underlying); } else { final String msg = String.format("Cannot decode 'delivery-annotations' from '%s'", underlying == null ? null : underlying.getClass().getSimpleName()); throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg); } }
@Override public AmqpSequence construct(Object underlying) throws AmqpErrorException { if(underlying instanceof List) { return new AmqpSequence((List)underlying); } else { final String msg = String.format("Cannot decode 'amqp-sequence' from '%s'", underlying == null ? null : underlying.getClass().getSimpleName()); throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg); } }
@Override public MessageAnnotations construct(Object underlying) throws AmqpErrorException { if(underlying instanceof Map) { return new MessageAnnotations((Map)underlying); } else { final String msg = String.format("Cannot decode 'message-annotations' from '%s'", underlying == null ? null : underlying.getClass().getSimpleName()); throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg); } }
@Override public ApplicationProperties construct(Object underlying) throws AmqpErrorException { if(underlying instanceof Map) { return new ApplicationProperties((Map)underlying); } else { final String msg = String.format("Cannot decode 'application-properties' from '%s'", underlying == null ? null : underlying.getClass().getSimpleName()); throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg); } }
@Override public MatchingSubjectFilter construct(Object underlying) throws AmqpErrorException { if(underlying instanceof String) { return new MatchingSubjectFilter((String)underlying); } else { final String msg = String.format("Cannot decode 'apache.org:legacy-amqp-topic-binding' from '%s'", underlying == null ? null : underlying.getClass().getSimpleName()); throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg); } }
@Override public JMSSelectorFilter construct(Object underlying) throws AmqpErrorException { if(underlying instanceof String) { return new JMSSelectorFilter((String)underlying); } else { final String msg = String.format("Cannot decode 'apache.org:selector-filter' from '%s'", underlying == null ? null : underlying.getClass().getSimpleName()); throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg); } }
@Override public String construct(final QpidByteBuffer in, final ValueHandler handler) throws AmqpErrorException { if (in.hasRemaining(4)) { int codePoint = in.getInt(); // TODO look wrong AMQP 1.0 type is actually UTF-32BE not a code point char[] chars = Character.toChars(codePoint); return new String(chars); } else { throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Cannot construct char: insufficient input data"); } } }
@Override public Date construct(final QpidByteBuffer in, final ValueHandler handler) throws AmqpErrorException { if (in.hasRemaining(8)) { long l = in.getLong(); return new Date(l); } else { throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Cannot construct timestamp: insufficient input data"); } } }
@Override protected void resumeLink(final Attach attach) throws AmqpErrorException { throw new AmqpErrorException(new Error(AmqpError.NOT_IMPLEMENTED, "Cannot resume a Coordinator Link.")); }
@SuppressWarnings("unused") public static DistributionMode convertToDistributionMode(final Object value) throws AmqpErrorException { if (value instanceof DistributionMode) { return (DistributionMode) value; } else if (value instanceof Symbol) { try { return StdDistMode.valueOf(value); } catch (IllegalArgumentException e) { return new UnknownDistributionMode((Symbol) value); } } final String message = String.format("Cannot construct 'distribution-mode' from type '%s'", value == null ? null : value.getClass().getSimpleName()); throw new AmqpErrorException(AmqpError.DECODE_ERROR, message); }
@Override public Double construct(final QpidByteBuffer in, final ValueHandler handler) throws AmqpErrorException { if (in.hasRemaining(8)) { return in.getDouble(); } else { throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Cannot construct double: insufficient input data"); } } }
@Override protected void reattachLink(final Attach attach) throws AmqpErrorException { throw new AmqpErrorException(new Error(AmqpError.NOT_IMPLEMENTED, "Cannot reattach a Coordinator Link.")); }
@Override int read(final QpidByteBuffer in) throws AmqpErrorException { if(!in.hasRemaining(4)) { throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode array"); } return in.getInt(); } };
@Override int read(final QpidByteBuffer in) throws AmqpErrorException { if(!in.hasRemaining()) { throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode array"); } return ((int)in.get()) & 0xff; } };