private static Object[] decodeNonPrimitive(final TypeConstructor constructor, final int count) { if(constructor instanceof ArrayEncoding) { ArrayEncoding arrayEncoding = (ArrayEncoding) constructor; Object[] array = new Object[count]; for(int i = 0; i < count; i++) { array[i] = arrayEncoding.readValueArray(); } return array; } else { Object[] array = (Object[]) Array.newInstance(constructor.getTypeClass(), count); for(int i = 0; i < count; i++) { array[i] = constructor.readValue(); } return array; } }
public void skipValue() { _underlyingEncoding.skipValue(); }
@Override public Object[] readArray() { return (Object[]) readConstructor().readValue(); }
int constructorPos = data.position(); TypeConstructor<?> constructor = decoder.readConstructor(); if (Header.class.equals(constructor.getTypeClass())) { header = (Header) constructor.readValue(); headerPosition = constructorPos; encodedHeaderSize = data.position(); expiration = System.currentTimeMillis() + header.getTtl().intValue(); } else if (DeliveryAnnotations.class.equals(constructor.getTypeClass())) { constructor.skipValue(); deliveryAnnotationsPosition = constructorPos; encodedDeliveryAnnotationsSize = data.position() - constructorPos; } else if (MessageAnnotations.class.equals(constructor.getTypeClass())) { messageAnnotationsPosition = constructorPos; messageAnnotations = (MessageAnnotations) constructor.readValue(); } else if (Properties.class.equals(constructor.getTypeClass())) { propertiesPosition = constructorPos; properties = (Properties) constructor.readValue(); } else if (ApplicationProperties.class.equals(constructor.getTypeClass())) { constructor.skipValue(); remainingBodyPosition = data.hasRemaining() ? data.position() : VALUE_NOT_PRESENT; break;
private static Object decodeArrayAsObject(final DecoderImpl decoder, final int count) if(constructor.encodesJavaPrimitive())
public Object[] readArray() { return (Object[]) readConstructor().readValue(); }
int constructorPos = buffer.position(); TypeConstructor<?> constructor = decoder.readConstructor(); if (Header.class.equals(constructor.getTypeClass())) { _header = (Header) constructor.readValue(); headerEnds = messagePaylodStart = buffer.position(); durable = _header.getDurable(); expiration = System.currentTimeMillis() + _header.getTtl().intValue(); } else if (DeliveryAnnotations.class.equals(constructor.getTypeClass())) { constructor.skipValue(); deliveryAnnotationsPosition = constructorPos; messagePaylodStart = buffer.position(); } else if (MessageAnnotations.class.equals(constructor.getTypeClass())) { _messageAnnotations = (MessageAnnotations) constructor.readValue(); } else if (Properties.class.equals(constructor.getTypeClass())) { _properties = (Properties) constructor.readValue(); if (ApplicationProperties.class.equals(constructor.getTypeClass())) { appLocation = buffer.position(); } else if (ApplicationProperties.class.equals(constructor.getTypeClass())) {
private static Object decodeArrayAsObject(final DecoderImpl decoder, final int count) if(constructor.encodesJavaPrimitive())
public Object[] readArray() { return (Object[]) readConstructor().readValue(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private <T> T scanForMessageSection(int scanStartPosition, Class...targetTypes) { ensureMessageDataScanned(); // In cases where we parsed out enough to know the value is not encoded in the message // we can exit without doing any reads or buffer hopping. if (scanStartPosition == VALUE_NOT_PRESENT) { return null; } ReadableBuffer buffer = data.duplicate().position(0); final DecoderImpl decoder = TLSEncode.getDecoder(); buffer.position(scanStartPosition); T section = null; decoder.setBuffer(buffer); try { while (buffer.hasRemaining()) { TypeConstructor<?> constructor = decoder.readConstructor(); for (Class<?> type : targetTypes) { if (type.equals(constructor.getTypeClass())) { section = (T) constructor.readValue(); return section; } } constructor.skipValue(); } } finally { decoder.setBuffer(null); } return section; }
private static Object[] decodeNonPrimitive(final TypeConstructor constructor, final int count) { if(constructor instanceof ArrayEncoding) { ArrayEncoding arrayEncoding = (ArrayEncoding) constructor; Object[] array = new Object[count]; for(int i = 0; i < count; i++) { array[i] = arrayEncoding.readValueArray(); } return array; } else { Object[] array = (Object[]) Array.newInstance(constructor.getTypeClass(), count); for(int i = 0; i < count; i++) { array[i] = constructor.readValue(); } return array; } }
private static Object decodeArrayAsObject(final DecoderImpl decoder, final int count) if(constructor.encodesJavaPrimitive())
@Override public void skipValue() { getDecoder().readConstructor().skipValue(); }
public Object[] readArray() { return (Object[]) readConstructor().readValue(); }
private static Object[] decodeNonPrimitive(final TypeConstructor constructor, final int count) { if(constructor instanceof ArrayEncoding) { ArrayEncoding arrayEncoding = (ArrayEncoding) constructor; Object[] array = new Object[count]; for(int i = 0; i < count; i++) { array[i] = arrayEncoding.readValueArray(); } return array; } else { Object[] array = (Object[]) Array.newInstance(constructor.getTypeClass(), count); for(int i = 0; i < count; i++) { array[i] = constructor.readValue(); } return array; } }
private static Object decodeArrayAsObject(final DecoderImpl decoder, final int count) if(constructor.encodesJavaPrimitive())
@Override public void skipValue() { getDecoder().readConstructor().skipValue(); }
public Boolean readBoolean(final Boolean defaultVal) { TypeConstructor constructor = readConstructor(); Object val = constructor.readValue(); if(val == null) { return defaultVal; } else if(val instanceof Boolean) { return (Boolean) val; } throw unexpectedType(val, Boolean.class); }
private static Object[] decodeNonPrimitive(final DecoderImpl decoder, final TypeConstructor constructor, final int count) { if (count > decoder.getByteBufferRemaining()) { throw new IllegalArgumentException("Array element count "+count+" is specified to be greater than the amount of data available ("+ decoder.getByteBufferRemaining()+")"); } if(constructor instanceof ArrayEncoding) { ArrayEncoding arrayEncoding = (ArrayEncoding) constructor; Object[] array = new Object[count]; for(int i = 0; i < count; i++) { array[i] = arrayEncoding.readValueArray(); } return array; } else { Object[] array = (Object[]) Array.newInstance(constructor.getTypeClass(), count); for(int i = 0; i < count; i++) { array[i] = constructor.readValue(); } return array; } }
@Override public void skipValue() { getDecoder().readConstructor().skipValue(); }