package com.cjt.zr.comm;
import java.util.regex.*;
//import sun.misc.*;
import java.io.*;
import java.security.*;
import java.text.*;
import java.util.*;
/**
* <p>
* Title: Gislei MSD
* </p>
*
* <p>
* Description: MSD
* </p>
*
* <p>
* Copyright: Copyright (c) 2007
* </p>
*
* <p>
* Company:
* </p>
*
* @author Gislei
* @version 1.0
*/
public class Util {
private static final char[] QUOTE_ENCODE = """.toCharArray();
private static final char[] AMP_ENCODE = "&".toCharArray();
private static final char[] LT_ENCODE = "<".toCharArray();
private static final char[] GT_ENCODE = ">".toCharArray();
private static MessageDigest digest = null;
public Util() {
}
public static boolean validateUserName(String username) {
Pattern p = Pattern.compile("^\\w+$");
Matcher m = p.matcher(username);
if (m.find()) {
return true;
}
return false;
}
public static String Array2String(String[] values) {
String result = "";
if (values == null) {
return result;
}
int len = values.length;
for (int i = 0; i < len; i++) {
result += values[i] + ",";
}
if (result.endsWith(",")) {
result = result.substring(result.length() - 1);
}
return result;
}
public static String Array2String(Object[] values) {
String result = "";
if (values == null) {
return result;
}
int len = values.length;
for (int i = 0; i < len; i++) {
result += values[i].toString() + ",";
}
if (result.endsWith(",")) {
result = result.substring(result.length() - 1);
}
return result;
}
public static String Array2String(List values) {
String result = "";
if (values == null) {
return result;
}
int len = values.size();
for (int i = 0; i < len; i++) {
result += values.get(i).toString() + ",";
}
if (result.endsWith(",")) {
result = result.substring(result.length() - 1);
}
return result;
}
public static String base64Encode(String txt) {
if (txt != null && txt.length() > 0) {
txt = new sun.misc.BASE64Encoder().encode(txt.getBytes());
}
return txt;
}
public static String base64Encode(byte[] txt) {
String encodeTxt = "";
if (txt != null && txt.length > 0) {
encodeTxt = new sun.misc.BASE64Encoder().encode(txt);
}
return encodeTxt;
}
public static String base64decode(String txt) {
if (txt != null && txt.length() > 0) {
byte[] buf;
try {
buf = new sun.misc.BASE64Decoder().decodeBuffer(txt);
txt = new String(buf);
} catch (IOException ex) {
}
}
return txt;
}
public static byte[] base64decodebyte(String txt) {
byte[] buf = null;
if (txt != null && txt.length() > 0) {
try {
buf = new sun.misc.BASE64Decoder().decodeBuffer(txt);
} catch (IOException ex) {
}
}
return buf;
}
/**
* Replaces all instances of oldString with newString in line.
*
* @param line
* the String to search to perform replacements on
* @param oldString
* the String that should be replaced by newString
* @param newString
* the String that will replace all instances of oldString
*
* @return a String will all instances of oldString replaced by newString
*/
public static final String replace(String line, String oldString, String newString) {
if (line == null) {
return null;
}
int i = 0;
if ((i = line.indexOf(oldString, i)) >= 0) {
char[] line2 = line.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuffer buf = new StringBuffer(line2.length);
buf.append(line2, 0, i).append(newString2);
i += oLength;
int j = i;
while ((i = line.indexOf(oldString, i)) > 0) {
buf.append(line2, j, i - j).append(newString2);
i += oLength;
j = i;
}
buf.append(line2, j, line2.length - j);
return buf.toString();
}
return line;
}
/**
* Replaces all instances of oldString with newString in line with the added
* feature that matches of newString in oldString ignore case.
*
* @param line
* the String to search to perform replacements on
* @param oldString
* the String that should be replaced by newString
* @param newString
* the String that will replace all instances of oldString
*
* @return a String will all instances of oldString replaced by newString
*/
public static final String replaceIgnoreCase(String line, String oldString, String newString) {
if (line == null) {
return null;
}
String lcLine = line.toLowerCase();
String lcOldString = oldString.toLowerCase();
int i = 0;
if ((i = lcLine.indexOf(lcOldString, i)) >= 0) {
char[] line2 = line.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuffer buf = new StringBuffer(line2.length);
buf.append(line2, 0, i).append(newString2);
i += oLength;
int j = i;
while ((i = lcLine.indexOf(lcOldString, i)) > 0) {
buf.append(line2, j, i - j).append(newString2);
i += oLength;
j = i;
}
buf.append(line2, j, line2.length - j);
return buf.toString();
}
return line;
}
/**
* Replaces all instances of oldString with newString in line with the added
* feature that matches of newString in oldString ignore case. The count
* paramater is set to the number of replaces performed.
*
* @param line
* the String to search to perform replacements on
* @param oldString
* the String that should be replaced by newString
* @param newString
* the String that will replace all instances of oldString
* @param count
* a value that will be updated with the number of replaces
* performed.
*
* @return a String will all instances of oldString replaced by newString
*/
public static final String replaceIgnoreCase(String line, String oldString, String newString, int[] count) {
if (line == null) {
return null;
}
String lcLine = line.toLowerCase();
String lcOldString = oldString.toLowerCase();
int i = 0;
if ((i = lcLine.indexOf(lcOldString, i)) >= 0) {
int counter = 0;
char[] line2 = line.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuffer buf = new StringBuffer(line2.length);
buf.append(line2, 0, i).append(newString2);
i += oLength;
int j = i;
while ((i = lcLine.indexOf(lcOldString, i)) > 0) {
counter++;
buf.append(line2, j, i - j).append(newString2);
i += oLength;
j = i;
}
buf.append(line2, j, line2.length - j);
count[0] = counter;
return buf.toString();
}
return line;
}
/**
* Replaces all instances of oldString with newString in line. The count
* Integer is updated with number of replaces.
*
* @param line
* the String to search to perform replacements on
* @param oldString
* the String that should be replaced by newString
* @param newString
* the String that will replace all instances of oldString
*
* @return a String will all instances of oldString replaced by newString
*/
public static final String replace(String line, String oldString, String newString, int[] count) {
if (line == null) {
return null;
}
int i = 0;
if ((i = line.indexOf(oldString, i)) >= 0) {
int counter = 0;
counter++;
char[] line2 = line.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuffer buf = new StringBuffer(line2.length);
buf.append(line2, 0, i).append(newString2);
i += oLength;
int j = i;
while ((i = line.indexOf(oldString, i)) > 0) {
counter++;
buf.append(line2, j, i - j).append(newString2);
i
没有合适的资源?快使用搜索试试~ 我知道了~
struts2+hibernate+spring框架整合实列
共198个文件
jar:73个
class:43个
java:40个
需积分: 9 12 下载量 178 浏览量
2009-07-30
09:42:21
上传
评论
收藏 19.93MB RAR 举报
温馨提示
struts2+hibernate+spring框架整合实列
资源详情
资源评论
资源推荐
收起资源包目录
struts2+hibernate+spring框架整合实列 (198个子文件)
Util.class 17KB
MSDUtil.class 16KB
IPSeeker.class 11KB
Constant.class 9KB
Page.class 9KB
UserLoginAction.class 5KB
DES.class 4KB
SysOptionsValues.class 4KB
AutoFilter.class 3KB
StringUtils.class 3KB
ImgUtil.class 3KB
BaseAction.class 3KB
PageTag.class 3KB
Pages.class 2KB
UserInfoHibernateDAO.class 2KB
UserInfoServiceImp.class 2KB
RegFilterBuilder.class 2KB
RequestBasePathInterceptor.class 2KB
RemoteAddrInterceptor.class 2KB
UserInfoHibernateDAO$1.class 2KB
RegexFilter.class 2KB
SysQueue.class 1KB
UserInfo.class 1KB
HQLCondition.class 987B
OrderObj.class 930B
OptionsString.class 873B
OptionsLong.class 867B
OptionsInt.class 864B
RadioInt.class 858B
PageList.class 850B
SysConfigException.class 820B
MsdException.class 802B
RegFilterBuilder$1.class 758B
IPSeeker$IPLocation.class 745B
IMGFilter.class 610B
FilterDirector.class 562B
IPEntry.class 441B
UserInfoService.class 366B
UserInfoDAO.class 337B
FilterBuilder.class 200B
RequestBasePathAware.class 194B
RemoteAddrAware.class 186B
Filter.class 157B
.classpath 6KB
css1.css 12KB
css3.css 4KB
admin.css 3KB
css1.css 2KB
incss.css 2KB
archiveslist.css 2KB
friend.css 2KB
read.css 2KB
archivespost.css 859B
css2.css 218B
actionerror.ftl 190B
actionerror.ftl 190B
spring.jar 2.47MB
hibernate3.jar 2.11MB
struts2-core-2.0.9.jar 2.1MB
jgroups-2.2.8.jar 1.54MB
ojdbc14.jar 1.47MB
checkstyle-all.jar 1.15MB
ant-1.6.5.jar 1010KB
xerces-2.6.2.jar 987KB
freemarker-2.3.8.jar 784KB
c3p0-0.9.1.jar 594KB
proxool-0.8.3.jar 465KB
javassist.jar 460KB
xwork-2.0.4.jar 445KB
antlr-2.7.6.jar 433KB
mysql-connector-java-3.1.11-bin.jar 430KB
quartz-all-1.5.2.jar 396KB
log4j-1.2.11.jar 342KB
mail.jar 339KB
struts-core-1.3.5.jar 312KB
dom4j-1.6.1.jar 307KB
cglib-2.1.3.jar 276KB
commons-lang-2.3.jar 240KB
jaxen-1.1-beta-7.jar 222KB
ehcache-1.2.3.jar 203KB
rome-0.8.jar 193KB
commons-collections-2.1.1.jar 171KB
concurrent-1.3.2.jar 167KB
ognl-2.6.11.jar 164KB
jdom.jar 150KB
urlrewrite-2.6.0.jar 145KB
cleanimports.jar 139KB
syndiag2.jar 139KB
tiles-core-2.0.4.jar 123KB
xml-apis.jar 121KB
junit-3.8.1.jar 118KB
commons-validator-1.3.0.jar 117KB
commons-beanutils-1.6.jar 116KB
oscache-2.1.jar 112KB
jaas.jar 102KB
spring-mock.jar 97KB
commons-chain-1.1.jar 88KB
commons-io-1.3.1.jar 82KB
ezmorph-1.0.1.jar 76KB
ant-junit-1.6.5.jar 72KB
共 198 条
- 1
- 2
t278739654
- 粉丝: 10
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0