コード例 #1
0
  /**
   * @Description: 拼装返回信息
   *
   * @author [email protected]
   * @param @param inObject
   * @param @return
   * @param @throws ServiceProxyException
   * @return Document
   * @throws
   */
  public Document ObjectToXML(VideoDisplayDevice displayServer) {
    /**
     * 信息格式:<br>
     * <Message> <DisplaySetting ID=1 HeartCycle=1 SysRebootTime=1 SysRebootCycle=1> <Monitor ID=1
     * Name="mingzi"> <Monitor ID=n Name="mingzi"> </Message>
     */
    Element rootElement = new Element("Message");
    // 得到显示设备ID
    String displayId = displayServer.getId();
    // 加入显示设备设置信息
    Element displayElement = new Element("DisplaySetting");
    displayElement.setAttribute("ID", displayId);

    String naming = displayServer.getNaming();
    displayElement.setAttribute("Naming", naming == null ? "" : naming);

    displayElement.setAttribute("HeartCycle", new Long(displayServer.getHeartCycle()).toString());
    displayElement.setAttribute("SysRebootTime", displayServer.getRebootTime());
    displayElement.setAttribute(
        "SysRebootCycle", new Long(displayServer.getRebootCycle()).toString());
    Element successElement = new Element("Success");
    successElement.setText("0");
    rootElement.addContent(successElement);
    rootElement.addContent(displayElement);

    // 获取该显示设备下所有的监视器
    List<VideoOutputChannel> vocList = vocManager.listVocByDisplayId(displayServer.getId());
    // 加入监视器信息
    for (VideoOutputChannel voc : vocList) {
      Element monitorElement = new Element("Monitor");
      monitorElement.setAttribute("ID", voc.getId());
      monitorElement.setAttribute("Name", voc.getName());
      monitorElement.setAttribute(
          "Naming", voc.getNaming() == null ? "" : String.valueOf(voc.getNaming()));
      monitorElement.setAttribute("ChannelId", "");
      rootElement.addContent(monitorElement);
    }
    Document doc = new Document(rootElement);
    return doc;
  }