public final class StandardConversions extends Object
| Constructor and Description |
|---|
StandardConversions() |
| Modifier and Type | Method and Description |
|---|---|
static String |
bytesToHex(byte[] bytes) |
static byte[] |
convertCharset(Object content,
Charset fromCharset,
Charset toCharset)
Convert text content.
|
static byte[] |
convertJavaToOctetStream(Object source,
MediaType sourceMediaType,
Marshaller marshaller)
Converts a java object to a sequence of bytes applying standard java serialization.
|
static byte[] |
convertJavaToProtoStream(Object source,
MediaType sourceMediaType,
org.infinispan.protostream.ImmutableSerializationContext ctx)
Converts a java object to a sequence of bytes using a ProtoStream
ImmutableSerializationContext. |
static byte[] |
convertJavaToText(Object source,
MediaType sourceMediaType,
MediaType destinationMediaType)
Converts a java object to a text/plain representation.
|
static Object |
convertOctetStreamToJava(byte[] source,
MediaType destination,
Marshaller marshaller)
Converts an octet stream to a Java object
|
static byte[] |
convertOctetStreamToText(byte[] source,
MediaType destination)
Converts generic byte[] to text.
|
static Object |
convertOctetStreamToUrlEncoded(Object content,
MediaType contentType) |
static String |
convertTextToObject(Object source,
MediaType sourceType)
Converts text content to the Java representation (String).
|
static byte[] |
convertTextToOctetStream(Object source,
MediaType sourceType)
Converts text content to binary.
|
static Object |
convertTextToText(Object source,
MediaType sourceType,
MediaType destinationType)
Convert text content to a different encoding.
|
static String |
convertTextToUrlEncoded(Object source,
MediaType sourceType)
Convert text format to a URL safe format.
|
static Object |
convertUrlEncodedToObject(Object content)
Handle x-www-form-urlencoded as single values for now.
|
static Object |
convertUrlEncodedToOctetStream(Object content) |
static Object |
convertUrlEncodedToText(Object content,
MediaType destinationType) |
static Object |
decodeObjectContent(Object content,
MediaType contentMediaType)
Decode UTF-8 as a java object.
|
static byte[] |
decodeOctetStream(Object input,
MediaType octetStream)
Decode a octet-stream content that is not a byte[].
|
static byte[] |
hexToBytes(String hex) |
static Object |
urlDecode(Object content) |
static String |
urlEncode(Object content,
MediaType mediaType) |
public static Object convertTextToText(Object source, MediaType sourceType, MediaType destinationType)
source - The source content.sourceType - MediaType for the source content.destinationType - the MediaType of the converted content.public static byte[] convertTextToOctetStream(Object source, MediaType sourceType)
source - The source content.sourceType - MediaType for the source content.EncodingException - if the source cannot be interpreted as plain text.public static String convertTextToObject(Object source, MediaType sourceType)
source - The source contentsourceType - the MediaType of the source content.EncodingException - if the source cannot be interpreted as plain text.public static String convertTextToUrlEncoded(Object source, MediaType sourceType)
source - the source text/plain content.sourceType - the MediaType of the source content.EncodingException - if the source format cannot be interpreted as plain/text.public static byte[] convertOctetStreamToText(byte[] source,
MediaType destination)
source - byte[] to convert.destination - MediaType of the desired text conversion.public static Object convertOctetStreamToJava(byte[] source, MediaType destination, Marshaller marshaller)
source - The source to convertdestination - The type of the converted object.public static byte[] convertJavaToOctetStream(Object source, MediaType sourceMediaType, Marshaller marshaller) throws IOException, InterruptedException
source - source the java object to convert.sourceMediaType - the MediaType matching application/x-application-object describing the source.EncodingException - if the sourceMediaType is not a application/x-java-object or if the conversion is
not supported.IOExceptionInterruptedExceptionpublic static byte[] convertJavaToProtoStream(Object source, MediaType sourceMediaType, org.infinispan.protostream.ImmutableSerializationContext ctx) throws IOException, InterruptedException
ImmutableSerializationContext.source - source the java object to convert.sourceMediaType - the MediaType matching application/x-application-object describing the source.EncodingException - if the sourceMediaType is not a application/x-java-object or if the conversion is
not supported.IOExceptionInterruptedExceptionpublic static byte[] convertJavaToText(Object source, MediaType sourceMediaType, MediaType destinationMediaType)
source - Object to convert.sourceMediaType - The MediaType for the source object.destinationMediaType - The required text/plain specification.public static Object decodeObjectContent(Object content, MediaType contentMediaType)
MediaType.
Currently supported types are primitives and String, plus a special "ByteArray" to describe a sequence of bytes.content - The content to decode.contentMediaType - the MediaType describing the content.EncodingException - if the provided type is not supported.public static byte[] convertCharset(Object content, Charset fromCharset, Charset toCharset)
content - Object to convert.fromCharset - Charset of the provided content.toCharset - Charset to convert to.public static byte[] decodeOctetStream(Object input, MediaType octetStream)
input - Object representing the binary content.octetStream - The MediaType describing the input.public static String bytesToHex(byte[] bytes)
public static byte[] hexToBytes(String hex)
public static Object convertUrlEncodedToObject(Object content)
public static Object convertUrlEncodedToText(Object content, MediaType destinationType)
Copyright © 2021 JBoss by Red Hat. All rights reserved.