Package com.zone.weixin4j.handler
Class MessageHandlerAdapter<M extends WeixinMessage>
- java.lang.Object
-
- com.zone.weixin4j.handler.MessageHandlerAdapter<M>
-
- All Implemented Interfaces:
WeixinMessageHandler
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)
能否处理请求boolean
canHandle0(WeixinRequest request, M message)
能否处理请求WeixinResponse
doHandle(WeixinRequest request, WeixinMessage message, Set<String> nodeNames)
处理请求abstract WeixinResponse
doHandle0(WeixinRequest request, M message)
处理请求int
weight()
缺省值为1,存在多个匹配到的MessageHandler则比较weight大小
-
-
-
Method Detail
-
canHandle
public boolean canHandle(WeixinRequest request, WeixinMessage message, Set<String> nodeNames) throws WeixinException
Description copied from interface:WeixinMessageHandler
能否处理请求- Specified by:
canHandle
in interfaceWeixinMessageHandler
- Parameters:
request
- 微信请求message
- 微信消息nodeNames
- 节点名称集合- Returns:
- true则执行doHandle
- Throws:
WeixinException
-
canHandle0
public boolean canHandle0(WeixinRequest request, M message) throws WeixinException
能否处理请求- Parameters:
request
- 微信请求message
- 微信消息- Returns:
- true则执行doHandler0
- Throws:
WeixinException
-
doHandle
public WeixinResponse doHandle(WeixinRequest request, WeixinMessage message, Set<String> nodeNames) throws WeixinException
Description copied from interface:WeixinMessageHandler
处理请求- Specified by:
doHandle
in interfaceWeixinMessageHandler
- Parameters:
request
- 微信请求message
- 微信消息nodeNames
- 节点名称集合- Returns:
- 回复内容
- Throws:
WeixinException
-
doHandle0
public abstract WeixinResponse doHandle0(WeixinRequest request, M message) throws WeixinException
处理请求- Parameters:
request
- 微信请求message
- 微信消息- Returns:
- Throws:
WeixinException
-
weight
public int weight()
缺省值为1,存在多个匹配到的MessageHandler则比较weight大小- Specified by:
weight
in interfaceWeixinMessageHandler
- Returns:
- 权重
-
-