Example usage for com.rabbitmq.client LongString toString

List of usage examples for com.rabbitmq.client LongString toString

Introduction

In this page you can find the example usage for com.rabbitmq.client LongString toString.

Prototype

@Override
public String toString();

Source Link

Document

Get the content as a String.

Usage

From source file:lfp.rabbitmq.presence.tests.PresenceTests.java

License:Mozilla Public License

String getHeaderString(Map<String, Object> headers, String key) {
    LongString s = (LongString) headers.get(key);
    if (s == null)
        return null;
    return s.toString();
}

From source file:org.eclipse.hono.dispatcher.amqp.DefaultAmqpHelper.java

License:Open Source License

/**
 * Extracts the header with the given key from the Delivery.
 *
 * @param d the amqp delivery/*w w  w.j  av a2  s  . co  m*/
 * @param key key of the header
 * @return value of the header or null if it does not exist
 */
public static String getHeader(final QueueingConsumer.Delivery d, final String key) {
    if (d.getProperties() != null && d.getProperties().getHeaders() != null) {
        final LongString value = (LongString) d.getProperties().getHeaders().get(key);
        return value != null ? value.toString() : null;
    }
    return null;
}

From source file:org.springframework.amqp.rabbit.support.DefaultMessagePropertiesConverterTests.java

License:Apache License

@Test
public void testLongLongString() {
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put("longString", longString);
    headers.put("string1025", LongStringHelper.asLongString(new byte[1025]));
    byte[] longBytes = new byte[1026];
    longBytes[0] = 'a';
    longBytes[1025] = 'z';
    LongString longString1026 = LongStringHelper.asLongString(longBytes);
    headers.put("string1026", longString1026);
    BasicProperties source = new BasicProperties.Builder().headers(headers).build();
    MessagePropertiesConverter converter = new DefaultMessagePropertiesConverter(1024, true);
    MessageProperties messageProperties = converter.toMessageProperties(source, envelope, "UTF-8");
    assertThat(messageProperties.getHeaders().get("longString"), instanceOf(String.class));
    assertThat(messageProperties.getHeaders().get("string1025"), instanceOf(DataInputStream.class));
    assertThat(messageProperties.getHeaders().get("string1026"), instanceOf(DataInputStream.class));
    MessagePropertiesConverter longConverter = new DefaultMessagePropertiesConverter(1025, true);
    messageProperties = longConverter.toMessageProperties(source, envelope, "UTF-8");
    assertThat(messageProperties.getHeaders().get("longString"), instanceOf(String.class));
    assertThat(messageProperties.getHeaders().get("string1025"), instanceOf(String.class));
    assertThat(messageProperties.getHeaders().get("string1026"), instanceOf(DataInputStream.class));

    longConverter = new DefaultMessagePropertiesConverter(1025);
    messageProperties = longConverter.toMessageProperties(source, envelope, "UTF-8");
    assertThat(messageProperties.getHeaders().get("longString"), instanceOf(String.class));
    assertThat(messageProperties.getHeaders().get("string1025"), instanceOf(String.class));
    assertThat(messageProperties.getHeaders().get("string1026"), instanceOf(LongString.class));

    BasicProperties basicProperties = longConverter.fromMessageProperties(messageProperties, "UTF-8");
    assertEquals(longString1026.toString(), basicProperties.getHeaders().get("string1026").toString());
}

From source file:ox.softeng.burst.xml.LongStringAdapter.java

@Override
public String marshal(LongString v) throws Exception {
    return v.toString();
}