コード例 #1
0
  private void prepareContent(
      Vector mess, Vector langs, String tmpPathDate, String fInput, String mask_name) {
    String sep = System.getProperty("line.separator");
    String jsp_name = util_format.replace(fInput.replace('\\', '/'), "//", "/");

    String tmp = util_format.replace(input_dir_path.replace('\\', '/'), "//", "/");
    String view_jsp_name = util_format.replace(jsp_name, tmp, "");

    jsp_name = jsp_name.substring(jsp_name.lastIndexOf("/") + 1, jsp_name.length());

    String tmp_integrity_log = "";

    String result = "";
    for (int i = 0; i < mess.size(); i++) {
      message mes = (message) mess.get(i);
      if (mes.getCD_MESS() != null
          && !mes.getCD_MESS().trim().equals("")
          && presented.get(mes.getCD_MESS()) != null) {
        tmp_integrity_log =
            tmp_integrity_log
                + "          KO-->"
                + "["
                + mes.getCD_MESS()
                + "] ["
                + mes.DESC_MESS
                + "] si presenta: "
                + presented.get(mes.getCD_MESS())
                + sep;
      } else presented.put(mes.getCD_MESS(), jsp_name);
      if (!isPresentMessage(mes)) {
        if (result.indexOf("cd_mess=\"" + mes.getCD_MESS() + "\"") == -1) {
          result += "	" + mes.toString() + sep;
          for (int j = 0; j < langs.size(); j++) {
            mes.setCD_LANG((String) langs.get(j));
            mes.setDESC_MESS("???");
            result += "	" + mes.toString() + sep;
          }
          result += sep;
        }
      }
    }
    if (!result.equals("")) {
      result = "<messages view=\"" + jsp_name + "\"> " + sep + result;
      result += "</messages>";
      String fileName = mask_name + "." + jsp_name + ".xml";
      while (fileName.indexOf("..") > -1) {
        fileName = util_format.replace(fileName, "..", ".");
      }

      fileName = tmpPathDate + "/" + fileName;

      result = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + sep + result;
      write2file(result, fileName);
    }
    if (!tmp_integrity_log.equals(""))
      integrity_log += sep + view_jsp_name + sep + tmp_integrity_log;
  }
コード例 #2
0
  private Vector getMessages(String file) throws Exception {
    file = util_format.replace(file, "//", "/");
    Vector result = new Vector();
    String sourceUrlString = file;

    PHPTagTypes.register();
    PHPTagTypes.PHP_SHORT.deregister();
    MasonTagTypes.register();
    String test = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"/>\n";
    test += getURLContent(sourceUrlString);

    //	Source source=new Source(new URL(sourceUrlString));
    Source source = new Source(test.subSequence(0, test.length()));
    source.setLogWriter(new OutputStreamWriter(System.err)); // send log messages to stderr
    source.fullSequentialParse();
    List elementList = source.findAllElements();
    HashMap jspParamDesc = new HashMap();
    for (Iterator i = elementList.iterator(); i.hasNext(); ) {
      Element element = (Element) i.next();
      if (element.getName().indexOf("bs:message") == 0) {
        Attributes atts = element.getAttributes();
        if (atts != null && atts.get("code") != null) {
          message mes = new message();
          mes.setCD_MESS(atts.get("code").getValue());
          mes.setCD_LANG("IT");
          try {
            mes.setDESC_MESS(atts.get("defaultValue").getValue());
          } catch (Exception e) {
          }
          result.add(mes);
        }
      }
      if (element.getName().indexOf("jsp:param") == 0) {
        Attributes atts = element.getAttributes();
        if (atts != null
            && atts.get("name") != null
            && atts.get("name").getValue().indexOf("code_tab_desc") == 0) {
          jspParamDesc.put(
              util_format.replace(atts.get("name").getValue(), "code_tab_desc", "def_tab_desc"),
              atts.get("value").getValue());
        }
        if (atts != null
            && atts.get("name") != null
            && atts.get("name").getValue().indexOf("def_tab_desc") == 0) {
          String code = (String) jspParamDesc.get(atts.get("name").getValue());
          if (code != null) {
            message mes = new message();
            mes.setCD_MESS(code);
            mes.setCD_LANG("IT");
            try {
              mes.setDESC_MESS(atts.get("value").getValue());
            } catch (Exception e) {
            }
            result.add(mes);
            jspParamDesc.remove(atts.get("name").getValue());
          }
        }
      }
      if (element.getName().indexOf("bs:show_lm_actionlabel") == 0) {
        Attributes atts = element.getAttributes();
        if (atts != null && atts.get("message_code") != null) {
          message mes = new message();
          mes.setCD_MESS(atts.get("message_code").getValue());
          mes.setCD_LANG("IT");
          try {
            mes.setDESC_MESS(atts.get("message_defaultValue").getValue());
          } catch (Exception e) {
          }
          result.add(mes);
        }
      }
      if (element.getName().indexOf("element") == 0
          || element.getName().indexOf("form-redirect") == 0) {
        Attributes atts = element.getAttributes();
        if (atts != null && atts.get("mess_id") != null) {
          message mes = new message();
          mes.setCD_MESS(atts.get("mess_id").getValue());
          mes.setCD_LANG("IT");
          try {
            mes.setDESC_MESS(atts.get("descr").getValue());
          } catch (Exception e) {
          }
          result.add(mes);
        }
      }
    }

    return result;
  }