📄 xmlutil.java
字号:
package com.jdon.cms.xml;
import com.jdon.util.PropsUtil;
import com.jdon.cms.Menu;
import com.jdon.util.Debug;
import java.io.*;
import com.jdon.util.UtilValidate;
import com.jdon.util.FileUtil;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Jdon.com Copyright (c) 2003</p>
* <p>Company: </p>
* @author banq
* @version 1.0
*/
public class XmlUtil {
public final static String module = XmlUtil.class.getName();
;
private final static PropsUtil propsUtil = PropsUtil.getInstance();
private final static String LINK = "body_";
private final static String CONFDIR = "WEB-INF/conf";
public final static String DATADIR = "data";
private final static String JSPDIR = "";
private final static String JSPURL = "/";
private static String homeDir = null;
public void setHomeDir(String homeDir) {
this.homeDir = homeDir;
}
public String getHomeDir() {
return this.homeDir;
}
private final static XmlUtil xmlUtil = new XmlUtil();
public static XmlUtil getInstance() {
return xmlUtil;
}
/**
*
* @return boolean
*/
public static void InitFileEnv() throws Exception {
boolean setup = false;
Debug.logVerbose("<<-->> InitFileEnv", module);
String setupStrs = propsUtil.getProperty(PropsUtil.SETUPNAME);
if (UtilValidate.isNotEmpty(setupStrs)) {
if ( (setupStrs.equalsIgnoreCase(PropsUtil.SETUPVALUE)))
setup = true;
}
if (!setup) {
try {
String confRealDir = getDirStr(CONFDIR);
Debug.logVerbose("<<-->> create conf real directory" + confRealDir,
module);
//create config directory
FileUtil.makehome(confRealDir);
String dataRealDir = getDirStr(DATADIR);
Debug.logVerbose("<<-->> create data real directory" + dataRealDir,
module);
//create content directory
FileUtil.makehome(dataRealDir);
propsUtil.setProperty(PropsUtil.SETUPNAME, PropsUtil.SETUPVALUE);
setup = true;
} catch (Exception e) {
Debug.logError("setup config directory error:", module);
throw new Exception(e);
}
}
}
public static String getDirStr(String dir) {
StringBuffer buffer = new StringBuffer(homeDir);
if (homeDir.endsWith(File.separator))
buffer.append(dir);
else
buffer.append(File.separator).append(dir);
return buffer.toString();
}
/**
* the home directory of xml
* @param filename
* @return
*/
public static String getConfDirStr(String prefix) {
StringBuffer buffer = new StringBuffer(getDirStr(CONFDIR));
buffer.append(File.separator);
buffer.append((prefix)).append(".").append("xml");
return buffer.toString();
}
/**
* the directory of page content file such as xx.html
* @param filename
* @return
*/
public static String getDataDirStr(String prefix) {
StringBuffer buffer = new StringBuffer(getDirStr(DATADIR));
buffer.append(File.separator);
buffer.append(prefix).append(".").append("jsp");
return buffer.toString();
}
/**
* get file path under the DATADIR
* @param Id
* @return
*/
public static String getDataUrlStr(String prefix) {
StringBuffer buffer = new StringBuffer("/");
buffer.append(DATADIR).append("/");
buffer.append(prefix).append(".").append("jsp");
return buffer.toString();
}
/**
* get jsp Url file such as /xxxx.jsp
* @param Id
* @return
*/
public static String getJspUrlStr(String prefix) {
StringBuffer buffer = new StringBuffer(JSPURL);
buffer.append(prefix).append(".").append("jsp");
return buffer.toString();
}
/**
* the home directory of Jsp
* @param filename
* @return
*/
public static String getJspDirStr(String prefix) {
StringBuffer buffer = new StringBuffer(homeDir);
if (!JSPDIR.equals(""))
buffer.append(File.separator).append(JSPDIR);
buffer.append(File.separator);
buffer.append(prefix).append(".").append("jsp");
return buffer.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -