public class CharsetUtils extends Object
| Constructor and Description |
|---|
CharsetUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
getCharset(String contentType) |
static String |
getEncoding(org.mule.runtime.core.api.event.CoreEvent event,
byte[] bytes,
org.slf4j.Logger logger)
Tries to figure out the encoding of the request in the following order
- checks if the content-type header includes the charset
- detects the payload encoding using BOM, or tries to auto-detect it
- return the mule message encoding
|
static String |
getEncoding(org.mule.runtime.api.message.Message message,
byte[] bytes,
org.slf4j.Logger logger)
Tries to figure out the encoding of the request in the following order
- checks if the content-type header includes the charset
- detects the payload encoding using BOM, or tries to auto-detect it
- return the mule message encoding
|
static String |
getEncoding(org.mule.runtime.api.message.Message message,
Object input,
org.slf4j.Logger logger)
Tries to figure out the encoding of the request in the following order
- checks if the content-type header includes the charset
- Determine what type is payload
- detects the payload encoding using BOM, or tries to auto-detect it
- return the mule message encoding
|
static String |
getEncoding(Object input,
org.slf4j.Logger logger)
Tries to figure out the encoding of the request in the following order
- Determine what type is payload
- detects the payload encoding using BOM, or tries to auto-detect it
- return the mule message encoding
|
static <T> String |
getEncoding(org.mule.runtime.api.metadata.TypedValue<T> typedValue,
Object input,
org.slf4j.Logger logger)
Tries to figure out the encoding of the request in the following order
- Determine what type is payload
- detects the payload encoding using BOM, or tries to auto-detect it
- return the mule message encoding
|
static String |
getHeaderCharset(org.mule.runtime.api.message.Message message)
Returns the charset specified by the content-type header or null if not specified
|
static String |
getPayloadCharset(org.mule.runtime.api.message.Message message,
org.slf4j.Logger logger) |
static String |
getXmlEncoding(org.mule.runtime.core.api.event.CoreEvent muleEvent,
byte[] payload,
Document document,
org.slf4j.Logger logger)
Tries to figure out the encoding of an xml request in the following order
- checks if the document has a content-type declaration
- detects the payload encoding using BOM, or tries to auto-detect it
- return the mule message encoding
|
static byte[] |
trimBom(byte[] content)
Removes BOM from byte array if present
|
public static String getEncoding(org.mule.runtime.core.api.event.CoreEvent event, byte[] bytes, org.slf4j.Logger logger)
event - mule eventbytes - payload byte arraylogger - where to logpublic static String getEncoding(org.mule.runtime.api.message.Message message, byte[] bytes, org.slf4j.Logger logger)
message - mule messagebytes - payload byte arraylogger - where to logpublic static String getEncoding(org.mule.runtime.api.message.Message message, Object input, org.slf4j.Logger logger) throws IOException
message - mule messageinput - payload that would be instrospectedlogger - where to logIOExceptionpublic static <T> String getEncoding(org.mule.runtime.api.metadata.TypedValue<T> typedValue, Object input, org.slf4j.Logger logger) throws IOException
typedValue - mule typed valueinput - payload that would be instrospectedlogger - where to logIOExceptionpublic static String getEncoding(Object input, org.slf4j.Logger logger) throws IOException
input - payload that would be instrospectedlogger - where to logIOExceptionpublic static String getXmlEncoding(org.mule.runtime.core.api.event.CoreEvent muleEvent, byte[] payload, Document document, org.slf4j.Logger logger)
muleEvent - mule eventpayload - xml payload as byte arraydocument - xml parsed documentlogger - where to logpublic static String getHeaderCharset(org.mule.runtime.api.message.Message message)
message - mule messagepublic static String getPayloadCharset(org.mule.runtime.api.message.Message message, org.slf4j.Logger logger)
public static byte[] trimBom(byte[] content)
content - byte arrayCopyright © 2019. All rights reserved.