Class AbstractMessageConverter
- java.lang.Object
-
- com.foxinmy.weixin4j.http.message.AbstractMessageConverter
-
- All Implemented Interfaces:
MessageConverter
- Direct Known Subclasses:
JsonMessageConverter
,XmlMessageConverter
public abstract class AbstractMessageConverter extends Object implements MessageConverter
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMessageConverter()
protected
AbstractMessageConverter(MimeType supportedMimeType)
protected
AbstractMessageConverter(MimeType... supportedMimeTypes)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canConvert(Class<?> clazz, HttpResponse response)
是否可以转换<T> T
convert(Class<? extends T> clazz, HttpResponse response)
转换消息protected abstract <T> T
convertInternal(Class<? extends T> clazz, InputStream body)
Charset
getCharset()
void
setCharset(Charset charset)
void
setSupportedMediaTypes(List<MimeType> supportedMimeTypes)
List<MimeType>
supportedMimeTypes()
获取可以转换的媒体类型protected abstract boolean
supports(Class<?> clazz, byte[] content)
满足其中一个supportsprotected boolean
supports(Class<?> clazz, MimeType mimeType)
满足其中一个supports
-
-
-
Field Detail
-
charset
protected Charset charset
-
-
Method Detail
-
getCharset
public Charset getCharset()
-
setCharset
public void setCharset(Charset charset)
-
supportedMimeTypes
public List<MimeType> supportedMimeTypes()
Description copied from interface:MessageConverter
获取可以转换的媒体类型- Specified by:
supportedMimeTypes
in interfaceMessageConverter
- Returns:
- 媒体列表
-
canConvert
public boolean canConvert(Class<?> clazz, HttpResponse response)
Description copied from interface:MessageConverter
是否可以转换- Specified by:
canConvert
in interfaceMessageConverter
- Parameters:
clazz
- 转换类型response
- 响应对象- Returns:
- 是否标识
-
supports
protected boolean supports(Class<?> clazz, MimeType mimeType)
满足其中一个supports- Parameters:
clazz
- 转换类型mimeType
- 媒体类型- Returns:
- 支持标识
-
supports
protected abstract boolean supports(Class<?> clazz, byte[] content)
满足其中一个supports- Parameters:
clazz
- 转换类型content
- 内容数据- Returns:
- 支持标识
-
convert
public <T> T convert(Class<? extends T> clazz, HttpResponse response) throws IOException
Description copied from interface:MessageConverter
转换消息- Specified by:
convert
in interfaceMessageConverter
- Parameters:
clazz
- 转换类型response
- 响应对象- Returns:
- 消息对象
- Throws:
IOException
-
convertInternal
protected abstract <T> T convertInternal(Class<? extends T> clazz, InputStream body) throws IOException
- Throws:
IOException
-
-