Example usage for org.dom4j Element elementText

List of usage examples for org.dom4j Element elementText

Introduction

In this page you can find the example usage for org.dom4j Element elementText.

Prototype

String elementText(QName qname);

Source Link

Usage

From source file:com.voa.weixin.message.recieve.RecieveLocationMessage.java

License:Open Source License

@Override
public void parseXml(Element root) {
    this.locationX = Float.valueOf(root.elementText("Location_X"));
    this.locationY = Float.valueOf(root.elementText("Location_Y"));
    this.scale = Integer.valueOf(root.elementText("Scale"));
    this.label = root.elementText("Label");
}

From source file:com.voa.weixin.message.recieve.RecieveMenuEvent.java

License:Open Source License

@Override
public void parseXml(Element root) {
    this.eventKey = root.elementText("EventKey");
}

From source file:com.voa.weixin.message.recieve.RecieveMessage.java

License:Open Source License

private void parsePubXml(Element root) {
    this.toUserName = root.elementText("ToUserName");
    this.fromUserName = root.elementText("FromUserName");
    String getTime = root.elementText("CreateTime");
    logger.debug("getTime : " + getTime);
    this.createTime = new Date((Long.parseLong(getTime) * 1000));
    this.msgType = root.elementText("MsgType");
    this.msgId = root.elementText("MsgId");

    logger.debug("createtime : " + this.createTime);
}

From source file:com.voa.weixin.message.recieve.RecieveTicketEvent.java

License:Open Source License

@Override
public void parseXml(Element root) {
    super.parseXml(root);
    this.eventKey = root.elementText("EventKey");
    this.ticket = root.elementText("Ticket");
}

From source file:com.voa.weixin.message.recieve.RecieveTxtMessage.java

License:Open Source License

@Override
public void parseXml(Element root) {
    this.content = root.elementText("Content");
}

From source file:com.voa.weixin.message.recieve.RecieveVedioMessage.java

License:Open Source License

@Override
public void parseXml(Element root) {
    this.mediaId = root.elementText("MediaId");
    this.thumbMediaId = root.elementText("ThumbMediaId");
}

From source file:com.voa.weixin.message.recieve.RecieveVoiceMessage.java

License:Open Source License

@Override
public void parseXml(Element root) {
    this.mediaId = root.elementText("MediaId");
    this.format = root.elementText("Format");
}

From source file:com.voa.weixin.mission.MissionManager.java

License:Open Source License

private void init() {
    Document doc = null;/*from   w w  w .j  a  v a2s . c om*/
    try {
        doc = WeixinUtils.getDocumentResource("weixin.mission.xml");

    } catch (Exception e) {
        logger.warn("can't find or parser weixin.mission.xml:" + e.getMessage());
    }
    if (doc == null)
        return;

    List<Element> missionEs = doc.getRootElement().elements("mission");

    for (Element missionE : missionEs) {
        String name = missionE.elementText("name");
        String period = missionE.elementText("period");
        String delay = missionE.elementText("delay");
        String className = missionE.elementText("class");

        try {
            Class clz = Class.forName(className);
            Constructor<Mission> constructor = clz.getConstructor(String.class);

            Mission mission = constructor.newInstance(name);

            mission.setDelay((Integer.valueOf(delay) * 1000));
            mission.setPeriod((Integer.valueOf(period) * 1000));

            missions.put(name, mission);

            timer.schedule(mission, mission.getDelay(), mission.getPeriod());
        } catch (Exception e) {
            logger.warn("mission can't be instance : " + name);
            logger.warn("cause by " + e.getMessage());
        }
    }

}

From source file:com.voa.weixin.task.TaskRepertory.java

License:Open Source License

/**
 * ??weixin.task.xml// w ww  . j  a  va2s.  co  m
 * @throws Exception
 */
public void init() throws Exception {
    Document doc = WeixinUtils.getDocumentResource("weixin.task.xml");

    if (doc == null)
        return;

    List<Element> taskEs = doc.getRootElement().elements("task");

    for (Element taskE : taskEs) {
        String name = taskE.elementText("name");
        String url = taskE.elementText("url");
        String method = taskE.elementText("method");
        String workClzName = taskE.elementText("work");
        String instance = taskE.elementText("instance");
        String clzName = taskE.elementText("class");

        Task task = null;
        try {
            if (clzName == null || clzName.equals("com.voa.weixin.task")) {
                task = new CommonTask();
            } else {
                Class taskClz = Class.forName(clzName);
                task = (Task) taskClz.newInstance();
            }
        } catch (Exception e) {
            logger.warn("task class not found : " + clzName);
        }

        task.setName(name);
        task.setUrl(url);
        task.setMethod(method == null ? "post" : method);
        task.setInstance(instance == null ? "multi" : instance);

        if (StringUtils.isNotEmpty(workClzName)) {
            try {
                Class workClz = Class.forName(workClzName);
                Work work = (Work) workClz.newInstance();
                tasks.put(name, task);
                taskWorkNames.put(name, workClzName);
            } catch (ClassNotFoundException e) {
                logger.warn("work class not found : " + workClzName);
            } catch (Exception e) {
                logger.warn("work class not be instance : " + workClzName);
            }

        } else {
            tasks.put(name, task);
        }
    }
}

From source file:com.xdtech.report.controller.ReadReportController.java

License:Apache License

@RequestMapping(params = "configReportPage")
public ModelAndView configReportPage(HttpServletRequest request, Long configId) throws Exception {
    String title = "";
    if (configId != null) {
        ConfigItem configItem = configService.loadConfigItem(configId);
        title = configItem.getName();/*from  w  w  w  .j a  v  a2 s. c om*/
        request.setAttribute("configItem", configItem);
        SAXReader reader = new SAXReader(); // User.hbm.xml??xml 
        //         Document doc = reader.read(new File("G:/my-dev/git/xdtech-shop/src/test/java/pageTemplate.xml"));
        // ??xml 
        Document doc = DocumentHelper.parseText(configItem.getXml()); // XML 
        Element rootElement = doc.getRootElement();
        Element subGridDataElement = rootElement.element("datagrid");// ?datagrid
        //??title
        if (null != subGridDataElement.elementText("title")) {
            title = subGridDataElement.elementText("title");
        }
        //??
        Element columnsElement = subGridDataElement.element("columns");
        if (null != columnsElement && !columnsElement.isRootElement()) {
            List<Element> columnList = columnsElement.elements();
            JSONArray columnsArray = new JSONArray();
            JSONObject columnJson = null;
            for (Element element : columnList) {
                columnJson = new JSONObject();
                columnJson.put("field", element.attributeValue("field"));
                columnJson.put("title", element.attributeValue("title"));
                columnsArray.add(columnJson);
            }
            //            System.out.println(columnsArray.toString());
            request.setAttribute("columns", columnsArray.toString());
        }
    }
    request.setAttribute("showReportGridId", UUID.randomUUID().toString() + "_grid");
    request.setAttribute("title", title);
    return new ModelAndView("report/read/showReportGrid_ftl");
}