public interface Content extends Bytes
Content can represent the state of a topic or can be used to update a topic. Content may also form the body of a message sent to or from a client.
Content is immutable and can only be created using a ContentBuilder
or by using convenience methods on ContentFactory
.
Specialised subTypes of the builder are available for special data formats.
Content is essentially an array of bytes which can be formatted in various ways using builders or interpreted using readers.
Modifier and Type | Interface and Description |
---|---|
static class |
Content.Encoding
Deprecated.
since 5.7 in future releases encoding will no longer be an
attribute of Content, therefore this facility should no
longer be used
|
Modifier and Type | Method and Description |
---|---|
String |
asString()
Returns the content as a String.
|
Content.Encoding |
getEncoding()
Deprecated.
since 5.7 in future releases encoding will no longer be an
attribute of Content, therefore this facility should not be
used
|
int |
length()
Returns the number of bytes of data in the content.
|
byte[] |
toBytes()
Return the content as an array of bytes.
|
asInputStream, copyTo, toByteArray
byte[] toBytes()
This actually returns the internal byte array which must not be altered. If this data is to be manipulated in any way, it must first be copied.
int length()
This does not take into account any encoding applied to the data.
String asString()
The byte content is converted to a String using the UTF-8 character set.
@Deprecated Content.Encoding getEncoding()
This is the encoding that will be used for the content when transmitted over a compatible communications link. For inbound content this indicates the encoding that the content arrived with.
Copyright © 2016 Push Technology Ltd. All Rights Reserved.