Package com.foxinmy.weixin4j.handler
Class MessageHandlerAdapter<M extends WeixinMessage>
- java.lang.Object
-
- com.foxinmy.weixin4j.handler.MessageHandlerAdapter<M>
-
- All Implemented Interfaces:
WeixinMessageHandler
- Direct Known Subclasses:
SubscribeMessageHandler
,TextMessageHandler
,VoiceMessageHandler
public abstract class MessageHandlerAdapter<M extends WeixinMessage> extends Object implements WeixinMessageHandler
消息适配器:对于特定的消息类型进行适配,如text文本、voice语音消息- Since:
- JDK 1.6
- Author:
- jinyu(foxinmy@gmail.com)
- See Also:
WeixinMessage
-
-
Constructor Summary
Constructors Constructor Description MessageHandlerAdapter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canHandle(WeixinRequest request, WeixinMessage message, Set<String> nodeNames)
能否处理请求protected boolean
canHandle0(WeixinRequest request, M message)
能否处理请求WeixinResponse
doHandle(WeixinRequest request, WeixinMessage message)
处理请求protected abstract WeixinResponse
doHandle0(M message)
处理请求int
weight()
缺省值为1,存在多个匹配到的MessageHandler则比较weight大小
-
-
-
Method Detail
-
canHandle
public boolean canHandle(WeixinRequest request, WeixinMessage message, Set<String> nodeNames)
Description copied from interface:WeixinMessageHandler
能否处理请求- Specified by:
canHandle
in interfaceWeixinMessageHandler
- Parameters:
request
- 微信请求message
- 微信消息nodeNames
- 节点名称集合- Returns:
- true则执行doHandle
-
canHandle0
protected boolean canHandle0(WeixinRequest request, M message)
能否处理请求- Parameters:
request
- 微信请求message
- 微信消息- Returns:
- true则执行doHandler0 @
-
doHandle
public WeixinResponse doHandle(WeixinRequest request, WeixinMessage message)
Description copied from interface:WeixinMessageHandler
处理请求- Specified by:
doHandle
in interfaceWeixinMessageHandler
- Parameters:
request
- 微信请求message
- 微信消息- Returns:
- 回复内容
-
doHandle0
protected abstract WeixinResponse doHandle0(M message)
处理请求- Parameters:
message
- 微信消息- Returns:
-
weight
public int weight()
缺省值为1,存在多个匹配到的MessageHandler则比较weight大小- Specified by:
weight
in interfaceWeixinMessageHandler
- Returns:
- 权重
-
-