code
stringlengths
3
1.18M
language
stringclasses
1 value
package com.legendshop.business.helper; import com.legendshop.util.Arith; public class AlipayAccount { private String account; private Double money; private int type; public String getAccountInfo(Double totalCash, String memo) { StringBuffer sb = new StringBuffer(); sb.append(this.account).append("^").append(calculteCash(totalCash)) .append("^").append(memo).append("|"); return sb.toString(); } private Double calculteCash(Double totalCash) { Double result = null; if (1 == this.type) result = Double.valueOf(Arith.mul(totalCash.doubleValue(), this.money.doubleValue())); else { result = this.money; } return result; } public String getAccount() { return this.account; } public void setAccount(String account) { this.account = account; } public Double getMoney() { return this.money; } public void setMoney(Double money) { this.money = money; } public int getType() { return this.type; } public void setType(int type) { this.type = type; } }
Java
package com.legendshop.business.helper; import com.legendshop.event.TaskItem; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TaskThread extends Thread { private static Logger log = LoggerFactory.getLogger(TaskThread.class); public TaskItem item; public TaskThread(TaskItem item) { this.item = item; } public void run() { log.debug("{} item start running at {}", this.item.getClass() .getSimpleName(), Long.valueOf(System.currentTimeMillis())); this.item.execute(); log.debug("{} item finished running at {}", this.item.getClass() .getSimpleName(), Long.valueOf(System.currentTimeMillis())); } }
Java
package com.legendshop.business.helper; import com.legendshop.util.AppUtils; import java.util.List; public class AlipayAccountHelper { private List<AlipayAccount> alipayAccounts; public String getAccountInfo(String totalCash, String memo) { String result = ""; Double total; if (AppUtils.isNotBlank(this.alipayAccounts)) { total = null; try { total = Double.valueOf(totalCash); } catch (Exception e) { return result; } for (AlipayAccount account : this.alipayAccounts) { result = result + account.getAccountInfo(total, memo); } } if (AppUtils.isNotBlank(result)) { return result.substring(0, result.length() - 1); } return result; } public void setAlipayAccounts(List<AlipayAccount> alipayAccounts) { this.alipayAccounts = alipayAccounts; } }
Java
package com.legendshop.business.helper; import com.legendshop.command.framework.State; import com.legendshop.core.exception.InternalException; import com.legendshop.core.helper.Checker; import com.legendshop.model.UserMessages; import javax.servlet.http.HttpServletRequest; public class InstallChecker implements Checker<State> { public boolean check(State state, HttpServletRequest request) { if (!state.isOK()) { UserMessages uem = new UserMessages(); uem.setTitle("系统状态异常"); if (state.getThrowable() != null) { uem.setDesc(state.getThrowable().getMessage()); } request.setAttribute(UserMessages.MESSAGE_KEY, uem); throw new InternalException("State Check Fail", "00", state.getErrCode()); } return true; } }
Java
package com.legendshop.business.helper; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; public class SecurityContextLogoutHandlerImpl extends SecurityContextLogoutHandler { public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { request.getSession() .setAttribute("SPRING_SECURITY_LAST_USERNAME", null); Cookie cookie = new Cookie("jforumUserInfo", null); cookie.setPath("/"); cookie.setMaxAge(0); response.addCookie(cookie); request.getSession().invalidate(); super.logout(request, response, authentication); } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.IntegerEnum; public enum ShopTypeEnum implements IntegerEnum { PERSONAL(Integer.valueOf(0)), BUSINESS(Integer.valueOf(1)); private Integer num; public Integer value() { return this.num; } private ShopTypeEnum(Integer num) { this.num = num; } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.StringEnum; public enum SubStatusEnum implements StringEnum { ORDER_CAPTURE("CA"), ORDER_DEL("DE"), PRICE_CHANGE("PC"), CREDIT_SCORE("CS"), DEBIT_SCORE("DS"), ORDER_OVER_TIME("OT"), CHANGE_STATUS("ST"); private final String value; private SubStatusEnum(String value) { this.value = value; } public String value() { return this.value; } public static boolean instance(String name) { SubStatusEnum[] licenseEnums = values(); for (SubStatusEnum licenseEnum : licenseEnums) { if (licenseEnum.name().equals(name)) { return true; } } return false; } public static String getValue(String name) { SubStatusEnum[] licenseEnums = values(); for (SubStatusEnum licenseEnum : licenseEnums) { if (licenseEnum.name().equals(name)) { return licenseEnum.value(); } } return null; } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.StringEnum; public enum RoleEnum implements StringEnum { ROLE_SUPERVISOR("1"), ROLE_ADMIN("2"), ROLE_USER("3"); private final String value; private RoleEnum(String value) { this.value = value; } public String value() { return this.value; } public static boolean instance(String name) { RoleEnum[] licenseEnums = values(); for (RoleEnum licenseEnum : licenseEnums) { if (licenseEnum.name().equals(name)) { return true; } } return false; } public static String getValue(String name) { RoleEnum[] licenseEnums = values(); for (RoleEnum licenseEnum : licenseEnums) { if (licenseEnum.name().equals(name)) { return licenseEnum.value(); } } return null; } }
Java
package com.legendshop.business.common; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.displaytag.export.excel.ExcelHssfView; public class SimpleChineseExcelView extends ExcelHssfView { public String getMimeType() { return "application/vnd.ms-excel;charset=UTF-8"; } protected String escapeColumnValue(Object rawValue) { if (rawValue == null) { return null; } String returnString = ObjectUtils.toString(rawValue); returnString = StringEscapeUtils.escapeJava(StringUtils .trimToEmpty(returnString)); returnString = StringUtils.replace(StringUtils.trim(returnString), "\\t", " "); returnString = StringUtils.replace(StringUtils.trim(returnString), "\\r", " "); returnString = StringEscapeUtils.unescapeJava(returnString); Pattern p = Pattern.compile("</?[div|span|a|font|b][^>]*>", 2); Matcher m = p.matcher(returnString); return m.replaceAll(""); } }
Java
package com.legendshop.business.common.download; import com.legendshop.command.framework.State; import com.legendshop.command.framework.StateImpl; import com.legendshop.core.ContextServiceLocator; import com.legendshop.core.UserManager; import com.legendshop.core.constant.FunctionEnum; import com.legendshop.core.helper.PropertiesUtil; import com.legendshop.model.entity.DownloadLog; import com.legendshop.util.AppUtils; import com.legendshop.util.ServiceLocatorIF; import com.legendshop.util.ip.IPSeeker; import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.io.PrintWriter; import java.util.Date; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DownloadFileServlet extends HttpServlet { private static final long serialVersionUID = 6658159370029368321L; protected Logger log = LoggerFactory .getLogger(DownloadFileServlet.class); String filePath = PropertiesUtil .getDownloadFilePath(); public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { String ipAttr = request.getRemoteAddr(); response.setContentType("text/html; charset=UTF-8"); String filename = request.getPathInfo(); if (!AppUtils.isBlank(filename)) { filename = filename.substring(1); State state = checkFunction(request, filename); if (!state.isOK()) { errorFound(response, state.getErrCode()); this.log.error( "{} attempt to download file {}, but without function", ipAttr, filename); return; } String fullName = this.filePath + "/" + filename; File file = new File(fullName); if (file.isFile()) { if (getDownloadLogService().checkCanDownload(ipAttr, filename)) { errorFound(response, "超过下载次数"); } else { this.log.info("{} download file {}", ipAttr, filename); String name = filename; if (filename.lastIndexOf("/") > -1) { name = filename .substring(filename.lastIndexOf("/") + 1); } DownloadLog downloadLog = new DownloadLog(); downloadLog.setDate(new Date()); downloadLog.setFileName(filename); downloadLog.setIp(ipAttr); downloadLog.setUserName(UserManager.getUsername(request .getSession())); downloadLog.setArea(IPSeeker.getInstance().getArea( downloadLog.getIp())); downloadLog.setCountry(IPSeeker.getInstance().getCountry( downloadLog.getIp())); downloadLog.setShopName((String) request.getSession() .getAttribute("shopName")); DownloadFileUtil.getInstance().downloadFile(response, fullName, name, true, getDownloadLogService(), downloadLog); } } else { errorFound(response, "Could not get file name"); } } else { errorFound(response, "Could not get file name"); } } private State checkFunction(HttpServletRequest request, String pathInfo) { State state = new StateImpl(); String info = pathInfo; int pos = pathInfo.lastIndexOf("/"); if (pos > -1) { info = pathInfo.substring(0, pos); } if (!AppUtils.isBlank(info)) { if (info.indexOf("secured") > -1) { if (!UserManager.hasFunction(request.getSession(), FunctionEnum.FUNCTION_SECURED.value())) { state.setErrCode("你还没有获得访问该目录的权限,请与管理员联系"); } } if ((info.indexOf("securest") > -1) && (!UserManager.hasFunction(request.getSession(), FunctionEnum.FUNCTION_SECUREST.value()))) { state.setErrCode("你还没有获得访问该保密目录的权限,请与管理员联系"); } if (info.indexOf("order") > -1) { String userName = UserManager.getUsername(request); if (AppUtils.isBlank(userName)) { state.setErrCode("你还没有登录系,不能下载"); } String prodId = info.substring(info.indexOf("order/") + 6, info.length()); if (prodId.indexOf("/") > -1) { prodId = prodId.substring(0, prodId.indexOf("/")); } if (!getDownloadLogService().isUserOrderProduct( Long.valueOf(prodId), userName)) { state.setErrCode("你还没有购买该商品,不能下载"); } } } return state; } private void errorFound(HttpServletResponse response, String cause) { PrintWriter printwriter = null; try { response.setContentType("text/html"); printwriter = response.getWriter(); printwriter.println("<html>"); printwriter.println("<br><br> " + cause); printwriter.println("</html>"); } catch (Exception e) { } finally { if (printwriter != null) { printwriter.flush(); printwriter.close(); try { response.flushBuffer(); } catch (IOException e) { e.printStackTrace(); } } } } protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doGet(req, resp); } public DownLoadCallBack getDownloadLogService() { return (DownLoadCallBack) ContextServiceLocator.getInstance().getBean( "downloadLogService"); } public static void main(String[] args) { String info = "D:/AppServer/apache-tomcat-6.0.18/upload/order/3454/sxdf"; String prodId = info.substring(info.indexOf("order/") + 6, info.length()); System.out.println(prodId); prodId = prodId.substring(0, prodId.indexOf("/")); System.out.println(prodId); } }
Java
package com.legendshop.business.common.download; import java.io.File; import java.io.FileInputStream; import java.net.URLEncoder; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; public class DownloadFileUtil { private static DownloadFileUtil instance; private static Logger logger = Logger .getLogger(DownloadFileUtil.class); public static DownloadFileUtil getInstance() { if (instance == null) { instance = new DownloadFileUtil(); } return instance; } public void downloadFile(HttpServletResponse response, String filePath, String fileName, boolean isDownload, DownLoadCallBack callBack, Object entity) { downloadFile(response, filePath, fileName, isDownload); callBack.afterDownload(entity); } public void downloadFile(HttpServletResponse response, String filePath, String fileName, boolean isDownload) { try { File file = new File(filePath); if ((!file.exists()) || (!file.isFile())) { logger.debug("File: " + filePath + " Not Exists"); response.setHeader("Content-Type", "text/html; charset=UTF-8"); ServletOutputStream os = response.getOutputStream(); os.println("文件不存在!联系管理员!"); } else { if (isDownload) { response.setHeader("Content-Type", "application/x-download; charset=UTF-8"); response.setHeader( "Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); response.setContentLength((int) file.length()); } else { String contentType = "application/pdf"; if ((fileName != null) && (fileName.endsWith(".doc"))) { contentType = "application/msword"; response.setHeader("Content-Type", contentType); } else if ((fileName != null) && (fileName.endsWith(".pdf"))) { contentType = "application/pdf"; response.setHeader("Content-Type", contentType); } else { contentType = "application/force-download"; response.setHeader("Content-Type", contentType); } response.setHeader("Content-Disposition", "filename=" + URLEncoder.encode(fileName, "UTF-8")); } FileInputStream fis = new FileInputStream(filePath); byte[] data = new byte[8192]; ServletOutputStream os = response.getOutputStream(); int i; while ((i = fis.read(data, 0, 8192)) != -1) { os.write(data, 0, i); } os.flush(); fis.close(); os.close(); logger.debug("Download File: " + filePath + " Finished"); } } catch (Exception e) { logger.error("DownloadFile: " + filePath + " Reason: " + e.toString()); } } }
Java
package com.legendshop.business.common.download; public abstract interface DownLoadCallBack { public abstract void afterDownload(Object paramObject); public abstract boolean checkCanDownload(String paramString1, String paramString2); public abstract boolean isUserOrderProduct(Long paramLong, String paramString); }
Java
package com.legendshop.business.common; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.displaytag.export.CsvView; public class SimpleChineseCsvView extends CsvView { public String getMimeType() { return "text/csv;charset=GBK"; } protected String escapeColumnValue(Object rawValue) { if (rawValue == null) { return null; } String returnString = ObjectUtils.toString(rawValue); returnString = StringEscapeUtils.escapeJava(StringUtils .trimToEmpty(returnString)); returnString = StringUtils.replace(StringUtils.trim(returnString), "\\t", " "); returnString = StringUtils.replace(StringUtils.trim(returnString), "\\r", " "); returnString = StringEscapeUtils.unescapeJava(returnString); Pattern p = Pattern.compile("</?[div|span|a|font][^>]*>", 2); Matcher m = p.matcher(returnString); return m.replaceAll(""); } }
Java
package com.legendshop.business.common; import java.util.List; import net.sf.json.JSONObject; import com.legendshop.model.dynamic.Item; import com.legendshop.model.dynamic.Model; import com.legendshop.model.dynamic.ModelType; import com.legendshop.util.AppUtils; public class DynamicPropertiesHelper { public String gerenateHTML(List<JSONObject> modelList) { StringBuffer sb = new StringBuffer(); if (AppUtils.isNotBlank(modelList)) { for (JSONObject job : modelList) { Model model = (Model) JSONObject.toBean(job, Model.class); if (ModelType.Select.equals(model.getType())) generateSelect(model, sb); else if (ModelType.Text.equals(model.getType())) generateText(model, sb); else if (ModelType.CheckBox.equals(model.getType())) generateCheckBox(model, sb); else if (ModelType.Radio.equals(model.getType())) { generateRadio(model, sb); } } } return sb.toString(); } public StringBuffer generateSelect(Model model, StringBuffer sb) { if (ModelType.Select.equals(model.getType())) { sb.append(model.getId()).append("&nbsp;<select id='") .append(model.getId()).append("' class='attrselect'") .append(" name='").append(model.getId()).append("'>"); sb.append("<option value=''>请选择</option>"); for (Item item : model.getItems()) { sb.append("<option value='").append(item.getKey()).append("'>") .append(item.getKey()).append("</option>"); } sb.append("</select><br>"); } return sb; } public StringBuffer generateText(Model model, StringBuffer sb) { if (ModelType.Text.equals(model.getType())) { if (AppUtils.isNotBlank(model.getItems())) { sb.append("<tr><th>").append(model.getId()).append("</th><td>") .append(model.getItems()[0].getValue()) .append("</td></tr>"); } else { sb.append("<div>").append(model.getId()).append("<input id='") .append(model.getId()).append("' class='attrtext'") .append(" name='").append(model.getId()).append(" value='") .append("value").append("'/></div>"); } } return sb; } public StringBuffer generateRadio(Model model, StringBuffer sb) { if (ModelType.Radio.equals(model.getType())) { sb.append(model.getId()).append("&nbsp;"); for (Item item : model.getItems()) { sb.append(item.getKey()).append("<input type='radio' id='") .append(model.getId()).append("' class='attrradio'") .append(" name='").append(model.getId()) .append("' value='").append(item.getKey()) .append("'/>&nbsp;"); } sb.append("<br>"); } return sb; } public StringBuffer generateCheckBox(Model model, StringBuffer sb) { if (ModelType.CheckBox.equals(model.getType())) { sb.append(model.getId()).append("&nbsp;"); for (Item item : model.getItems()) { sb.append(item.getKey()).append("<input type='checkbox' id='") .append(item.getKey()).append("' class='attrchx'") .append("' name='").append(model.getId()) .append("'/>&nbsp;"); } sb.append("<br>"); } return sb; } }
Java
package com.legendshop.business.common; import com.legendshop.model.dynamic.Item; import com.legendshop.model.dynamic.Model; public class SimpleDynamicPropertiesHelper extends DynamicPropertiesHelper { public StringBuffer generateSelect(Model model, StringBuffer sb) { sb.append(model.getId()).append("&nbsp;<select id='") .append(model.getId()).append("' class='attrselect'") .append(" name='").append(model.getId()).append("'>"); sb.append("<option value=''>请选择</option>"); for (Item item : model.getItems()) { sb.append("<option value='").append(item.getKey()).append("'>") .append(item.getKey()).append("</option>"); } sb.append("</select><br>"); return sb; } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.IntegerEnum; public enum ProductStatusEnum implements IntegerEnum { PROD_ONLINE(Integer.valueOf(1)), PROD_OFFLINE(Integer.valueOf(0)); private Integer num; public Integer value() { return this.num; } private ProductStatusEnum(Integer num) { this.num = num; } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.IntegerEnum; public enum NewsCategoryStatusEnum implements IntegerEnum { NEWS_OFF(Integer.valueOf(2)), NEWS_NEWS(Integer.valueOf(1)), NEWS_TOP(Integer.valueOf(0)), NEWS_SORT(Integer.valueOf(3)), NEWS_BOTTOM(Integer.valueOf(4)); private Integer num; public Integer value() { return this.num; } private NewsCategoryStatusEnum(Integer num) { this.num = num; } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.StringEnum; public enum ProductTypeEnum implements StringEnum { PRODUCT("P"), GROUP("G"), SECOND_HAND("S"), DISCOUNT("D"); private String value; public String value() { return this.value; } private ProductTypeEnum(String value) { this.value = value; } }
Java
package com.legendshop.business.common; import com.legendshop.core.helper.FunctionUtil; import com.legendshop.model.entity.Basket; import com.legendshop.model.entity.Product; import com.legendshop.model.entity.ShopDetail; import com.legendshop.search.LuceneIndexer; import com.legendshop.search.SearchEntity; import com.legendshop.util.AppUtils; import com.legendshop.util.Arith; import com.legendshop.util.TimerUtil; import com.legendshop.util.des.DES2; import java.io.PrintStream; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Random; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CommonServiceUtil extends FunctionUtil { private static Logger log = LoggerFactory .getLogger(CommonServiceUtil.class); public static synchronized String getSubNember(String userName) { String subNumber = ""; String now = TimerUtil.dateToStr(new Date()); subNumber = now; subNumber = subNumber.replace("-", ""); subNumber = subNumber.replace(" ", ""); subNumber = subNumber.replace(":", ""); Random r = new Random(); subNumber = new StringBuilder().append(subNumber) .append(randomNumeric(r, 8)).toString(); return subNumber; } private static String randomNumeric(Random random, int count) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < count; i++) { int val = random.nextInt(10); sb.append(String.valueOf(val)); } return sb.toString(); } public static int random(int count) { Random random = new Random(); return random.nextInt(count); } public static void main(String[] args) { long t1 = System.currentTimeMillis(); for (int i = 0; i < 10000; i++) { int re = random(2); System.out.println(re); } long t2 = System.currentTimeMillis(); System.out.println(new StringBuilder().append("t2 - t1 = ") .append(t2 - t1).toString()); } public static SearchEntity createSearchEntity(Object obj) { SearchEntity entity = null; if ((obj instanceof Product)) { Product product = (Product) obj; entity = new SearchEntity(); entity.setContents(product.getName() + " " + product.getContent()); entity.setDate(product.getRecDate()); entity.setEntityType(LuceneIndexer.SEARCH_ENTITY_PROD); entity.setProdId(product.getProdId()); entity.setPrice(product.getCash()); entity.setUserId(product.getUserId()); } else if ((obj instanceof ShopDetail)) { ShopDetail sd = (ShopDetail) obj; entity = new SearchEntity(); entity.setShopId(sd.getShopId()); entity.setContents(sd.getStoreName() + " " + sd.getSitename() + " " + sd.getBriefDesc() + " " + sd.getDetailDesc()); entity.setDate(sd.getAddtime()); entity.setEntityType(LuceneIndexer.SEARCH_ENTITY_SHOPDETAIL); entity.setUserId(sd.getUserId()); entity.setProvinceid(String.valueOf(sd.getProvinceid())); entity.setCityid(String.valueOf(sd.getCityid())); entity.setAreaid(String.valueOf(sd.getAreaid())); } return entity; } public static Double calculateTotalCash(List<Basket> baskets) { if (AppUtils.isNotBlank(baskets)) { Double totalcash = Double.valueOf(0.0D); for (Basket bo : baskets) { try { double total = Arith.mul(bo.getBasketCount().intValue(), bo .getCash().doubleValue()); if (bo.getCarriage() != null) { total = Arith .add(total, bo.getCarriage().doubleValue()); } bo.setTotal(Double.valueOf(total)); totalcash = Double.valueOf(Arith.add( totalcash.doubleValue(), bo.getTotal().doubleValue())); } catch (Exception e) { log.error("calculateTotalCash ", e); } } return totalcash; } return null; } public static Double calculateTotalCash(Map<String, Basket> basketMap) { Double totalcash = Double.valueOf(0.0D); for (Basket basket : basketMap.values()) { try { double total = Arith.mul(basket.getBasketCount().intValue(), basket.getCash().doubleValue()); if (basket.getCarriage() != null) { total = Arith .add(total, basket.getCarriage().doubleValue()); } basket.setTotal(Double.valueOf(total)); totalcash = Double.valueOf(Arith.add(totalcash.doubleValue(), basket.getTotal().doubleValue())); } catch (Exception e) { log.error("convert count", e); } } return totalcash; } public static Integer generateRandom() { Random r = new Random(); return new Integer(r.nextInt(100000)); } public static DES2 getDES() { return new DES2("!23done!"); } }
Java
package com.legendshop.business.common; import com.lowagie.text.BadElementException; import com.lowagie.text.Cell; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.FontFactory; import com.lowagie.text.HeaderFooter; import com.lowagie.text.PageSize; import com.lowagie.text.Phrase; import com.lowagie.text.Rectangle; import com.lowagie.text.Table; import com.lowagie.text.pdf.PdfWriter; import java.io.OutputStream; import java.util.Iterator; import java.util.List; import javax.servlet.jsp.JspException; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; import org.displaytag.Messages; import org.displaytag.exception.BaseNestableJspTagException; import org.displaytag.exception.SeverityEnum; import org.displaytag.export.BinaryExportView; import org.displaytag.model.Column; import org.displaytag.model.ColumnIterator; import org.displaytag.model.HeaderCell; import org.displaytag.model.Row; import org.displaytag.model.RowIterator; import org.displaytag.model.TableModel; public class SimpleChinesePdfView implements BinaryExportView { /* */private TableModel model; /* */private boolean exportFull; /* */private boolean header; /* */private boolean decorated; /* */private Table tablePDF; /* */private Font smallFont; /* */ /* */public void setParameters(TableModel tableModel, boolean exportFullList, boolean includeHeader, boolean decorateValues) /* */{ /* 98 */this.model = tableModel; /* 99 */this.exportFull = exportFullList; /* 100 */this.header = includeHeader; /* 101 */this.decorated = decorateValues; /* */} /* */ /* */protected void initTable() /* */throws BadElementException /* */{ /* 110 */this.tablePDF = new Table(this.model.getNumberOfColumns()); /* 111 */this.tablePDF.setDefaultVerticalAlignment(4); /* 112 */this.tablePDF.setCellsFitPage(true); /* 113 */this.tablePDF.setWidth(100.0F); /* */ /* 115 */this.tablePDF.setPadding(2.0F); /* 116 */this.tablePDF.setSpacing(0.0F); /* */ /* 119 */this.smallFont = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", 12.0F); /* */} /* */ /* */public String getMimeType() /* */{ /* 130 */return "application/pdf;charset=UTF-8"; /* */} /* */ /* */protected void generatePDFTable() /* */throws JspException, BadElementException /* */{ /* 140 */if (this.header) /* */{ /* 142 */generateHeaders(); /* */} /* 144 */this.tablePDF.endHeaders(); /* 145 */generateRows(); /* */} /* */ /* */public void doExport(OutputStream out) /* */throws JspException /* */{ /* */try /* */{ /* 162 */initTable(); /* */ /* 165 */Document document = new Document(PageSize.A4.rotate(), 60.0F, 60.0F, 40.0F, 40.0F); /* 166 */document.addCreationDate(); /* 167 */HeaderFooter footer = new HeaderFooter(new Phrase("", this.smallFont), true); /* 168 */footer.setBorder(0); /* 169 */footer.setAlignment(1); /* */ /* 171 */PdfWriter.getInstance(document, out); /* */ /* 174 */generatePDFTable(); /* 175 */document.open(); /* 176 */document.setFooter(footer); /* 177 */document.add(this.tablePDF); /* 178 */document.close(); /* */} /* */catch (Exception e) /* */{ /* 183 */throw new PdfGenerationException(e); /* */} /* */} /* */ /* */protected void generateHeaders() /* */throws BadElementException /* */{ /* 193 */Iterator iterator = this.model.getHeaderCellList().iterator(); /* */ /* 195 */while (iterator.hasNext()) /* */{ /* 197 */HeaderCell headerCell = (HeaderCell) iterator.next(); /* */ /* 199 */String columnHeader = headerCell.getTitle(); /* */ /* 201 */if (columnHeader == null) /* */{ /* 203 */columnHeader = StringUtils.capitalize(headerCell .getBeanPropertyName()); /* */} /* */ /* 206 */Cell hdrCell = getCell(columnHeader); /* 207 */hdrCell.setGrayFill(0.9F); /* 208 */hdrCell.setHeader(true); /* 209 */this.tablePDF.addCell(hdrCell); /* */} /* */} /* */ /* */protected void generateRows() /* */throws JspException, BadElementException /* */{ /* 222 */RowIterator rowIterator = this.model .getRowIterator(this.exportFull); /* */ /* 224 */while (rowIterator.hasNext()) /* */{ /* 226 */Row row = rowIterator.next(); /* */ /* 229 */ColumnIterator columnIterator = row .getColumnIterator(this.model.getHeaderCellList()); /* */ /* 231 */while (columnIterator.hasNext()) /* */{ /* 233 */Column column = columnIterator.nextColumn(); /* */ /* 236 */Object value = column.getValue(this.decorated); /* */ /* 238 */Cell cell = getCell(ObjectUtils.toString(value)); /* 239 */this.tablePDF.addCell(cell); /* */} /* */} /* */} /* */ /* */private Cell getCell(String value) /* */throws BadElementException /* */{ /* 252 */Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(value), this.smallFont)); /* 253 */cell.setVerticalAlignment(4); /* 254 */cell.setLeading(8.0F); /* 255 */return cell; /* */} /* */ /* */static class PdfGenerationException extends BaseNestableJspTagException /* */{ /* */private static final long serialVersionUID = 899149338534L; /* */ /* */public PdfGenerationException(Throwable cause) /* */{ /* 277 */super(null, Messages.getString("PdfView.errorexporting"), cause); /* */} /* */ /* */public SeverityEnum getSeverity() /* */{ /* 288 */return SeverityEnum.ERROR; /* */} /* */ } /* */ }
Java
package com.legendshop.business.common; import java.io.Serializable; import java.util.Date; public class SubForm implements Serializable { private static final long serialVersionUID = -6924455471052900466L; private Double total; private Long payType; private String basketId; private String other; private Integer userId; private String userName; private String orderName; private String userPass; private String userMail; private String userAdds; private String payTypeName; private String userTel; private Date userRegtime; private String userRegip; private Date userLasttime; private String userLastip; private String userPostcode; public Double getTotal() { return this.total; } public void setTotal(Double total) { this.total = total; } public Long getPayType() { return this.payType; } public void setPayType(Long payType) { this.payType = payType; } public String getBasketId() { return this.basketId; } public void setBasketId(String basketId) { this.basketId = basketId; } public String getOther() { return this.other; } public void setOther(String other) { this.other = other; } public Integer getUserId() { return this.userId; } public void setUserId(Integer userId) { this.userId = userId; } public String getUserName() { return this.userName; } public void setUserName(String userName) { this.userName = userName; } public String getOrderName() { return this.orderName; } public void setOrderName(String orderName) { this.orderName = orderName; } public String getUserPass() { return this.userPass; } public void setUserPass(String userPass) { this.userPass = userPass; } public String getUserMail() { return this.userMail; } public void setUserMail(String userMail) { this.userMail = userMail; } public String getUserAdds() { return this.userAdds; } public void setUserAdds(String userAdds) { this.userAdds = userAdds; } public String getPayTypeName() { return this.payTypeName; } public void setPayTypeName(String payTypeName) { this.payTypeName = payTypeName; } public String getUserTel() { return this.userTel; } public void setUserTel(String userTel) { this.userTel = userTel; } public Date getUserRegtime() { return this.userRegtime; } public void setUserRegtime(Date userRegtime) { this.userRegtime = userRegtime; } public String getUserRegip() { return this.userRegip; } public void setUserRegip(String userRegip) { this.userRegip = userRegip; } public Date getUserLasttime() { return this.userLasttime; } public void setUserLasttime(Date userLasttime) { this.userLasttime = userLasttime; } public String getUserLastip() { return this.userLastip; } public void setUserLastip(String userLastip) { this.userLastip = userLastip; } public String getUserPostcode() { return this.userPostcode; } public void setUserPostcode(String userPostcode) { this.userPostcode = userPostcode; } }
Java
package com.legendshop.business.common.page; import com.legendshop.core.constant.PageDefinition; import com.legendshop.core.constant.PagePathCalculator; import javax.servlet.http.HttpServletRequest; public enum FowardPage implements PageDefinition { VARIABLE(""), INDEX_QUERY("/index"), ADV_LIST_QUERY("/admin/advertisement/query"), BRAND_LIST_QUERY("/admin/brand/query"), LINK_LIST_QUERY("/admin/externallink/query"), HOT_LIST_QUERY("/admin/hotsearch/query"), IMG_LIST_QUERY("/admin/imgFile/query"), IJPG_LIST_QUERY("/admin/indexjpg/query"), LOGO_LIST_QUERY("/admin/logo/query"), LEAGUE_LIST_QUERY("/admin/myleague/query"), NEWS_LIST_QUERY("/admin/news/query"), NEWSCAT_LIST_QUERY("/admin/newsCategory/query"), NSORT_LIST_QUERY("/admin/nsort/query"), PAY_TYPE_LIST_QUERY("/admin/paytype/query"), PROD_LIST_QUERY("/admin/product/query"), SHOP_DETAIL_LIST_QUERY("/admin/shopDetail/query"), SORT_LIST_QUERY("/admin/sort/query"), PARAM_LIST_QUERY("/system/systemParameter/query"), PROD_COMM_LIST_QUERY("/admin/productcomment/query"), USER_COMM_LIST_QUERY("/admin/userComment/query"), VLOG_LIST_QUERY("/admin/visitLog/query"), FUNCTION_LIST_QUERY("/member/right/listFunction"), FIND_FUNCTION_BY_ROLE("/member/role/functions"), FIND_ALL_ROLE("/member/right/findAllRole"), FIND_ROLE_BY_USER("/member/user/findRoleByUser"), FIND_USER_ROLES("/member/user/roles"), ALL_ROLE("/member/role/query"), USER_DETAIL_LIST_QUERY("/admin/userDetail/query"), PUB_LIST_QUERY("/admin/pub/query"), DYNAMIC_QUERY("/dynamic/query"), USERS_LIST("/member/user/query"), DELIVERYCORP_LIST_QUERY("/admin/deliveryCorp/query"), DELIVERYTYPE_LIST_QUERY("/admin/deliveryType/query"), PARTNER_LIST_QUERY("/admin/partner/query"); private final String value; public String getValue(HttpServletRequest request) { return getValue(request, this.value); } public String getValue(HttpServletRequest request, String path) { return PagePathCalculator.calculateActionPath("forward:", path); } private FowardPage(String value) { this.value = value; } }
Java
package com.legendshop.business.common.page; import com.legendshop.core.constant.PageDefinition; import com.legendshop.core.constant.PagePathCalculator; import javax.servlet.http.HttpServletRequest; public enum FrontPage implements PageDefinition { VARIABLE(""), ERROR_PAGE("/common/error"), INSTALL("/install/index"), ALL_PAGE("/all"), FAIL("/fail"), TOPALL("/topAll"), TOP("/top"), TOPSORT("/topsort"), TOPSORTNEWS("/topsortnews"), TOPNEWS("/topnews"), VIEWS("/views"), COPY_ALL("/copyAll"), HOTON("/hoton"), HOTSALE("/hotSale"), FRIENDLINK("/friendlink"), HOTVIEW("/hotview"), INDEX_PAGE("/index"), ALL("/all"), PROD_PIC_GALLERY("/gallery"), IPSEARCH("/ipsearch"), BOUGHT("/bought"), CASH_SAVE("/cashsave"), RESETPASSWORD("/resetpassword"); private final String value; public String getValue(HttpServletRequest request) { return getValue(request, this.value); } public String getValue(HttpServletRequest request, String path) { return PagePathCalculator.calculateFronendPath(request, path); } private FrontPage(String value) { this.value = value; } }
Java
package com.legendshop.business.common.page; import com.legendshop.core.constant.PageDefinition; import com.legendshop.core.constant.PagePathCalculator; import javax.servlet.http.HttpServletRequest; public enum TilesPage implements PageDefinition { VARIABLE(""), NO_LOGIN("loginhint."), AFTER_OPERATION("afterOperation."), NSORT("nsort."), LOGIN("login."), LEAVEWORD("leaveword."), NEWS("news."), ALL_NEWS("allNews."), PAGE_CASH("cash."), REG("reg."), LEAGUE("league."), PRODUCTSORT("productSort."), SEARCHALL("searchall."), PAGE_SUB("savesub."), MYACCOUNT("myaccount."), SHOPCONTACT("shopcontact."), BUY("buy."), ORDER("order."), OPENSHOP("openShop."); private final String value; public String getValue(HttpServletRequest request) { return getValue(request, this.value); } public String getValue(HttpServletRequest request, String path) { return PagePathCalculator.calculateTilesPath(path, "default"); } private TilesPage(String value) { this.value = value; } }
Java
package com.legendshop.business.common.page; import com.legendshop.core.constant.PageDefinition; import com.legendshop.core.constant.PagePathCalculator; import javax.servlet.http.HttpServletRequest; public enum RedirectPage implements PageDefinition { VARIABLE(""); private final String value; public String getValue(HttpServletRequest request) { return getValue(request, this.value); } public String getValue(HttpServletRequest request, String path) { return PagePathCalculator.calculateActionPath("redirect:", path); } private RedirectPage(String value) { this.value = value; } }
Java
package com.legendshop.business.common.page; import com.legendshop.core.constant.PageDefinition; import com.legendshop.core.constant.PagePathCalculator; import javax.servlet.http.HttpServletRequest; public enum BackPage implements PageDefinition { VARIABLE(""), BACK_ERROR_PAGE("/common/error"), ORDERDETAIL("/order/orderDetail"), ADV_LIST_PAGE("/advertisement/advertisementList"), ADV_EDIT_PAGE("/advertisement/advertisement"), BRAND_LIST_PAGE("/brand/brandList"), BRAND_EDIT_PAGE("/brand/brand"), LINK_LIST_PAGE("/externallink/externallinkList"), LINK_EDIT_PAGE("/externallink/externallink"), HOT_LIST_PAGE("/hotsearch/hotsearchList"), HOT_EDIT_PAGE("/hotsearch/hotsearch"), IMG_LIST_PAGE("/imgFile/imgFileList"), IMG_EDIT_PAGE("/prod/prod"), DASH_BOARD("/dashboard/index"), ADMIN_HOME("/frame/index"), ADMIN_TOP("/frame/top"), IJPG_LIST_PAGE("/indexjpg/indexjpgList"), IJPG_EDIT_PAGE("/indexjpg/indexjpg"), UPGRADE_PAGE("/dashboard/upgrade"), LOGIN_HIST_LIST_PAGE("/loginhistory/loginHistoryList"), LOGIN_HIST_SUM_PAGE("/loginhistory/loginHistorySum"), LOGO_LIST_PAGE("/logo/logoList"), LOGO_EDIT_PAGE("/logo/logo"), LUCENE_PAGE("/lucene/reindexer"), LEAGUE_LIST_PAGE("/myleague/myleagueList"), LEAGUE_EDIT_PAGE("/myleague/myleague"), NEWS_LIST_PAGE("/news/newsList"), NEWS_EDIT_PAGE("/news/news"), NEWSCAT_LIST_PAGE("/newsCategory/newsCategoryList"), NEWSCAT_EDIT_PAGE("/newsCategory/newsCategory"), NSORT_LIST_PAGE("/nsort/nsortList"), NSORT_EDIT_PAGE("/nsort/nsort"), NSORT_APPENDBRAND_PAGE("/nsort/appendBrand"), ORDER_LIST_PAGE("/order/orderList"), PAY_PAGE("/payment/payto"), PAY_TYPE_LIST_PAGE("/payType/payTypeList"), PAY_TYPE_EDIT_PAGE("/payType/payType"), PROD_LIST_PAGE("/prod/prodList"), PROD_EDIT_PAGE("/prod/prod"), APPEND_PRODUCT("/prod/appendProduct"), CREATEP_RODUCT_STEP("/prod/createProductStep"), PROD_COMM_LIST_PAGE("/prodComment/prodCommentList"), PROD_COMM_EDIT_PAGE("/prodComment/prodComment"), PUB_LIST_PAGE("/pub/pubList"), PUB_EDIT_PAGE("/pub/pub"), SHOP_DETAIL_LIST_PAGE("/shopDetail/shopDetailList"), SHOP_DETAIL_EDIT_PAGE("/shopDetail/shopDetail"), SORT_LIST_PAGE("/sort/sortList"), SORT_EDIT_PAGE("/sort/sort"), PARAM_LIST_PAGE("/systemParameter/systemParameterList"), PARAM_EDIT_PAGE("/systemParameter/systemParameter"), USER_COMM_LIST_PAGE("/userComment/userCommentList"), USER_COMM_EDIT_PAGE("/userComment/userComment"), USER_DETAIL_LIST_PAGE("/userDetail/userDetailList"), VLOG_LIST_PAGE("/visitLog/visitLogList"), VLOG_EDIT_PAGE("/visitLog/visitLog"), SHOW_DYNAMIC_ATTRIBUTE("/xml/showDynamicAttribute"), SHOW_DYNAMIC("/xml/showdynamic"), DYNAMIC_ATTRIBUTE("/xml/dynamicAttribute"), UPDATE_FUNCTION("/member/right/updateFunction"), ROLE_FUNCTION("/member/right/findFunctionByRole"), FIND_OTHER_FUNCTION_LIST("/member/right/findOtherfunctionList"), FUNCTION_LIST("/member/right/functionList"), ROLE_LIST("/member/right/roleList"), FIND_ROLE_BY_FUNCTION("/member/right/findRoleByFunction"), FIND_ROLE_BY_USER_PAGE("/member/user/findRoleByUser"), UPDATE_USER_STATUS("/member/user/updateUserStatus"), UPDATE_USER_PASSWORD("/member/user/updateUserPassword"), MODIFY_USER("/member/user/saveUser"), FIND_OTHER_ROLE_BY_USER("/member/user/findOtherRoleByUser"), FIND_FUNCTION_BY_USER("/member/user/findFunctionByUser"), USER_LIST_PAGE("/member/user/userlist"), SAVE_ROLE("/member/right/saveRole"), MODIFYPRICE("/order/modifyPrice"), DELIVERYCORP_LIST_PAGE("/deliveryCorp/deliveryCorpList"), DELIVERYCORP_EDIT_PAGE("/deliveryCorp/deliveryCorp"), DELIVERYTYPE_LIST_PAGE("/deliveryType/deliveryTypeList"), DELIVERYTYPE_EDIT_PAGE("/deliveryType/deliveryType"), PARTNER_LIST_PAGE("/partner/partnerList"), PARTNER_EDIT_PAGE("/partner/partner"), PARTNER_CHANGE_PASSWORD_PAGE("/partner/partnerChangePassword"); private final String value; private BackPage(String value) { this.value = value; } public String getValue(HttpServletRequest request) { return getValue(request, this.value); } public String getValue(HttpServletRequest request, String path) { return PagePathCalculator.calculateBackendPath(request, path); } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.StringEnum; public enum VisitTypeEnum implements StringEnum { INDEX("0"), HW("1"); private final String value; private VisitTypeEnum(String value) { this.value = value; } public String value() { return this.value; } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.IntegerEnum; public enum CommentTypeEnum implements IntegerEnum { COMMENT_UN_READ(Integer.valueOf(0)), COMMENT_READED(Integer.valueOf(1)), COMMONTALK(Integer.valueOf(2)); private Integer num; public Integer value() { return this.num; } private CommentTypeEnum(Integer num) { this.num = num; } public static void main(String[] args) { } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.IntegerEnum; import java.io.PrintStream; public enum OrderStatusEnum implements IntegerEnum { UNPAY(Integer.valueOf(1)), PADYED(Integer.valueOf(2)), CONSIGNMENT(Integer.valueOf(3)), SUCCESS(Integer.valueOf(4)), CLOSE(Integer.valueOf(5)), REFUNDMENT(Integer.valueOf(6)), PAY_AT_GOODS_ARRIVED(Integer.valueOf(7)); private Integer num; public Integer value() { return this.num; } private OrderStatusEnum(Integer num) { this.num = num; } public static void main(String[] args) { System.out.println(SUCCESS.value()); System.out.println(SUCCESS); } }
Java
package com.legendshop.business.common.fck; import com.legendshop.core.UserManager; import com.legendshop.core.constant.ParameterEnum; import com.legendshop.core.exception.PermissionException; import com.legendshop.core.helper.FileProcessor; import com.legendshop.core.helper.PropertiesUtil; import java.io.IOException; import java.io.InputStream; import net.fckeditor.connector.exception.InvalidCurrentFolderException; import net.fckeditor.connector.exception.WriteException; import net.fckeditor.connector.impl.LocalConnector; import net.fckeditor.handlers.ResourceType; import net.fckeditor.requestcycle.ThreadLocalData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ContextConnector extends LocalConnector { private final Logger log = LoggerFactory.getLogger(ContextConnector.class); public String fileUpload(ResourceType type, String currentFolder, String fileName, InputStream inputStream) throws InvalidCurrentFolderException, WriteException { String userName = UserManager.getUsername(ThreadLocalData.getRequest()); if (userName == null) { throw new PermissionException("did not logon yet!", "29"); } String name = fileName; try { int size = inputStream.available(); if ((size < 0) || (size > ((Long) PropertiesUtil.getObject( ParameterEnum.MAX_FILE_SIZE, Long.class)).longValue())) throw new RuntimeException( "File is 0 or File Size exceeded MAX_FILE_SIZE: " + size); } catch (IOException e) { this.log.error("fileUpload error", e); } String path = PropertiesUtil.getBigFilesAbsolutePath() + "/" + userName + "/editor" + "/image/" + currentFolder; FileProcessor.uploadFile(inputStream, path, "", fileName, true, false); return name; } }
Java
package com.legendshop.business.common.fck; import com.legendshop.core.exception.PermissionException; import com.legendshop.core.helper.PropertiesUtil; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import net.fckeditor.requestcycle.impl.ServerRootPathBuilder; public class ContextPathBuilder extends ServerRootPathBuilder { public String getUserFilesPath(HttpServletRequest request) { String userName = (String) request.getSession().getAttribute( "SPRING_SECURITY_LAST_USERNAME"); if (userName == null) { throw new PermissionException("did not logon yet!", "29"); } return request.getContextPath() + super.getUserFilesPath(request) + "/" + userName + "/editor"; } public String getUserFilesAbsolutePath(HttpServletRequest request) { String userName = (String) request.getSession().getAttribute( "SPRING_SECURITY_LAST_USERNAME"); if (userName == null) { throw new PermissionException("did not logon yet!", "29"); } return PropertiesUtil.getBigFilesAbsolutePath() + "/" + userName + "/editor"; } }
Java
package com.legendshop.business.common.fck; import javax.servlet.http.HttpServletRequest; import net.fckeditor.requestcycle.UserAction; public class EnabledUserAction implements UserAction { public boolean isCreateFolderEnabled(HttpServletRequest request) { return true; } public boolean isEnabledForFileBrowsing(HttpServletRequest request) { return true; } public boolean isEnabledForFileUpload(HttpServletRequest request) { return true; } }
Java
package com.legendshop.business.common; public abstract interface CacheKeys { public static final String ADVERTISEMENTDAO_GETADVERTISEMENT = "AdvertisementDao_getAdvertisement"; public static final String EXTERNALLINKDAO_GETEXTERNALLINKORDERBYBS = "ExternalLinkDao_getExternalLinkOrderbybs"; public static final String PRODUCTDAO_GETCOMMEND_PROD = "ProductDao_getCommendProdProd"; public static final String PRODUCTDAO_GETRELEATION_PROD = "ProductDao_getReleationProdProd"; public static final String PRODUCTDAO_GETNEWEST_PROD = "ProductDao_getNewestProdProd"; public static final String RPODUCTDAO_GETORDERhotsale = "ProductDao_getOrderhotsale"; public static final String IMGFILEDAO_GETINDEXJPEG = "ImgFileDao_getIndexJpeg"; public static final String IMGFILEDAO_GETPRODUCTPICS = "ImgFileDao_getProductPics"; public static final String LOGODAO_GETLOGO = "LogoDao_getLogo"; public static final String NEWSDAO_GETNEWS = "NewsDao_getNews"; public static final String NSORTDAO_GETNSORT = "NsortDao_getNsort"; public static final String NSORTDAO_GETNSORTLIST = "NsortDaoImpl.getNsortList"; public static final String NSORTDAO_GETNSORTBYSORTID = "NsortDaoImpl.getNsortBySortId"; public static final String PUBDAO_GETPUB = "PubDao_getPub"; public static final String SHOPDETAILDAO_ISSHOPEXISTS = "ShopDetailDao_isShopExists"; public static final String SHOPDETAILDAO_CANBELEAGUESHOP = "ShopDetailDao_canbeLeagueShop"; public static final String SHOPDETAILDAO_GETSHOPDETAILVIEW = "ShopDetailDao_getShopDetailView"; public static final String SHOPDETAILDAO_ISLEAGUESHOPEXISTS = "ShopDetailDao_isLeagueShopExists"; public static final String HOTSEARCHDAO_GETSEARCH = "HotsearchDao_getSearch"; public static final String SORTDAO_GETSORT = "SortDao_getSort"; }
Java
package com.legendshop.business.common; import com.legendshop.core.AttributeKeys; public class Constants implements AttributeKeys { public static final String BASKET_KEY = "BASKET_KEY"; public static final String BASKET_COUNT = "BASKET_COUNT"; public static final String PRODUCT_LESS = "PRODUCT_LESS"; public static final String BASKET_TOTAL_CASH = "BASKET_TOTAL_CASH"; public static final String BASKET_HW_COUNT = "BASKET_HW_COUNT"; public static final String BASKET_HW_ATTR = "BASKET_HW_ATTR"; public static final String CLUB_COOIKES_NAME = "jforumUserInfo"; public static final Integer REG_USER_EXIST = Integer.valueOf(1); public static final Integer REG_EMAIL_EXIST = Integer.valueOf(2); public static final Integer REG_USER_EMAIL_EXIST = Integer.valueOf(3); public static final Integer REG_CHECK_NORMAL = Integer.valueOf(0); public static final String COUPLET = "COUPLET"; public static final Short PRODUCTTYPE_HW = Short.valueOf("1"); public static final Short PRODUCTTYPE_NEWS = Short.valueOf("2"); public static final Short PRODUCTTYPE_SHOP = Short.valueOf("3"); public static final Short HW_TEMPLATE_ATTRIBUTE = Short.valueOf("1"); public static final Short HW_TEMPLATE_PARAMETER = Short.valueOf("2"); public static final String VISIT_HISTORY = "VisitHistory"; public static final String ORDER_STATUS = "ORDER_STATUS"; public static final String TOKEN = "SESSION_TOKEN"; public static final String USER_REG_ADV_950 = "USER_REG_ADV_950"; public static final String USER_REG_ADV_740 = "USER_REG_ADV_740"; public static final String LOGONED_COMMENT = "LOGONED_COMMENT"; public static final String ANONYMOUS_COMMENT = "ANONYMOUS_COMMENT"; public static final String NO_COMMENT = "NO_COMMENT"; public static final String BUYED_COMMENT = "BUYED_COMMENT"; public static final String FAIL = "fail"; }
Java
package com.legendshop.business.common; import com.legendshop.core.AttributeKeys; import com.legendshop.core.ContextServiceLocator; import com.legendshop.core.StartupService; import com.legendshop.core.helper.PropertiesUtil; import com.legendshop.core.helper.RealPathUtil; import com.legendshop.util.AppUtils; import com.legendshop.util.ServiceLocatorIF; import com.legendshop.util.sql.ConfigCode; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; public class InitSysListener implements ServletContextListener { private static Logger log = LoggerFactory .getLogger(InitSysListener.class); private static boolean state = false; public void contextDestroyed(ServletContextEvent event) { } public void contextInitialized(ServletContextEvent event) { log.info("********* Initializing LegendShop System now *************"); String realPath = RealPathUtil.getSystemRealPath(event .getServletContext()); if ((realPath != null) && (!realPath.endsWith("/"))) { realPath = realPath + "/"; } PropertiesUtil.setSystemRealPath(realPath); initspring(event); ConfigCode sQlCode = ConfigCode.getInstance("classpath*:DAL.cfg.xml"); boolean debugMode = PropertiesUtil.isSystemInDebugMode(); log.debug("System in DEBUG MODE is {}", Boolean.valueOf(debugMode)); sQlCode.setDebug(debugMode); if (AppUtils.isBlank(PropertiesUtil.getLegendShopSystemId())) { PropertiesUtil.changeLegendShopSystemId(); } event.getServletContext().setAttribute("WEB_SUFFIX", AttributeKeys.WEB_SUFFIX); if (PropertiesUtil.isSystemInstalled()) { StartupService startupService = (StartupService) ContextServiceLocator .getInstance().getBean("startupService"); startupService.startup(event.getServletContext()); } log.info("********* LegendShop System Initialized successful **********"); } private boolean initspring(ServletContextEvent event) { if (state) { return state; } ApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(event.getServletContext()); if (ctx == null) state = false; else { state = true; } String[] beans = ctx.getBeanDefinitionNames(); StringBuffer sb = new StringBuffer("[ "); if (!AppUtils.isBlank(beans)) { for (String bean : beans) { sb.append(bean).append(" "); } sb.append(" ]"); log.debug("系统配置的Spring Bean " + sb.toString()); } ContextServiceLocator.getInstance().setContext(ctx); return state; } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.IntegerEnum; public enum MyLeagueEnum implements IntegerEnum { ONGOING(Integer.valueOf(0)), AGREE(Integer.valueOf(1)), DENY(Integer.valueOf(2)), NONE(Integer.valueOf(3)), DONE(Integer.valueOf(4)), THESAME(Integer.valueOf(5)), ERROR(Integer.valueOf(6)); private Integer num; public Integer value() { return this.num; } private MyLeagueEnum(Integer num) { this.num = num; } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.IntegerEnum; public enum ShopStatusEnum implements IntegerEnum { ONLINE(Integer.valueOf(1)), AGREE(Integer.valueOf(1)), OFFLINE(Integer.valueOf(0)), AUDITING(Integer.valueOf(-1)), REJECT(Integer.valueOf(-2)), CLOSE(Integer.valueOf(-3)); private Integer num; public Integer value() { return this.num; } private ShopStatusEnum(Integer num) { this.num = num; } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.StringEnum; import java.io.PrintStream; public enum RegisterEnum implements StringEnum { REGISTER_SUCCESS("reg.success.actived"), REGISTER_NO_USER_FOUND("user.isNotExist"), REGISTER_CODE_NOT_MATCH("error.image.validation"), REGISTER_FAIL("reg.fail.actived"); private final String value; private RegisterEnum(String value) { this.value = value; } public String value() { return this.value; } public static void main(String[] args) { System.out.println(REGISTER_SUCCESS.value); } }
Java
package com.legendshop.business.common; import com.legendshop.core.constant.IntegerEnum; import com.legendshop.model.entity.PayType; public enum PayTypeEnum implements IntegerEnum { ALI_DIRECT_PAY(Integer.valueOf(1)), ALI_PAY(Integer.valueOf(2)), PAY_AT_GOODS_ARRIVED(Integer.valueOf(3)); private Integer num; public Integer value() { return this.num; } private PayTypeEnum(Integer num) { this.num = num; } public static void main(String[] args) { } public static boolean isAlipay(PayType payType) { if (payType == null) { return false; } return (ALI_DIRECT_PAY.value().equals(payType.getPayTypeId())) || (ALI_PAY.value().equals(payType.getPayTypeId())); } }
Java
package com.legendshop.core.tag; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.SimpleTagSupport; import com.legendshop.core.ContextServiceLocator; public abstract class LegendShopTag extends SimpleTagSupport { protected HttpServletRequest request() { return (HttpServletRequest) pageContext().getRequest(); } protected void setAttribute(String paramString, Object paramObject) { request().setAttribute(paramString, paramObject); } protected HttpServletResponse response() { return (HttpServletResponse) pageContext().getResponse(); } protected void write(String paramString) throws IOException { pageContext().getOut().write(paramString); } protected void invokeJspBody() throws JspException, IOException { if (getJspBody() != null) getJspBody().invoke(pageContext().getOut()); } protected Object getBean(String paramString) { return ContextServiceLocator.getInstance().getBean(paramString); } @SuppressWarnings("unchecked") protected <T> T getBean(Class<T> clazz) { return (T) getBean(clazz.getName()); } protected PageContext pageContext() { return (PageContext) getJspContext(); } }
Java
package com.legendshop.core.tag; import java.io.IOException; import java.net.URLEncoder; import javax.servlet.jsp.JspException; import org.apache.commons.lang.StringUtils; import com.legendshop.core.AttributeKeys; public class URLTag extends LegendShopTag { public static final String URL_ENCODE = "UTF-8"; private String _$2; private boolean _$1; public void doTag() throws JspException, IOException { StringBuilder localStringBuilder = new StringBuilder(128) .append(request().getContextPath()); if (this._$1) { if (this._$2 == null) this._$2 = ""; String[] arrayOfString1 = this._$2.split("/"); for (String str : arrayOfString1) { if (!StringUtils.isNotEmpty(str)) continue; localStringBuilder.append("/").append( URLEncoder.encode(str, "UTF-8")); } } else { localStringBuilder.append(this._$2); } localStringBuilder.append(AttributeKeys.WEB_SUFFIX); write(response().encodeURL(localStringBuilder.toString())); } public void setAddress(String paramString) { this._$2 = paramString; } public void setEncode(boolean paramBoolean) { this._$1 = paramBoolean; } }
Java
package com.legendshop.core.tag; import java.io.IOException; public class TemplateResourceTag extends LegendShopTag { private String _$1; public void doTag() throws IOException { //TODO 为啥会多加了 128 // String str = 128 + request().getContextPath() + this._$1; String str = request().getContextPath() + this._$1; write(str); } public void setItem(String paramString) { this._$1 = paramString; } }
Java
package com.legendshop.core.tag; import com.legendshop.core.helper.ResourceBundleHelper; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.DynamicAttributes; import org.springframework.web.servlet.LocaleResolver; public class I18nTag extends LegendShopTag implements DynamicAttributes { private static LocaleResolver _$3; private String _$2; private final List<Object> _$1 = new ArrayList<Object>(); public I18nTag() { if (_$3 == null) _$3 = (LocaleResolver) getBean("localeResolver"); } public void doTag() throws JspException, IOException { Locale localLocale = _$3.resolveLocale(request()); if (this._$1.size() == 0) { String localObject = ResourceBundleHelper.getString(localLocale, this._$2); write(localObject); } else { String[] localObject = new String[this._$1.size()]; for (int i = 0; i < this._$1.size(); i++) { String str2 = (String) this._$1.get(i); if ((str2 != null) && (str2.startsWith("message:"))) localObject[i] = ResourceBundleHelper.getString( localLocale, str2.substring("message:".length())); else localObject[i] = str2; } String str1 = ResourceBundleHelper.getString(localLocale, this._$2, localObject); write(str1); } } public void setKey(String paramString) { this._$2 = paramString; } public void setDynamicAttribute(String paramString1, String paramString2, Object paramObject) throws JspException { this._$1.add(paramObject); } }
Java
package com.legendshop.core.tag; import javax.servlet.jsp.tagext.TagSupport; import com.legendshop.core.helper.PropertiesUtil; public class SettingsTag extends TagSupport { private static final long serialVersionUID = -8943927608529578818L; private String _$1; public int doStartTag() { Boolean localBoolean = PropertiesUtil.getBooleanObject(this._$1); if ((localBoolean != null) && (localBoolean.booleanValue())) return 1; return 0; } public void setKey(String paramString) { this._$1 = paramString; } }
Java
package org.springframework.web.servlet.mvc.annotation; import com.legendshop.central.license.LicenseEnum; import com.legendshop.core.exception.PermissionException; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.springframework.web.servlet.ModelAndView; public class MethodHandlerAdapter extends AnnotationMethodHandlerAdapter { public ModelAndView handle(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, Object paramObject) throws Exception { String str = (String)paramHttpServletRequest.getSession().getServletContext().getAttribute("UN_AUTH_MSG"); if (LicenseEnum.UN_AUTH.name().equals(str)) throw new PermissionException(str, "29"); return super.handle(paramHttpServletRequest, paramHttpServletResponse, paramObject); } }
Java
package com.legendshop.central.install; import com.legendshop.core.ContextServiceLocator; import com.legendshop.core.StartupService; import com.legendshop.core.constant.ConfigPropertiesEnum; import com.legendshop.core.datasource.RefreshableDataSource; import com.legendshop.core.exception.InternalException; import com.legendshop.core.helper.PropertiesUtil; import com.legendshop.util.AppUtils; import com.legendshop.util.ServiceLocatorIF; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; import org.logicalcobwebs.proxool.ProxoolDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SetupImpl implements Setup { private static Logger _$8 = LoggerFactory.getLogger(SetupImpl.class); private DBManager _$7 = null; private final String _$6 = "com.mysql.jdbc.Driver"; private String _$5; private String _$4; private String _$3; private String _$2; private String _$1; public String getDomainName() { return this._$2; } public void setDomainName(String paramString) { this._$2 = paramString; } private SetupImpl() { } public SetupImpl(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6, String paramString7) { this._$4 = paramString1; this._$3 = paramString2; this._$2 = paramString6; this._$1 = paramString7; this._$5 = ("jdbc:mysql://" + paramString4 + ":" + paramString5 + "/" + paramString3 + "?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf-8"); this._$7 = new DBManager("com.mysql.jdbc.Driver", this._$5, this._$4, this._$3); } public void startSetup(HttpServletRequest paramHttpServletRequest) { if (PropertiesUtil.isSystemInstalled()) throw new InternalException("LegendShop 已经安装,请勿重复安装", "00"); String str1 = StringUtils.replace(paramHttpServletRequest.getSession().getServletContext().getRealPath("/"), "\\", "/"); System.out.println("realPath = " + str1); _$8.info("realPath = {}", str1); if ((str1 != null) && (!str1.endsWith("/"))) { _$8.info("realPath append /"); str1 = str1 + "/"; } String str2 = PropertiesUtil.getProperties("config/global.properties", ConfigPropertiesEnum.LEGENDSHOP_VERSION.name()); paramHttpServletRequest.getSession().getServletContext().setAttribute("DOMAIN_NAME", this._$2); if ("1".equals(this._$1)) try { String str3 = str1 + "install/db/legendshop-struct" + str2 + ".sql"; String str4 = readFile(str3); if (!AppUtils.isBlank(str4)) this._$7.batchUpdate(str4.split(";")); str3 = str1 + "install/db/legendshop-data" + str2 + ".sql"; this._$7.batchUpdate(readFilePerLine(str3)); } catch (Exception localException1) { throw new DBException(); } else _$8.info("LegendShop " + str2 + " 跳过数据库,直接安装系统。installDb = " + this._$1); try { changePropertiesFileV3(str1, paramHttpServletRequest); } catch (Exception localException2) { throw new PropertiesException("changePropertiesFileV3 error"); } try { System.out.println("addDataSource calling"); RefreshableDataSource localRefreshableDataSource = (RefreshableDataSource)ContextServiceLocator.getInstance().getBean("dataSource"); localRefreshableDataSource.setDataSource(getDataSource()); } catch (Exception localException3) { _$8.error("addDataSource in startup error", localException3); } StartupService localStartupService = (StartupService)ContextServiceLocator.getInstance().getBean("startupService"); localStartupService.startup(paramHttpServletRequest.getSession().getServletContext()); _$8.info("LegendShop " + str2 + " 已经安装成功。"); } public ProxoolDataSource getDataSource() { ProxoolDataSource localProxoolDataSource = new ProxoolDataSource(); localProxoolDataSource.setDriver("com.mysql.jdbc.Driver"); localProxoolDataSource.setDriverUrl(this._$5); localProxoolDataSource.setUser(this._$4); localProxoolDataSource.setPassword(this._$3); System.out.println("ProxoolDataSource =-" + localProxoolDataSource); return localProxoolDataSource; } public boolean changePropertiesFileV3(String paramString, HttpServletRequest paramHttpServletRequest) { _$2(paramString); _$1(paramString); return true; } private void _$2(String paramString) { String str = paramString + "WEB-INF/classes/config/jdbc.properties"; HashMap localHashMap = new HashMap(); localHashMap.put("jdbc.url", this._$5); localHashMap.put("jdbc.username", this._$4); localHashMap.put("jdbc.password", this._$3); localHashMap.put("alias", this._$4); localHashMap.put("prototypeCount", "20"); localHashMap.put("minimumConnectionCount", "10"); PropertiesUtil.writeProperties(str, localHashMap); } private void _$1(String paramString) { String str = paramString + "WEB-INF/classes/config/common.properties"; HashMap localHashMap = new HashMap(); localHashMap.put("DOMAIN_NAME", this._$2); localHashMap.put(ConfigPropertiesEnum.INSTALLED.name(), "true"); localHashMap.put(ConfigPropertiesEnum.DOWNLOAD_PATH.name(), PropertiesUtil.getDownloadFilePath()); localHashMap.put(ConfigPropertiesEnum.SMALL_PIC_PATH.name(), PropertiesUtil.getSmallFilesAbsolutePath()); localHashMap.put(ConfigPropertiesEnum.BIG_PIC_PATH.name(), PropertiesUtil.getBigFilesAbsolutePath()); localHashMap.put(ConfigPropertiesEnum.BACKUP_PIC_PATH.name(), PropertiesUtil.getBackupFilesAbsolutePath()); localHashMap.put(ConfigPropertiesEnum.LUCENE_PATH.name(), PropertiesUtil.getLucenePath()); PropertiesUtil.writeProperties(str, localHashMap); } public boolean changePropertiesFile(String paramString, HttpServletRequest paramHttpServletRequest) { String str1 = paramHttpServletRequest.getContextPath(); String str2 = paramString + "WEB-INF/classes/config/jdbc.properties"; HashMap localHashMap = new HashMap(); localHashMap.put("jdbc.url", this._$5); localHashMap.put("jdbc.username", this._$4); localHashMap.put("jdbc.password", this._$3); localHashMap.put("alias", this._$4); PropertiesUtil.writeProperties(str2, localHashMap); str2 = paramString + "WEB-INF/classes/config/acegi-cas.properties"; localHashMap = new HashMap(); localHashMap.put("cas.server.url", this._$2 + "cas"); if (AppUtils.isBlank(str1)) localHashMap.put("cas.service.url", this._$2); else localHashMap.put("cas.service.url", this._$2 + str1.substring(1)); PropertiesUtil.writeProperties(str2, localHashMap); str2 = paramString + "WEB-INF/classes/config/fckeditor.properties"; localHashMap = new HashMap(); localHashMap.put(ConfigPropertiesEnum.DOWNLOAD_PATH.name(), paramString + "download"); localHashMap.put("connector.smallFilesAbsolutePath", _$1(paramString, str1, "photoserver/smallImage")); PropertiesUtil.writeProperties(str2, localHashMap); str2 = paramString + "WEB-INF/classes/fckeditor.properties"; localHashMap = new HashMap(); String str3 = "connector.userFilesAbsolutePath"; localHashMap.put(str3, _$1(paramString, str1, "photoserver/bigImage")); PropertiesUtil.writeProperties(str2, localHashMap); str2 = _$1(paramString, str1, "cas/") + "WEB-INF/classes/config/common.properties"; localHashMap = new HashMap(); int i = paramHttpServletRequest.getServerPort(); if (i == 80) localHashMap.put("cas.server.url", "http://" + paramHttpServletRequest.getServerName() + "/cas"); else localHashMap.put("cas.server.url", "http://" + paramHttpServletRequest.getServerName() + ":" + paramHttpServletRequest.getServerPort() + "/cas"); PropertiesUtil.writeProperties(str2, localHashMap); str2 = _$1(paramString, str1, "cas/") + "WEB-INF/cas.properties"; localHashMap = new HashMap(); localHashMap.put("jdbc.url", this._$5); localHashMap.put("jdbc.username", this._$4); localHashMap.put("jdbc.password", this._$3); localHashMap.put("alias", this._$4); PropertiesUtil.writeProperties(str2, localHashMap); String str4 = _$1(paramString, str1, "managerWeb/"); str2 = str4 + "WEB-INF/classes/config.properties"; localHashMap = new HashMap(); localHashMap.put("upLoadPath", str4 + "dowonload"); PropertiesUtil.writeProperties(str2, localHashMap); str2 = str4 + "WEB-INF/classes/config/jdbc.properties"; localHashMap = new HashMap(); localHashMap.put("jdbc.url", this._$5); localHashMap.put("jdbc.username", this._$4); localHashMap.put("jdbc.password", this._$3); localHashMap.put("alias", this._$4); PropertiesUtil.writeProperties(str2, localHashMap); str2 = str4 + "WEB-INF/classes/config/acegi-cas.properties"; localHashMap = new HashMap(); localHashMap.put("cas.server.url", this._$2 + "cas"); localHashMap.put("cas.service.url", this._$2 + "managerWeb"); PropertiesUtil.writeProperties(str2, localHashMap); return true; } private String _$1(String paramString1, String paramString2, String paramString3) { if (paramString1 == null) return null; String str = _$1(paramString1, paramString2) + paramString3; File localFile = new File(str); if (!localFile.exists()) localFile.mkdirs(); return str; } private String _$1(String paramString1, String paramString2) { if (AppUtils.isBlank(paramString2)) paramString2 = "/ROOT"; String str = paramString1.substring(0, paramString1.length() - paramString2.length()); return str; } public String readFile(String paramString) { StringBuffer localStringBuffer = new StringBuffer(); try { File localFile = new File(paramString); if (!localFile.exists()) throw new InternalException(paramString + " 文件不存在", "24", null); FileInputStream localFileInputStream = new FileInputStream(localFile); BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localFileInputStream, "UTF-8")); String str = ""; while ((str = localBufferedReader.readLine()) != null) { if ((str == null) || ("".equals(str))) continue; localStringBuffer.append(str); } } catch (Exception localException) { localException.printStackTrace(); } return localStringBuffer.toString(); } public String[] readFilePerLine(String paramString) { ArrayList localArrayList = new ArrayList(); try { File localFile = new File(paramString); if (!localFile.exists()) throw new InternalException(paramString + " 数据文件不存在", "00"); FileInputStream localFileInputStream = new FileInputStream(localFile); BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localFileInputStream, "UTF-8")); String str = ""; while ((str = localBufferedReader.readLine()) != null) { if ((str == null) || ("".equals(str)) || ("&nbsp;".equals(str))) continue; localArrayList.add(str); } } catch (Exception localException) { localException.printStackTrace(); } String[] arrayOfString = new String[localArrayList.size()]; for (int i = 0; i < arrayOfString.length; i++) arrayOfString[i] = ((String)localArrayList.get(i)); return arrayOfString; } public static void main(String[] paramArrayOfString) { SetupImpl localSetupImpl = new SetupImpl(); localSetupImpl.changePropertiesFileV3("D:\\java\\server\\apache-tomcat-6.0.18\\webapps\\ROOT\\", null); } }
Java
package com.legendshop.central.install; import java.io.PrintStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DBManager { Logger _$6 = LoggerFactory.getLogger(DBManager.class); private static DBManager _$5 = null; private final String _$4; private final String _$3; private final String _$2; private final String _$1; public DBManager(String paramString1, String paramString2, String paramString3, String paramString4) { this._$4 = paramString1; this._$3 = paramString2; this._$2 = paramString3; this._$1 = paramString4; try { Class.forName(paramString1); } catch (ClassNotFoundException localClassNotFoundException) { System.err.println("connectDB(): " + localClassNotFoundException.getMessage()); } } public Connection getConnection() throws SQLException { DriverManager.setLoginTimeout(10); Connection localConnection = DriverManager.getConnection(this._$3, this._$2, this._$1); return localConnection; } public Connection getConnection(String paramString1, String paramString2, String paramString3) throws SQLException { return DriverManager.getConnection(paramString1, paramString2, paramString3); } public void cleanup(Connection paramConnection, Statement paramStatement, ResultSet paramResultSet) { try { if (paramResultSet != null) { paramResultSet.close(); paramResultSet = null; } } catch (Exception localException1) { this._$6.error("", localException1); } try { if (paramStatement != null) { paramStatement.close(); paramStatement = null; } } catch (Exception localException2) { this._$6.error("", localException2); } try { if ((paramConnection != null) && (!paramConnection.isClosed())) { paramConnection.close(); paramConnection = null; } } catch (Exception localException3) { this._$6.error("", localException3); } } public void batchUpdate(String[] paramArrayOfString) { Statement localStatement = null; Connection localConnection = null; String str = null; try { localConnection = getConnection(); localConnection.setAutoCommit(false); localStatement = localConnection.createStatement(); for (int i = 0; i < paramArrayOfString.length; i++) { if ((paramArrayOfString[i] == null) || (paramArrayOfString[i].equals(""))) continue; str = paramArrayOfString[i].trim(); try { if (i == 0) { this._$6.info("数据导入中,请勿关闭服务器,LegendShop DB Version:" + str); } else { localStatement.executeUpdate(str); if (i % 100 == 0) localConnection.commit(); } } catch (Exception localException2) { this._$6.error("ERROR SQL: {},Exception :{}", str, localException2.getMessage()); } } localConnection.commit(); } catch (Exception localException1) { this._$6.error("ERROR SQL: {}", str); this._$6.error("", localException1); try { localConnection.rollback(); } catch (SQLException localSQLException) { localSQLException.printStackTrace(); } } finally { cleanup(localConnection, localStatement, null); } } }
Java
package com.legendshop.central.install; public class PropertiesException extends RuntimeException { public PropertiesException(String paramString) { super(paramString); } }
Java
package com.legendshop.central.install; public class DBException extends RuntimeException { }
Java
package com.legendshop.central.install; public class DbInfo { private Integer _$2; private String _$1; public Integer getResult() { return this._$2; } public void setResult(Integer paramInteger) { this._$2 = paramInteger; } public String getDesc() { return this._$1; } public void setDesc(String paramString) { this._$1 = paramString; } }
Java
package com.legendshop.central.install; import java.sql.Connection; import java.sql.DatabaseMetaData; import javax.servlet.http.HttpServletRequest; public class TestDB { private Integer _$3 = Integer.valueOf(0); private Integer _$2 = Integer.valueOf(1); private Integer _$1 = Integer.valueOf(2); public DbInfo testDB(HttpServletRequest paramHttpServletRequest) { DbInfo localDbInfo = new DbInfo(); String str1 = paramHttpServletRequest.getParameter("jdbc_driver"); String str2 = paramHttpServletRequest.getParameter("jdbc_url"); String str3 = paramHttpServletRequest.getParameter("jdbc_username"); String str4 = paramHttpServletRequest.getParameter("jdbc_password"); try { DBManager localDBManager = new DBManager(str1, str2, str3, str4); Connection localConnection = localDBManager.getConnection(); DatabaseMetaData localDatabaseMetaData = localConnection.getMetaData(); int i = localDatabaseMetaData.getDatabaseMajorVersion(); if (i < 4) { localDbInfo.setResult(this._$2); localDbInfo.setDesc("Legend Shop 不支持MySql4"); } else { localDbInfo.setResult(this._$3); localDbInfo.setDesc("当前MySQL版本是:" + localDatabaseMetaData.getDatabaseProductVersion()); } } catch (Exception localException) { localDbInfo.setResult(this._$1); localDbInfo.setDesc(localException.getMessage()); } return localDbInfo; } }
Java
package com.legendshop.central.install; import javax.servlet.http.HttpServletRequest; public abstract interface Setup { public abstract void startSetup(HttpServletRequest paramHttpServletRequest); }
Java
package com.legendshop.central; import com.legendshop.central.license.BusinessModeEnum; import com.legendshop.central.license.HealthCheckImpl; import com.legendshop.core.constant.ConfigPropertiesEnum; import com.legendshop.core.helper.PropertiesUtil; import com.legendshop.core.page.PagerUtil; import javax.servlet.ServletContext; public class HealthCheckerHolder { private static HealthCheckerHolder _$2 = null; private static boolean _$1 = false; private HealthCheckerHolder(ServletContext paramServletContext) { PagerUtil.setPath(paramServletContext.getContextPath()); paramServletContext.setAttribute(ConfigPropertiesEnum.CURRENCY_PATTERN.name(), PropertiesUtil.getCurrencyPattern()); paramServletContext.setAttribute("DOMAIN_NAME", PropertiesUtil.getDomainName()); // TODO 到时需要修改 paramServletContext.setAttribute("LEGENDSHOP_DOMAIN_NAME", "http://localhost:9090"); paramServletContext.setAttribute(ConfigPropertiesEnum.LEGENDSHOP_VERSION.name(), PropertiesUtil.getProperties("config/global.properties", ConfigPropertiesEnum.LEGENDSHOP_VERSION.name())); paramServletContext.setAttribute("BUSINESS_MODE", BusinessModeEnum.C2C.name()); paramServletContext.setAttribute("RUNTIME_MODE", "PROD"); paramServletContext.setAttribute("LANGUAGE_MODE", "userChoice"); } private void _$1(ServletContext paramServletContext) { if ((PropertiesUtil.isSystemInstalled()) && (!_$1)) { new Thread(new HealthCheckImpl(paramServletContext)).start(); _$1 = true; } } public static synchronized boolean isInitialized(ServletContext paramServletContext) { if (_$2 == null) _$2 = new HealthCheckerHolder(paramServletContext); _$2._$1(paramServletContext); return _$2 != null; } }
Java
package com.legendshop.central.event; import com.legendshop.central.license.LicenseEnum; import com.legendshop.central.license.LicenseHelper; import com.legendshop.event.EventContext; import com.legendshop.event.processor.BaseProcessor; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; public class LicenseStatusCheckProcessor extends BaseProcessor<EventContext> { public void process(EventContext paramEventContext) { String str1 = paramEventContext.getHttpRequest().getParameter("liensekey"); String str2 = LicenseHelper.updateLicense(paramEventContext.getHttpRequest().getSession().getServletContext(), str1); if (LicenseEnum.isNormal(str2)) paramEventContext.setResponse(Boolean.valueOf(true)); } }
Java
package com.legendshop.central.event; import com.legendshop.central.license.LSResponse; import com.legendshop.central.license.LicenseEnum; import com.legendshop.central.license.LicenseHelper; import com.legendshop.event.EventContext; import com.legendshop.event.processor.BaseProcessor; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class FunctionCheckProcessor extends BaseProcessor<EventContext> { private static Logger _$1 = LoggerFactory.getLogger(FunctionCheckProcessor.class); public void process(EventContext paramEventContext) { Boolean localBoolean = Boolean.valueOf(true); String str1 = (String)paramEventContext.getRequest(); LSResponse localLSResponse = (LSResponse)paramEventContext.getHttpRequest().getSession().getServletContext().getAttribute("LEGENSHOP_LICENSE"); if (localLSResponse == null) try { localLSResponse = LicenseHelper.getPersistedResopnse(); } catch (Exception localException) { } if (localLSResponse != null) { String str2 = localLSResponse.getLicense(); if ((LicenseEnum.FREE.name().equals(str2)) || (LicenseEnum.UNKNOWN.name().equals(str2))) { _$1.debug("user name = {} did not have function on this componment", str1); localBoolean = Boolean.valueOf(false); } } paramEventContext.setResponse(localBoolean); } }
Java
package com.legendshop.central.event; import com.legendshop.central.dao.CentralDao; import com.legendshop.central.license.LSResponse; import com.legendshop.central.license.LicenseEnum; import com.legendshop.core.constant.ParameterEnum; import com.legendshop.core.helper.PropertiesUtil; import com.legendshop.event.EventContext; import com.legendshop.event.processor.BaseProcessor; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; public class CanAddShopDetailProcessor extends BaseProcessor<EventContext> { private CentralDao _$1; public void process(EventContext paramEventContext) { LSResponse localLSResponse = (LSResponse)paramEventContext.getHttpRequest().getSession().getServletContext().getAttribute("LEGENSHOP_LICENSE"); if (!((Boolean)PropertiesUtil.getObject(ParameterEnum.OPEN_SHOP, Boolean.class)).booleanValue()) { paramEventContext.setResponse(Boolean.valueOf(false)); return; } Integer localInteger = null; if (localLSResponse == null) { localInteger = _$1(null, LicenseEnum.FREE); } else { String str = localLSResponse.getLicense(); if (LicenseEnum.instance(str)) localInteger = _$1(localLSResponse, LicenseEnum.valueOf(str)); else localInteger = _$1(localLSResponse, LicenseEnum.FREE); } if (localInteger == null) { paramEventContext.setResponse(Boolean.valueOf(true)); return; } paramEventContext.setResponse(Boolean.valueOf(localInteger.intValue() > _$1().longValue())); } private Integer _$1(LSResponse paramLSResponse, LicenseEnum paramLicenseEnum) { if ((paramLSResponse != null) && (paramLSResponse.getShopCount() != null)) return paramLSResponse.getShopCount(); if ((LicenseEnum.B2C_YEAR.equals(paramLicenseEnum)) || (LicenseEnum.C2C_YEAR.equals(paramLicenseEnum))) return Integer.valueOf(100); if ((LicenseEnum.FREE.equals(paramLicenseEnum)) || (LicenseEnum.EXPIRED.equals(paramLicenseEnum))) return Integer.valueOf(10); if ((LicenseEnum.B2C_ALWAYS.equals(paramLicenseEnum)) || (LicenseEnum.C2C_ALWAYS.equals(paramLicenseEnum))) return null; return Integer.valueOf(0); } private Long _$1() { return this._$1.getMaxShopDetail(); } public void setCentralDao(CentralDao paramCentralDao) { this._$1 = paramCentralDao; } }
Java
package com.legendshop.central.event; import com.legendshop.central.license.LSResponse; import com.legendshop.central.license.LicenseEnum; import com.legendshop.event.EventContext; import com.legendshop.event.processor.BaseProcessor; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; public class NeedUpgradeCheckProcessor extends BaseProcessor<EventContext> { public void process(EventContext paramEventContext) { LSResponse localLSResponse = (LSResponse)paramEventContext.getHttpRequest().getSession().getServletContext().getAttribute("LEGENSHOP_LICENSE"); if (localLSResponse != null) { String str = localLSResponse.getLicense(); if ((LicenseEnum.instance(str)) && (LicenseEnum.needUpgrade(str))) paramEventContext.setResponse(Boolean.valueOf(true)); } } }
Java
package com.legendshop.central.license; import java.io.Serializable; public class LSRequest extends DtoEntity implements Serializable { private static final long serialVersionUID = -2573903794153845729L; private String _$9; private String _$8; private String _$7; private String _$6; private String _$5; private String _$4; private String _$3; private String _$2; public String getIp() { return this._$9; } public void setIp(String paramString) { this._$9 = paramString; } public String getHostname() { return this._$8; } public void setHostname(String paramString) { this._$8 = paramString; } public String getDomainName() { return this._$7; } public void setDomainName(String paramString) { this._$7 = paramString; } public String getDate() { return this._$6; } public void setDate(String paramString) { this._$6 = paramString; } public String getBusinessMode() { return this._$5; } public void setBusinessMode(String paramString) { this._$5 = paramString; } public String getLanguage() { return this._$4; } public void setLanguage(String paramString) { this._$4 = paramString; } public String toString() { return "LSRequest:" + "ip=" + this._$9 + ",hostname=" + this._$8 + ",domainName=" + this._$7 + ",date=" + this._$6 + ",businessMode=" + this._$5 + ",language=" + this._$4 + ",version=" + this._$3 + ",licenseKey=" + this._$2; } public String getVersion() { return this._$3; } public void setVersion(String paramString) { this._$3 = paramString; } public String getLicenseKey() { return this._$2; } public void setLicenseKey(String paramString) { this._$2 = paramString; } }
Java
package com.legendshop.central.license; public class DtoEntity { private String _$1; public String getAction() { return this._$1; } public void setAction(String paramString) { this._$1 = paramString; } }
Java
package com.legendshop.central.license; import com.legendshop.core.constant.ConfigPropertiesEnum; import com.legendshop.core.helper.PropertiesUtil; import com.legendshop.util.AppUtils; import com.legendshop.util.TimerUtil; import com.legendshop.util.converter.ByteConverter; import com.legendshop.util.des.DES2; import com.legendshop.util.ip.LocalAddress; import com.legendshop.util.ip.LocalAddressUtil; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.HashMap; import java.util.Map; import javax.servlet.ServletContext; import net.sf.json.JSONObject; public class LicenseHelper { private static HttpClientLicenseHelper _$2 = new HttpClientLicenseHelper(); private static String _$1 = PropertiesUtil.getSystemRealPath() + "WEB-INF/license.out"; public static String getLicense(ServletContext paramServletContext) { LSResponse localLSResponse = (LSResponse)paramServletContext.getAttribute("LEGENSHOP_LICENSE"); if (LicenseEnum.UN_AUTH.name().equals(localLSResponse.getLicense())) return LicenseEnum.getValue(localLSResponse.getLicense()) + LicenseWarnMessage.EXPIRED_WARNING.value(); return null; } public static String checkLicense(ServletContext paramServletContext) throws Exception { String str = _$1(paramServletContext, "checkLicense", null); LSResponse localLSResponse = null; try { if (AppUtils.isNotBlank(str)) { JSONObject localJSONObject = JSONObject.fromObject(str); localLSResponse = (LSResponse)JSONObject.toBean(localJSONObject, LSResponse.class); persistResopnse(localLSResponse); return _$1(paramServletContext, localLSResponse); } return _$1(paramServletContext, getPersistedResopnse()); } catch (Exception localException) { } return _$1(paramServletContext, getPersistedResopnse()); } private static String _$1(ServletContext paramServletContext, LSResponse paramLSResponse) { if (paramLSResponse != null) { paramServletContext.setAttribute("LEGENSHOP_LICENSE", paramLSResponse); if (LicenseEnum.instance(paramLSResponse.getLicense())) paramServletContext.setAttribute("licenseDesc", LicenseEnum.valueOf(paramLSResponse.getLicense()).value()); return paramLSResponse.getLicense(); } return null; } public static void persistResopnse(LSResponse paramLSResponse) throws Exception { HashMap localHashMap = new HashMap(); localHashMap.put("resopnse", paramLSResponse); localHashMap.put("validate", AppUtils.getCRC32(paramLSResponse.toString())); FileOutputStream localFileOutputStream = null; ObjectOutputStream localObjectOutputStream = null; try { localFileOutputStream = new FileOutputStream(_$1); localObjectOutputStream = new ObjectOutputStream(localFileOutputStream); localObjectOutputStream.writeObject(localHashMap); } catch (Exception localException) { } finally { if (localObjectOutputStream != null) localObjectOutputStream.flush(); if (localFileOutputStream != null) localFileOutputStream.close(); } } public static LSResponse getPersistedResopnse() throws Exception { FileInputStream localFileInputStream = null; ObjectInputStream localObjectInputStream = null; try { localFileInputStream = new FileInputStream(_$1); localObjectInputStream = new ObjectInputStream(localFileInputStream); Map localMap = (Map)localObjectInputStream.readObject(); Long localLong1 = (Long)localMap.get("validate"); LSResponse localLSResponse1 = (LSResponse)localMap.get("resopnse"); Long localLong2 = AppUtils.getCRC32(localLSResponse1.toString()); if ((localLong1 != null) && (localLong1.equals(localLong2))) { LSResponse localLSResponse2 = localLSResponse1; return localLSResponse2; } } catch (Exception localException) { } finally { if (localObjectInputStream != null) localObjectInputStream.close(); if (localFileInputStream != null) localFileInputStream.close(); } return null; } public static String updateLicense(ServletContext paramServletContext, String paramString) { try { String str = _$1(paramServletContext, "updateLicense", paramString); if (AppUtils.isNotBlank(str)) { JSONObject localJSONObject = JSONObject.fromObject(str); LSResponse localLSResponse = (LSResponse)JSONObject.toBean(localJSONObject, LSResponse.class); return _$1(paramServletContext, localLSResponse); } } catch (Exception localException) { return null; } return null; } private static String _$1(ServletContext paramServletContext, String paramString1, String paramString2) { try { String str1 = PropertiesUtil.getLegendShopSystemId(); if (str1 == null) { DES2 localDES2 = new DES2(); str1 = ByteConverter.encode(localDES2.byteToString(localDES2.createEncryptor(TimerUtil.getStrDate()))); } DES2 localDES2 = new DES2(); String str2 = new String(localDES2.createDecryptor(localDES2.stringToByte(ByteConverter.decode(str1)))); LocalAddress localLocalAddress = LocalAddressUtil.getLocalAddress(); LSRequest localLSRequest = new LSRequest(); localLSRequest.setAction(paramString1); localLSRequest.setBusinessMode((String)paramServletContext.getAttribute("BUSINESS_MODE")); localLSRequest.setDomainName((String)paramServletContext.getAttribute("DOMAIN_NAME")); localLSRequest.setLanguage((String)paramServletContext.getAttribute("LANGUAGE_MODE")); localLSRequest.setHostname(localLocalAddress.getHostName()); localLSRequest.setIp(localLocalAddress.getIp()); localLSRequest.setDate(str2); localLSRequest.setVersion((String)paramServletContext.getAttribute(ConfigPropertiesEnum.LEGENDSHOP_VERSION.name())); if (paramString2 != null) localLSRequest.setLicenseKey(paramString2); String str3 = JSONObject.fromObject(localLSRequest).toString(); return _$2.postMethod(str3); } catch (Exception localException) { } return null; } }
Java
package com.legendshop.central.license; import javax.servlet.ServletContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class HealthCheckImpl implements HealthCheck { protected Logger log = LoggerFactory.getLogger(HealthCheckImpl.class); private int _$3 = 10800000; private final ServletContext _$2; private final boolean _$1 = true; public String check() { try { return LicenseHelper.checkLicense(this._$2); } catch (Exception localException) { } return LicenseEnum.UNKNOWN.name(); } public HealthCheckImpl(ServletContext paramServletContext) { this._$2 = paramServletContext; } public void run() { while (this._$2 != null) try { String str = check(); if (LicenseEnum.instance(str)) if ((LicenseEnum.UN_AUTH.name().equals(str)) || (LicenseEnum.EXPIRED.name().equals(str))) { this._$2.setAttribute("UN_AUTH_MSG", LicenseEnum.UN_AUTH.name()); } else { this._$2.setAttribute("UN_AUTH_MSG", "NORMAL"); this._$3 = 21600000; } Thread.sleep(this._$3); } catch (Exception localException) { this.log.error("HealthCheckImpl run", localException); } } }
Java
package com.legendshop.central.license; import com.legendshop.core.constant.StringEnum; public enum LicenseWarnMessage implements StringEnum { EXPIRED_WARNING(",请购买商业版权"), EXPIRED_ERROR(",已经过期,请购买商业版权"), SYSTEM_ERROR(",系统错误,请确认是否安装成功"); private final String _$2; private LicenseWarnMessage(String paramString) { this._$2 = paramString; } public String value() { return this._$2; } public static boolean instance(String paramString) { LicenseWarnMessage[] arrayOfLicenseWarnMessage1 = values(); for (LicenseWarnMessage localLicenseWarnMessage : arrayOfLicenseWarnMessage1) if (localLicenseWarnMessage.name().equals(paramString)) return true; return false; } public static String getValue(String paramString) { LicenseWarnMessage[] arrayOfLicenseWarnMessage1 = values(); for (LicenseWarnMessage localLicenseWarnMessage : arrayOfLicenseWarnMessage1) if (localLicenseWarnMessage.name().equals(paramString)) return localLicenseWarnMessage.value(); return null; } }
Java
package com.legendshop.central.license; import com.legendshop.core.exception.PermissionException; import java.io.IOException; import java.io.PrintStream; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; public class HttpClientLicenseHelper { private final String _$1; public HttpClientLicenseHelper() { // TODO 需要修改 this._$1 = "http://localhost:9090/license/query"; } public HttpClientLicenseHelper(String paramString) { this._$1 = (paramString + "/license/query"); } public String getMethod(String paramString) { //TODO 不知道拿来干啥,暂时先改成空 //Object localObject1 = null; String localObject1 = null; HttpClient localHttpClient = new HttpClient(); GetMethod localGetMethod = new GetMethod("http://localhost:9090/license/servlet/LicenseServlet?date=123x"); try { localHttpClient.executeMethod(localGetMethod); System.out.println(localGetMethod.getStatusLine()); System.out.println(localGetMethod.getStatusCode()); System.out.println(localGetMethod.getResponseBodyAsString()); } catch (HttpException localHttpException) { } catch (IOException localIOException) { } catch (PermissionException localPermissionException) { throw localPermissionException; } finally { localGetMethod.releaseConnection(); } return localObject1; } public String postMethod(String paramString) { String str = null; HttpClient localHttpClient = new HttpClient(); PostMethod localPostMethod = new PostMethod(this._$1); NameValuePair[] arrayOfNameValuePair = new NameValuePair[1]; arrayOfNameValuePair[0] = new NameValuePair("_ENTITY", paramString); localPostMethod.addParameters(arrayOfNameValuePair); try { localHttpClient.executeMethod(localPostMethod); str = localPostMethod.getResponseBodyAsString(); } catch (Exception localException) { } finally { localPostMethod.releaseConnection(); } return str; } }
Java
package com.legendshop.central.license; import com.legendshop.core.constant.StringEnum; public enum BusinessModeEnum implements StringEnum { B2C("单用户"), C2C("多用户"); private final String _$2; private BusinessModeEnum(String paramString) { this._$2 = paramString; } public String value() { return this._$2; } public static boolean instance(String paramString) { BusinessModeEnum[] arrayOfBusinessModeEnum1 = values(); for (BusinessModeEnum localBusinessModeEnum : arrayOfBusinessModeEnum1) if (localBusinessModeEnum.name().equals(paramString)) return true; return false; } public static String getValue(String paramString) { BusinessModeEnum[] arrayOfBusinessModeEnum1 = values(); for (BusinessModeEnum localBusinessModeEnum : arrayOfBusinessModeEnum1) if (localBusinessModeEnum.name().equals(paramString)) return localBusinessModeEnum.value(); return null; } }
Java
package com.legendshop.central.license; import java.io.Serializable; public class LSResponse extends DtoEntity implements Serializable { private static final long serialVersionUID = 5411216601389890098L; private String _$8; private String _$7; private String _$6; private String _$5; private String _$4; private String _$3; private Integer _$2 = Integer.valueOf(10); public String getIp() { return this._$8; } public void setIp(String paramString) { this._$8 = paramString; } public String getHostname() { return this._$7; } public void setHostname(String paramString) { this._$7 = paramString; } public String getDomainName() { return this._$6; } public void setDomainName(String paramString) { this._$6 = paramString; } public String getExpireDate() { return this._$5; } public void setExpireDate(String paramString) { this._$5 = paramString; } public String getNewestVersion() { return this._$4; } public void setNewestVersion(String paramString) { this._$4 = paramString; } public String getLicense() { return this._$3; } public void setLicense(String paramString) { this._$3 = paramString; } public Integer getShopCount() { return this._$2; } public void setShopCount(Integer paramInteger) { this._$2 = paramInteger; } public String toString() { return "response:" + this._$8 + this._$7 + this._$6 + this._$5 + this._$4 + this._$3 + this._$2; } }
Java
package com.legendshop.central.license; import com.legendshop.core.constant.StringEnum; public enum LicenseEnum implements StringEnum { B2C_ALWAYS("单用户终身正式版"), C2C_ALWAYS("多用户终身正式版"), B2C_YEAR("单用户年度正式版"), C2C_YEAR("多用户年度正式版"), FREE("免费版"), EXPIRED("免费版"), UNKNOWN("未知版本"), UN_AUTH("未授权系统"); private final String _$2; private LicenseEnum(String paramString) { this._$2 = paramString; } public String value() { return this._$2; } public static boolean instance(String paramString) { LicenseEnum[] arrayOfLicenseEnum1 = values(); for (LicenseEnum localLicenseEnum : arrayOfLicenseEnum1) if (localLicenseEnum.name().equals(paramString)) return true; return false; } public static boolean needUpgrade(String paramString) { LicenseEnum[] arrayOfLicenseEnum1 = { B2C_ALWAYS, C2C_ALWAYS }; for (LicenseEnum localLicenseEnum : arrayOfLicenseEnum1) if (localLicenseEnum.name().equals(paramString)) return false; return true; } public static boolean isNormal(String paramString) { LicenseEnum[] arrayOfLicenseEnum1 = { B2C_ALWAYS, C2C_ALWAYS, B2C_YEAR, C2C_YEAR }; for (LicenseEnum localLicenseEnum : arrayOfLicenseEnum1) if (localLicenseEnum.name().equals(paramString)) return true; return false; } public static String getValue(String paramString) { LicenseEnum[] arrayOfLicenseEnum1 = values(); for (LicenseEnum localLicenseEnum : arrayOfLicenseEnum1) if (localLicenseEnum.name().equals(paramString)) return localLicenseEnum.value(); return null; } }
Java
package com.legendshop.central.license; public abstract interface HealthCheck extends Runnable { public abstract String check(); }
Java
package com.legendshop.central.dao.impl; import com.legendshop.central.dao.CentralDao; import com.legendshop.core.dao.impl.BaseDaoImpl; public class CentralDaoImpl extends BaseDaoImpl implements CentralDao { public Long getMaxShopDetail() { return (Long)findUniqueBy("select count(*) from ShopDetail sd where sd.status = 1", Long.class, new Object[0]); } }
Java
package com.legendshop.central.dao; public abstract interface CentralDao { public abstract Long getMaxShopDetail(); }
Java
package com.legendshop.central; import com.legendshop.core.plugins.Plugin; import com.legendshop.core.plugins.PluginConfig; import javax.servlet.ServletContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CentralPlugin implements Plugin { private final Logger _$2 = LoggerFactory.getLogger(CentralPlugin.class); private PluginConfig _$1; public void bind(ServletContext paramServletContext) { this._$2.info("binding CentralPlugin config"); HealthCheckerHolder.isInitialized(paramServletContext); } public void unbind(ServletContext paramServletContext) { } public PluginConfig getPluginConfig() { return this._$1; } public void setPluginConfig(PluginConfig paramPluginConfig) { this._$1 = paramPluginConfig; } }
Java
package com.legendshop.util; import java.io.IOException; import java.util.Enumeration; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletResponse; public class LanguageFilter implements Filter { FilterConfig _$1; public void doFilter(ServletRequest paramServletRequest, ServletResponse paramServletResponse, FilterChain paramFilterChain) throws IOException, ServletException { HttpServletResponse localHttpServletResponse = (HttpServletResponse) paramServletResponse; Enumeration localEnumeration = this._$1.getInitParameterNames(); while (localEnumeration.hasMoreElements()) { String str = (String) localEnumeration.nextElement(); localHttpServletResponse.setHeader(str, this._$1.getInitParameter(str)); } paramFilterChain .doFilter(paramServletRequest, localHttpServletResponse); } public void init(FilterConfig paramFilterConfig) { this._$1 = paramFilterConfig; } public void destroy() { this._$1 = null; } }
Java
package com.legendshop.util; import java.io.File; public class FileTimeWrapper implements Comparable<Object> { private File file; public FileTimeWrapper(File file) { this.file = file; } public int compareTo(Object obj) { if (obj instanceof FileTimeWrapper) { FileTimeWrapper fileTimeWrapper = (FileTimeWrapper) obj; if (this.file.lastModified() - fileTimeWrapper.getFile().lastModified() > 0L) { return -1; } else if (this.file.lastModified() - fileTimeWrapper.getFile().lastModified() < 0L) { return 1; } else { return 0; } } else { throw new AssertionError(); } } public File getFile() { return this.file; } }
Java
package com.legendshop.util; import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.List; public class DateUtil { public static final String CM_LONG_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static final String CM_SHORT_DATE_FORMAT = "yyyyMMdd"; public static final String CM_SHORT_MONTH_FORMAT = "yyyy-MM"; public static final String CM_SHORT_YEAR_FORMAT = "yyyy"; public static final String YEAR_MONTH = "yyyyMM"; public static final String[] MONTH = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; public static final String[] DAY = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; public static DateFormat dateFormat = DateFormat .getDateInstance(0); public static String getToday() { java.util.Date localDate = new java.util.Date(); String str = DateToString(localDate, "yyyyMMdd"); return str; } public static long getTodayInTimeFormat() { java.util.Date localDate = new java.util.Date(); long l = localDate.getTime(); return l; } public static String getNowYear() { java.util.Date localDate = new java.util.Date(); String str = DateToString(localDate, "yyyy"); return str; } public static Timestamp getNowTime() { return new Timestamp(System.currentTimeMillis()); } public static String getMonth() { java.util.Date localDate = new java.util.Date(); String str = DateToString(localDate, "yyyy-MM"); return str; } public static String getMonth(String paramString) { java.util.Date localDate = new java.util.Date(); String str = DateToString(localDate, paramString); return str; } public static String getNextMonth() { java.util.Date localDate = new java.util.Date(); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); localCalendar.add(2, 1); String str = DateToString(localCalendar.getTime(), "yyyy-MM"); return str; } public static String getNextMonth(String paramString) { java.util.Date localDate = new java.util.Date(); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); localCalendar.add(2, 1); String str = DateToString(localCalendar.getTime(), paramString); return str; } public static java.sql.Date getMonthDate(java.util.Date paramDate, int paramInt) { Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(paramDate); localCalendar.add(2, paramInt); java.util.Date localDate = localCalendar.getTime(); return new java.sql.Date(localDate.getTime()); } public static String getUpMonth() { java.util.Date localDate = new java.util.Date(); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); localCalendar.add(2, -1); String str = DateToString(localCalendar.getTime(), "yyyy-MM"); return str; } public static String getUpMonth(String paramString1, String paramString2, String paramString3) { java.sql.Date localDate = getDate(paramString1, paramString2, "01"); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); localCalendar.add(2, -1); String str = DateToString(localCalendar.getTime(), paramString3); return str; } public static String getNextMonth(String paramString1, String paramString2, String paramString3) { java.sql.Date localDate = getDate(paramString1, paramString2, "01"); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); localCalendar.add(2, 1); String str = DateToString(localCalendar.getTime(), paramString3); return str; } public static List getYear(java.util.Date paramDate, int paramInt) { ArrayList localArrayList = new ArrayList(); Calendar localCalendar = Calendar.getInstance(); int i = Math.abs(paramInt); int j; String str; if (paramInt >= 0) for (j = 0; j < paramInt; j++) { localCalendar.setTime(paramDate); localCalendar.add(1, j); str = DateToString(localCalendar.getTime(), "yyyy"); localArrayList.add(str); } else for (j = 1; j <= i; j++) { localCalendar.setTime(paramDate); localCalendar.add(1, -j); str = DateToString(localCalendar.getTime(), "yyyy"); localArrayList.add(str); } return localArrayList; } public static String getTomorrow() { java.util.Date localDate = new java.util.Date(); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); localCalendar.add(5, 1); String str = DateToString(localCalendar.getTime(), "yyyyMMdd"); return str; } public static String getDayAfterTomorrow() { java.util.Date localDate = new java.util.Date(); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); localCalendar.add(5, 2); String str = DateToString(localCalendar.getTime(), "yyyyMMdd"); return str; } public static String getYesterday() { java.util.Date localDate = new java.util.Date(); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); localCalendar.add(5, -1); String str = DateToString(localCalendar.getTime(), "yyyyMMdd"); return str; } public static String getFullDateString(String paramString) { java.util.Date localDate = StringToDate(paramString); return dateFormat.format(localDate); } public static String DateToString(java.util.Date paramDate, String paramString) { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( paramString); return localSimpleDateFormat.format(paramDate); } public static java.util.Date StringToDate(String paramString) { java.util.Date localDate = new java.util.Date(); SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "yyyyMMdd"); try { localDate = localSimpleDateFormat.parse(paramString); } catch (ParseException localParseException) { localParseException.printStackTrace(); } return localDate; } public static java.util.Date StringToDate(String paramString1, String paramString2) { java.util.Date localDate = new java.util.Date(); SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( paramString2); try { localDate = localSimpleDateFormat.parse(paramString1); } catch (ParseException localParseException) { localParseException.printStackTrace(); } return localDate; } public static String getEndDate(String paramString, int paramInt) { Calendar localCalendar = Calendar.getInstance(); java.util.Date localDate = StringToDate(paramString); localCalendar.setTime(localDate); localCalendar.add(5, paramInt); return DateToString(localCalendar.getTime(), "yyyyMMdd"); } public static String getEndDateForSQLDate(String paramString, int paramInt) { Calendar localCalendar = Calendar.getInstance(); java.util.Date localDate = StringToDateByFormat(paramString, "yyyyMMdd"); localCalendar.setTime(localDate); localCalendar.add(5, paramInt); return DateToString(localCalendar.getTime(), "yyyyMMdd"); } public static java.util.Date StringToDateByFormat(String paramString1, String paramString2) { java.util.Date localDate = new java.util.Date(); SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( paramString2); try { localDate = localSimpleDateFormat.parse(paramString1); } catch (ParseException localParseException) { localParseException.printStackTrace(); } return localDate; } public static List getEndWeekDayOfMonth(String paramString1, String paramString2) { ArrayList localArrayList = new ArrayList(); String str = ""; int i = daysInMonth(paramString1, paramString2); int j = 0; for (int k = 1; k <= i; k++) { j = getWeekOfMonth(paramString1, paramString2, String.valueOf(k)); if (j != 5) continue; if (k < 10) localArrayList.add(paramString1 + paramString2 + "0" + String.valueOf(k)); else localArrayList.add(paramString1 + paramString2 + String.valueOf(k)); } for (int k = 0; k < localArrayList.size(); k++) System.out.println("end week list[" + k + "]:" + localArrayList.get(k)); return localArrayList; } public static int daysInMonth(String paramString1, String paramString2) { int i = Integer.parseInt(paramString1); int j = Integer.parseInt(paramString2); GregorianCalendar localGregorianCalendar = new GregorianCalendar(i, j, 0); int[] arrayOfInt = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; arrayOfInt[1] += (localGregorianCalendar .isLeapYear(localGregorianCalendar.get(1)) ? 1 : 0); return arrayOfInt[localGregorianCalendar.get(2)]; } public static int getWeekOfMonth(String paramString1, String paramString2, String paramString3) { java.sql.Date localDate = getDate(paramString1, paramString2, paramString3); int i = 0; try { Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); i = localCalendar.get(7); if (i <= 1) i = 7; else i -= 1; } catch (Exception localException) { localException.printStackTrace(); } return i; } public static java.sql.Date getDate(String paramString1, String paramString2, String paramString3) { java.sql.Date localDate = null; try { String str = paramString1 + "-" + paramString2 + "-" + paramString3; SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd"); java.util.Date localDate1 = localSimpleDateFormat.parse(str); localDate = new java.sql.Date(localDate1.getTime()); } catch (Exception localException) { System.out.println("Exception " + localException); } return localDate; } public static String getFirstDayOfMonth() { StringBuffer localStringBuffer = new StringBuffer(); String str = getToday(); localStringBuffer.append(str.substring(0, 6)).append("01"); return localStringBuffer.toString(); } public static long getFirstDayOfMonthInTimeFormat() { StringBuffer localStringBuffer = new StringBuffer(); String str = getToday(); localStringBuffer.append(str.substring(0, 6)).append("01"); long l = StringToDateByFormat(localStringBuffer.toString(), "yyyyMMdd") .getTime(); return l; } public static String getFirstDayOfOffsetMonth(int paramInt) { StringBuffer localStringBuffer = new StringBuffer(); java.util.Date localDate = new java.util.Date(); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); localCalendar.add(2, paramInt); String str = DateToString(localCalendar.getTime(), "yyyyMM"); localStringBuffer.append(str).append("01"); return localStringBuffer.toString(); } public static long StingToLong(String paramString) { return StringToDateByFormat(paramString, "yyyyMMdd").getTime(); } public static long StingToLong(String paramString1, String paramString2) { return StringToDateByFormat(paramString1, paramString2).getTime(); } public static String getEndDateOfUpMonth(java.util.Date paramDate) { StringBuffer localStringBuffer = new StringBuffer(); String str1 = DateToString(paramDate, "yyyyMMdd"); String str2 = getUpMonth(str1.substring(0, 4), str1.substring(4, 6), "yyyyMM"); localStringBuffer.append(str2).append( daysInMonth(str2.substring(0, 4), str2.substring(4))); str1 = localStringBuffer.toString(); localStringBuffer = null; return str1; } public static String getEndDateOfNextMonth(java.util.Date paramDate) { StringBuffer localStringBuffer = new StringBuffer(); String str1 = DateToString(paramDate, "yyyyMMdd"); String str2 = getNextMonth(str1.substring(0, 4), str1.substring(4, 6), "yyyyMM"); localStringBuffer.append(str2).append( daysInMonth(str2.substring(0, 4), str2.substring(4))); str1 = localStringBuffer.toString(); localStringBuffer = null; return str1; } public static java.util.Date add(java.util.Date paramDate, int paramInt, long paramLong) { Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(paramDate); localCalendar.add(paramInt, (int) paramLong); return localCalendar.getTime(); } public static String getFirstDayOfOffsetMonth(String paramString1, String paramString2, int paramInt) { java.util.Date localDate = StringToDate(paramString1, paramString2); Calendar localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); localCalendar.set(5, 1); localCalendar.add(2, paramInt); String str = DateToString(localCalendar.getTime(), "yyyyMMdd"); return str; } public static java.util.Date getFirstDayOfMonth(String paramString1, String paramString2) { return null; } }
Java
package com.legendshop.util.xml; import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.io.StringReader; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.dom4j.Document; import org.dom4j.Node; import org.dom4j.io.SAXReader; import org.springframework.core.io.ClassPathResource; public class Configure { private Document _$4 = null; private Node _$3 = null; private String _$2 = null; private List<Node> _$1 = null; public void parse(String paramString) throws ConfigException { _$2(paramString); } public void parseXmlStr(String paramString) throws ConfigException { _$1(paramString); } public String currentPath() { return this._$2; } public void changePath(String paramString) throws ConfigException { this._$2 = paramString; this._$3 = this._$4.selectSingleNode(paramString); if (this._$3 == null) throw new ConfigException(paramString + " not found."); } public String getItemProp(String paramString) throws ConfigException { String str = this._$3.valueOf('@' + paramString); if (str == null) throw new ConfigException(paramString + " not found"); return str; } public String getItemProp(String paramString1, String paramString2) throws ConfigException { changePath(paramString1); return getItemProp(paramString2); } @Deprecated public String getItemProp(String paramString1, String paramString2, int paramInt) throws ConfigException { this._$1 = this._$4.selectNodes(paramString1); try { this._$3 = ((Node) this._$1.get(paramInt)); if (this._$3 == null) throw new ConfigException("the index =" + paramInt + " node of " + paramString1 + " not found!"); } catch (Exception localException) { throw new ConfigException("the index =" + paramInt + " node of " + paramString1 + " not found!" + localException); } String str = this._$3.valueOf(paramString2); if (str == null) throw new ConfigException(paramString2 + " not found"); return str; } public List<String> getItemPropList(String paramString) throws ConfigException { LinkedList localLinkedList = new LinkedList(); this._$1 = this._$4.selectNodes(this._$2); Iterator localIterator = this._$1.iterator(); while (localIterator.hasNext()) { Node localNode = (Node) localIterator.next(); String str = localNode.valueOf('@' + paramString); if ((str != null) && (!str.equals(""))) localLinkedList.add(str); } return localLinkedList; } public List<String> getItemPropList(String paramString1, String paramString2) throws ConfigException { this._$2 = paramString1; this._$1 = this._$4.selectNodes(paramString1); return getItemPropList(paramString2); } @Deprecated public List getItemPropList(String paramString1, String paramString2, String paramString3, int paramInt) throws ConfigException { try { this._$1 = this._$4.selectNodes(paramString1); this._$3 = ((Node) this._$1.get(paramInt)); if (this._$3 == null) throw new ConfigException("the index =" + paramInt + " node of " + paramString1 + " not found!"); } catch (Exception localException) { throw new ConfigException("the index =" + paramInt + " node of " + paramString1 + " not found!" + localException); } this._$1 = this._$3.selectNodes(paramString2); ArrayList localArrayList = new ArrayList(); Iterator localIterator = this._$1.iterator(); while (localIterator.hasNext()) { Node localNode = (Node) localIterator.next(); String str = localNode.valueOf('@' + paramString3); if ((str != null) && (!str.equals(""))) localArrayList.add(str); } return localArrayList; } public String getItemValueEx(String paramString1, String paramString2, String paramString3) { String str = null; try { getItemValue(paramString1, paramString2); } catch (Exception localException) { str = paramString3; } return str; } public String getItemValueEx(String paramString1, String paramString2, String paramString3, String paramString4) { String str = null; try { str = getItemValue(paramString1, paramString2, paramString3); } catch (Exception localException) { str = paramString4; } return str; } public String getItemValue(String paramString1, String paramString2, String paramString3) throws ConfigException { String str = null; try { str = getItemValue(paramString1, paramString3); } catch (Exception localException) { str = getItemValue(paramString2, paramString3); } return str; } public String getItemValue(String paramString1, String paramString2) throws ConfigException { changePath(paramString1); return getItemValue(paramString2); } @Deprecated public String getItemValue(String paramString1, String paramString2, int paramInt) throws ConfigException { this._$1 = this._$4.selectNodes(paramString1); try { this._$3 = ((Node) this._$1.get(paramInt)); if (this._$3 == null) throw new ConfigException("the index =" + paramInt + " node of " + paramString1 + " not found!"); } catch (Exception localException) { throw new ConfigException("the index =" + paramInt + " node of " + paramString1 + " not found!" + localException); } Node localNode = this._$3.selectSingleNode("./" + paramString2); if (localNode == null) throw new ConfigException(paramString2 + " not found"); return localNode.getText(); } public String getItemValue(String paramString) throws ConfigException { if ((this._$2 != null) && (!this._$2.equals(""))) this._$3 = this._$4.selectSingleNode(this._$2); Node localNode = this._$3.selectSingleNode("./" + paramString); if (localNode == null) throw new ConfigException(paramString + " not found"); return localNode.getText(); } public String getItemValue() throws ConfigException { String str = this._$3.getText(); if (str == null) throw new ConfigException("data error ,curPath has something wrong"); return str; } public List<String> getItemValueList(String paramString) throws ConfigException { LinkedList localLinkedList = new LinkedList(); Iterator localIterator1 = this._$1.iterator(); while (localIterator1.hasNext()) { Node localNode1 = (Node) localIterator1.next(); List localList = localNode1.selectNodes("./" + paramString); Iterator localIterator2 = localList.iterator(); while (localIterator2.hasNext()) { Node localNode2 = (Node) localIterator2.next(); localLinkedList.add(localNode2.getText()); } } return localLinkedList; } public List<String> getItemValueListWithFullPath(String paramString) throws ConfigException { List localList = this._$3.selectNodes(paramString); LinkedList localLinkedList = new LinkedList(); Iterator localIterator = localList.iterator(); while (localIterator.hasNext()) { Node localNode = (Node) localIterator.next(); localLinkedList.add(localNode.getText()); } return localLinkedList; } public List getItemValueList(String paramString1, String paramString2) throws ConfigException { this._$1 = this._$4.selectNodes(paramString1); return getItemValueList(paramString2); } @Deprecated public List getItemValueList(String paramString1, String paramString2, int paramInt) throws ConfigException { this._$1 = this._$4.selectNodes(paramString1); try { this._$3 = ((Node) this._$1.get(paramInt)); if (this._$3 == null) throw new ConfigException("the index =" + paramInt + " node of " + paramString1 + " not found!"); } catch (Exception localException) { throw new ConfigException("the index =" + paramInt + " node of " + paramString1 + " not found!" + localException); } ArrayList localArrayList = new ArrayList(); List localList = this._$3.selectNodes("./" + paramString2); Iterator localIterator = localList.iterator(); while (localIterator.hasNext()) { Node localNode = (Node) localIterator.next(); localArrayList.add(localNode.getText()); } return localArrayList; } public int getItemCount(String paramString) throws ConfigException { changePath(paramString); return getItemCount(); } public int getItemCount() { try { List localList = this._$3.selectNodes("./*"); if (localList != null) return localList.size(); return 0; } catch (Exception localException) { System.out.println(" Cofigure getItemCount fail : " + localException.toString()); } return 0; } public HashMap getItem(String paramString) throws ConfigException { changePath(paramString); return getItem(); } public HashMap<String, String> getItem() throws ConfigException { List localList = this._$3.selectNodes("./*"); HashMap localHashMap = new HashMap(); Iterator localIterator = localList.iterator(); while (localIterator.hasNext()) { Node localNode = (Node) localIterator.next(); localHashMap.put(localNode.getName(), localNode.getText()); } return localHashMap; } public List getItemNameList(String paramString) throws ConfigException { changePath(paramString); return getItemNameList(); } public List getItemNameList() throws ConfigException { List localList = this._$3.selectNodes("./*"); LinkedList localLinkedList = new LinkedList(); Iterator localIterator = localList.iterator(); while (localIterator.hasNext()) { Node localNode = (Node) localIterator.next(); localLinkedList.add(localNode.getName()); } return localLinkedList; } private void _$2(String paramString) throws ConfigException { SAXReader localSAXReader = new SAXReader(); Document localDocument = null; try { localDocument = localSAXReader.read(getFile(paramString)); } catch (Exception localException) { throw new ConfigException("解析XML文件出错", localException); } this._$4 = localDocument; this._$3 = this._$4.getRootElement(); } public void parse(File paramFile) throws ConfigException { SAXReader localSAXReader = new SAXReader(); Document localDocument = null; try { localDocument = localSAXReader.read(paramFile); } catch (Exception localException) { throw new ConfigException("解析XML文件出错", localException); } this._$4 = localDocument; this._$3 = this._$4.getRootElement(); } private void _$1(String paramString) throws ConfigException { SAXReader localSAXReader = new SAXReader(); Document localDocument = null; try { localDocument = localSAXReader.read(new StringReader(paramString)); } catch (Exception localException) { throw new ConfigException("解析XML字符串出错", localException); } this._$4 = localDocument; this._$3 = this._$4.getRootElement(); } public File getFile(String paramString) throws IOException { File localFile = null; if (paramString.startsWith("classpath")) { int i = paramString.indexOf(":"); String str = paramString.substring(i + 1); ClassPathResource localClassPathResource = new ClassPathResource( str); localFile = localClassPathResource.getFile(); } else { localFile = new File(paramString); } return localFile; } }
Java
package com.legendshop.util.xml; public class ConfigException extends Exception { private static final long serialVersionUID = 2878865248118400325L; public ConfigException() { } public ConfigException(String paramString) { super(paramString); } public ConfigException(String paramString, Throwable paramThrowable) { super(paramString, paramThrowable); } }
Java
package com.legendshop.util; import java.io.PrintStream; import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import org.apache.log4j.Logger; public class TimerUtil { private static final Logger _$2 = Logger .getRootLogger(); private static String _$1 = "yyyy-MM-dd"; public static String TIME_MIN = "MIN"; public static String TIME_HOUR = "HOUR"; public static String TIME_DAY = "DAY"; public static String TIME_MONTH = "MONTH"; public static String TIME_YEAR = "YEAR"; public static String MID_DATA_FORMAT; public static Calendar calendar = new GregorianCalendar(); public static DateFormat dateFormat; public static String JAVA_DATE_FORMAT = "yyyy:MM:dd HH:mm:ss"; public static String ORACLE_DATE_FORMAT = "YYYY:MM:DD HH24:mi:ss"; public static String MSSQLSERVER_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; public TimerUtil() { } public TimerUtil(String paramString) { _$1 = paramString; } public String getStrCurrentDate() { String str = null; try { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat(_$1); str = localSimpleDateFormat.format(new Date()); } catch (Exception localException) { _$2.error(localException.getMessage()); } return str; } public long getTimeToLong(String paramString) { Date localDate = null; try { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat(_$1); ParsePosition localParsePosition = new ParsePosition(0); localDate = localSimpleDateFormat.parse(paramString, localParsePosition); } catch (Exception localException) { _$2.error(localException.getMessage()); } return localDate.getTime(); } public static Date getCurrentDate() { return new Date(); } public static Date getNowDateShort() { Date localDate1 = new Date(); SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd"); String str = localSimpleDateFormat.format(localDate1); ParsePosition localParsePosition = new ParsePosition(0); Date localDate2 = localSimpleDateFormat.parse(str, localParsePosition); return localDate2; } public static String getStrDate() { Date localDate = new Date(); SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); String str = localSimpleDateFormat.format(localDate); return str; } public static String getStrDateShort() { Date localDate = new Date(); SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd"); String str = localSimpleDateFormat.format(localDate); return str; } public static Date strToDate(String paramString) { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); ParsePosition localParsePosition = new ParsePosition(0); Date localDate = localSimpleDateFormat.parse(paramString, localParsePosition); return localDate; } public static String dateToStr(Date paramDate) { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); String str = localSimpleDateFormat.format(paramDate); return str; } public static String dateToStrShort(Date paramDate) { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd"); String str = localSimpleDateFormat.format(paramDate); return str; } public static Date strToDateShort(String paramString) { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd"); ParsePosition localParsePosition = new ParsePosition(0); Date localDate = localSimpleDateFormat.parse(paramString, localParsePosition); return localDate; } public static Date getLastDate(long paramLong) { Date localDate1 = new Date(); long l = localDate1.getTime() - 122400000L * paramLong; Date localDate2 = new Date(l); return localDate2; } public static Date getDate(Date paramDate, Integer paramInteger, String paramString) { if (paramInteger != null) return getDate(paramDate, paramInteger.intValue(), paramString); return paramDate; } public static Date getDate(Date paramDate, int paramInt, String paramString) { calendar.setTime(paramDate); if (paramString.equalsIgnoreCase(TIME_MIN)) calendar.add(12, paramInt); else if (paramString.equalsIgnoreCase(TIME_HOUR)) calendar.add(11, paramInt); else if (paramString.equalsIgnoreCase(TIME_DAY)) calendar.add(5, paramInt); else if (paramString.equalsIgnoreCase(TIME_MONTH)) calendar.add(2, paramInt); else if (paramString.equalsIgnoreCase(TIME_YEAR)) calendar.add(1, paramInt); return calendar.getTime(); } public static String getOracleDateStr(Date paramDate) { if (paramDate == null) return null; SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( JAVA_DATE_FORMAT); String str = localSimpleDateFormat.format(paramDate); return str; } public static String getSqlServerDateStr(Date paramDate) { if (paramDate == null) return null; SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( MSSQLSERVER_DATE_FORMAT); String str = localSimpleDateFormat.format(paramDate); return str; } public static void main(String[] paramArrayOfString) { TimerUtil localTimerUtil = new TimerUtil("yyyy-MM-dd HH:mm:ss"); Date localDate1 = new Date(); Date localDate2 = getCurrentDate(); Date localDate3 = strToDateShort("2006-12-12"); long l = localDate3.getTime(); System.out.println("getNowDay==" + localTimerUtil); System.out.println("nowLong==" + l); System.out.println("date ==" + dateToStr(localDate1)); System.out.println("date111==" + dateToStr(getDate(localDate1, 100, TIME_YEAR))); } static { MID_DATA_FORMAT = "yyyy-MM-dd"; dateFormat = new SimpleDateFormat(MID_DATA_FORMAT); } }
Java
package com.legendshop.util; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.Serializable; import java.text.NumberFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.GregorianCalendar; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.CRC32; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.oro.text.regex.MalformedPatternException; public class AppUtils { private static Logger _$1 = Logger.getLogger(AppUtils.class); public static Locale getLocaleFromCookie( HttpServletRequest paramHttpServletRequest) { Locale localLocale = null; String str1 = null; String str2 = null; Cookie[] arrayOfCookie = paramHttpServletRequest.getCookies(); if (arrayOfCookie != null) for (int i = 0; i < arrayOfCookie.length; i++) { Cookie localObject = arrayOfCookie[i]; if ("Language".equals(localObject.getName())) { str2 = localObject.getValue(); _$1.debug("Found language cookie with value = " + str2); } else { if (!localObject.getName().equals("Country")) continue; str1 = localObject.getValue(); _$1.debug("Found country cookie with value = " + str1); } } if ((str1 != null) && (str2 != null)) localLocale = new Locale(str2, str1); return localLocale; } public static boolean isValidLocale(Locale paramLocale) { return (paramLocale.getLanguage().equals("zh")) || (paramLocale.getLanguage().equals("en")); } public static boolean isNotEmpty(String paramString) { return (paramString != null) && (paramString.length() > 0); } public static boolean isEmpty(String paramString) { return !isNotEmpty(paramString); } public static String cleanParam(Object paramObject) { String str = String.valueOf(paramObject); if ((str == null) || (str.equals("null"))) str = ""; return str.trim(); } public static boolean isValidString(String str) { String[] strArray = {"#", "&", "^", "%", "*", "/", "\\", "(", ")" }; for (String s : strArray) { if (str.indexOf(s) != -1) { return false; } } return true; } public static String trimToSummaryStr(String paramString) { int i = 40; if (isEmpty(paramString)) return paramString; if (paramString.length() > i) { String str = paramString.substring(0, paramString.indexOf(" ", i)); str = str + "..."; return str; } return paramString; } public static String getDisplayDate(Calendar paramCalendar) { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "MM/dd/yyyy"); if (paramCalendar != null) return localSimpleDateFormat.format(paramCalendar.getTime()); return ""; } public static Calendar str2Calendar(String paramString) { Calendar localCalendar = null; if (!isEmpty(paramString)) try { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( "MM/dd/yyyy"); Date localDate = localSimpleDateFormat.parse(paramString); localCalendar = Calendar.getInstance(); localCalendar.setTime(localDate); } catch (ParseException localParseException) { } return localCalendar; } public static String getCurrentDate() { return getDisplayDate(GregorianCalendar.getInstance()); } public static String col2Str(Collection paramCollection, String paramString) { StringBuffer localStringBuffer = new StringBuffer(); if ((paramCollection != null) && (!paramCollection.isEmpty())) { localStringBuffer.append(" Num of " + paramString + ": " + paramCollection.size() + " |"); Iterator localIterator = paramCollection.iterator(); while (localIterator.hasNext()) { Object localObject = localIterator.next(); localStringBuffer.append(" " + localObject.toString()); } } else { localStringBuffer.append(paramString + ": [null]"); } return localStringBuffer.toString(); } public static String getUrlPath(HttpServletRequest paramHttpServletRequest) { return getUrlRoot(paramHttpServletRequest) + paramHttpServletRequest.getContextPath(); } public static String getUrlRoot(HttpServletRequest paramHttpServletRequest) { String str1 = paramHttpServletRequest.getServerName(); int i = paramHttpServletRequest.getServerPort(); String str2 = "http://" + str1 + ":" + i; _$1.debug("URL root: " + str2); return str2; } public static String getGBString(String paramString) { try { return new String(paramString.getBytes("ISO-8859-1"), "GB2312"); } catch (Exception localException) { } return null; } public static String getISOString(String paramString) { try { return new String(paramString.getBytes("GB2312"), "ISO-8859-1"); } catch (Exception localException) { } return null; } public static String object2Str(Object paramObject) { if (paramObject != null) return paramObject.toString(); return null; } public static Integer str2Integer(String paramString) { Integer localInteger = null; try { if (paramString != null) localInteger = Integer.valueOf(paramString); } catch (NumberFormatException localNumberFormatException) { } return localInteger; } public static void printCollection(Collection paramCollection) { if (paramCollection != null) { Iterator localIterator = paramCollection.iterator(); _$1.debug("#size = : " + paramCollection.size()); while (localIterator.hasNext()) _$1.debug(localIterator.next().toString()); } } public static boolean isBlank(String paramString) { return (paramString == null) || (paramString.trim().length() <= 0); } public static boolean isNotBlank(String paramString) { return !isBlank(paramString); } public static boolean isBlank(Object[] paramArrayOfObject) { return (paramArrayOfObject == null) || (paramArrayOfObject.length <= 0); } public static boolean isNotBlank(Object[] paramArrayOfObject) { return !isBlank(paramArrayOfObject); } public static boolean isBlank(Object paramObject) { return (paramObject == null) || ("".equals(paramObject)); } public static boolean isNotBlank(Object paramObject) { return !isBlank(paramObject); } public static boolean isBlank(Collection paramCollection) { return (paramCollection == null) || (paramCollection.size() <= 0); } public static boolean isNotBlank(Collection paramCollection) { return !isBlank(paramCollection); } public static boolean isBlank(Set paramSet) { return (paramSet == null) || (paramSet.size() <= 0); } public static boolean isNotBlank(Set paramSet) { return !isBlank(paramSet); } public static boolean isBlank(Serializable paramSerializable) { return paramSerializable == null; } public static boolean isNotBlank(Serializable paramSerializable) { return !isBlank(paramSerializable); } public static boolean isBlank(Map paramMap) { return (paramMap == null) || (paramMap.size() <= 0); } public static boolean isNotBlank(Map paramMap) { return !isBlank(paramMap); } public static Object dto2Entity(Object paramObject1, Object paramObject2) { try { BeanUtils.copyProperties(paramObject2, paramObject1); } catch (Exception localException) { _$1.error("dto to entity error: " + localException); } return paramObject2; } public static Object entity2Dto(Object paramObject1, Object paramObject2) { try { BeanUtils.copyProperties(paramObject2, paramObject1); } catch (Exception localException) { _$1.error("dto to entity error: " + localException); } return paramObject2; } public static String[] list2Strings(List paramList) { String[] arrayOfString = null; try { if (paramList == null) return null; arrayOfString = new String[paramList.size()]; for (int i = 0; i < paramList.size(); i++) arrayOfString[i] = ((String) paramList.get(i)); } catch (Exception localException) { _$1.error("list is null: " + localException); } return arrayOfString; } public static List Strings2list(String[] paramArrayOfString) { ArrayList localArrayList = new ArrayList(); try { if (paramArrayOfString == null) return null; for (int i = 0; i < paramArrayOfString.length; i++) localArrayList.add(paramArrayOfString[i]); } catch (Exception localException) { _$1.error("list is null: " + localException); } return localArrayList; } public static String[] searchByKeyword(String paramString) { Pattern.compile("[' ']+"); Pattern localPattern = Pattern .compile("[.。!?#@#¥$%&*()()=《》<>‘、’;:\"\\?!:']"); Matcher localMatcher = localPattern.matcher(paramString); String str1 = localMatcher.replaceAll(" ").replaceAll(",", ","); String str2 = StringUtils.replace(str1, " ", ","); String[] arrayOfString = StringUtils.split(str2, ","); return arrayOfString; } public static String formatNumber(Long paramLong) { if (paramLong == null) return null; NumberFormat localNumberFormat = NumberFormat.getIntegerInstance(); localNumberFormat.setMinimumIntegerDigits(8); localNumberFormat.setGroupingUsed(false); return localNumberFormat.format(paramLong); } public static Long getCRC32(String paramString) { CRC32 localCRC32 = new CRC32(); localCRC32.update(paramString.getBytes()); return Long.valueOf(localCRC32.getValue()); } public static void main(String[] paramArrayOfString) { System.out.println(getCRC32("123")); } public static String convertTemplate(String paramString1, String paramString2, Map paramMap) throws MalformedPatternException { String str = null; StringBuffer localStringBuffer = new StringBuffer(); try { File localFile = new File(paramString1); if (!localFile.exists()) return localStringBuffer.toString(); FileInputStream localFileInputStream = new FileInputStream( localFile); BufferedReader localBufferedReader = new BufferedReader( new InputStreamReader(localFileInputStream, "UTF-8")); str = new String(); while ((str = localBufferedReader.readLine()) != null) localStringBuffer.append(StringUtil.convert(str, paramString2, paramMap) + "\n"); localBufferedReader.close(); localFileInputStream.close(); } catch (IOException localIOException) { System.out.println("got an IOException error!"); localIOException.printStackTrace(); } return localStringBuffer.toString(); } public static String convertTemplate(String paramString, Map paramMap) throws MalformedPatternException { return convertTemplate(paramString, "\\#[a-zA-Z]+\\#", paramMap); } }
Java
package com.legendshop.util; import org.apache.commons.beanutils.Converter; public final class StringConverter implements Converter { public Object convert(Class paramClass, Object paramObject) { if ((paramObject == null) || ("".equals(paramObject.toString()))) return null; return paramObject.toString(); } }
Java
package com.legendshop.util.sql; import com.legendshop.util.AppUtils; import java.util.HashMap; public class ParamsMap extends HashMap<String, String> { private static final long serialVersionUID = -7720526189745315572L; public void addParams(String paramString1, String paramString2) { if ((AppUtils.isBlank(paramString1)) || (AppUtils.isBlank(paramString2))) return; super.put(paramString1, paramString2); } }
Java
package com.legendshop.util.sql; public class ObjectSignature { protected String objClassName; protected String methodName = null; public ObjectSignature(String paramString) { this.objClassName = paramString; } public String getObjectClassName() { return this.objClassName; } public static String toSignature(String paramString1, String paramString2) { StringBuffer localStringBuffer = new StringBuffer(paramString1); localStringBuffer.append('.').append(paramString2); return localStringBuffer.toString(); } public String getMethodName() { return this.methodName; } public void setMethodName(String paramString) { this.methodName = paramString; } public String toSignature() { return toSignature(getObjectClassName(), this.methodName); } protected ObjectSignature() { this.objClassName = null; } }
Java
package com.legendshop.util.sql; import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; import org.apache.oro.text.regex.MalformedPatternException; import org.apache.oro.text.regex.MatchResult; import org.apache.oro.text.regex.Pattern; import org.apache.oro.text.regex.PatternMatcherInput; import org.apache.oro.text.regex.Perl5Compiler; import org.apache.oro.text.regex.Perl5Matcher; import com.legendshop.util.AppUtils; public class DynamicCode { Logger _$8 = Logger.getLogger(DynamicCode.class); private static final String _$7 = "\\$.*\\$"; private static final String _$6 = "{.*?}"; private static final String _$5 = "{!"; private static final String _$4 = "{?"; private static final String _$3 = "{"; private static final String _$2 = "}"; private static final String _$1 = "||"; public String convert(String paramString1, String paramString2, Map<String, String> paramMap) throws MalformedPatternException { StringBuffer localStringBuffer = new StringBuffer(paramString1); Perl5Compiler localPerl5Compiler = new Perl5Compiler(); Pattern localPattern = localPerl5Compiler.compile(paramString2); Perl5Matcher localPerl5Matcher = new Perl5Matcher(); PatternMatcherInput localPatternMatcherInput = new PatternMatcherInput( paramString1.toString()); int i = 0; while (localPerl5Matcher.contains(localPatternMatcherInput, localPattern)) { MatchResult localMatchResult = localPerl5Matcher.getMatch(); int j = localMatchResult.length(); String str1 = localMatchResult.toString(); String str2 = _$1(str1, paramMap); localStringBuffer.replace(localMatchResult.beginOffset(0) + i, localMatchResult.endOffset(0) + i, str2); i += str2.length() - j; } return localStringBuffer.toString(); } public String convert(String paramString, Map<String, String> paramMap) { try { if (AppUtils.isBlank(paramString)) return null; return convert(paramString, _$6, paramMap); } catch (Exception localException) { this._$8.error("获取动态SQL出错" + localException); } return null; } private String _$1(String paramString, Map<String, String> paramMap) throws MalformedPatternException { boolean bool1 = paramString.startsWith(_$5); boolean bool2 = paramString.startsWith(_$4); StringBuffer localStringBuffer = null; String str1 = null; if (bool1) { int i = paramString.indexOf(_$1); if (i != -1) str1 = paramString.substring(0, paramString.indexOf(_$1) + 2); else str1 = _$5; localStringBuffer = new StringBuffer(_$1(paramString, str1, _$2)); } else if (bool2) { localStringBuffer = new StringBuffer(_$1(paramString, _$4, _$2)); } else { localStringBuffer = new StringBuffer(_$1(paramString, _$3, _$2)); } Perl5Compiler localPerl5Compiler = new Perl5Compiler(); Pattern localPattern = localPerl5Compiler.compile(_$7); Perl5Matcher localPerl5Matcher = new Perl5Matcher(); PatternMatcherInput localPatternMatcherInput = new PatternMatcherInput( localStringBuffer.toString()); int i = 0; while (localPerl5Matcher.contains(localPatternMatcherInput, localPattern)) { MatchResult localMatchResult = localPerl5Matcher.getMatch(); int j = localMatchResult.length(); String str2 = localMatchResult.toString(); String str3 = (String) paramMap.get(str2.substring(1, str2.length() - 1)); if ((bool1) && (str3 == null)) { String str4 = _$1(str1, _$5, _$1); if ((!str4.startsWith(_$5)) && (!str4.endsWith(_$1))) str3 = str4.trim(); else str3 = ""; } if (str3 != null) { if (!bool2) { localStringBuffer.replace(localMatchResult.beginOffset(0) + i, localMatchResult.endOffset(0) + i, str3); i += str3.length() - j; } else { localStringBuffer.replace(localMatchResult.beginOffset(0) + i, localMatchResult.endOffset(0) + i, "?"); i += str3.length() - j; } } else return ""; } return localStringBuffer.toString(); } private String _$1(String paramString1, String paramString2, String paramString3) { if ((paramString1 == null) || (paramString1 == paramString2) || (paramString1 == paramString3)) return paramString1; if ((!paramString1.startsWith(paramString2)) || (!paramString1.endsWith(paramString3))) return paramString1; return paramString1.substring(paramString2.length(), paramString1.length() - paramString3.length()); } public static void main(String[] paramArrayOfString) throws MalformedPatternException { DynamicCode localDynamicCode = new DynamicCode(); long l1 = System.currentTimeMillis(); for (int i = 0; i < 100; i++) localDynamicCode._$1(localDynamicCode); long l2 = System.currentTimeMillis(); System.out.println("total time :" + (l2 - l1)); System.out.println("avage time :" + (float) (l2 - l1) / 100.0F); } private void _$1(DynamicCode paramDynamicCode) throws MalformedPatternException { HashMap<String, String> localHashMap = new HashMap<String, String>(); localHashMap.put("id", "1"); localHashMap.put("id1", "2"); localHashMap.put("name", "hewq"); localHashMap.put("condition", "and moc = 1"); localHashMap.put("memo2", "df"); String str1 = " select * from t_scheme where 1==1 \n { and id = $id$ } \n { and name = $name$ } \n {$condition$} \n {! default value || and memo1 = $memo1$} \n { and memo2 = $memo2$} \n order by id "; String str2 = paramDynamicCode.convert(str1, _$6, localHashMap); System.out.println(str2); } }
Java
package com.legendshop.util.sql; import java.io.File; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import org.apache.log4j.Logger; import com.legendshop.util.xml.Configure; public class CodeItem { private static Logger _$6 = Logger.getLogger(CodeItem.class); private Map<String, String> _$5 = null; private boolean _$4 = false; private File _$3 = null; private long _$2; private String _$1; public CodeItem() { } public CodeItem(String paramString) { this._$1 = paramString; } public Collection<String> getObjectSignatures() { return this._$5.keySet(); } public boolean getInitStatus() { return this._$4; } public String getConfigFileName() { return this._$1; } public String getCode(String paramString) { if (!this._$5.containsKey(paramString)) { _$6.warn(this._$1 + " CodeItem getCode not found ,signature = " + paramString); return null; } return (String) this._$5.get(paramString); } public boolean init() { Configure localConfigure = new Configure(); try { this._$3 = new File(this._$1); this._$2 = this._$3.lastModified(); localConfigure.parse(this._$1); int i = localConfigure .getItemCount("/DataAccessLayer/BusinessObjects"); for (int j = 1; j <= i; j++) { String str1 = localConfigure.getItemProp( "/DataAccessLayer/BusinessObjects/Object[" + j + "]", "objectName"); int k = localConfigure .getItemCount("/DataAccessLayer/BusinessObjects/Object[" + j + "]"); for (int m = 0; m < k; m++) { String str2 = "/DataAccessLayer/BusinessObjects/Object[" + j + "]"; String str3 = localConfigure.getItemProp(str2 + "/Method[" + (m + 1) + "]", "name"); String str4 = localConfigure.getItemValue(str2, "/Method[" + (m + 1) + "]"); String str5 = ObjectSignature.toSignature(str1, str3); // TODO 临时改动 if (this._$5 == null) this._$5 =new HashMap<String, String>(); if (this._$5.containsKey(str5)) _$6.warn(this._$1 + " unique constraint violated ,key = " + str5); else this._$5.put(str5, str4); } } } catch (Exception localException) { localException.printStackTrace(); this._$4 = false; return this._$4; } this._$4 = true; return this._$4; } public String toString() { StringBuffer localStringBuffer = new StringBuffer(); Set<Entry<String, String>> localSet = this._$5.entrySet(); Iterator<Entry<String, String>> localIterator = localSet.iterator(); int i = 0; while (localIterator.hasNext()) { i++; Entry<String, String> localEntry = localIterator.next(); localStringBuffer.append("<Method Name=") .append((String) localEntry.getKey()).append(">\n"); String str = " " + (String) localEntry.getValue(); localStringBuffer.append(str.toString()); localStringBuffer.append("\n</Method>").append('\n'); } return localStringBuffer.toString(); } public boolean containsObjectSignature(String paramString) { return this._$5.containsKey(paramString); } public static void main(String[] paramArrayOfString) { // TODO CodeItem localCodeItem = new CodeItem( "D:\\Eclipse3.2.2\\TcrmWorkSpace\\jcf1.2\\bin\\xml\\business\\DAOObject4.dal.xml"); localCodeItem.init(); System.out.println("Init Status:" + localCodeItem.getInitStatus()); System.out.println(localCodeItem.toString()); } public Map<String, String> getCodes() { return this._$5; } public boolean isModified() { if (this._$3 == null) return false; return this._$3.lastModified() > this._$2; } public String getConfName() { return this._$1; } }
Java
package com.legendshop.util.sql; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.log4j.Logger; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import com.legendshop.util.AppUtils; import com.legendshop.util.xml.Configure; public class ConfigCode { private static Logger _$12 = Logger.getLogger(ConfigCode.class); private static final String _$11 = "2009-05-23"; private static ConfigCode _$10 = null; private boolean _$9 = false; private Map<String, String> _$8 = null; private Map<String, CodeItem> _$7 = null; private Collection<String> _$6 = null; private File _$5 = null; private long _$4; private boolean _$3 = false; private final DynamicCode _$2 = new DynamicCode(); private String _$1 = "classpath*:DAL.cfg.xml"; public static ConfigCode getInstance() { if (_$10 == null) { _$10 = new ConfigCode(); if (!_$10._$3) _$10._$3(_$10._$1); } return _$10; } public static ConfigCode getInstance(String paramString) { if (_$10 == null) { _$10 = new ConfigCode(); if (!_$10._$3) { _$10.setConfName(paramString); _$10._$3(paramString); } } return _$10; } public static ConfigCode refresh() { if (!_$10._$3) _$12.warn("ConfigCode还没有初始化,不能刷新,先要调用getInstance方法"); else _$12.info("注意:开始刷新ConfigCode!"); String str = _$10.getConfName(); _$10 = null; _$10 = new ConfigCode(); if (!_$10._$3) { _$10.setConfName(str); _$10._$3(str); } return _$10; } private String _$4(String paramString) { CodeItem localCodeItem = _$2(paramString); if (localCodeItem == null) { _$12.warn(" getCodeFromCodeItem return null, signature = " + paramString); return null; } return localCodeItem.getCode(paramString); } public String getCode(String paramString) { if (this._$9) { if (_$10._$2()) { _$12.debug(this._$1 + " had modify,load again!"); _$10 = new ConfigCode(); _$10._$3(this._$1); } return _$4(paramString); } String str = (String) this._$8.get(paramString); if (str == null) { _$12.warn(" getCode return null, signature = " + paramString); return null; } return str; } public String getCode(String paramString, Map<String, String> paramMap) { if (this._$9) { if (_$10._$2()) { _$12.debug(this._$1 + " had modify,load again!"); _$10 = new ConfigCode(); _$10._$3(this._$1); } return this._$2.convert(_$4(paramString), paramMap); } String str = (String) this._$8.get(paramString); if (AppUtils.isBlank(str)) { _$12.warn(" getCode return null, signature = " + paramString); return null; } return this._$2.convert(str, paramMap); } private boolean _$3(String paramString) { if (this._$3) { _$12.warn("ConfigCode had inited, should not init again"); return true; } _$12.info("The current version of DAL is : 2009-05-23."); Configure localConfigure = new Configure(); try { this._$5 = getFile(paramString); this._$4 = this._$5.lastModified(); localConfigure.parse(paramString); String str1 = "/DataAccessLayer/MappingFiles"; int i = localConfigure.getItemCount(str1); for (int j = 1; j <= i; j++) { str1 = "/DataAccessLayer/MappingFiles/Mapping[" + j + "]"; String str2 = localConfigure.getItemProp(str1, "resource"); if (str2.startsWith("classpath")) { Resource[] localObject1 = getResources(str2); for (int k = 0; k < localObject1.length; k++) { Resource localObject2 = localObject1[k]; String str3 = localObject2.getFile().toString(); CodeItem localCodeItem = new CodeItem(str3); localCodeItem.init(); _$12.debug("mapping filename=" + str3 + "\n" + localCodeItem.toString()); // TODO 临时改动 if (this._$7 == null) this._$7 = new HashMap<String, CodeItem>(); this._$7.put(str3, localCodeItem); _$1(localCodeItem.getObjectSignatures()); // TODO 临时改动 if (this._$8 == null) this._$8 = new HashMap<String, String>(); this._$8.putAll(localCodeItem.getCodes()); } } else { CodeItem localObject1 = new CodeItem(str2); localObject1.init(); _$12.debug("mapping filename=" + str2 + "\n" + ((CodeItem) localObject1).toString()); // TODO 临时改动 if (this._$7 == null) this._$7 = new HashMap<String, CodeItem>(); this._$7.put(str2, localObject1); _$1(localObject1.getObjectSignatures()); // TODO 临时改动 if (this._$8 == null) this._$8 = new HashMap<String, String>(); this._$8.putAll(((CodeItem) localObject1).getCodes()); } } } catch (Exception localException) { _$12.error("初始化DAL配置文件出错", localException); this._$3 = false; return this._$3; } this._$3 = true; return this._$3; } public String toString() { StringBuffer localStringBuffer = new StringBuffer(); Iterator localIterator = this._$7.entrySet().iterator(); while (localIterator.hasNext()) { Map.Entry localEntry = (Map.Entry) localIterator.next(); localStringBuffer.append("<Mapping resource=") .append((String) localEntry.getKey()).append(">\n"); CodeItem localCodeItem = (CodeItem) localEntry.getValue(); localStringBuffer.append(localCodeItem.toString()); localStringBuffer.append("</Mapping>").append('\n'); } return localStringBuffer.toString(); } private CodeItem _$2(String paramString) { CodeItem localCodeItem = null; Iterator localIterator = this._$7.values().iterator(); while (localIterator.hasNext()) { localCodeItem = (CodeItem) localIterator.next(); if (localCodeItem.isModified()) { String str = localCodeItem.getConfName(); localCodeItem = new CodeItem(str); localCodeItem.init(); this._$7.put(str, localCodeItem); _$12.debug(str + " had modify,load again!"); } if (localCodeItem.containsObjectSignature(paramString)) return localCodeItem; } _$12.warn(" getCodeItem return null, objectSignature = " + paramString); return null; } private CodeItem _$1(String paramString) { CodeItem localCodeItem = (CodeItem) this._$7.get(paramString); if (localCodeItem == null) _$12.warn(" getCodeItemByFile return null, mappingFileName = " + paramString); return localCodeItem; } private void _$1(Collection<String> paramCollection) { if (this._$6 == null) this._$6 = new ArrayList(); Iterator localIterator = paramCollection.iterator(); while (localIterator.hasNext()) { String str = (String) localIterator.next(); if (this._$6.contains(str)) _$12.warn(" unique constraint violated ,key = " + str); this._$6.add(str); } } private boolean _$2() { if (this._$5 == null) return false; return this._$5.lastModified() > this._$4; } private Map<String, CodeItem> _$1() { return this._$7; } public Map<String, String> getParameters() { return this._$8; } private void _$1(Map<String, CodeItem> paramMap) { this._$7 = paramMap; } public void setDebug(boolean paramBoolean) { this._$9 = paramBoolean; } public boolean isInitStatus() { return this._$3; } public boolean isDebug() { return this._$9; } public String getConfName() { return this._$1; } public void setConfName(String paramString) { this._$1 = paramString; } public Resource[] getResources(String paramString) throws Exception { PathMatchingResourcePatternResolver localPathMatchingResourcePatternResolver = new PathMatchingResourcePatternResolver(); if (paramString.startsWith("classpath")) return localPathMatchingResourcePatternResolver .getResources(paramString); return localPathMatchingResourcePatternResolver .getResources("classpath*:" + paramString); } public File getFile(String paramString) throws IOException { File localFile = null; if (paramString.startsWith("classpath")) { int i = paramString.indexOf(":"); String str = paramString.substring(i + 1); ClassPathResource localClassPathResource = new ClassPathResource( str); localFile = localClassPathResource.getFile(); } else { localFile = new File(paramString); } return localFile; } public static void main(String[] paramArrayOfString) { try { ConfigCode localConfigCode = getInstance(); localConfigCode.setDebug(true); String str1 = ObjectSignature.toSignature("TestObject1", "find"); String str2 = localConfigCode.getCode(str1); HashMap localHashMap = new HashMap(); localHashMap.put("id", "1"); localHashMap.put("name", "何文强"); localHashMap.put("condition1", "and address = gm"); System.out.println(localConfigCode.getCode("TestObject1.update", localHashMap)); System.out.println(localConfigCode.getCode("TestObject1.update")); } catch (Exception localException) { localException.printStackTrace(); } } }
Java
package com.legendshop.util; import java.io.PrintStream; import java.math.BigDecimal; public class Arith { private static final int _$1 = 10; public static double add(double paramDouble1, double paramDouble2) { BigDecimal localBigDecimal1 = new BigDecimal( Double.toString(paramDouble1)); BigDecimal localBigDecimal2 = new BigDecimal( Double.toString(paramDouble2)); return localBigDecimal1.add(localBigDecimal2).doubleValue(); } public static double sub(double paramDouble1, double paramDouble2) { BigDecimal localBigDecimal1 = new BigDecimal( Double.toString(paramDouble1)); BigDecimal localBigDecimal2 = new BigDecimal( Double.toString(paramDouble2)); return localBigDecimal1.subtract(localBigDecimal2).doubleValue(); } public static double mul(double paramDouble1, double paramDouble2) { BigDecimal localBigDecimal1 = new BigDecimal( Double.toString(paramDouble1)); BigDecimal localBigDecimal2 = new BigDecimal( Double.toString(paramDouble2)); return localBigDecimal1.multiply(localBigDecimal2).doubleValue(); } public static double div(double paramDouble1, double paramDouble2) { return div(paramDouble1, paramDouble2, 10); } public static double div(double paramDouble1, double paramDouble2, int paramInt) { if (paramInt < 0) throw new IllegalArgumentException( "The scale must be a positive integer or zero"); BigDecimal localBigDecimal1 = new BigDecimal( Double.toString(paramDouble1)); BigDecimal localBigDecimal2 = new BigDecimal( Double.toString(paramDouble2)); return localBigDecimal1.divide(localBigDecimal2, paramInt, 4) .doubleValue(); } public static double round(double paramDouble, int paramInt) { if (paramInt < 0) throw new IllegalArgumentException( "The scale must be a positive integer or zero"); BigDecimal localBigDecimal1 = new BigDecimal( Double.toString(paramDouble)); BigDecimal localBigDecimal2 = new BigDecimal("1"); return localBigDecimal1.divide(localBigDecimal2, paramInt, 4) .doubleValue(); } public static void main(String[] paramArrayOfString) { System.out.println(0.06000000000000001D); System.out.println(add(0.05D, 0.01D)); System.out.println(0.5800000000000001D); System.out.println(sub(1.0D, 0.42D)); System.out.println(401.49999999999994D); System.out.println(mul(4.015D, 100.0D)); System.out.println(1.233D); System.out.println(div(123.3D, 100.0D, 2)); } }
Java
package com.legendshop.util; import java.io.File; import java.io.FileInputStream; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; public class DownloadFileUtil { private static DownloadFileUtil _$2; private static Logger _$1 = Logger .getLogger(DownloadFileUtil.class .getName()); public static DownloadFileUtil getInstance() { if (_$2 == null) _$2 = new DownloadFileUtil(); return _$2; } public static String toUtf8String(String paramString) { StringBuffer localStringBuffer = new StringBuffer(); for (int i = 0; i < paramString.length(); i++) { char c = paramString.charAt(i); if ((c >= 0) && (c <= 'ÿ')) { localStringBuffer.append(c); } else { byte[] arrayOfByte; try { arrayOfByte = String.valueOf(c).getBytes("utf-8"); } catch (Exception localException) { localException.printStackTrace(); arrayOfByte = new byte[0]; } for (int j = 0; j < arrayOfByte.length; j++) { int k = arrayOfByte[j]; if (k < 0) k += 256; localStringBuffer.append("%" + Integer.toHexString(k).toUpperCase()); } } } return localStringBuffer.toString(); } public static String getEncodingFileName(String paramString) { _$1.debug("EncodingFileName: " + paramString); int i = paramString.lastIndexOf("."); String str1 = paramString; String str2 = ""; int j = 56; if (i > -1) { str1 = paramString.substring(0, i); str2 = paramString.substring(i); j = j - str2.length() - 4; } String str3 = ""; try { int k = str1.getBytes("GBK").length; if (k > j) { k = j; str3 = "...."; } String str4 = new String(str1.getBytes("GBK"), 0, k, "GBK"); if ("".equals(str4)) str4 = new String(str1.getBytes("GBK"), 0, k + 1, "GBK"); _$1.debug("Encode File Name: " + str4 + str3 + str2); return str4 + str3 + str2; } catch (Exception localException) { localException.printStackTrace(); } return null; } public void downloadFile(HttpServletResponse paramHttpServletResponse, String paramString1, String paramString2, boolean paramBoolean) { try { File localFile = new File(paramString1); Object localObject; if ((!localFile.exists()) || (!localFile.isFile())) { _$1.debug("File: " + paramString1 + " Not Exists"); paramHttpServletResponse.setHeader("Content-Type", "text/html; charset=GBK"); localObject = paramHttpServletResponse.getOutputStream(); ((ServletOutputStream) localObject).println("文件不存在!联系管理员!"); } else { if (paramBoolean) { paramHttpServletResponse.setHeader("Content-Type", "application/octet-stream; charset=GBK"); paramHttpServletResponse.setHeader("Content-Disposition", "attachment; filename=" + toUtf8String(paramString2)); } else { localObject = "application/pdf; charset=GBK"; if ((paramString2 != null) && (paramString2.endsWith(".doc"))) { localObject = "application/msword; charset=GBK"; paramHttpServletResponse.setHeader("Content-Type", (String) localObject); } else if ((paramString2 != null) && (paramString2.endsWith(".pdf"))) { localObject = "application/pdf; charset=GBK"; paramHttpServletResponse.setHeader("Content-Type", (String) localObject); } else { localObject = "application/force-download"; paramHttpServletResponse.setHeader("Content-Type", (String) localObject); } paramHttpServletResponse.setHeader("Content-Disposition", "filename=" + toUtf8String(paramString2)); } localObject = new FileInputStream(paramString1); byte[] arrayOfByte = new byte[8192]; ServletOutputStream localServletOutputStream = paramHttpServletResponse .getOutputStream(); int i; while ((i = ((FileInputStream) localObject).read(arrayOfByte, 0, 8192)) != -1) localServletOutputStream.write(arrayOfByte, 0, i); localServletOutputStream.flush(); ((FileInputStream) localObject).close(); localServletOutputStream.close(); _$1.debug("Download File: " + paramString1 + " Finished"); } } catch (Exception localException) { _$1.error("DownloadFile: " + paramString1 + " Error", localException); } } }
Java
package com.legendshop.util; import java.io.IOException; import java.io.OutputStream; import java.security.MessageDigest; import java.text.StringCharacterIterator; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; import org.apache.commons.lang.StringUtils; import org.apache.oro.text.regex.MalformedPatternException; import org.apache.oro.text.regex.MatchResult; import org.apache.oro.text.regex.Pattern; import org.apache.oro.text.regex.PatternMatcherInput; import org.apache.oro.text.regex.Perl5Compiler; import org.apache.oro.text.regex.Perl5Matcher; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; public class StringUtil extends StringUtils { public static int intToString(String paramString) { return Integer.parseInt(paramString); } public static String stringToInt(int paramInt) { return String.valueOf(paramInt); } public static String stringToInt(Integer paramInteger) { return String.valueOf(paramInteger.intValue()); } public static String arrayToString(String[] paramArrayOfString, String paramString) { StringBuffer localStringBuffer = new StringBuffer(); for (int i = 0; i < paramArrayOfString.length; i++) localStringBuffer.append(paramArrayOfString[i]).append(paramString); return localStringBuffer.toString().substring(0, localStringBuffer.length() - 1); } public static String[] stringtoArray(String paramString1, String paramString2) { if (paramString1 == null) { String[] arrayOfString = new String[1]; arrayOfString[0] = paramString1; return arrayOfString; } if (paramString2 == null) paramString2 = ","; StringTokenizer localStringTokenizer = new StringTokenizer( paramString1, paramString2); int i = localStringTokenizer.countTokens(); String[] arrayOfString = new String[i]; for (int j = 0; j < i; j++) arrayOfString[j] = localStringTokenizer.nextToken(); return arrayOfString; } public static String[] stringtoArray(String paramString, char paramChar) { return stringtoArray(paramString, String.valueOf(paramChar)); } public static String[] stringtoArray(String paramString) { return stringtoArray(paramString, ","); } public static void printStrings(String[] paramArrayOfString, String paramString, OutputStream paramOutputStream) { try { if (paramArrayOfString != null) { int i = paramArrayOfString.length - 1; for (int j = 0; j < i; j++) if (paramArrayOfString[j] != null) { if (paramArrayOfString[j].indexOf(paramString) > -1) paramOutputStream.write(("\"" + paramArrayOfString[j] + "\"" + paramString) .getBytes()); else paramOutputStream .write((paramArrayOfString[j] + paramString) .getBytes()); } else paramOutputStream.write("null".getBytes()); if (paramArrayOfString[i] != null) { if (paramArrayOfString[i].indexOf(paramString) > -1) paramOutputStream .write(("\"" + paramArrayOfString[i] + "\"") .getBytes()); else paramOutputStream.write(paramArrayOfString[i] .getBytes()); } else paramOutputStream.write("null".getBytes()); } else { paramOutputStream.write("null".getBytes()); } paramOutputStream.write("\n".getBytes()); } catch (IOException localIOException) { } } public static void printStrings(String[] paramArrayOfString, String paramString) { printStrings(paramArrayOfString, paramString, System.out); } public static void printStrings(String[] paramArrayOfString, OutputStream paramOutputStream) { printStrings(paramArrayOfString, ",", paramOutputStream); } public static void printStrings(String[] paramArrayOfString) { printStrings(paramArrayOfString, ",", System.out); } public static String getReplaceString(String paramString1, String paramString2, String[] paramArrayOfString) { Object localObject = paramString2; if ((paramString2 == null) || (paramArrayOfString == null) || (paramArrayOfString.length < 1)) return paramString2; if (paramString1 == null) paramString1 = "%"; for (int i = 0; i < paramArrayOfString.length; i++) { String str1 = paramString1 + Integer.toString(i + 1); int j = ((String) localObject).indexOf(str1); if (j == -1) continue; String str2 = ((String) localObject).substring(0, j); if (i < paramArrayOfString.length) str2 = str2 + paramArrayOfString[i]; else str2 = str2 + paramArrayOfString[(paramArrayOfString.length - 1)]; str2 = str2 + ((String) localObject).substring(j + 2); localObject = str2; } return (String) localObject; } public static String getReplaceString(String paramString, String[] paramArrayOfString) { return getReplaceString("%", paramString, paramArrayOfString); } public static boolean contains(String[] paramArrayOfString, String paramString, boolean paramBoolean) { for (int i = 0; i < paramArrayOfString.length; i++) if (paramBoolean == true) { if (paramArrayOfString[i].equals(paramString)) return true; } else if (paramArrayOfString[i].equalsIgnoreCase(paramString)) return true; return false; } public static boolean contains(String[] paramArrayOfString, String paramString) { return contains(paramArrayOfString, paramString, true); } public static boolean containsIgnoreCase(String[] paramArrayOfString, String paramString) { return contains(paramArrayOfString, paramString, false); } public static String combineStringArray(String[] paramArrayOfString, String paramString) { int i = paramArrayOfString.length - 1; if (paramString == null) paramString = ""; StringBuffer localStringBuffer = new StringBuffer(i * 8); for (int j = 0; j < i; j++) { localStringBuffer.append(paramArrayOfString[j]); localStringBuffer.append(paramString); } localStringBuffer.append(paramArrayOfString[i]); return localStringBuffer.toString(); } public static String fillString(char paramChar, int paramInt) { String str = ""; for (int i = 0; i < paramInt; i++) str = str + paramChar; return str; } public static String trimLeft(String paramString) { String str = paramString; if (str == null) return str; char[] arrayOfChar = str.toCharArray(); int i = -1; for (int j = 0; (j < arrayOfChar.length) && (Character.isWhitespace(arrayOfChar[j])); j++) i = j; if (i != -1) str = str.substring(i + 1); return str; } public static String trimRight(String paramString) { String str = paramString; if (str == null) return str; char[] arrayOfChar = str.toCharArray(); int i = -1; for (int j = arrayOfChar.length - 1; (j > -1) && (Character.isWhitespace(arrayOfChar[j])); j--) i = j; if (i != -1) str = str.substring(0, i); return str; } public static String escapeCharacter(String paramString, HashMap paramHashMap) { if ((paramString == null) || (paramString.length() == 0)) return paramString; if (paramHashMap.size() == 0) return paramString; StringBuffer localStringBuffer = new StringBuffer(); StringCharacterIterator localStringCharacterIterator = new StringCharacterIterator( paramString); int j; for (int i = localStringCharacterIterator.first(); i != 65535; j = localStringCharacterIterator .next()) { String str = String.valueOf(i); if (paramHashMap.containsKey(str)) str = (String) paramHashMap.get(str); localStringBuffer.append(str); } return localStringBuffer.toString(); } public static int getByteLength(String paramString) { int i = 0; for (int j = 0; j < paramString.length(); j++) { int k = paramString.charAt(j); int m = k >>> 8; i += (m == 0 ? 1 : 2); } return i; } public static int getSubtringCount(String paramString1, String paramString2) { if ((paramString1 == null) || (paramString1.length() == 0)) return 0; int i = 0; for (int j = paramString1.indexOf(paramString2); j >= 0; j = paramString1 .indexOf(paramString2, j + 1)) i++; return i; } public static String encodePassword(String paramString1, String paramString2) { byte[] arrayOfByte1 = paramString1.getBytes(); MessageDigest localMessageDigest = null; try { localMessageDigest = MessageDigest.getInstance(paramString2); } catch (Exception localException) { localException.printStackTrace(); return paramString1; } localMessageDigest.reset(); localMessageDigest.update(arrayOfByte1); byte[] arrayOfByte2 = localMessageDigest.digest(); StringBuffer localStringBuffer = new StringBuffer(); for (int i = 0; i < arrayOfByte2.length; i++) { if ((arrayOfByte2[i] & 0xFF) < 16) localStringBuffer.append("0"); localStringBuffer.append(Long.toString(arrayOfByte2[i] & 0xFF, 16)); } return localStringBuffer.toString(); } public static String encodeString(String paramString) { BASE64Encoder localBASE64Encoder = new BASE64Encoder(); return localBASE64Encoder.encodeBuffer(paramString.getBytes()).trim(); } public static String decodeString(String paramString) { BASE64Decoder localBASE64Decoder = new BASE64Decoder(); try { return new String(localBASE64Decoder.decodeBuffer(paramString)); } catch (IOException localIOException) { throw new RuntimeException(localIOException.getMessage(), localIOException.getCause()); } } public static String convert(String paramString1, String paramString2, Map paramMap) throws MalformedPatternException { StringBuffer localStringBuffer = new StringBuffer(paramString1); Perl5Compiler localPerl5Compiler = new Perl5Compiler(); Pattern localPattern = localPerl5Compiler.compile(paramString2); Perl5Matcher localPerl5Matcher = new Perl5Matcher(); PatternMatcherInput localPatternMatcherInput = new PatternMatcherInput( paramString1.toString()); int i = 0; String str1 = null; try { while (localPerl5Matcher.contains(localPatternMatcherInput, localPattern)) { MatchResult localMatchResult = localPerl5Matcher.getMatch(); if (!AppUtils.isNotBlank(localMatchResult)) continue; int j = localMatchResult.length(); str1 = localMatchResult.toString(); String str2 = (String) paramMap.get(str1); localStringBuffer.replace(localMatchResult.beginOffset(0) + i, localMatchResult.endOffset(0) + i, str2); i += str2.length() - j; } } catch (Exception localException) { throw new RuntimeException("can not replace key " + str1, localException); } return localStringBuffer.toString(); } public static String convert(String paramString, String[] paramArrayOfString) { StringBuffer localStringBuffer = new StringBuffer(paramString); int i = 0; while (localStringBuffer.indexOf("?") != -1) { localStringBuffer.replace(localStringBuffer.indexOf("?"), localStringBuffer.indexOf("?") + 1, paramArrayOfString[i]); i++; if (i <= paramArrayOfString.length - 1) continue; } return localStringBuffer.toString(); } public static void main(String[] paramArrayOfString) { String[] arrayOfString = stringtoArray("test1/test2/test3", "/"); String str1 = arrayToString(arrayOfString, " "); System.out.println("ss=" + str1); printStrings(arrayOfString, "\\"); System.out.println("ssssssss==" + "1111abc1".indexOf("1abc")); str1 = "test1test2test3"; boolean bool = contains(arrayOfString, "test1"); System.out.println("result=" + contains(arrayOfString, "test3")); char c = 'c'; String str2 = fillString(c, 2); System.out.println("cc=" + str2); String str3 = "4ccc!_#$"; System.out.println("getByteLength==" + getByteLength(str3)); } }
Java
package com.legendshop.util; import java.io.PrintStream; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.Vector; import org.htmlparser.Attribute; import org.htmlparser.Node; import org.htmlparser.Tag; import org.htmlparser.lexer.Lexer; import org.htmlparser.nodes.TextNode; public class SafeHtml { private static Set _$3 = new HashSet(); private static Set _$2 = new HashSet(); private static Set _$1 = new HashSet(); private static void _$1(String paramString, Set paramSet) { if (paramString == null) return; String[] arrayOfString = paramString.toUpperCase().split(","); for (int i = 0; i < arrayOfString.length; i++) paramSet.add(arrayOfString[i].trim()); } public String ensureAllAttributesAreSafe(String paramString) { StringBuffer localStringBuffer = new StringBuffer(paramString.length()); try { Lexer localLexer = new Lexer(paramString); Node localNode; while ((localNode = localLexer.nextNode()) != null) { if ((localNode instanceof Tag)) { Tag localTag = (Tag) localNode; _$1(localTag, false); localStringBuffer.append(localTag.toHtml()); continue; } localStringBuffer.append(localNode.toHtml()); } } catch (Exception localException) { throw new RuntimeException("Problems while parsing HTML", localException); } return localStringBuffer.toString(); } public String makeSafe(String paramString) { if ((paramString == null) || (paramString.length() == 0)) return paramString; StringBuffer localStringBuffer1 = new StringBuffer(paramString.length()); try { Lexer localLexer = new Lexer(paramString); Node localNode; while ((localNode = localLexer.nextNode()) != null) { boolean bool = localNode instanceof TextNode; Object localObject; if (bool) { localObject = localNode.toHtml(); if ((((String) localObject).indexOf('>') > -1) || (((String) localObject).indexOf('<') > -1)) { StringBuffer localStringBuffer2 = new StringBuffer( (String) localObject); replaceAll(localStringBuffer2, "<", "&lt;"); replaceAll(localStringBuffer2, ">", "&gt;"); replaceAll(localStringBuffer2, "\"", "&quot;"); localNode.setText(localStringBuffer2.toString()); } } if ((bool) || (((localNode instanceof Tag)) && (_$1(localNode)))) { localStringBuffer1.append(localNode.toHtml()); } else { localObject = new StringBuffer(localNode.toHtml()); replaceAll((StringBuffer) localObject, "<", "&lt;"); replaceAll((StringBuffer) localObject, ">", "&gt;"); localStringBuffer1.append(((StringBuffer) localObject) .toString()); } } } catch (Exception localException) { throw new RuntimeException("Error while parsing HTML", localException); } return (String) localStringBuffer1.toString(); } private boolean _$1(Node paramNode) { Tag localTag = (Tag) paramNode; if (!_$3.contains(localTag.getTagName())) return false; _$1(localTag, true); return true; } private void _$1(Tag paramTag, boolean paramBoolean) { Vector localVector = new Vector(); Iterator localIterator = paramTag.getAttributesEx().iterator(); while (localIterator.hasNext()) { Attribute localAttribute = (Attribute) localIterator.next(); String str1 = localAttribute.getName(); if (str1 == null) { localVector.add(localAttribute); } else { str1 = str1.toUpperCase(); if (localAttribute.getValue() == null) { localVector.add(localAttribute); continue; } String str2 = localAttribute.getValue().toLowerCase(); if (((paramBoolean) && (!_$2(str1))) || (!_$1(str1, str2))) continue; if (localAttribute.getValue().indexOf("&#") > -1) localAttribute.setValue(localAttribute.getValue() .replaceAll("&#", "&amp;#")); localVector.add(localAttribute); } } paramTag.setAttributesEx(localVector); } private boolean _$2(String paramString) { return _$2.contains(paramString); } private boolean _$1(String paramString1, String paramString2) { if ((paramString1.length() >= 2) && (paramString1.charAt(0) == 'O') && (paramString1.charAt(1) == 'N')) return false; if ((paramString2.indexOf('\n') > -1) || (paramString2.indexOf('\r') > -1) || (paramString2.indexOf(0) > -1)) return false; if (("HREF".equals(paramString1)) || ("SRC".equals(paramString1))) { if (!_$1(paramString2)) return false; } else if (("STYLE".equals(paramString1)) && (paramString2.indexOf('(') > -1)) return false; return true; } private boolean _$1(String paramString) { int i = 0; if ((i != 0) && (paramString.length() > 0) && (paramString.charAt(0) == '/')) return true; Iterator localIterator = _$1.iterator(); while (localIterator.hasNext()) { String str = localIterator.next().toString().toLowerCase(); if (paramString.startsWith(str)) return true; } return false; } public static String replaceAll(StringBuffer paramStringBuffer, String paramString1, String paramString2) { for (int i = paramStringBuffer.indexOf(paramString1); i > -1; i = paramStringBuffer .indexOf(paramString1)) paramStringBuffer.replace(i, i + paramString1.length(), paramString2); return paramStringBuffer.toString(); } public static void main(String[] paramArrayOfString) { SafeHtml localSafeHtml = new SafeHtml(); String str1 = "<html><table><tr><td>aaa<script type=\"text/javascript\">function b(){alert(21);}b();</script><p>测试</p></td></tr></table></html>"; String str2 = localSafeHtml.makeSafe(str1); String str3 = localSafeHtml.ensureAllAttributesAreSafe(str1); System.out.println(str2); System.out.println(str3); } static { _$1("u, a, img, i, u, li, ul, font, br, p, b, hr,pre", _$3); _$1("src, href, size, face, color, target, rel", _$2); _$1("http://, https://, mailto:, ftp://", _$1); } }
Java
package com.legendshop.util; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class CookieUtil { private final HttpServletRequest _$3; private final HttpServletResponse _$2; private final int _$1; public CookieUtil(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, int paramInt) { this._$3 = paramHttpServletRequest; this._$2 = paramHttpServletResponse; this._$1 = paramInt; } public CookieUtil(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) { this._$3 = paramHttpServletRequest; this._$2 = paramHttpServletResponse; this._$1 = -1; } public void addCookie(String paramString1, String paramString2) { Cookie localCookie = new Cookie(paramString1, paramString2); localCookie.setPath("/"); localCookie.setMaxAge(this._$1); this._$2.addCookie(localCookie); } public String getCookieValue(String paramString) { if (paramString != null) { Cookie localCookie = getCookie(paramString); if (localCookie != null) return localCookie.getValue(); } return ""; } public Cookie getCookie(String paramString) { Cookie[] arrayOfCookie = this._$3.getCookies(); Cookie localCookie = null; try { if ((arrayOfCookie != null) && (arrayOfCookie.length > 0)) for (int i = 0; i < arrayOfCookie.length; i++) { localCookie = arrayOfCookie[i]; if (localCookie.getName().equals(paramString)) return localCookie; } } catch (Exception localException) { localException.printStackTrace(); } return localCookie; } public boolean deleteCookie(String paramString) { if (paramString != null) { Cookie localCookie = getCookie(paramString); if (localCookie != null) { localCookie.setMaxAge(0); localCookie.setPath("/"); this._$2.addCookie(localCookie); return true; } } return false; } }
Java
package com.legendshop.util; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Set; import org.apache.log4j.Logger; public class EnvironmentConfig { private static Logger _$3 = Logger .getLogger(EnvironmentConfig.class); static EnvironmentConfig _$2; private static Map<String, Object> _$1 = new HashMap(); public static EnvironmentConfig getInstance() { if (_$2 == null) _$2 = new EnvironmentConfig(); return _$2; } private Properties _$2(String paramString) { Properties localProperties = (Properties) _$1.get(paramString); if (localProperties == null) try { Object localObject = null; try { localObject = new FileInputStream(paramString); } catch (Exception localException2) { if (paramString.startsWith("/")) localObject = EnvironmentConfig.class .getResourceAsStream(paramString); else localObject = EnvironmentConfig.class .getResourceAsStream("/" + paramString); } localProperties = new Properties(); localProperties.load((InputStream) localObject); _$1.put(paramString, localProperties); ((InputStream) localObject).close(); } catch (Exception localException1) { _$3.error("getProperties: ", localException1); } return (Properties) localProperties; } public String getPropertyValue(String paramString1, String paramString2) { Properties localProperties = _$2(paramString1); try { return localProperties.getProperty(paramString2); } catch (Exception localException) { localException.printStackTrace(System.out); } return null; } private void _$1(String paramString1, String paramString2, String paramString3) { if (paramString3 == null) paramString3 = ""; Properties localProperties = _$2(paramString1); try { FileOutputStream localFileOutputStream = new FileOutputStream( paramString1); localProperties.setProperty(paramString2, paramString3); localProperties.store(localFileOutputStream, "set"); } catch (IOException localIOException) { localIOException.printStackTrace(); } } public synchronized void writeProperties(String paramString, Map<String, String> paramMap) { Properties localProperties = _$2(paramString); try { FileOutputStream localFileOutputStream = new FileOutputStream( paramString); Iterator localIterator = paramMap.keySet().iterator(); while (localIterator.hasNext()) { String str1 = (String) localIterator.next(); String str2 = (String) paramMap.get(str1); if (str2 == null) str2 = ""; localProperties.setProperty(str1, str2); } localProperties.store(localFileOutputStream, "set"); } catch (IOException localIOException) { localIOException.printStackTrace(); } _$1(paramString); } private void _$1(String paramString) { _$3.info("reload configuration file " + paramString); Properties localProperties = null; try { Object localObject = null; try { localObject = new FileInputStream(paramString); } catch (Exception localException2) { _$3.warn("initProperties, error message: " + localException2.getLocalizedMessage()); if (paramString.startsWith("/")) localObject = EnvironmentConfig.class .getResourceAsStream(paramString); else localObject = EnvironmentConfig.class .getResourceAsStream("/" + paramString); } localProperties = new Properties(); localProperties.load((InputStream) localObject); _$1.put(paramString, localProperties); ((InputStream) localObject).close(); } catch (Exception localException1) { _$3.error("initProperties: ", localException1); } } }
Java
package com.legendshop.util; public abstract interface FileConfig { public static final String ConfigFile = "config/common.properties"; public static final String ConfigFileRealPath = "WEB-INF/classes/config/common.properties"; public static final String FckeditorFile = "fckeditor.properties"; public static final String FckeditorFileRealPath = "WEB-INF/classes/fckeditor.properties"; public static final String GlobalFile = "config/global.properties"; public static final String GlobalFileRealPath = "WEB-INF/classes/config/global.properties"; public static final String JdbcFilePath = "config/jdbc.properties"; public static final String JdbcFileRealPath = "WEB-INF/classes/config/jdbc.properties"; }
Java
package com.legendshop.util; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigDecimal; import java.text.DateFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; public final class BeanHelper extends BeanUtils { private static final Log _$4 = LogFactory.getLog(BeanHelper.class); private static final DateFormat _$3 = new SimpleDateFormat("yyyy-MM-dd"); private static final DateFormat _$2 = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); private static final NumberFormat _$1 = NumberFormat.getInstance(); public static Date parseDate(String paramString) { if ((paramString == null) || (paramString.trim().equals(""))) return null; Date localDate = null; try { localDate = _$3.parse(paramString); } catch (Exception localException) { throw new RuntimeException("错误的日期格式 : " + paramString); } return localDate; } public static String formatDate(Date paramDate) { if (paramDate == null) return null; String str = null; try { str = _$3.format(paramDate); } catch (Exception localException) { throw new RuntimeException("无法解析的日期 : " + paramDate); } return str; } public static void copyProperties(Object paramObject1, Object paramObject2, boolean paramBoolean) { try { Set localSet1 = BeanUtils.describe(paramObject2).keySet(); Set localSet2 = BeanUtils.describe(paramObject1).keySet(); Iterator localIterator = localSet1.iterator(); while (localIterator.hasNext()) { Object localObject1 = localIterator.next(); String str = localObject1.toString(); if ((!str.equals("class")) && (localSet2.contains(str))) { Object localObject2 = PropertyUtils.getNestedProperty( paramObject2, str); if ((localObject2 == null) && (paramBoolean)) continue; Class localClass1 = PropertyUtils.getPropertyDescriptor( paramObject2, str).getPropertyType(); Class localClass2 = PropertyUtils.getPropertyDescriptor( paramObject1, str).getPropertyType(); if (localClass1 == localClass2) { PropertyUtils.setNestedProperty(paramObject1, str, localObject2); continue; } if (localClass1 == String.class) localObject2 = ConvertUtils.convert( (String) localObject2, localClass2); else if (localClass2 == String.class) localObject2 = ConvertUtils.convert(localObject2); if ((localObject2 != null) && (localClass2 == localObject2.getClass())) PropertyUtils.setNestedProperty(paramObject1, str, localObject2); else _$4.warn("源数据类型[" + localClass1.getName() + "]和目标数据类型[" + localClass2.getName() + "]不匹配, 忽略此次赋值"); } } } catch (Exception localException) { throw new RuntimeException("复制属性出错 ...", localException); } } public static void copyProperties(Object paramObject1, Object paramObject2) throws IllegalAccessException, InvocationTargetException { copyProperties(paramObject1, paramObject2, true); } public static Integer getInt(String paramString, Integer paramInteger) { if ((paramString == null) || (paramString.trim().equals(""))) return paramInteger; Integer localInteger = null; try { localInteger = Integer.valueOf(paramString); } catch (Exception localException) { localInteger = paramInteger; } return localInteger; } public static Long getLong(String paramString, Long paramLong) { if ((paramString == null) || (paramString.trim().equals(""))) return paramLong; Long localLong = null; try { localLong = Long.valueOf(paramString); } catch (Exception localException) { localLong = paramLong; } return localLong; } public static Float getFloat(String paramString, Float paramFloat) { if ((paramString == null) || (paramString.trim().equals(""))) return paramFloat; Float localFloat = null; try { localFloat = Float.valueOf(paramString); } catch (Exception localException) { localFloat = paramFloat; } return localFloat; } public static Double getDouble(String paramString, Double paramDouble) { if ((paramString == null) || (paramString.trim().equals(""))) return paramDouble; Double localDouble = null; try { localDouble = Double.valueOf(paramString); } catch (Exception localException) { localDouble = paramDouble; } return localDouble; } public static Integer getInt(String paramString) { return getInt(paramString, Integer.valueOf(0)); } public static Long getLong(String paramString) { return getLong(paramString, Long.valueOf(0L)); } public static Float getFloat(String paramString) { return getFloat(paramString, Float.valueOf(0.0F)); } public static Double getDouble(String paramString) { return getDouble(paramString, Double.valueOf(0.0D)); } public static String describeAsString(Object paramObject) { return ToStringBuilder.reflectionToString(paramObject, ToStringStyle.MULTI_LINE_STYLE); } public static String getNotNullString(Object paramObject) { return paramObject == null ? "" : String.valueOf(paramObject); } public static Object getBeanProperty(Object paramObject, String paramString) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtils.getProperty(paramObject, paramString); } public static Double getDoubleByObject(Object paramObject) { if (paramObject == null) return Double.valueOf(0.0D); Double localDouble = null; try { localDouble = Double.valueOf(String.valueOf(paramObject)); } catch (Exception localException) { localDouble = Double.valueOf(0.0D); } return localDouble; } public static BigDecimal getBigDecimalByObject(Object paramObject) { if (paramObject == null) return BigDecimal.valueOf(0.0D); BigDecimal localBigDecimal = null; try { localBigDecimal = new BigDecimal(String.valueOf(paramObject)); } catch (Exception localException) { localBigDecimal = BigDecimal.valueOf(0.0D); } return localBigDecimal; } public static Map Object2Map(Object paramObject) throws Exception { return describe(paramObject); } public static void Map2Object(Map paramMap, Object paramObject) throws Exception { populate(paramObject, paramMap); } public static String formatNumber(Object paramObject) { if ((paramObject != null) || ((paramObject instanceof Number))) return _$1.format(paramObject); return ""; } public static Object converToString(Object paramObject) { if (paramObject == null) return null; if ((paramObject instanceof String)) return paramObject; if ((paramObject instanceof Date)) return formatDate((Date) paramObject); if ((paramObject instanceof Double)) return formatNumber(paramObject); return String.valueOf(paramObject); } public static Object Object2Object(Class paramClass, Object paramObject) { try { Object localObject = paramClass.newInstance(); return Object2Object(localObject, paramObject); } catch (InstantiationException localInstantiationException) { localInstantiationException.printStackTrace(); } catch (IllegalAccessException localIllegalAccessException) { localIllegalAccessException.printStackTrace(); } return null; } public static Object Object2Object(Object paramObject1, Object paramObject2) { try { Method[] arrayOfMethod1 = paramObject2.getClass() .getDeclaredMethods(); ArrayList localArrayList = new ArrayList(); String str2; Object localObject1; Object localObject2; for (int i = 0; i < arrayOfMethod1.length; i++) { String str1 = arrayOfMethod1[i].getName(); if (str1.indexOf("get") != 0) continue; str2 = _$1(str1); localObject1 = arrayOfMethod1[i].invoke(paramObject2, new Object[0]); localObject2 = new FieldBean(); ((FieldBean) localObject2).setFieldname(str2); ((FieldBean) localObject2).setFieldvalue(localObject1); localArrayList.add(localObject2); } Method[] arrayOfMethod2 = paramObject1.getClass() .getDeclaredMethods(); for (int j = 0; j < arrayOfMethod2.length; j++) { str2 = arrayOfMethod2[j].getName(); if (str2.indexOf("set") != 0) continue; localObject1 = _$1(str2); localObject2 = null; for (int k = 0; k < localArrayList.size(); k++) { FieldBean fieldBean = (FieldBean) localArrayList.get(k); String str3 = fieldBean.getFieldname(); if (!((String) localObject1).equals(str3)) continue; localObject2 = fieldBean.getFieldvalue(); arrayOfMethod2[j].invoke(paramObject1, new Object[] {localObject2 }); break; } } return paramObject1; } catch (SecurityException localSecurityException) { localSecurityException.printStackTrace(); } catch (IllegalArgumentException localIllegalArgumentException) { localIllegalArgumentException.printStackTrace(); } catch (IllegalAccessException localIllegalAccessException) { localIllegalAccessException.printStackTrace(); } catch (InvocationTargetException localInvocationTargetException) { localInvocationTargetException.printStackTrace(); } return null; } public static String filter(String paramString) { if ((paramString == null) || (paramString.length() == 0)) return paramString; StringBuffer localStringBuffer = null; String str = null; for (int i = 0; i < paramString.length(); i++) { str = null; switch (paramString.charAt(i)) { case '<': str = "&lt;"; break; case '>': str = "&gt;"; } if (localStringBuffer == null) { if (str == null) continue; localStringBuffer = new StringBuffer(paramString.length() + 50); if (i > 0) localStringBuffer.append(paramString.substring(0, i)); localStringBuffer.append(str); } else if (str == null) { localStringBuffer.append(paramString.charAt(i)); } else { localStringBuffer.append(str); } } return localStringBuffer == null ? paramString : localStringBuffer.toString(); } private static String _$1(String paramString) { if ((paramString == null) || ("".equals(paramString))) return null; return paramString.substring(3).toLowerCase(); } public static Field getDeclaredField(Object paramObject, String paramString) throws NoSuchFieldException { Assert.notNull(paramObject); Assert.hasText(paramString); return getDeclaredField(paramObject.getClass(), paramString); } public static Field getDeclaredField(Class paramClass, String paramString) throws NoSuchFieldException { Assert.notNull(paramClass); Assert.hasText(paramString); Class localClass = paramClass; while (localClass != Object.class) try { return localClass.getDeclaredField(paramString); } catch (NoSuchFieldException localNoSuchFieldException) { localClass = localClass.getSuperclass(); } throw new NoSuchFieldException("No such field: " + paramClass.getName() + '.' + paramString); } public static Object forceGetProperty(Object paramObject, String paramString) throws NoSuchFieldException { Assert.notNull(paramObject); Assert.hasText(paramString); Field localField = getDeclaredField(paramObject, paramString); boolean bool = localField.isAccessible(); localField.setAccessible(true); Object localObject = null; try { localObject = localField.get(paramObject); } catch (IllegalAccessException localIllegalAccessException) { _$4.info("error wont' happen"); } localField.setAccessible(bool); return localObject; } public static void forceSetProperty(Object paramObject1, String paramString, Object paramObject2) throws NoSuchFieldException { Assert.notNull(paramObject1); Assert.hasText(paramString); Field localField = getDeclaredField(paramObject1, paramString); boolean bool = localField.isAccessible(); localField.setAccessible(true); try { localField.set(paramObject1, paramObject2); } catch (IllegalAccessException localIllegalAccessException) { _$4.info("Error won't happen"); } localField.setAccessible(bool); } public static Object invokePrivateMethod(Object paramObject, String paramString, Object[] paramArrayOfObject) throws NoSuchMethodException { Assert.notNull(paramObject); Assert.hasText(paramString); Class[] arrayOfClass = new Class[paramArrayOfObject.length]; for (int i = 0; i < paramArrayOfObject.length; i++) arrayOfClass[i] = paramArrayOfObject[i].getClass(); Class localClass1 = paramObject.getClass(); Method localMethod = null; Class localClass2 = localClass1; while (localClass2 != Object.class) try { localMethod = localClass2.getDeclaredMethod(paramString, arrayOfClass); } catch (NoSuchMethodException localNoSuchMethodException) { localClass2 = localClass2.getSuperclass(); } if (localMethod == null) throw new NoSuchMethodException("No Such Method:" + localClass1.getSimpleName() + paramString); boolean bool = localMethod.isAccessible(); localMethod.setAccessible(true); Object localObject = null; try { localObject = localMethod.invoke(paramObject, paramArrayOfObject); } catch (Exception localException) { ReflectionUtils.handleReflectionException(localException); } localMethod.setAccessible(bool); return localObject; } public static List<Field> getFieldsByType(Object paramObject, Class paramClass) { ArrayList localArrayList = new ArrayList(); Field[] arrayOfField1 = paramObject.getClass().getDeclaredFields(); for (Field localField : arrayOfField1) { if (!localField.getType().isAssignableFrom(paramClass)) continue; localArrayList.add(localField); } return localArrayList; } public static Class getPropertyType(Class paramClass, String paramString) throws NoSuchFieldException { return getDeclaredField(paramClass, paramString).getType(); } public static String getGetterName(Class paramClass, String paramString) { Assert.notNull(paramClass, "Type required"); Assert.hasText(paramString, "FieldName required"); if (paramClass.getName().equals("boolean")) return "is" + StringUtils.capitalize(paramString); return "get" + StringUtils.capitalize(paramString); } public static Method getGetterMethod(Class paramClass, String paramString) { try { return paramClass.getMethod(getGetterName(paramClass, paramString), new Class[0]); } catch (NoSuchMethodException localNoSuchMethodException) { _$4.error(localNoSuchMethodException.getMessage(), localNoSuchMethodException); } return null; } static { _$1.setMinimumIntegerDigits(1); _$1.setMinimumFractionDigits(2); _$1.setMaximumFractionDigits(2); } } class FieldBean { public String fieldname; public Object fieldvalue; public String getFieldname() { return this.fieldname; } public void setFieldname(String fieldname) { this.fieldname = fieldname; } public Object getFieldvalue() { return this.fieldvalue; } public void setFieldvalue(Object fieldvalue) { this.fieldvalue = fieldvalue; } }
Java
package com.legendshop.util; import org.springframework.security.authentication.encoding.Md5PasswordEncoder; public class MD5Util { static final int _$21 = 7; static final int _$20 = 12; static final int _$19 = 17; static final int _$18 = 22; static final int _$17 = 5; static final int _$16 = 9; static final int _$15 = 14; static final int _$14 = 20; static final int _$13 = 4; static final int _$12 = 11; static final int _$11 = 16; static final int _$10 = 23; static final int _$9 = 6; static final int _$8 = 10; static final int _$7 = 15; static final int _$6 = 21; static final byte[] _$5 = {-128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; private long[] _$4 = new long[4]; private long[] _$3 = new long[2]; private byte[] _$2 = new byte[64]; public String digestHexStr; private byte[] _$1 = new byte[16]; public String getMD5ofStr(String paramString) { _$2(); _$1(paramString.getBytes(), paramString.length()); _$1(); this.digestHexStr = ""; for (int i = 0; i < 16; i++) this.digestHexStr += byteHEX(this._$1[i]); return this.digestHexStr; } public MD5Util() { _$2(); } private void _$2() { this._$3[0] = 0L; this._$3[1] = 0L; this._$4[0] = 1732584193L; this._$4[1] = 4023233417L; this._$4[2] = 2562383102L; this._$4[3] = 271733878L; } private long _$4(long paramLong1, long paramLong2, long paramLong3) { return paramLong1 & paramLong2 | (paramLong1 ^ 0xFFFFFFFF) & paramLong3; } private long _$3(long paramLong1, long paramLong2, long paramLong3) { return paramLong1 & paramLong3 | paramLong2 & (paramLong3 ^ 0xFFFFFFFF); } private long _$2(long paramLong1, long paramLong2, long paramLong3) { return paramLong1 ^ paramLong2 ^ paramLong3; } private long _$1(long paramLong1, long paramLong2, long paramLong3) { return paramLong2 ^ (paramLong1 | paramLong3 ^ 0xFFFFFFFF); } private long _$4(long paramLong1, long paramLong2, long paramLong3, long paramLong4, long paramLong5, long paramLong6, long paramLong7) { paramLong1 += _$4(paramLong2, paramLong3, paramLong4) + paramLong5 + paramLong7; paramLong1 = (int) paramLong1 << (int) paramLong6 | (int) paramLong1 >>> (int) (32L - paramLong6); paramLong1 += paramLong2; return paramLong1; } private long _$3(long paramLong1, long paramLong2, long paramLong3, long paramLong4, long paramLong5, long paramLong6, long paramLong7) { paramLong1 += _$3(paramLong2, paramLong3, paramLong4) + paramLong5 + paramLong7; paramLong1 = (int) paramLong1 << (int) paramLong6 | (int) paramLong1 >>> (int) (32L - paramLong6); paramLong1 += paramLong2; return paramLong1; } private long _$2(long paramLong1, long paramLong2, long paramLong3, long paramLong4, long paramLong5, long paramLong6, long paramLong7) { paramLong1 += _$2(paramLong2, paramLong3, paramLong4) + paramLong5 + paramLong7; paramLong1 = (int) paramLong1 << (int) paramLong6 | (int) paramLong1 >>> (int) (32L - paramLong6); paramLong1 += paramLong2; return paramLong1; } private long _$1(long paramLong1, long paramLong2, long paramLong3, long paramLong4, long paramLong5, long paramLong6, long paramLong7) { paramLong1 += _$1(paramLong2, paramLong3, paramLong4) + paramLong5 + paramLong7; paramLong1 = (int) paramLong1 << (int) paramLong6 | (int) paramLong1 >>> (int) (32L - paramLong6); paramLong1 += paramLong2; return paramLong1; } private void _$1(byte[] paramArrayOfByte, int paramInt) { byte[] arrayOfByte = new byte[64]; int j = (int) (this._$3[0] >>> 3) & 0x3F; //TODO 暂时这样处理 //if (this._$3[0] += (paramInt << 3) < paramInt << 3) if ((this._$3[0] += paramInt << 3) < (long)(paramInt << 3)) this._$3[1] += 1L; this._$3[1] += (paramInt >>> 29); int k = 64 - j; int i; if (paramInt >= k) { _$1(this._$2, paramArrayOfByte, j, 0, k); _$1(this._$2); for (i = k; i + 63 < paramInt; i += 64) { _$1(arrayOfByte, paramArrayOfByte, 0, i, 64); _$1(arrayOfByte); } j = 0; } else { i = 0; } _$1(this._$2, paramArrayOfByte, j, i, paramInt - i); } private void _$1() { byte[] arrayOfByte = new byte[8]; _$1(arrayOfByte, this._$3, 8); int i = (int) (this._$3[0] >>> 3) & 0x3F; int j = i < 56 ? 56 - i : 120 - i; _$1(_$5, j); _$1(arrayOfByte, 8); _$1(this._$1, this._$4, 16); } private void _$1(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, int paramInt1, int paramInt2, int paramInt3) { for (int i = 0; i < paramInt3; i++) paramArrayOfByte1[(paramInt1 + i)] = paramArrayOfByte2[(paramInt2 + i)]; } private void _$1(byte[] paramArrayOfByte) { long l1 = this._$4[0]; long l2 = this._$4[1]; long l3 = this._$4[2]; long l4 = this._$4[3]; long[] arrayOfLong = new long[16]; _$1(arrayOfLong, paramArrayOfByte, 64); l1 = _$4(l1, l2, l3, l4, arrayOfLong[0], 7L, 3614090360L); l4 = _$4(l4, l1, l2, l3, arrayOfLong[1], 12L, 3905402710L); l3 = _$4(l3, l4, l1, l2, arrayOfLong[2], 17L, 606105819L); l2 = _$4(l2, l3, l4, l1, arrayOfLong[3], 22L, 3250441966L); l1 = _$4(l1, l2, l3, l4, arrayOfLong[4], 7L, 4118548399L); l4 = _$4(l4, l1, l2, l3, arrayOfLong[5], 12L, 1200080426L); l3 = _$4(l3, l4, l1, l2, arrayOfLong[6], 17L, 2821735955L); l2 = _$4(l2, l3, l4, l1, arrayOfLong[7], 22L, 4249261313L); l1 = _$4(l1, l2, l3, l4, arrayOfLong[8], 7L, 1770035416L); l4 = _$4(l4, l1, l2, l3, arrayOfLong[9], 12L, 2336552879L); l3 = _$4(l3, l4, l1, l2, arrayOfLong[10], 17L, 4294925233L); l2 = _$4(l2, l3, l4, l1, arrayOfLong[11], 22L, 2304563134L); l1 = _$4(l1, l2, l3, l4, arrayOfLong[12], 7L, 1804603682L); l4 = _$4(l4, l1, l2, l3, arrayOfLong[13], 12L, 4254626195L); l3 = _$4(l3, l4, l1, l2, arrayOfLong[14], 17L, 2792965006L); l2 = _$4(l2, l3, l4, l1, arrayOfLong[15], 22L, 1236535329L); l1 = _$3(l1, l2, l3, l4, arrayOfLong[1], 5L, 4129170786L); l4 = _$3(l4, l1, l2, l3, arrayOfLong[6], 9L, 3225465664L); l3 = _$3(l3, l4, l1, l2, arrayOfLong[11], 14L, 643717713L); l2 = _$3(l2, l3, l4, l1, arrayOfLong[0], 20L, 3921069994L); l1 = _$3(l1, l2, l3, l4, arrayOfLong[5], 5L, 3593408605L); l4 = _$3(l4, l1, l2, l3, arrayOfLong[10], 9L, 38016083L); l3 = _$3(l3, l4, l1, l2, arrayOfLong[15], 14L, 3634488961L); l2 = _$3(l2, l3, l4, l1, arrayOfLong[4], 20L, 3889429448L); l1 = _$3(l1, l2, l3, l4, arrayOfLong[9], 5L, 568446438L); l4 = _$3(l4, l1, l2, l3, arrayOfLong[14], 9L, 3275163606L); l3 = _$3(l3, l4, l1, l2, arrayOfLong[3], 14L, 4107603335L); l2 = _$3(l2, l3, l4, l1, arrayOfLong[8], 20L, 1163531501L); l1 = _$3(l1, l2, l3, l4, arrayOfLong[13], 5L, 2850285829L); l4 = _$3(l4, l1, l2, l3, arrayOfLong[2], 9L, 4243563512L); l3 = _$3(l3, l4, l1, l2, arrayOfLong[7], 14L, 1735328473L); l2 = _$3(l2, l3, l4, l1, arrayOfLong[12], 20L, 2368359562L); l1 = _$2(l1, l2, l3, l4, arrayOfLong[5], 4L, 4294588738L); l4 = _$2(l4, l1, l2, l3, arrayOfLong[8], 11L, 2272392833L); l3 = _$2(l3, l4, l1, l2, arrayOfLong[11], 16L, 1839030562L); l2 = _$2(l2, l3, l4, l1, arrayOfLong[14], 23L, 4259657740L); l1 = _$2(l1, l2, l3, l4, arrayOfLong[1], 4L, 2763975236L); l4 = _$2(l4, l1, l2, l3, arrayOfLong[4], 11L, 1272893353L); l3 = _$2(l3, l4, l1, l2, arrayOfLong[7], 16L, 4139469664L); l2 = _$2(l2, l3, l4, l1, arrayOfLong[10], 23L, 3200236656L); l1 = _$2(l1, l2, l3, l4, arrayOfLong[13], 4L, 681279174L); l4 = _$2(l4, l1, l2, l3, arrayOfLong[0], 11L, 3936430074L); l3 = _$2(l3, l4, l1, l2, arrayOfLong[3], 16L, 3572445317L); l2 = _$2(l2, l3, l4, l1, arrayOfLong[6], 23L, 76029189L); l1 = _$2(l1, l2, l3, l4, arrayOfLong[9], 4L, 3654602809L); l4 = _$2(l4, l1, l2, l3, arrayOfLong[12], 11L, 3873151461L); l3 = _$2(l3, l4, l1, l2, arrayOfLong[15], 16L, 530742520L); l2 = _$2(l2, l3, l4, l1, arrayOfLong[2], 23L, 3299628645L); l1 = _$1(l1, l2, l3, l4, arrayOfLong[0], 6L, 4096336452L); l4 = _$1(l4, l1, l2, l3, arrayOfLong[7], 10L, 1126891415L); l3 = _$1(l3, l4, l1, l2, arrayOfLong[14], 15L, 2878612391L); l2 = _$1(l2, l3, l4, l1, arrayOfLong[5], 21L, 4237533241L); l1 = _$1(l1, l2, l3, l4, arrayOfLong[12], 6L, 1700485571L); l4 = _$1(l4, l1, l2, l3, arrayOfLong[3], 10L, 2399980690L); l3 = _$1(l3, l4, l1, l2, arrayOfLong[10], 15L, 4293915773L); l2 = _$1(l2, l3, l4, l1, arrayOfLong[1], 21L, 2240044497L); l1 = _$1(l1, l2, l3, l4, arrayOfLong[8], 6L, 1873313359L); l4 = _$1(l4, l1, l2, l3, arrayOfLong[15], 10L, 4264355552L); l3 = _$1(l3, l4, l1, l2, arrayOfLong[6], 15L, 2734768916L); l2 = _$1(l2, l3, l4, l1, arrayOfLong[13], 21L, 1309151649L); l1 = _$1(l1, l2, l3, l4, arrayOfLong[4], 6L, 4149444226L); l4 = _$1(l4, l1, l2, l3, arrayOfLong[11], 10L, 3174756917L); l3 = _$1(l3, l4, l1, l2, arrayOfLong[2], 15L, 718787259L); l2 = _$1(l2, l3, l4, l1, arrayOfLong[9], 21L, 3951481745L); this._$4[0] += l1; this._$4[1] += l2; this._$4[2] += l3; this._$4[3] += l4; } private void _$1(byte[] paramArrayOfByte, long[] paramArrayOfLong, int paramInt) { int i = 0; for (int j = 0; j < paramInt; j += 4) { paramArrayOfByte[j] = (byte) (int) (paramArrayOfLong[i] & 0xFF); paramArrayOfByte[(j + 1)] = (byte) (int) (paramArrayOfLong[i] >>> 8 & 0xFF); paramArrayOfByte[(j + 2)] = (byte) (int) (paramArrayOfLong[i] >>> 16 & 0xFF); paramArrayOfByte[(j + 3)] = (byte) (int) (paramArrayOfLong[i] >>> 24 & 0xFF); i++; } } private void _$1(long[] paramArrayOfLong, byte[] paramArrayOfByte, int paramInt) { int i = 0; for (int j = 0; j < paramInt; j += 4) { paramArrayOfLong[i] = (b2iu(paramArrayOfByte[j]) | b2iu(paramArrayOfByte[(j + 1)]) << 8 | b2iu(paramArrayOfByte[(j + 2)]) << 16 | b2iu(paramArrayOfByte[(j + 3)]) << 24); i++; } } public static long b2iu(byte paramByte) { return paramByte; } public static String byteHEX(byte paramByte) { char[] arrayOfChar1 = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; char[] arrayOfChar2 = new char[2]; arrayOfChar2[0] = arrayOfChar1[(paramByte >>> 4 & 0xF)]; arrayOfChar2[1] = arrayOfChar1[(paramByte & 0xF)]; String str = new String(arrayOfChar2); return str; } public static String toMD5(String paramString) { MD5Util localMD5Util = new MD5Util(); return localMD5Util.getMD5ofStr(paramString); } public static String Md5Password(String paramString1, String paramString2) { if (paramString2 != null) { Md5PasswordEncoder localMd5PasswordEncoder = new Md5PasswordEncoder(); localMd5PasswordEncoder.setEncodeHashAsBase64(false); return localMd5PasswordEncoder.encodePassword(paramString2, paramString1); } return null; } }
Java
package com.legendshop.util.des; import com.legendshop.util.converter.ByteConverter; import com.sun.crypto.provider.SunJCE; import java.io.IOException; import java.io.PrintStream; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Security; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.KeyGenerator; import javax.crypto.NoSuchPaddingException; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; public class DES2 { private final String _$7 = "DES"; private KeyGenerator _$6; private SecretKey _$5; private Cipher _$4; private byte[] _$3; private byte[] _$2; private String _$1 = "12345678"; public DES2(String paramString) { if (paramString != null) init(paramString); else init(paramString); } public DES2() { init(this._$1); } public void init(String paramString) { Security.addProvider(new SunJCE()); try { this._$6 = KeyGenerator.getInstance("DES"); byte[] arrayOfByte = paramString.getBytes(); this._$5 = new SecretKeySpec(arrayOfByte, "DES"); this._$4 = Cipher.getInstance("DES"); } catch (NoSuchAlgorithmException localNoSuchAlgorithmException) { localNoSuchAlgorithmException.printStackTrace(); } catch (NoSuchPaddingException localNoSuchPaddingException) { localNoSuchPaddingException.printStackTrace(); } } public byte[] createEncryptor(byte[] paramArrayOfByte) { try { this._$4.init(1, this._$5); this._$3 = this._$4.doFinal(paramArrayOfByte); } catch (InvalidKeyException localInvalidKeyException) { localInvalidKeyException.printStackTrace(); } catch (BadPaddingException localBadPaddingException) { localBadPaddingException.printStackTrace(); } catch (IllegalBlockSizeException localIllegalBlockSizeException) { localIllegalBlockSizeException.printStackTrace(); } return this._$3; } public byte[] createEncryptor(String paramString) { return createEncryptor(paramString.getBytes()); } public byte[] createDecryptor(byte[] paramArrayOfByte) { try { this._$4.init(2, this._$5); this._$2 = this._$4.doFinal(paramArrayOfByte); } catch (InvalidKeyException localInvalidKeyException) { localInvalidKeyException.printStackTrace(); } catch (BadPaddingException localBadPaddingException) { localBadPaddingException.printStackTrace(); } catch (IllegalBlockSizeException localIllegalBlockSizeException) { localIllegalBlockSizeException.printStackTrace(); } return this._$2; } public String byteToString(byte[] paramArrayOfByte) { String str = null; BASE64Encoder localBASE64Encoder = new BASE64Encoder(); str = localBASE64Encoder.encode(paramArrayOfByte); return str; } public byte[] stringToByte(String paramString) { BASE64Decoder localBASE64Decoder = new BASE64Decoder(); byte[] arrayOfByte = null; try { arrayOfByte = localBASE64Decoder.decodeBuffer(paramString); } catch (IOException localIOException) { localIOException.printStackTrace(); } return arrayOfByte; } public void printByte(byte[] paramArrayOfByte) { System.out.println("*********开始输出字节流**********"); System.out.println("字节流: " + paramArrayOfByte.toString()); for (int i = 0; i < paramArrayOfByte.length; i++) System.out.println("第 " + i + "字节为:" + paramArrayOfByte[i]); System.out.println("*********结束输出字节流**********"); } public static void main(String[] paramArrayOfString) throws Exception { DES2 localDES2 = new DES2("ABCDEFGH"); localDES2.test(localDES2); } public void test(DES2 paramDES2) throws Exception { String str1 = "gdfndjfjgdfjgoiu3i4ou234uisifsoipfhdf好地方"; System.out.println("加密前的数据:" + str1); String str2 = paramDES2.byteToString(paramDES2.createEncryptor(str1)); System.out.println("加密后的数据:" + str2); String str3 = ByteConverter.encode(str2); System.out.println("加密后的16进制编码 :" + str3); String str4 = ByteConverter.decode(str3); System.out.println("解密后的16进制编码 :" + str4); String str5 = new String(paramDES2.createDecryptor(paramDES2 .stringToByte(str4))); System.out.println("解密后的数据:" + str5); } public String getKeyString() { return this._$1; } public void setKeyString(String paramString) { this._$1 = paramString; } }
Java
package com.legendshop.util.uid; import java.io.PrintStream; import java.net.InetAddress; public class UUIDGenerator { private static final int _$3; private static short _$2; private static final int _$1; protected static short getHiTime() { return (short) (int) (System.currentTimeMillis() >>> 32); } protected static int getLoTime() { return (int) System.currentTimeMillis(); } protected static String format(int paramInt) { String str = Integer.toHexString(paramInt); StringBuffer localStringBuffer = new StringBuffer("00000000"); localStringBuffer.replace(8 - str.length(), 8, str); return localStringBuffer.toString(); } protected static String format(short paramShort) { String str = Integer.toHexString(paramShort); StringBuffer localStringBuffer = new StringBuffer("0000"); localStringBuffer.replace(4 - str.length(), 4, str); return localStringBuffer.toString(); } public static synchronized String generate() { return 20 + format(_$3) + format(_$1) + format(getHiTime()) + format(getLoTime()) + format(_$2++); } public static synchronized String generate8Hex() { return format(getLoTime()); } public static void main(String[] paramArrayOfString) { System.out.println(generate()); System.out.println(generate8Hex()); } static { int i; try { byte[] arrayOfByte = InetAddress.getLocalHost().getAddress(); i = arrayOfByte[0] << 24 & 0xFF000000 | arrayOfByte[1] << 16 & 0xFF0000 | arrayOfByte[2] << 8 & 0xFF00 | arrayOfByte[3] & 0xFF; } catch (Exception localException) { i = 0; } _$3 = i; _$2 = 0; _$1 = (int) (System.currentTimeMillis() >>> 8); } }
Java
package com.legendshop.util.uid; public class UID { private static long _$4 = System.currentTimeMillis(); private static short _$3 = -32768; private static Object _$2 = new Object(); private static long _$1 = 1000L; public static String getUID() { long l = 0L; int i = 0; int j = 0; synchronized (_$2) { if (_$3 == 32767) { int k = 0; while (k == 0) { l = System.currentTimeMillis(); if (l < _$4 + _$1) { try { Thread.currentThread(); Thread.sleep(_$1); } catch (InterruptedException localInterruptedException) { } continue; } _$4 = l; _$3 = -32768; k = 1; } } else { l = _$4; } i = _$3++; j = _$1(); } String str = Integer.toString(j, 16) + "`" + Long.toString(l, 16) + "`" + Integer.toString(i, 16); if (str.length() > 24) str = str.substring(str.length() - 24); return str; } private static int _$1() { return new Object().hashCode(); } public static void main(String[] paramArrayOfString) { for (int i = 0; i < 100000000; i++) { String str = getUID(); System.out.println(i + "=" + str); } } }
Java
package com.legendshop.util.uid; import java.util.Random; public class RandomNumber { private final int _$4; private final int _$3; private final int[] _$2; Random _$1 = new Random(); public RandomNumber(int paramInt1, int paramInt2) { this._$4 = paramInt1; this._$3 = paramInt2; this._$2 = new int[this._$4]; for (int i = 0; i < paramInt1; i++) this._$2[i] = i; } public int[] getRamdomNumber() { int i = this._$4 - 1; for (int j = 0; j < this._$3; j++) { int k = this._$1.nextInt(i); swap(k, i); i--; } int[] arrayOfInt = new int[this._$3]; for (int k = 0; k < arrayOfInt.length; k++) arrayOfInt[k] = this._$2[(this._$4 - 1 - k)]; return arrayOfInt; } public void swap(int paramInt1, int paramInt2) { int i = this._$2[paramInt1]; this._$2[paramInt1] = this._$2[paramInt2]; this._$2[paramInt2] = i; } public static void main(String[] paramArrayOfString) { RandomNumber localRandomNumber = new RandomNumber(20, 6); for (int i = 0; i < 10; i++) { int[] arrayOfInt = localRandomNumber.getRamdomNumber(); StringBuilder localStringBuilder = new StringBuilder(); for (int j = 0; j < arrayOfInt.length; j++) localStringBuilder.append(arrayOfInt[j]).append(","); System.out.println(localStringBuilder.toString()); } } }
Java
package com.legendshop.util.uid; import java.io.Serializable; import java.util.Properties; import org.hibernate.Hibernate; import org.hibernate.dialect.Dialect; import org.hibernate.engine.SessionImplementor; import org.hibernate.id.AbstractUUIDGenerator; import org.hibernate.id.Configurable; import org.hibernate.type.Type; import org.hibernate.util.PropertiesHelper; public class UIDGenerator extends AbstractUUIDGenerator implements Configurable { private static long _$5 = System.currentTimeMillis(); private static short _$4 = -32768; private static Object _$3 = new Object(); private static long _$2 = 1000L; private String _$1 = ""; public Serializable generate(SessionImplementor paramSessionImplementor, Object paramObject) { long l = 0L; int i = 0; int j = 0; synchronized (_$3) { if (_$4 == 32767) { int k = 0; while (k == 0) { l = System.currentTimeMillis(); if (l < _$5 + _$2) { try { Thread.currentThread(); Thread.sleep(_$2); } catch (InterruptedException localInterruptedException) { } continue; } _$5 = l; _$4 = -32768; k = 1; } } else { l = _$5; } i = _$4++; j = _$1(); } String str = Integer.toString(j, 16) + this._$1 + Long.toString(l, 16) + this._$1 + Integer.toString(i, 16); if (str.length() > 24) str = str.substring(str.length() - 24); return (Serializable) str; } public Serializable generate_old( SessionImplementor paramSessionImplementor, Object paramObject) { String str = paramObject.getClass().getName(); return 64 + str.substring(str.lastIndexOf('.') + 1) + this._$1 + (short) getIP() + this._$1 + Math.abs((short) getJVM()) + this._$1 + getCount(); } private static int _$1() { return new Object().hashCode(); } public void configure(Type paramType, Properties paramProperties, Dialect paramDialect) { this._$1 = PropertiesHelper.getString("separator", paramProperties, ""); } @SuppressWarnings("deprecation") public static void main(String[] paramArrayOfString) throws Exception { Properties localProperties = new Properties(); localProperties.setProperty("separator", ""); UIDGenerator localUIDGenerator1 = new UIDGenerator(); ((Configurable) localUIDGenerator1).configure(Hibernate.STRING, localProperties, null); UIDGenerator localUIDGenerator2 = new UIDGenerator(); ((Configurable) localUIDGenerator2).configure(Hibernate.STRING, localProperties, null); for (int i = 0; i < 10; i++) { String str1 = (String) localUIDGenerator1.generate(null, localUIDGenerator1); System.out.println(str1); String str2 = (String) localUIDGenerator2.generate(null, localUIDGenerator2); System.out.println(str2); } } }
Java
package com.legendshop.util.converter; import java.io.ByteArrayOutputStream; import java.util.Date; import com.legendshop.util.TimerUtil; import com.legendshop.util.des.DES2; public class ByteConverter { private static String _$1 = "0123456789ABCDEF"; public static String stringToHexString(String paramString) { String str1 = ""; for (int i = 0; i < paramString.length(); i++) { int j = paramString.charAt(i); String str2 = Integer.toHexString(j); str1 = str1 + str2; } return str1; } public static String encode(String paramString) { byte[] arrayOfByte = paramString.getBytes(); StringBuilder localStringBuilder = new StringBuilder( arrayOfByte.length * 2); for (int i = 0; i < arrayOfByte.length; i++) { localStringBuilder.append(_$1.charAt((arrayOfByte[i] & 0xF0) >> 4)); localStringBuilder.append(_$1.charAt((arrayOfByte[i] & 0xF) >> 0)); } return localStringBuilder.toString(); } public static String decode(String paramString) { ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream( paramString.length() / 2); for (int i = 0; i < paramString.length(); i += 2) localByteArrayOutputStream .write(_$1.indexOf(paramString.charAt(i)) << 4 | _$1.indexOf(paramString.charAt(i + 1))); return new String(localByteArrayOutputStream.toByteArray()); } public static String encode(String paramString, int paramInt) { byte[] arrayOfByte = paramString.getBytes(); StringBuilder localStringBuilder = new StringBuilder( arrayOfByte.length * 2); for (int i = 0; i < arrayOfByte.length; i++) { localStringBuilder.append(_$1 .charAt((arrayOfByte[i] & 0xF0) >> paramInt)); localStringBuilder.append(_$1.charAt((arrayOfByte[i] & 0xF) >> 0)); } return localStringBuilder.toString(); } public static String decode(String paramString, int paramInt) { ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream( paramString.length() / 2); for (int i = 0; i < paramString.length(); i += 2) localByteArrayOutputStream .write(_$1.indexOf(paramString.charAt(i)) << paramInt | _$1.indexOf(paramString.charAt(i + 1))); return new String(localByteArrayOutputStream.toByteArray()); } private static byte _$1(byte paramByte1, byte paramByte2) { int i = Byte.decode("0x" + new String(new byte[] {paramByte1 })) .byteValue(); i = (byte) (i << 4); int j = Byte.decode("0x" + new String(new byte[] {paramByte2 })) .byteValue(); return (byte) (i | j); } public static byte[] HexString2Bytes(String paramString) { byte[] arrayOfByte1 = new byte[6]; byte[] arrayOfByte2 = paramString.getBytes(); for (int i = 0; i < 6; i++) arrayOfByte1[i] = _$1(arrayOfByte2[(i * 2)], arrayOfByte2[(i * 2 + 1)]); return arrayOfByte1; } public static byte[] hexStringToBytes(String paramString) throws IllegalArgumentException { int i = paramString.length(); if (i % 2 > 0) { paramString = "0" + paramString; i++; } byte[] arrayOfByte = new byte[i / 2]; char[] arrayOfChar = paramString.toUpperCase().toCharArray(); int j = 0; int k = 0; while (j < arrayOfByte.length) { int m = _$1.indexOf(arrayOfChar[(k++)]); if (m < 0) throw new IllegalArgumentException(arrayOfChar[(k - 1)] + " is not a hex char"); int n = _$1.indexOf(arrayOfChar[(k++)]); if (n < 0) throw new IllegalArgumentException(arrayOfChar[(k - 1)] + " is not a hex char"); arrayOfByte[j] = (byte) (m << 4 | n); j++; } return arrayOfByte; } public static void main(String[] paramArrayOfString) { String str1 = "413779696E723974526D3944524A585A613348736165596331796D7A2B377967"; DES2 localDES2 = new DES2(); String str2 = new String(localDES2.createDecryptor(localDES2 .stringToByte(decode(str1)))); Date localDate = TimerUtil.strToDate(str2); System.out.println("date = " + localDate); System.out.println("s1 = " + str2); System.out.println(encode("AB")); System.out.println(decode(str1)); byte[] arrayOfByte = hexStringToBytes("4142"); System.out.println("length = " + arrayOfByte.length); for (int i = 0; i < arrayOfByte.length; i++) { int j = arrayOfByte[i]; System.out.println(j); } String str3 = "1234"; String str4 = encode(encode(str3, 2), 6); System.out.println(str4); System.out.println(decode(decode(str4, 2), 6)); } }
Java
package com.legendshop.util.converter; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.MissingResourceException; import org.apache.log4j.Logger; public class ConvertDateUtil { private static Logger _$3 = Logger.getLogger(ConvertDateUtil.class); private static String _$2 = null; private static String _$1 = "HH:mm"; public static synchronized String getDatePattern() { try { _$2 = "yyyy-MM-dd"; } catch (MissingResourceException localMissingResourceException) { _$2 = "MM/dd/yyyy"; } return _$2; } public static final String getDate(Date paramDate) { SimpleDateFormat localSimpleDateFormat = null; String str = ""; if (paramDate != null) { localSimpleDateFormat = new SimpleDateFormat(getDatePattern()); str = localSimpleDateFormat.format(paramDate); } return str; } public static final Date convertStringToDate(String paramString1, String paramString2) throws ParseException { SimpleDateFormat localSimpleDateFormat = null; Date localDate = null; localSimpleDateFormat = new SimpleDateFormat(paramString1); if (_$3.isDebugEnabled()) _$3.debug("converting '" + paramString2 + "' to date with mask '" + paramString1 + "'"); try { localDate = localSimpleDateFormat.parse(paramString2); } catch (ParseException localParseException) { throw new ParseException(localParseException.getMessage(), localParseException.getErrorOffset()); } return localDate; } public static String getTimeNow(Date paramDate) { return getDateTime(_$1, paramDate); } public static Calendar getToday() throws ParseException { Date localDate = new Date(); SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( getDatePattern()); String str = localSimpleDateFormat.format(localDate); GregorianCalendar localGregorianCalendar = new GregorianCalendar(); localGregorianCalendar.setTime(convertStringToDate(str)); return localGregorianCalendar; } public static final String getDateTime(String paramString, Date paramDate) { SimpleDateFormat localSimpleDateFormat = null; String str = ""; if (paramDate == null) { _$3.error("aDate is null!"); } else { localSimpleDateFormat = new SimpleDateFormat(paramString); str = localSimpleDateFormat.format(paramDate); } return str; } public static final String convertDateToString(Date paramDate) { return getDateTime(getDatePattern(), paramDate); } public static Date convertStringToDate(String paramString) throws ParseException { Date localDate = null; try { if (_$3.isDebugEnabled()) _$3.debug("converting date with pattern: " + getDatePattern()); localDate = convertStringToDate(getDatePattern(), paramString); } catch (ParseException localParseException) { _$3.error("Could not convert '" + paramString + "' to a date, throwing exception"); localParseException.printStackTrace(); throw new ParseException(localParseException.getMessage(), localParseException.getErrorOffset()); } return localDate; } }
Java
package com.legendshop.util.converter; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import org.apache.commons.beanutils.ConversionException; import org.apache.commons.lang.StringUtils; public class TimestampConverter extends DateConverter { public static final String TS_FORMAT = ConvertDateUtil.getDatePattern() + " HH:mm:ss.S"; protected Object convertToDate(Class paramClass, Object paramObject) { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat(TS_FORMAT); if ((paramObject instanceof String)) try { if (StringUtils.isEmpty(paramObject.toString())) return null; return localSimpleDateFormat.parse((String) paramObject); } catch (Exception localException) { throw new ConversionException( "Error converting String to Timestamp"); } throw new ConversionException("Could not convert " + paramObject.getClass().getName() + " to " + paramClass.getName()); } protected Object convertToString(Class paramClass, Object paramObject) { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat(TS_FORMAT); if ((paramObject instanceof Date)) try { return localSimpleDateFormat.format(paramObject); } catch (Exception localException) { throw new ConversionException( "Error converting Timestamp to String"); } return paramObject.toString(); } }
Java