Example usage for org.dom4j Node getText

List of usage examples for org.dom4j Node getText

Introduction

In this page you can find the example usage for org.dom4j Node getText.

Prototype

String getText();

Source Link

Document

Returns the text of this node.

Usage

From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java

/**
 * ??//from   w  w  w.  j  av  a2s.  c  o  m
 *
 * @param doc4j ??Dom
 * @param toUserName ??
 * @param fromUserName ????OpenID
 * @param eventKey KEY???
 * @return ?
 * @throws ServiceException ServiceException
 */
protected Document scanCodeEventReceive(Document doc4j, String toUserName, String fromUserName, String eventKey)
        throws ServiceException {
    Document respDoc4j;
    Node eventNode = doc4j.selectSingleNode("/xml/Event");
    Element scanCodeInfoNode = (Element) doc4j.selectSingleNode("/xml/ScanCodeInfo");
    Element scanTypeNode = scanCodeInfoNode.element("ScanType");
    Element scanResultNode = scanCodeInfoNode.element("ScanResult");
    String event = eventNode == null ? "" : eventNode.getText();
    String scanType = scanTypeNode.getText();
    String scanResult = scanResultNode.getText();
    WechatEventScancodeCommonMessageRequest scanCodePushMessage = new WechatEventScancodeCommonMessageRequest(
            toUserName, fromUserName, event, eventKey);
    scanCodePushMessage.new ScanCodeInfo(scanType, scanResult);
    //TODO return messageReceive(scanCodePushMessage);
    return null;
}

From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java

/**
 * ?//from  w w  w.  jav a  2  s. co m
 *
 * @param doc4j ??Dom
 * @param toUserName ??
 * @param fromUserName ????OpenID
 * @param eventKey KEY???
 * @return ?
 * @throws ServiceException ServiceException
 */
protected Document unSubscribeEventReceive(Document doc4j, String toUserName, String fromUserName,
        String eventKey) throws ServiceException {
    Node ticketNode = doc4j.selectSingleNode("/xml/Ticket");
    String ticket = ticketNode == null ? "" : ticketNode.getText();

    WechatEventUnSubscribeMessageRequest unSubscribeMessage = new WechatEventUnSubscribeMessageRequest(
            toUserName, fromUserName, "unsubscribe", eventKey);
    unSubscribeMessage.setTicket(ticket);
    return messageRecive(unSubscribeMessage);
}

From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java

/**
  * /*w  ww  . ja  va 2s  . co m*/
  *
  * @param doc4j ??Dom
  * @param toUserName ??
  * @param fromUserName ????OpenID d
  * @param eventKey KEY???
  * @return ?
  * @throws ServiceException ServiceException
  */
protected Document subscribeEventReceive(Document doc4j, String toUserName, String fromUserName,
        String eventKey) throws ServiceException {
    Node ticketNode = doc4j.selectSingleNode("/xml/Ticket");
    String ticket = ticketNode == null ? "" : ticketNode.getText();

    WechatEventSubscribeMessageRequest subscribeMessage = new WechatEventSubscribeMessageRequest(toUserName,
            fromUserName, "subscribe", eventKey);
    subscribeMessage.setTicket(ticket);
    return messageRecive(subscribeMessage);
}

From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java

/**
 * ????//  w ww.j a  va 2s .c o m
 *
 * @param doc4j ??Dom
 * @param toUserName ??
 * @param fromUserName ????OpenID
 * @param eventKey KEY???
 * @return ?
 * @throws ServiceException ServiceException
 */
protected Document scanEventReceive(Document doc4j, String toUserName, String fromUserName, String eventKey)
        throws ServiceException {
    Node ticketNode = doc4j.selectSingleNode("/xml/Ticket");
    String ticket = ticketNode == null ? "" : ticketNode.getText();

    WechatEventScanMessageRequest scanMessage = new WechatEventScanMessageRequest(toUserName, fromUserName,
            "scan", eventKey);
    scanMessage.setTicket(ticket);
    return messageRecive(scanMessage);
}

From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java

/**
 * ??/*from  www  .j a v  a  2 s. co m*/
 *
 * @param doc4j ??Dom
 * @param toUserName ??
 * @param fromUserName ????OpenID
 * @param eventKey KEY???
 * @return ?
 * @throws ServiceException ServiceException
 */
protected Document locationEventReceive(Document doc4j, String toUserName, String fromUserName, String eventKey)
        throws ServiceException {
    Node latitudeNode = doc4j.selectSingleNode("/xml/Latitude");
    Node longitudeNode = doc4j.selectSingleNode("/xml/Longitude");
    Node precisionNode = doc4j.selectSingleNode("/xml/Precision");
    String latitude = latitudeNode == null ? "" : latitudeNode.getText();
    String longitude = longitudeNode == null ? "" : longitudeNode.getText();
    String precision = precisionNode == null ? "" : precisionNode.getText();

    WechatEventLocationMessageRequest locationMessage = new WechatEventLocationMessageRequest(toUserName,
            fromUserName, "location", eventKey);
    locationMessage.setLatitude(latitude);
    locationMessage.setLongitude(longitude);
    locationMessage.setPrecision(precision);
    return messageRecive(locationMessage);
}

From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java

protected Document linkMessageReceive(Document doc4j, WechatMessage wechatMessage) throws ServiceException {
    Node titleNode = doc4j.selectSingleNode("/xml/Title");
    Node descriptionNode = doc4j.selectSingleNode("/xml/Description");
    Node urlNode = doc4j.selectSingleNode("/xml/Url");

    String title = titleNode == null ? "" : titleNode.getText();
    String description = descriptionNode == null ? "" : descriptionNode.getText();
    String url = urlNode == null ? "" : urlNode.getText();

    WechatNormalLinkMessageRequest linkMessage = new WechatNormalLinkMessageRequest();
    try {/* w ww  .j  a v  a 2  s .co  m*/
        BeanUtils.copyProperties(linkMessage, wechatMessage);
    } catch (IllegalAccessException | InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    linkMessage.setTitle(title);
    linkMessage.setDescription(description);
    linkMessage.setUrl(url);
    return messageRecive(linkMessage);
}

From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java

protected Document locationMessageReceive(Document doc4j, WechatMessage wechatMessage) throws ServiceException {
    Node locationXNode = doc4j.selectSingleNode("/xml/Location_X");
    Node locationYNode = doc4j.selectSingleNode("/xml/Location_Y");
    Node scaleNode = doc4j.selectSingleNode("/xml/Scale");
    Node labelNode = doc4j.selectSingleNode("/xml/Label");

    BigDecimal locationX = locationXNode == null ? new BigDecimal(0) : new BigDecimal(locationXNode.getText());
    BigDecimal locationY = locationYNode == null ? new BigDecimal(0) : new BigDecimal(locationYNode.getText());
    BigDecimal scale = scaleNode == null ? new BigDecimal(0) : new BigDecimal(scaleNode.getText());
    String label = labelNode == null ? "" : labelNode.getText();

    WechatNormalLocationMessageRequest locationMessage = new WechatNormalLocationMessageRequest();
    try {//from   w w  w . java  2s.  c  o m
        BeanUtils.copyProperties(locationMessage, wechatMessage);
    } catch (IllegalAccessException | InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    locationMessage.setLocationX(locationX);
    locationMessage.setLocationY(locationY);
    locationMessage.setScale(scale);
    locationMessage.setLabel(label);
    return messageRecive(locationMessage);
}

From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java

protected Document shortvideoMessageReceive(Document doc4j, WechatMessage wechatMessage)
        throws ServiceException {
    Node msgIdNode = doc4j.selectSingleNode("/xml/MsgId");
    Node mediaIdNode = doc4j.selectSingleNode("/xml/MediaId");
    Node thumbMediaIdNode = doc4j.selectSingleNode("/xml/ThumbMediaId");

    String msgId = msgIdNode == null ? "" : msgIdNode.getText();
    String mediaId = mediaIdNode == null ? "" : mediaIdNode.getText();
    String thumbMediaId = thumbMediaIdNode == null ? "" : thumbMediaIdNode.getText();

    WechatNormalShortvideoMessageRequest shortVodeoMessage = new WechatNormalShortvideoMessageRequest();
    try {//from ww w .j  a va 2  s.  co  m
        BeanUtils.copyProperties(shortVodeoMessage, wechatMessage);
    } catch (IllegalAccessException | InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    shortVodeoMessage.setMsgId(msgId);
    shortVodeoMessage.setMediaId(mediaId);
    shortVodeoMessage.setThumbMediaId(thumbMediaId);
    Document respDoc4j = messageRecive(shortVodeoMessage);
    return respDoc4j;
}

From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java

protected Document videoMessageReceive(Document doc4j, WechatMessage wechatMessage) throws ServiceException {
    Node msgIdNode = doc4j.selectSingleNode("/xml/MsgId");
    Node mediaIdNode = doc4j.selectSingleNode("/xml/MediaId");
    Node thumbMediaIdNode = doc4j.selectSingleNode("/xml/ThumbMediaId");

    String msgId = msgIdNode == null ? "" : msgIdNode.getText();
    String mediaId = mediaIdNode == null ? "" : mediaIdNode.getText();
    String thumbMediaId = thumbMediaIdNode == null ? "" : thumbMediaIdNode.getText();

    WechatNormalVideoMessageRequest videoMessage = new WechatNormalVideoMessageRequest();
    try {//from w w  w  .  ja  v  a2 s  .  c  o m
        BeanUtils.copyProperties(videoMessage, wechatMessage);
    } catch (IllegalAccessException | InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    videoMessage.setMsgId(msgId);
    videoMessage.setMediaId(mediaId);
    videoMessage.setThumbMediaId(thumbMediaId);
    Document respDoc4j = messageRecive(videoMessage);
    return respDoc4j;
}

From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java

protected Document voiceMessageReceive(Document doc4j, WechatMessage wechatMessage) throws ServiceException {
    Node msgIdNode = doc4j.selectSingleNode("/xml/MsgId");
    Node mediaIdNode = doc4j.selectSingleNode("/xml/MediaId");
    Node formatNode = doc4j.selectSingleNode("/xml/Format");

    String msgId = msgIdNode == null ? "" : msgIdNode.getText();
    String mediaId = mediaIdNode == null ? "" : mediaIdNode.getText();
    String format = formatNode == null ? "" : formatNode.getText();

    WechatNormalVoiceMessageRequest voiceMessage = new WechatNormalVoiceMessageRequest();
    try {/*from   w  ww  .j  a  v a  2  s  .c  o m*/
        BeanUtils.copyProperties(voiceMessage, wechatMessage);
    } catch (IllegalAccessException | InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    voiceMessage.setMsgId(msgId);
    voiceMessage.setMediaId(mediaId);
    voiceMessage.setFormat(format);
    Document respDoc4j = messageRecive(voiceMessage);
    return respDoc4j;
}