package core.page; import java.io.BufferedReader; import java.io.File; import java.io.StringReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; import base.SsC; import core.PrjApp; import ss.AppB; import ss.AppC; import ss.ccp.CcpB; import ss.ccp.CcpFieldB; import ss.cmn.file.FileU; import ss.cmn.ser.SerU; import ss.cmn.str.StrU; import ss.cmn.str.StrWeb; import ss.log.SsLog; import ss.log.ThdLog; import ss.obj.ObjB; import ss.obj.ObjC; import ss.obj.ObjFieldB; import ss.page.PageB; import ss.page.PageC; import ss.page.PageU; import ss.page.TabC; import ss.search.SearchC; import ss.skin.SkinC; // 来自 pms-core:XmslBjCompiler implements BjCompiler(接口类)。Lin public class PageComper { // 增加,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin private static final Logger log4j = LogManager.getLogger(PageComper.class); ///// 来自 FileTranslator。 // 移到 PageCompC。Lin // private static final String INTERPOLE_JSPTOP_BEGIN = ""; // private static final String INTERPOLE_JSPTOP_END = ""; // private static final String INTERPOLE_HEAD_BEGIN = ""; // private static final String INTERPOLE_HEAD_END = ""; /* 去掉,不写应用名。Lin private static final String SET_APPNAME_JSP = "pms/clip/SetAppName.jsp"; // "/main/sheji/setAppName.jsp"。Lin private static final String SET_APPNAME_SCRIPT = "<%-- setAppName.jsp is 404 --%><% pageContext.setAttribute(wd.core.web.service.ServiceConst.APP_NAME,\"#{APPNAME}#\");%>\n"; private static final String SET_XMDM_JSP = "pms/clip/SetXmdm.jsp"; // "/main/sheji/setXmdm.jsp"。Lin private static final String SET_XMDM_SCRIPT = "<%-- setXmdm.jsp is 404 --%><% r\n if(pageContext.getSession().getAttribute(wd.core.common.CoreConstVars.XMMC)==null)\r\n\tpageContext.getSession().setAttribute(wd.core.common.CoreConstVars.XMMC,\"#{XMDM}#\");\r\n %>\r\n"; */ /* 去掉,不用文件,用常量 PageCompC.SCR_clearToken。Lin private static final String CLEAR_TOKEN_JSP = "pms/clip/ClearToken.jsp"; // "/main/sheji/tokenClear.jsp"。Lin private static final String CLEAR_TOKEN_SCRIPT = "<%-- tokenClear.jsp is 404 --%>\r\n"; */ // private static final String ADD_REMOVE_TOKEN_SCRIPT = "\r\n"; ///// // 浅编译部件。Lin // 入口参数 fileName 优先。 // 不分 MiniBuilder、P18Builder // 区别只在于 PageObject 是否为 null // 把 fileName、pageB 都做为入口参数 // public boolean miniCompile(String fileName, PageB pageobj, int type, String destDir) // 入口参数改为只有 pageName。Lin // 再调整为 PMS 编译项目的部件 -- 增加支持多线程。Lin // 增加 compPage(CompPageB),去掉 pageName(String) 和 srcDir(String) -- 上层直接产生到文件名 // 增加 prjApp(PrjApp) -- 用 PrjApp 和 CompPageB 来生成编译后的文件位置和文件名 // 另,对 PMS 本身的首页 编译后的存放位置,不做特别处理 -- 手工再拷贝到 PMS 项目的 webapp 目录里 public static boolean compPage(CompPageB compPage, PrjApp prjApp) { String pageName = compPage.pageName; // 增加。Lin /* 再调整为 PMS 编译项目的部件。Lin PageB pageObj = PrjApp.pageMap.get(pageName); */ PageB pageObj = prjApp.pageMap.get(pageName); ///// 来自 MiniBuilder.build()。(@Override // extends PageBuilder /* 再去掉,改为入口参数 -- 直接由上层产生到文件名 -- PMS/CompPage.jsp。Lin String reader; // StringReader。改用 fileName。Lin */ try { /* 改用 fileName。Lin reader = getSourceCode(AppB.webRoot + srcDir + pageName +".jsp"); // 统一用 srcDir。Lin */ /* 再去掉,改为入口参数 -- 直接由上层产生到文件名 -- PMS/CompPage.jsp。Lin reader = prjApp.webRoot + srcDir + pageName +".jsp"; // 统一用 srcDir。Lin // = AppB.。再增加支持多线程。Lin */ if (pageObj == null) { // 登录页、个人首页。Lin SsLog.print("prjApp.pageMap 没有找到:"+ pageName); // 少一级 PageC.PAGE_dir 目录。Lin // reader = getSourceCode(SsApp.webRoot + srcDir + pageName +".jsp"); // 统一用 srcDir。Lin /* 再去掉 false = bySys,原来的程序有增加 、 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin createNewFileWithUrl(reader, null, AppB.webRoot + pageName +".jsp", false); // 不用 .Md5Name。Lin */ /* 再调整为 PMS 编译项目的部件。Lin * 增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程 * pageObj(PageB) 移到 prjApp 前面 * 源文件为 ".ss.jsp"(PageC.PAGE_ssExt),编译后的目标文件为 ".jsp"(AppC.EXT_jsp) createNewFileWithUrl(reader, null, prjApp.webRoot + pageName +".jsp"); // , AppB.。再增加支持多线程。Lin */ doCompPage(compPage.srcFileName, prjApp.webRoot + pageName + AppC.EXT_jsp, null, prjApp); } else { // reader = getSourceCode(SsApp.webRoot + srcDir + PageC.PAGE_dir + pageName +".jsp"); // 统一用 srcDir。Lin /* 兜兜转转,直接点。Lin * 去掉 FileTranslator FileTranslator f=new FileTranslator(); f.setAppName(getFactory().getWebapp().getName()); f.setJapSuffix(common.ConstVars.RUN); f.setPageobj(null); if(reader!=null) f.createNewFileWithUrl(reader, getFactory().getGeneratePath()); */ /* 再去掉 false = bySys,原来的程序有增加 、 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin createNewFileWithUrl(reader, pageObj, AppB.webRoot + PageU.cmptPageFileName(pageObj), false); */ /* 再增加支持多线程 -- PMS 需要。Lin createNewFileWithUrl(reader, pageObj, AppB.webRoot + PageU.cmptPageFileName(pageObj)); */ /* 再调整为 PMS 编译项目的部件。Lin * 增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程 * pageObj(PageB) 移到 prjApp 前面 createNewFileWithUrl(reader, pageObj, prjApp.webRoot + PageU.cmptPageFileName(pageObj)); */ String tgtPageName = (prjApp.inDebug)? pageName : PageU.md5PageName(pageName); // MD5 部件名。Lin doCompPage(compPage.srcFileName, prjApp.webRoot + PageU.cmptPageFileName(tgtPageName), pageObj, prjApp); /// 增加自动生成 _baseInfo、_miniInfo,并编译刷新 pageMap。Lin /* 再改,部件文件名前缀 "env_" 改为增加的属性 env= 了。Lin * 就是找 dw_inp 等,直接找 "_inp"/"_miniInp" 就行了 -- 去掉了 "env_" 后,env_inp 改为 objInp,没有 "_inp" 了。Lin if (!pageName.startsWith(PageC.PAGE_envPre) && // 不包含 "env_inp"。Lin (pageName.endsWith(PageC.PAGE_inpSuf) || // "_input")。Lin pageName.endsWith(PageC.PAGE_miniInpSuf))) { // "_miniInput")。Lin */ if (pageName.endsWith(PageC.PAGE_inpSfx) || pageName.endsWith(PageC.PAGE_miniInpSfx)) { String infoPageName = pageName.replace(PageC.PAGE_inpSfx, PageC.PAGE_baseInfoSfx) // "_input", "_baseInfo")。Lin .replace(PageC.PAGE_miniInpSfx, PageC.PAGE_miniInfoSfx); // "_miniInput", "_miniBaseInfo")。Lin PageB infoPage = prjApp.pageMap.get(infoPageName); // = PrjApp.。再增加支持多线程。Lin if (infoPage != null && !infoPage.bySys) // 手工写的 Info Page。Lin return true; /* 复制到 "_baseInfo"/"_miniInfo"。Lin * 不复制了,直接从 "_inp"/"_miniInp" 读 FileU.copyFile(reader, AppB.webRoot + srcDir + infoPageName +".jsp"); */ infoPage = makeInfoPageB(pageObj, infoPageName, prjApp); // 生成 Info PageB。Lin String serDir = prjApp.webRoot + AppC.CFG_serDir; // = PrjApp.appRoot。再增加支持多线程。Lin SerU.doSer(infoPage, serDir + pageName); // 用 "_inp" 保存 -- 项目启动时加载。Lin prjApp.pageMap.put(infoPage.name, infoPage); // 更新 pageMap。Lin // PrjApp.。再增加支持多线程。Lin /* 再去掉 true = bySys,原来的程序有增加 、 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin createNewFileWithUrl(reader, infoPage, AppB.webRoot + PageU.cmptPageFileName(infoPage), true); */ /* 再增加支持多线程 -- PMS 需要。Lin createNewFileWithUrl(reader, infoPage, AppB.webRoot + PageU.cmptPageFileName(infoPage)); */ /* 再调整为 PMS 编译项目的部件。Lin * 增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程 * pageObj(PageB) 移到 prjApp 前面 createNewFileWithUrl(reader, infoPage, prjApp.webRoot + PageU.cmptPageFileName(infoPage)); */ tgtPageName = (prjApp.inDebug)? infoPageName : PageU.md5PageName(infoPageName); // MD5 部件名。Lin doCompPage(compPage.srcFileName, prjApp.webRoot + PageU.cmptPageFileName(tgtPageName), infoPage, prjApp); } /// } } catch (Exception e) { /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin e.printStackTrace(); */ log4j.error("PageComper.compPage( 异常", e); ThdLog.wrMsg(String.format(AppC.TITLE_errLine, "编译部件错误"), e.toString(), e.getCause()); // RlsLoger.。Lin return false; } return true; ///// } // 生成 Info PageB。Lin // 参考自 pms-core:PmsUtil.(Wj) addRealate_baseinfo(Wj wj, Long yhid, GeneralDBAccess gdba)。Lin // 再增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程 -- PMS 需要。Lin private static PageB makeInfoPageB(PageB pageObj, String infoPageName, PrjApp prjApp) { /* 改。Lin ViewObject vo = PmsFinder.findViewObject(wj.getDxm(), wj.getXmslid(), gdba); */ ObjB vo = prjApp.objMap.get(pageObj.objName); // 一定有 .objName。Lin // PrjApp.。再增加支持多线程。Lin String infoDesc = vo.desc +"基本情况"; /* 再去掉,即使有细分部件,也叫 "文书基本情况"。Lin * 即使用改成了 "文书来文基本情况" 也是没用的,"查看文书"/"查看文书.来文" 是在 ??? 重新生成的。Lin for (ObjFuncB f : vo.funcMap.values()) { // .getFuns()。Lin for (ObjFuncPluginB plu : f.pluginList) { if (infoPageName.equals(plu.name)) { infoDesc = vo.desc + plu.desc +"基本情况"; break; } } } */ PageB info = new PageB(); // 与 PageB 的成员变量一致。Lin info.biz = pageObj.biz; info.objName = pageObj.objName; info.isEnv = true; info.isInfo = true; info.isInp = false; info.bySys = true; /* 去掉 PageB.type 了。同时,MD 的部件名,加前缀 mp_/pad_/ext_(外部访问,微信) 了。Lin * 去掉 、 等。Lin // 再去掉 bySys,原来的程序有增加 、 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin // 再增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程 // pageObj(PageB) 移到 prjApp 前面 private static void doCompPage(String srcFileName, // 被替换的源文件路径(此文件不会被修改) String tgtFileName, // 替换后生成的新文件路径 PageB pageobj, // 被替换的源 PageB PrjApp prjApp /* 再去掉 bySys。Lin boolean bySys // 根据 dw_inp.jsp 生成 dw_baseInfo.jsp -- 增加 、 等。Lin */ ) throws Exception { /* 再改,IDEA:'StringBuffer result' may be declared as 'StringBuilder'。Lin StringBuffer result=new StringBuffer(); */ StringBuilder result = new StringBuilder(); // CACHE = new ThreadLocal>(); /* 去掉,没有 _view.jsp 了。Lin boolean isViewJsp = ConstVars.VIEW.equals(japSuffix); */ boolean isHelpJsp = false; /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List List fileContentStrList = new LinkedList<>();// 包含文件中所有内容的字符串 */ List fileContentStrList = new LinkedList<>();// 包含文件中所有内容的字符串 // 发布程序自动添加html、head、body start 150209 by ye /* * fileContentStrList.add(""); fileContentStrList.add(""); * fileContentStrList.add(""); * fileContentStrList.add(""); fileContentStrList.add(""); */ // 发布程序自动添加html、head、body end 150209 by ye /// 改为在这添加,且只对 dw_inp.jsp 生成 dw_baseInfo.jsp 时。Lin /* 再去掉,原来的程序有增加 、 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin if (bySys) { fileContentStrList.add(""); fileContentStrList.add(""); // fileContentStrList.add(""); fileContentStrList.add(""); fileContentStrList.add(""); } */ /// List jsFileList = new ArrayList<>(); List tbodyFileList = new ArrayList<>(); Map tldFileMap = new HashMap<>(); BufferedReader in = null; String s; // PrintStream ps = null; try { /* 再改,IDEA:Type may be primitive。Lin Boolean pageExist = (pageobj != null); */ boolean pageExist = (pageobj != null); // String yyxtidSql="select yyxt_id from ejlm where ymid="+ymid; // gdba.select( yyxtidSql); // String yyxtid=null; // if (gdba.getNowselect().getRowCount() > 0) { // yyxtid=gdba.getColumnAsString("yyxt_id"); // } // String dm = WebUtil.getYyhByWzid(gdba, wzid); // 读取源文件的所有内容 // System.out.println(new File(srcFilePath).exists()); /* 去掉,移到 jspUpdate() 里 -- 只有这里用到。Lin String[] array = { WebC.SS_name, PrjApp.prjName }; // "wd",appName。Lin */ /// 帮助功能变量准备start /// // String bjdm = pageobj.getName(); // String gdgd = null; // Bj bj = new Bj(); // bj.setBjid(Long.valueOf(bjId)); // // gdba.selectById(bj); // bjdm = bj.getDm(); // if (bjdm != null && bjdm.startsWith("help_")) { // isHelpJsp = true; // } /* 去掉 csc(保存所有属性的键值对),已经写到 .name、.width 等了。Lin Map json = pageExist?pageobj.getCsc():new HashMap(); */ // gdgd = json.get("gdgd"); // DesignOutSide dots = new DesignOutSide(Long.parseLong(ymid), gdba); /* 去掉 csc(保存所有属性的键值对),已经写到 .name、.width 等了 -- 用 .isMakeBySys。Lin boolean systemCreate = "1".equals(json.get("sfxtcj") + ""); */ /* 再改,IDEA:Variable 'systemCreate' is never used。Lin boolean systemCreate = pageExist? pageobj.bySys : false; */ // Ym ym = new Ym(); // ym.setYmid(Long.parseLong(ymid)); // gdba.selectById(ym); // if (bjId != null) { // String bjdmSql = "select dm,bqgd from bj where bjid = :bjid"; // SqlCommandImpl sqlCmd = new SqlCommandImpl(bjdmSql); // sqlCmd.setInt("bjid", Long.valueOf(bjId)); // gdba.select(sqlCmd); // if (gdba.getRowCount() > 0) { // bjdm = gdba.getColumnAsString("dm"); // bqgd = gdba.getColumnAsString("bqgd"); // } // } // List wdHelpExecutableJsStringList = new // ArrayList(); // String wdhelpForPagejs = new // WdHelpForWholePage().getExecutableJsString("", dm, bjdm); // // 整个页面的帮助 // if (wdhelpForPagejs != null) { // wdHelpExecutableJsStringList.add(wdhelpForPagejs); // } /// 存储帮助功能的可执行js代码段 /// /// 帮助功能变量准备 end /// // StringReader reader = null; /* 去掉入口参数 ymid、wzid、gdba(wdgdba)。Lin * 去掉 appName,直接用 PrjApp.prjName * 移到 PageCompU,reader 改为 fileName -- 在 compFile() 里读入 reader = transformCommonwrite(reader, appName, null, null, wdgdba); */ StringReader reader = PageCompU.compFile(srcFileName); //noinspection SuspiciousIndentAfterControlStatement if (pageExist) if (pageobj.isInfo || pageobj.isInp) { // if (isMobile()) { //// reader = addMobileViewObjectTools(reader, dm, ym.getObject(), bj.getDm(), ymid, wzid, isViewJsp, systemCreate, gdba); // } else { /* 去掉 appName,不支持多个应用。Lin * 去掉 isViewJsp,没有 ViewJsp 了。Lin * 去掉 pageobj.getObjectName(),有 pageobj 就够了。Lin * 去掉 wdgdba,需要时再获取数据库连接。Lin * 去掉 ymid、wzid -- 两个 null。Lin * 去掉 appName,直接用 PrjApp.prjName * 再增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程。Lin reader = addViewObjectTools(reader, appName , pageobj.getObjectName(),pageobj, null, null, isViewJsp, systemCreate, wdgdba); */ reader = addViewObjectTools(reader, pageobj, prjApp); // } } if (reader == null) return; in = new BufferedReader(reader); boolean hasTab = false; boolean wdFitHeight = false; boolean wdDragHeight = false; boolean wdDragWidth = false; boolean showMsgPopup=false; // 新增,修改,变动三合一部件:没有html,body,head,form boolean isObjectInput = true; String reg_applicationcode = "@applicationCode"; // String reg_pagewrite = ""; // 去掉,归入 JspTagComper。Lin /* 再改,规范命名。Lin * wdOddClass > ssOddClazz * wdEvenClass > ssEvenClazz * wdHoverClass > ssHovClazz String reg_tbody = "<(tbody\\s*.*)(wdOddClass.*|wdEvenClass.*|wdHoverClass.*)>"; */ String reg_tbody = "<(tbody\\s*.*)(ssOddClazz.*|ssEvenClazz.*|ssHovClazz.*)>"; String reg_goto = "@goto\\{.*?\\}@"; // String reg_wdpage = ""; // 去掉,归入 JspTagComper。Lin // String common_write_regexp = // "]*?)(/>|(>[\\s\\S]*?))"; // String jsonStr=null; int index = 0; while ((s = in.readLine()) != null) { /// ??? // if (s.contains("${delete}")) // System.out.println("in.readLine()"); ///??? // String strUrl = ""; // 再,移到下面用到的地方。按 IDEA 规范 -- Variable 'strUrl' initializer '""' is redundant。Lin // ArrayList list = matchAll(ss,reg,0); // 判断是否有wdSecondaryTab if (s.contains("tab-div")) hasTab = true; if (s.contains("ssFith")) // ("wdFitHeight"))。Lin wdFitHeight = true; if (s.contains("ssDragh")) // ("wdDragHeight"))。Lin wdDragHeight = true; if (s.contains("ssDragw")) // ("wdDragWidth"))。Lin wdDragWidth = true; if (s.contains("wd.display.showMsgPopup")) showMsgPopup = true; //noinspection SuspiciousIndentAfterControlStatement if(pageExist) if (isHelpJsp // isHelpJsp 没有被赋值 -- false???Lin && (s.contains("> pageList = StrU.findMatch2(strUrl, reg_pagewrite, 0); List> wdpageList = StrU.findMatch2(strUrl, reg_wdpage, 0); */ List> tbodyList = StrU.findMatch2(strUrl, reg_tbody, 0); List> gotoList = StrU.findMatch2(strUrl, reg_goto, 0); // ArrayList> matchedCommonWriteList = // new ArrayList>(); // if (CoreConstVars.TRANSFORM_COMMONWRITE_TAG) // matchedCommonWriteList.addAll(matchAll2(strUrl, // common_write_regexp, 0)); // 获取帮助功能的js代码段 start // if (bjdm != null) { // String executableJsString = new // WdHelpAssistAjaxImpl().getExecutableJsString(strUrl, dm, // bjdm); // if (executableJsString != null) { // wdHelpExecutableJsStringList.add(executableJsString); // } // } // 获取帮助功能的js代码段 end /* 去掉,归入 JspTagComper。Lin if (pageList.size() > 0) strUrl = pageUpdate(strUrl, pageList); if (wdpageList.size() > 0) strUrl = pageUpdate(strUrl, wdpageList); */ /* 再改,IDEA:'tbodyList.size() > 0' can be replaced with '!tbodyList.isEmpty()'。Lin if (tbodyList.size() > 0) { */ if (!(tbodyList.isEmpty())) { String tmpe; for (Map map : tbodyList) { // String tmpe = ""; // 再,移到 for 上面。IDEA -- Variable 'tmpe' initializer '""' is redundant。Lin String content = (String) map.get("content"); /* 再改,去掉 id="wdTbody?",好像没用到。Lin * .ss.jsp 的 ", " id=\"wdTbody" + index++ + "\">"); /// 另,content 里的 里的 {} 会导致 java.util.regex.PatternSyntaxException。Lin strUrl = strUrl.replaceAll(content, tmpe); /// content = tmpe; } */ tbodyUpdate(tbodyFileList, content); } } /* 再改,IDEA:'gotoList.size() > 0' can be replaced with '!gotoList.isEmpty()'。Lin if (gotoList.size() > 0) { // new */ if (!(gotoList.isEmpty())) // new /* 去掉 appName、ymid、wzid、gdba。Lin * null = ymid,null = wzid strUrl = gotoUpdate(strUrl, gotoList, appName, null, null, wdgdba); */ strUrl = gotoUpdate(strUrl, gotoList); // if (matchedCommonWriteList.size() > 0) { // strUrl = updateCommonWriteStr(strUrl, // matchedCommonWriteList, dm, ymid, wzid); // } /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List fileContentStrList.add(strUrl); */ fileContentStrList.add(new StringBuilder(strUrl)); } // 发布程序自动添加html、head、body start 150209 by ye /* * fileContentStrList.add(""); * fileContentStrList.add(""); */ // 发布程序自动添加html、head、body end 150209 by ye /// 改为在这添加,且只对 dw_inp.jsp 生成 dw_baseInfo.jsp 时。Lin /* 再去掉,原来的程序有增加 、 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin if (bySys) { fileContentStrList.add(""); fileContentStrList.add(""); } */ /// /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List for (String ss : fileContentStrList) { */ for (StringBuilder ss : fileContentStrList) { /// ??? //if (ss.contains("${delete}")) // System.out.println("fileContentStrList"); ///??? /* 去掉 array 入口参数,直接在方法里定义。Lin jspUpdate(ss, array, jsFileList, tldFileMap); */ /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List loadExtFileName(ss, jsFileList, tldFileMap, prjApp); // 再增加 PrjApp。Lin */ loadExtFileName(String.valueOf(ss), jsFileList, tldFileMap, prjApp); // 再增加 PrjApp。Lin } boolean tldInited = false; // ps = new PrintStream(newFilePath); /* 去掉,isLastOne 没用到。Lin * 因为 isLastOne 没用到,lastcount 也没用到了 // 计算输出最后一行 int lastcount = 0; boolean isLastOne = false; */ // 系统部件 /* 去掉 PageConfig.systemComponent(),直接在 page.xml 里的 写 "website"/"phome"。Lin * 去掉 cat,改回用 type 了 * systemComponent(),原:true = 除 "18=PC,80=MD,90=Pad,85=MD Home,95=Pad Home" 外 boolean sysPage = pageExist && PageConfig.systemComponent(pageobj.getType()); */ /* 去掉 isHomep(PageB.type 和 isWebsite(PageB.type,增加 .isHomep 和 .isSitep -- 来自插件的 \r\n"; */ /* 再改,IDEA:String concatenation '+=' in loop。Lin。Lin top += "<%pageContext.setAttribute(\"wdpageinformation\",\"" + new Gson().toJson(a).replaceAll("\"", "'") +"\");%>\r\n"; */ top.append("<%pageContext.setAttribute(\"wdpageinformation\",\"") .append(new Gson().toJson(a).replaceAll("\"", "'")).append("\");%>\r\n"); // 去掉 StrJson.toJsonStr(),直接用 new Gson().toJson()。Lin } /* 用 PageCompC.。Lin top += "\n"; */ /* 再改,IDEA:String concatenation '+=' in loop。Lin top += PageCompC.HTML_docType +"\r\n"; */ top.append(PageCompC.HTML_docType +"\r\n"); /* 再改,IDEA:String concatenation '+=' in loop。Lin top += PageCompC.INTERPOLE_JSPTOP_END +"\r\n"; */ top.append(PageCompC.INTERPOLE_JSPTOP_END +"\r\n"); /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List str = top + str; */ str = top.append(str); tldInited = true; /* 去掉,没有 _view.jsp 了。Lin if (isViewJsp && isObjectInput) { // str += "\n"; str += new CommonWriteFactory(appName, null, null, wdgdba).transform(""); str += "\r\n"; str += "\r\n"; str += "\r\n"; str += "\r\n"; str += "\r\n"; } */ } /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List if ("".equalsIgnoreCase(str.trim())) { str += "\r\n"+ PageCompC.INTERPOLE_HEAD_BEGIN; */ if ("".equalsIgnoreCase(str.toString().trim())) { str.append("\r\n"+ PageCompC.INTERPOLE_HEAD_BEGIN); /* 改为新UI。Lin * "新UI,所有head引入的内容,都放到/page/clip/header.jsp文件中" /// * 用 PageCompC.PAGE_meta。Lin // str += "\n" // + "\n" // + "\n"; /// * /// * 再改,IDEA:String concatenation '+=' in loop。Lin // * List 改为 List // str += "\r\n"+ PageCompC.HTML_meta; /// * str.append("\r\n"+ PageCompC.HTML_meta); // 移动端分支 移动端标准样式 update by Rd 2016-03-29 // if (isMobile()) { // str += "\n"; // } else { // style.css只有一个2017-08-07 // 暂时写死 20150210 /// * 去掉 getSetAppNameStr(),用 readJspCont(String jspPath, String defaultCont, String reg, String replace)。Lin // * 去掉 appName,直接用 PrjApp.prjName // str += getSetXmdmJspCode(appName); /// * /// * 去掉,不写应用名。Lin // str += PageU.readJspCont(SET_XMDM_JSP, SET_XMDM_SCRIPT, "#{XMDM}#", PrjApp.prjName); /// * /// * 用 PageCompC.。Lin // str += "\r\n"; /// * /// * 再改,IDEA:String concatenation '+=' in loop。Lin // * List 改为 List // str += "\r\n"+ PageCompC.SCR_loginState; /// * str.append("\r\n"+ PageCompC.SCR_loginState); /// * 用 @ss。Lin // String strSkinString = ""; /// * /// * 再改为 .ss,用 @ 导致 IDEA -- Tag start is not closed。Lin // String strSkinString = ""; /// * String strSkinString = ""; // if (CoreConstVars.TRANSFORM_COMMONWRITE_TAG) { /// * 去掉了 CommonWriteFactory() 结构函数。Lin // * 去掉 appName,直接用 PrjApp.prjName // * 去掉 CommonWriteFactory,归入 TagComper // * 用 TagComper.transform(str),SkinTagComper 没盖写过 // str += new CommonWriteFactory(appName, null, null, wdgdba).getTransformer("skin").transform(strSkinString) + "\r\n"; /// * /// * 再改,IDEA:String concatenation '+=' in loop。Lin // * List 改为 List // str += "\r\n"+ TagComper.compTag(strSkinString); /// * str.append("\r\n").append(TagComper.compTag(strSkinString)); // } else { // str += strSkinString; // } // 跟页面样式有关的语句,请勿胡乱注释 // str += // "\n"; // } /// 不写死引入 JS、CSS,自动找到并引入 -- 以后再弄。Lin /// 添加帮助功能的css和js start /// // if (bjdm != null) { // str += // "\n"; /// * 再改,IDEA:String concatenation '+=' in loop。Lin // * List 改为 List // str += "\r\n"; // // /wd/js/。Lin /// * str.append("\r\n"); // str += // "\r\n"; /// * 再改,IDEA:String concatenation '+=' in loop。Lin // * List 改为 List // str += "\r\n"; // // /wd/js/artDialog/。Lin /// * str.append("\r\n"); // str += // "\r\n";// // 剪切板js // } /// 添加帮助功能的css和js end /// /// * 再改,IDEA:String concatenation '+=' in loop。Lin // * List 改为 List // str += "\r\n" // // /wd/。Lin // + "\r\n"; // str += "\r\n"; // // /wd/js/。Lin /// * str.append("\r\n") .append("\r\n"); str.append("\r\n"); // str += "\r\n "; /// * 再改,IDEA:String concatenation '+=' in loop。Lin // * List 改为 List // str += "\r\n"; // // /wd/js/。Lin // str += "\r\n"; // // /wd/js/。Lin // str += "\r\n"; // // /wd/。Lin // str += "\r\n"; // // /wd/。Lin /// * str.append("\r\n"); str.append("\r\n"); str.append("\r\n"); str.append("\r\n"); // 伪滚动条 /// * 再改,IDEA:String concatenation '+=' in loop。Lin // * List 改为 List // str += "\r\n"; // // /wd/js/nicescroll376/。Lin // str += "\r\n"; // // /wd/js/nicescroll376/。Lin /// * str.append("\r\n"); str.append("\r\n"); // System.out.println("..."); for (String file : jsFileList) { if (StringUtils.isBlank(file)) // 去掉 StrU.isNull(),直接用 StringUtils.isBlank()。Lin continue; String fileLower = file.toLowerCase(); // System.out.println("file:"+file); if (fileLower.endsWith(".js")) /// * 用 PageCompC.。Lin // str += "\r\n"; /// * /// * 再改,IDEA:String concatenation '+=' in loop。Lin // * List 改为 List // str += "\r\n"+ String.format(PageCompC.HTML_js, file); /// * str.append("\r\n").append(String.format(PageCompC.HTML_js, file)); else /// * 用 PageCompC.。Lin // str += "\r\n"; /// * /// * 再改,IDEA:String concatenation '+=' in loop。Lin // * List 改为 List // str += "\r\n"+ String.format(PageCompC.HTML_css, file); /// * str.append("\r\n").append(String.format(PageCompC.HTML_css, file)); } */ str.append("\r\n" + PageCompU.getIncludeTag(PageCompC.PAGE_CLIP_PATH_header)); /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List str += "\r\n"+ PageCompC.INTERPOLE_HEAD_END; */ str.append("\r\n" + PageCompC.INTERPOLE_HEAD_END); } /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List if ("".equalsIgnoreCase(str.trim())) { */ if ("".equalsIgnoreCase(str.toString().trim())) { /* 再改,IDEA:String concatenation '+=' in loop。Lin String script = ""; // 定义放在增加的 if {} 外面。Lin */ StringBuilder script = new StringBuilder(); // 定义放在增加的 if {} 外面。Lin /* 再改,IDEA:'tbodyFileList.size() > 0' can be replaced with '!tbodyFileList.isEmpty()'。Lin if (tbodyFileList.size() > 0) { // 增加判断,避免输出空的 。Lin */ if (!(tbodyFileList.isEmpty())) { // 增加判断,避免输出空的 。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script = ""; */ script.append(""); } //script += "\n\r" + "<%@include file=\"/wd/page/glbjRunJspCommonEnd.jsp\"%>\n\r"; // script += // "\r\n"; if(pageExist) /* 去掉 Tempcode。Lin if (wdFitHeight || wdDragHeight || pageobj.getTempcode().isEnvPage()) { */ if (wdFitHeight || wdDragHeight || pageobj.isEnv) { if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script += "\r\n"; // 增加。Lin */ script.append("\r\n"); // 增加。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script += "\r\n"; script += "\r\n"; script += ""; */ script.append("\r\n"); script.append("\r\n"); script.append(""); } // if ("env".equals(ym.getDm())) { // script += "\r\n"; // } if (wdDragHeight) { if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script += "\r\n"; // 增加。Lin */ script.append("\r\n"); // 增加。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script += "\r\n"; script += ""; */ script.append("\r\n"); script.append(""); } if (wdDragWidth) { if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script += "\r\n"; // 增加。Lin */ script.append("\r\n"); // 增加。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script += "\r\n"; script += ""; */ script.append("\r\n"); script.append(""); } /// 添加可配置二级选项卡js start /// //noinspection SuspiciousIndentAfterControlStatement if (pageExist) if (hasTab) { if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script += "\r\n"; // 增加。Lin */ script.append("\r\n"); // 增加。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script += ""; script += "\r\n"; script += "\r\n"; script += String.format("", 1, pageobj.name); // 不用 id -- pageobj.getId()。Lin */ script.append(""); script.append("\r\n"); script.append("\r\n"); script.append(String.format("", 1, pageobj.name)); } if (pageExist) { /* 用 PageCompC.。Lin script += "\r\n"; script += "\r\n"; script += "\r\n"; */ if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script += "\r\n"; // 增加。Lin */ script.append("\r\n"); // 增加。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin script += PageCompC.SCR_resizeWin; */ script.append(PageCompC.SCR_resizeWin); } // }else{ // script += // "\r\n"; // } /// 添加帮助功能的js start /// // script += "\r\n"; // if (StringUtil.notNull(bjdm)) /* 去掉 appName,直接用 PrjApp.prjName。Lin * 用 @ss * 移到 PageCompU str = "\r\n" + transformCommonwrite("", appName, null, null, wdgdba) + "\r\n" + str; */ /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List str = PageCompU.compTag("") +"\r\n"+ str; */ /* 再改为 .ss,用 @ 导致 IDEA -- Tag start is not closed。Lin str = new StringBuilder(PageCompU.compTag("") +"\r\n"+ str); */ str = new StringBuilder(PageCompU.compTag("") +"\r\n"+ str); if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List str = script +"\r\n" + str; */ str = new StringBuilder(script).append("\r\n").append(str); /// 添加帮助功能的js end /// /// 添加字段初始化功能 start /// if(pageExist){//判断是否需要添加字段初始化的js /* 用 PageCompC.。Lin StringBuilder wdRecordJs = new StringBuilder(); wdRecordJs.append("\n"); wdRecordJs.append(""); wdRecordJs.append("\r\n"); str = wdRecordJs.toString() + str; */ /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List str = String.format(PageCompC.SCR_pval, pageobj.name) +"\r\n" + str; */ str = new StringBuilder(String.format(PageCompC.SCR_pval, pageobj.name)).append("\r\n").append(str); } /// 添加字段初始化功能 end /// String stript=""; if(pageExist && !showMsgPopup){ /* 用 PageCompC.。Lin * 增加 stript += "try{\r\n" + "wd.display.showMsgPopup('${msg}');\r\n" +"}catch(err){\r\n" +"console.error(err);\r\n" +"}"; */ stript += PageCompC.SCR_popupMsg; } if(pageExist){ /* 用 PageCompC.。Lin * 增加 stript += "" +"try{\r\n" + "wd.display.setCloseWindowParam('${"+PageC.WIN_closeParm+"}');\r\n" +"}catch(err){\r\n" +"console.error(err);\r\n" +"}" +""; */ if (StringUtils.isNotBlank(stript)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin stript += "\r\n"; // 增加。Lin stript += String.format(PageCompC.SCR_wrCloseWinParm, PageC.WIN_closeParm, PageC.WIN_closeParm); } /* 去掉,已含 。Lin if(StrU.notNull(stript)){ str+="\r\n"; } */ if (StringUtils.isNotBlank(stript)) // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List str = str +"\r\n"+ stript; */ str.append("\r\n").append(stript); } /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List if ("".equalsIgnoreCase(str.trim())) { */ if ("".equalsIgnoreCase(str.toString().trim())) /* 去掉 getClearTokenScript(),统一用 PageUtil.readJspCont()。Lin str += getClearTokenScript(); */ /* 再改用 PageCompC.SCR_clearToken。Lin str += PageU.readJspCont(CLEAR_TOKEN_JSP, CLEAR_TOKEN_SCRIPT, null, null); // null = 不替换 */ /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List str += "\r\n"+ PageCompC.SCR_clearPageToken; */ // str.append("\r\n"+ PageCompC.SCR_clearPageToken); 固定的页面尾片断,改为引入/page/clip/footer.jsp Ben(20251225) str.append("\r\n" + PageCompU.getIncludeTag(PageCompC.PAGE_CLIP_PATH_footer)); String strStr = str.toString(); // 增加,不改原 String.replace(。Lin //noinspection SuspiciousIndentAfterControlStatement if (pageExist) /* 再改,IDEA:String concatenation '+=' in loop。Lin * List 改为 List if (str.contains("")) { str = str.replace("", ""); // pageobj.getId() } result.append(str +"\r\n"); */ if (strStr.contains("")) strStr = strStr.replace("", ""); // pageobj.getId() result.append(strStr).append("\r\n"); // ps.println();// 输出到新文件 } String sourceHtml = result.toString(); /* 去掉 bjlbm,直接用 .cat 来判断。Lin * 去掉 cat 改回用 type 判断 Long bjlbm=pageExist?Long.parseLong(pageobj.getBjlbm()):null; if (pageExist&&bjlbm >= 5000 && bjlbm <= 10000) { */ /* 去掉 isHomep(PageB.type 和 isWebsite(PageB.type,增加 .isHomep 和 .isSitep -- 来自插件的 csc = new HashMap<>(); /* 不支持多个应用。Lin * 去掉 ApplicationConfig(application.xml),归入 SsC * 去掉 appName,直接用 PrjApp.prjName WebApp app=WD.getApp(appName); csc.put("projectDesc", app.getApplicationConfig().getProjectDesc()); csc.put("appName", appName); */ csc.put("appName", prjApp.name); // , PrjApp.。再,支持多线程。Lin csc.put("projectDesc", prjApp.desc); // , PrjApp.。再,支持多线程。Lin sourceHtml = PageU.paseSymbol(csc, sourceHtml); // DesignOutSide.paseSymbol() /* 再改,IDEA:'new File(tgtFileName).getParentFile().exists()==false' * can be simplified to '!new File(tgtFileName).getParentFile().exists()'。Lin if(new File(tgtFileName).getParentFile().exists()==false) */ if (!(new File(tgtFileName).getParentFile().exists())) new File(tgtFileName).getParentFile().mkdirs(); FileU.wrStr(tgtFileName, sourceHtml); } catch (Exception e) { /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin e.printStackTrace(); */ log4j.error("PageComper.doCompPage( 异常", e); ThdLog.wrMsg(String.format(AppC.TITLE_errLine, "编译部件错误"), e.toString(), e.getCause()); // RlsLoger.。Lin throw e; } finally { if (in != null) in.close(); } // return; // 去掉,不必要 -- 按 IDEA 规范。Lin } /// ** // * // * script script补充项目代码 // * @param srcStr // * @param appName // * @return /// * /* 去掉,不支持多个应用。Lin // 来自 FileTranslator.translateScriptSrc()。Lin // 去掉 appName,直接用 PrjApp.prjName // public static String translateScriptSrc(String srcStr,String appName) { private static String translateScriptSrc(String srcStr){ String ss[] = StrWeb.findLabelName(srcStr, "script", "src"); if (ss != null) { String src = ss[1]; String srcV = ss[1]; if (!src.startsWith("/")) { srcStr = srcStr.replace(srcV, "/"+ PrjApp.prjName +"/"+ srcV); // appName。Lin } } return srcStr; } */ // 来自 FileTranslator.jspUpdate(String s, String[] array, List jsFileList, Map tldFileMap)。Lin // 合并 toLeadJsMap 和 toLeadTldMap 到 grpMapMap // 去掉 array,直接在 jspUpdate() 里定义 // 再增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程。Lin private static void loadExtFileName(String s, List jsFileList, Map tldFileMap, PrjApp prjApp) { String[] array = { "wd", prjApp.name }; // "wd",appName。从 createNewFileWithUrl() 里移下来。Lin // , PrjApp.。再,支持多线程。Lin // 先用 "wd",不用 WebC.SS_name -- 改动太大。Lin String jspReg; // String tldReg = ""; // 去掉,改用 PageCompC.PAGE_tldReg。Lin for (String yym : array) { /* 用 PageCompC.PAGE_JsCssReg。Lin jspReg = "([\\W" + yym + "]\\.)([\\w*\\.]*)?(\\W)"; */ jspReg = String.format(PageCompC.PAGE_jsCssReg, yym); // tldReg = "<(\\w+:)(\\w+\\s*?.*?)>"; // 去掉,改用 PageCompC.PAGE_tldReg。Lin List> jspList = StrU.findMatch2(s, jspReg, 2); List> tldList = StrU.findMatch2(s, PageCompC.PAGE_tldReg, 1); // tldReg。Lin // System.out.println("应用名:"+yym+"--:"+WD.getApp(yym)); /* 去掉,不支持多个应用。Lin * WD 用 SsApp.grpMapSsMap,项目用 PrjApp.grpMapMap * 不区分 toLeadJsMap 和 toLeadTldMap,用 .grpMapMap WebApp app = WD.getApp(yym); if (app == null) continue; Map> toLeadJsMap = app.getToLeadJsMap(); Map> toLeadTldMap = app.getToLeadTldMap(); */ Map> grpMapMap; if (yym.equals("wd")) // "wd" // 先用 "wd",不用 WebC.SS_name -- 改动太大。Lin grpMapMap = PageCompC.grpMapSsMap; // SsApp.。Lin // = PrjApp.。移到 PageCompC 了。Lin else grpMapMap = prjApp.grpMapMap; // = PrjApp.。再,支持多线程。Lin Map> map = new HashMap<>(); List jsList = new ArrayList<>(); int index = 0; /* 再改,IDEA:'jspList.size() != 0' can be replaced with '!jspList.isEmpty()'。Lin if (jspList.size() != 0) { */ if (!(jspList.isEmpty())) { for (Map m : jspList) { String content = yym +"."+ m.get("content"); jsList.add(content); /* 不支持多个应用。Lin * 不区分 toLeadJsMap 和 toLeadTldMap,用 SsApp.grpMapMap * 提到最外面,不用几个地方都赋值 set -- 只确定到 .grpMapMap Set>> set = toLeadJsMap.entrySet(); */ Set>> set = grpMapMap.entrySet(); /* 再改,IDEA:'while' loop can be replaced with enhanced 'for'。Lin Iterator>> it = set.iterator(); while (it.hasNext()) { Entry> entry = it.next(); */ for (Entry> entry : set) { String key = entry.getKey(); if (key.endsWith(".*")) { String temp = key.replaceAll("\\.\\*", ""); if (content.startsWith(temp)) { List list = new ArrayList<>(); int tmpe = key.split("\\.").length; /* 再改,IDEA:Can be replaced with 'Math.max()' call。Lin index = tmpe > index ? tmpe : index; */ index = Math.max(tmpe, index); if (null == map.get(tmpe + "")) { list.add(key); map.put(tmpe + "", list); } else { if (!map.get(tmpe + "").contains(key)) map.get(tmpe + "").add(key); } } } } } } for (int i = 2; i <= index; i++) { if (map.get(i +"") != null) { for (String key : map.get(i +"")) { /* 不区分 toLeadJsMap 和 toLeadTldMap,用 SsApp.grpMapMap。Lin List tempList = toLeadJsMap.get(key); */ List tempList = grpMapMap.get(key); for (String file : tempList) { if (!jsFileList.contains(file)) jsFileList.add(file); } } } } /* 再改,IDEA:'jsList.size() != 0' can be replaced with '!jsList.isEmpty()'。Lin if (jsList.size() != 0) { */ if (!(jsList.isEmpty())) { for (String key : jsList) { /* 不区分 toLeadJsMap 和 toLeadTldMap,用 SsApp.grpMapMap。Lin List tempList = toLeadJsMap.get(key); */ List tempList = grpMapMap.get(key); if (tempList != null) { for (String file : tempList) { if (!jsFileList.contains(file)) jsFileList.add(file); } } } } /* 再改,IDEA:'jsList.size() != 0' can be replaced with '!jsList.isEmpty()'。Lin if (tldList.size() != 0) { */ if (!(tldList.isEmpty())) { for (Map m : tldList) { String content = (String) m.get("content"); /* 不区分 toLeadJsMap 和 toLeadTldMap,用 SsApp.grpMapMap。Lin Set>> set = toLeadTldMap.entrySet(); */ Set>> set = grpMapMap.entrySet(); /* 再改,IDEA:'while' loop can be replaced with enhanced 'for'。Lin Iterator>> it = set.iterator(); while (it.hasNext()) { Entry> entry = it.next(); */ for (Entry> entry : set) { String key = entry.getKey(); if (key.startsWith(content)) { /* 不区分 toLeadJsMap 和 toLeadTldMap,用 SsApp.grpMapMap。Lin List tldArr = toLeadTldMap.get(key); */ List tldArr = grpMapMap.get(key); for (String file : tldArr) { tldFileMap.put(content.replaceAll(":", ""), file); } } } } } } } /** * 替换@goto * * @param srcStr; * @param resList; * @return String */ // 来自 FileTranslator.gotoUpdate()。Lin // 去掉 appName、ymid、wzid、gdba // private static String gotoUpdate(String srcStr, List> resList, String appName, String ymid, String wzid, GeneralDBAccess gdba) { private static String gotoUpdate(String srcStr, List> resList) { List list = new ArrayList<>(); int i = 0; // i 没有被赋值???-- 永远等于 0。Lin int start = 0; /* 再改,IDEA:Variable 'end' initializer '-1' is redundant。Lin int end = -1; */ int end; for (Map m : resList) { end = Integer.parseInt(m.get("start").toString()); String subStr = srcStr.substring(start, end); list.add(subStr); start = Integer.parseInt(m.get("end").toString()); } end = srcStr.length(); String subStr = srcStr.substring(start, end); list.add(subStr); /* 去掉,没用到。Lin int j = -1; */ /* 再改,IDEA:String concatenation '+=' in loop。Lin * String 改为 StringBuilder String newStr = list.get(0);// 最终输出到页面的字符串 */ StringBuilder newStr = new StringBuilder(list.get(0));// 最终输出到页面的字符串 for (Map m : resList) { // j++; String gotoStr = m.get("content").toString(); try { // String rs = translateServiceStr(serviceStr,// 要翻译的@service字符串 // appName, ymid, wzid, gdba, false); /* 去掉结构函数了。Lin * 去掉 appName、ymid、wzid 了 * 入口参数的 false 为 runWithoutJSP,不用设置 runWithoutJSP -- 可以直接 new GotoTranslator() String rs = new GotoTranslator(appName, ymid, wzid, false).translate(gotoStr); */ String rs = new GotoTranslator().translate(gotoStr); /* 再改,IDEA:String concatenation '+=' in loop。Lin * String> 改为 StringBuilder newStr += rs; */ newStr.append(rs); /* 再改,IDEA:'catch' branch identical to 'RuntimeException' branch。Lin } catch (RuntimeException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } */ } catch (Exception e) { /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin e.printStackTrace(); */ log4j.error("PageComper.gotoUpdate() 异常", e); } /* 再改,IDEA:String concatenation '+=' in loop。Lin * String> 改为 StringBuilder * i 没有被赋值???-- 永远等于 0。Lin newStr += list.get(i + 1); */ newStr.append(list.get(i +1)); } ///// return newStr; return newStr.toString(); } // 来自 FileTranslator.tbodyUpdate()。Lin private static void tbodyUpdate(List tbodyFileList, String strUlr) throws Exception { strUlr = strUlr.replaceAll(">", "/>"); Document document = DocumentHelper.parseText(strUlr); Element rootElement = document.getRootElement(); String wdOddClass = rootElement.attributeValue("ssOddClazz"); // ("wdOddClass")。Lin String wdEvenClass = rootElement.attributeValue("ssEvenClazz"); // ("wdEvenClass")。Lin String wdHoverClass = rootElement.attributeValue("ssHovClazz"); // ("wdHoverClass")。Lin String id = rootElement.attributeValue("id"); tbodyFileList.add("wd.display.initTrDisplay(" + (id == null? "null" : ("\"")+ id +"\"") +"," + (wdOddClass == null? "null" : ("\""+ wdOddClass +"\"")) +"," + (wdEvenClass == null? "null" : ("\""+ wdEvenClass +"\"")) +"," + (wdHoverClass == null? "null" : ("\""+ wdHoverClass +"\"")) +");"); } /* 去掉,归入 xxxTagComper。Lin // 来自 FileTranslator.pageUpdate(String s, List> pageList)。Lin private static String pageUpdate(String s, List> pageList) { String newStr = ""; int start = 0; int end = 0; String content = null; for (Map map : pageList) { content = map.get("content").toString(); start = Integer.parseInt(map.get("start").toString()); newStr += s.substring(end, start); end = Integer.parseInt(map.get("end").toString()); if (content.matches("")) { newStr += "" + StringEscapeUtils.escapeHtml3("<这里有个旧的分页标签,用wd:page>") + ""; } else if (content.matches("")) { String name = content.split("\"")[1]; ///* 去掉,不支持多个应用。Lin ///* 去掉加载时加的 "/<应用名>/" 前缀了,含 "/wd/"。Lin /// String yym = name.split("/")[1]; /// WebApp webApp = WD.getApp(yym); /// // System.out.println("WD.getApp(yym);:" /// // + WD.getApp(yym)); /// // System.out.println(name + "--webApp.getJsCssRealPathMap():" /// // + webApp.getJsCssRealPathMap()); /// String path = webApp.getJsCssRealPathMap().get(name); /// end。Lin String path = TagComper.readRealFileName(name); newStr += "<%@include file=\""+ path +"\"%>"; } else { newStr += content; } } return newStr; } */ /** * * 发布前: