优化代码,删除工具类测试代码。

This commit is contained in:
thinkgem
2018-04-10 21:06:34 +08:00
parent 8630873100
commit 737cff469d
18 changed files with 398 additions and 440 deletions

View File

@@ -201,18 +201,18 @@ public class AesUtils {
}
}
public static void main(String[] args) {
String s = "hello word!";
System.out.println(s);
String k = genKeyString();
System.out.println(k);
String ss = encode(s, k);
System.out.println(ss);
String sss = decode(ss, k);
System.out.println(sss);
}
// public static void main(String[] args) {
//
// String s = "hello word!";
// System.out.println(s);
//
// String k = genKeyString();
// System.out.println(k);
// String ss = encode(s, k);
// System.out.println(ss);
// String sss = decode(ss, k);
// System.out.println(sss);
//
// }
}

View File

@@ -81,35 +81,35 @@ public class IdGenerate {
return null;
}
public static void main(String[] args) {
System.out.println(uuid());
System.out.println(nextId());
System.out.println(nextCode("8"));
System.out.println(nextCode("09"));
System.out.println(nextCode("009"));
System.out.println(nextCode("E09"));
System.out.println(nextCode("EC09"));
System.out.println(nextCode("EC0101"));
System.out.println(nextCode("EC0109"));
System.out.println(nextCode("EC02T03"));
System.out.println(nextCode("EC02T099"));
System.out.println(nextCode("EC02T100"));
System.out.println(nextCode("EC02T10A"));
// // 数值型ID重复验证测试
// Set<String> set = SetUtils.newHashSet();
// try{
// for (int i=0; i<100; i++){
// String id = String.valueOf(nextId());
// if (set.contains(id)){
// throw new Exception(id + " exists");
// }
// set.add(id);
// System.out.println(id);
// Thread.sleep(100);
// }
// }catch (Exception e) {
// e.printStackTrace();
// }
}
// public static void main(String[] args) {
// System.out.println(uuid());
// System.out.println(nextId());
// System.out.println(nextCode("8"));
// System.out.println(nextCode("09"));
// System.out.println(nextCode("009"));
// System.out.println(nextCode("E09"));
// System.out.println(nextCode("EC09"));
// System.out.println(nextCode("EC0101"));
// System.out.println(nextCode("EC0109"));
// System.out.println(nextCode("EC02T03"));
// System.out.println(nextCode("EC02T099"));
// System.out.println(nextCode("EC02T100"));
// System.out.println(nextCode("EC02T10A"));
//// // 数值型ID重复验证测试
//// Set<String> set = SetUtils.newHashSet();
//// try{
//// for (int i=0; i<100; i++){
//// String id = String.valueOf(nextId());
//// if (set.contains(id)){
//// throw new Exception(id + " exists");
//// }
//// set.add(id);
//// System.out.println(id);
//// Thread.sleep(100);
//// }
//// }catch (Exception e) {
//// e.printStackTrace();
//// }
// }
}

View File

@@ -4,12 +4,6 @@
package com.jeesite.common.idgen;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.TimeUnit;
import com.jeesite.common.collect.SetUtils;
/**
* 来自于twitter项目snowflake的id产生方案全局唯一时间有序。
@@ -112,50 +106,50 @@ public class IdWorker {
return System.currentTimeMillis();
}
//////////// test ////////////
public static void main(String[] args) throws Exception {
final Set<Long> set = SetUtils.newHashSet();
final IdWorker w1 = new IdWorker(-1, -1);
final IdWorker w2 = new IdWorker(-1, -1);
final CyclicBarrier cdl = new CyclicBarrier(100);
for (int i = 0; i < 1000; i++) {
new Thread(new Runnable() {
@Override
public void run() {
try {
cdl.await();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (BrokenBarrierException e) {
e.printStackTrace();
}
// id
Long id = w1.nextId();
if (set.contains(id)){
System.out.println(id + " exists");
}
set.add(id);
System.out.println(id);
// id2
Long id2 = w2.nextId();
if (set.contains(id2)){
System.out.println(id2 + " exists");
}
set.add(id2);
System.out.println(id2);
}
}).start();
}
try {
TimeUnit.SECONDS.sleep(5);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
// //////////// test ////////////
//
// public static void main(String[] args) throws Exception {
// final Set<Long> set = SetUtils.newHashSet();
//
// final IdWorker w1 = new IdWorker(-1, -1);
// final IdWorker w2 = new IdWorker(-1, -1);
// final CyclicBarrier cdl = new CyclicBarrier(100);
//
// for (int i = 0; i < 1000; i++) {
// new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// cdl.await();
// } catch (InterruptedException e) {
// e.printStackTrace();
// } catch (BrokenBarrierException e) {
// e.printStackTrace();
// }
//
// // id
// Long id = w1.nextId();
// if (set.contains(id)){
// System.out.println(id + " exists");
// }
// set.add(id);
// System.out.println(id);
//
// // id2
// Long id2 = w2.nextId();
// if (set.contains(id2)){
// System.out.println(id2 + " exists");
// }
// set.add(id2);
// System.out.println(id2);
// }
// }).start();
// }
// try {
// TimeUnit.SECONDS.sleep(5);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
}

View File

@@ -6,7 +6,6 @@ package com.jeesite.common.image;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;
@@ -171,12 +170,12 @@ public class CaptchaUtils {
return s;
}
public static void main(String[] args) throws IOException {
FileOutputStream fos = new FileOutputStream("x:\\captcha.png");
String s = generateCaptcha(fos);
System.out.println(s);
fos.close();
}
// public static void main(String[] args) throws IOException {
//
// FileOutputStream fos = new FileOutputStream("x:\\captcha.png");
// String s = generateCaptcha(fos);
// System.out.println(s);
// fos.close();
//
// }
}

View File

@@ -57,9 +57,9 @@ public class ImageGeo {
System.out.println(filename + ": (" + lat + ", " + lon + ")");
}
public static void main(String[] args) {
ImageGeo imageGeo = new ImageGeo(ImageGeo.class.getResource("IMAG0068.jpg").getFile());
System.out.println(imageGeo.lon + "," + imageGeo.lat);
}
// public static void main(String[] args) {
// ImageGeo imageGeo = new ImageGeo(ImageGeo.class.getResource("IMAG0068.jpg").getFile());
// System.out.println(imageGeo.lon + "," + imageGeo.lat);
// }
}

View File

@@ -8,7 +8,6 @@ import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.imageio.ImageIO;
@@ -20,7 +19,7 @@ import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
* <b>function:</b> 缩放图片工具类,创建缩略图、伸缩图片比例
* 缩放图片工具类,创建缩略图、伸缩图片比例
* @author hoojo
* @createDate 2012-2-3 上午10:08:47
* @file ScaleImageUtils.java
@@ -35,7 +34,7 @@ public abstract class ImageUtils {
private static final String DEFAULT_FILE_PATH = FileUtils.getTempDirectoryPath();
/**
* <b>function:</b> 设置图片压缩质量枚举类;
* 设置图片压缩质量枚举类;
* Some guidelines: 0.75 high quality、0.5 medium quality、0.25 low quality
* @author hoojo
* @createDate 2012-2-7 上午11:31:45
@@ -61,7 +60,7 @@ public abstract class ImageUtils {
private static Image image;
/**
* <b>function:</b> 通过目标对象的大小和标准(指定)大小计算出图片缩小的比例
* 通过目标对象的大小和标准(指定)大小计算出图片缩小的比例
* @author hoojo
* @createDate 2012-2-6 下午04:41:48
* @param targetWidth 目标的宽度
@@ -87,7 +86,7 @@ public abstract class ImageUtils {
}
/**
* <b>function:</b> 将Image的宽度、高度缩放到指定width、height并保存在savePath目录
* 将Image的宽度、高度缩放到指定width、height并保存在savePath目录
* @author hoojo
* @createDate 2012-2-6 下午04:54:35
* @param width 缩放的宽度
@@ -120,7 +119,7 @@ public abstract class ImageUtils {
}
/**
* <b>function:</b> 可以设置图片缩放质量,并且可以根据指定的宽高缩放图片
* 可以设置图片缩放质量,并且可以根据指定的宽高缩放图片
* @author hoojo
* @createDate 2012-2-7 上午11:01:27
* @param width 缩放的宽度
@@ -162,7 +161,7 @@ public abstract class ImageUtils {
}
/**
* <b>function:</b> 通过指定大小和图片的大小,计算出图片缩小的合适大小
* 通过指定大小和图片的大小,计算出图片缩小的合适大小
* @author hoojo
* @createDate 2012-2-6 下午05:53:10
* @param width 指定的宽度
@@ -180,7 +179,7 @@ public abstract class ImageUtils {
}
/**
* <b>function:</b> 通过指定的比例和图片对象,返回一个放大或缩小的宽度、高度
* 通过指定的比例和图片对象,返回一个放大或缩小的宽度、高度
* @author hoojo
* @createDate 2012-2-7 上午10:27:59
* @param scale 缩放比例
@@ -210,8 +209,7 @@ public abstract class ImageUtils {
}
/**
*
* <b>function:</b> 将指定的targetFile图片文件的宽度、高度大于指定width、height的图片缩小并保存在savePath目录
* 将指定的targetFile图片文件的宽度、高度大于指定width、height的图片缩小并保存在savePath目录
* @author hoojo
* @createDate 2012-2-6 下午04:57:02
* @param width 缩小的宽度
@@ -230,7 +228,7 @@ public abstract class ImageUtils {
/**
*
* <b>function:</b> 将指定的targetURL网络图片文件的宽度、高度大于指定width、height的图片缩小并保存在savePath目录
* 将指定的targetURL网络图片文件的宽度、高度大于指定width、height的图片缩小并保存在savePath目录
* @author hoojo
* @createDate 2012-2-6 下午04:57:07
* @param width 缩小的宽度
@@ -248,7 +246,7 @@ public abstract class ImageUtils {
}
/**
* <b>function:</b> 将一个本地的图片文件按照指定的比例进行缩放
* 将一个本地的图片文件按照指定的比例进行缩放
* @author hoojo
* @createDate 2012-2-7 上午10:29:18
* @param scale 缩放比例
@@ -265,7 +263,7 @@ public abstract class ImageUtils {
}
/**
* <b>function:</b> 将一个网络图片文件按照指定的比例进行缩放
* 将一个网络图片文件按照指定的比例进行缩放
* @author hoojo
* @createDate 2012-2-7 上午10:30:56
* @param scale 缩放比例
@@ -282,7 +280,7 @@ public abstract class ImageUtils {
}
/**
* <b>function:</b> 按照固定宽度进行等比缩放本地图片
* 按照固定宽度进行等比缩放本地图片
* @author hoojo
* @createDate 2012-2-7 上午10:49:56
* @param width 固定宽度
@@ -299,7 +297,7 @@ public abstract class ImageUtils {
}
/**
* <b>function:</b> 按照固定宽度进行等比缩放网络图片
* 按照固定宽度进行等比缩放网络图片
* @author hoojo
* @createDate 2012-2-7 上午10:50:52
* @param width 固定宽度
@@ -317,7 +315,7 @@ public abstract class ImageUtils {
/**
*
* <b>function:</b> 按照固定高度进行等比缩放本地图片
* 按照固定高度进行等比缩放本地图片
* @author hoojo
* @createDate 2012-2-7 上午10:51:17
* @param height 固定高度
@@ -334,7 +332,7 @@ public abstract class ImageUtils {
}
/**
* <b>function:</b> 按照固定高度进行等比缩放网络图片
* 按照固定高度进行等比缩放网络图片
* @author hoojo
* @createDate 2012-2-7 上午10:52:23
* @param height 固定高度
@@ -350,18 +348,10 @@ public abstract class ImageUtils {
return resize(size[0], size[1], savePath, image);
}
/**
* <b>function:</b>
* @author hoojo
* @createDate 2012-2-3 上午10:08:47
* @param args
* @throws IOException
* @throws MalformedURLException
* @throws ImageFormatException
*/
public static void main(String[] args) throws ImageFormatException, MalformedURLException, IOException {
System.out.println(ImageUtils.resize(140, 140, null, new URL("http://www.open-open.com/lib/images/logo.jpg")));
ImageUtils.resize(100, 100, ImageQuality.high.getQuality(), null, ImageIO.read(new URL("http://www.open-open.com/lib/images/logo.jpg")));
}
// public static void main(String[] args) throws ImageFormatException, MalformedURLException, IOException {
//
// System.out.println(ImageUtils.resize(140, 140, null, new URL("http://www.open-open.com/lib/images/logo.jpg")));
// ImageUtils.resize(100, 100, ImageQuality.high.getQuality(), null, ImageIO.read(new URL("http://www.open-open.com/lib/images/logo.jpg")));
// }
}

View File

@@ -125,35 +125,32 @@ public class ZxingUtils {
return null;
}
/**
* @param args
*/
public static void main(String[] args) {
// 条形码
String imgPath = "target\\zxing_EAN13.png";
String contents = "6923450657713";
int width = 105, height = 50;
ZxingUtils.encode(contents, width, height, imgPath);
System.out.println("finished zxing EAN-13 encode.");
String decodeContent = ZxingUtils.decode(imgPath);
System.out.println("解码内容如下:" + decodeContent);
System.out.println("finished zxing EAN-13 decode.");
// 二维码
String imgPath2 = "target\\zxing.png";
String contents2 = "Hello Gem, welcome to Zxing!" + "\nBlog [ http://thinkgem.iteye.com ]" + "\nEMail [ thinkgem@163.com ]";
int width2 = 300, height2 = 300;
ZxingUtils.encode2(contents2, width2, height2, imgPath2);
System.out.println("finished zxing encode.");
String decodeContent2 = ZxingUtils.decode2(imgPath2);
System.out.println("解码内容如下:" + decodeContent2);
System.out.println("finished zxing decode.");
}
// public static void main(String[] args) {
//
// // 条形码
// String imgPath = "target\\zxing_EAN13.png";
// String contents = "6923450657713";
// int width = 105, height = 50;
//
// ZxingUtils.encode(contents, width, height, imgPath);
// System.out.println("finished zxing EAN-13 encode.");
//
// String decodeContent = ZxingUtils.decode(imgPath);
// System.out.println("解码内容如下:" + decodeContent);
// System.out.println("finished zxing EAN-13 decode.");
//
// // 二维码
// String imgPath2 = "target\\zxing.png";
// String contents2 = "Hello Gem, welcome to Zxing!" + "\nBlog [ http://thinkgem.iteye.com ]" + "\nEMail [ thinkgem@163.com ]";
// int width2 = 300, height2 = 300;
//
// ZxingUtils.encode2(contents2, width2, height2, imgPath2);
// System.out.println("finished zxing encode.");
//
// String decodeContent2 = ZxingUtils.decode2(imgPath2);
// System.out.println("解码内容如下:" + decodeContent2);
// System.out.println("finished zxing decode.");
//
// }
}

View File

@@ -87,16 +87,16 @@ public class ByteUtils {
return String.format(formatStr, (size)) + "B";
}
public static void main(String[] args) {
System.out.println(ByteUtils.formatByteSize(1023));
System.out.println(ByteUtils.formatByteSize(1L * UNIT));
System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT));
System.out.println(ByteUtils.formatByteSize(1L * UNIT * 1023));
System.out.println(ByteUtils.formatByteSize(1L * 1023 * 1023 * 1023));
System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT * UNIT));
System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT * UNIT * UNIT));
System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT * UNIT * UNIT * UNIT));
System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT * UNIT * UNIT * UNIT * UNIT));
}
// public static void main(String[] args) {
// System.out.println(ByteUtils.formatByteSize(1023));
// System.out.println(ByteUtils.formatByteSize(1L * UNIT));
// System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT));
// System.out.println(ByteUtils.formatByteSize(1L * UNIT * 1023));
// System.out.println(ByteUtils.formatByteSize(1L * 1023 * 1023 * 1023));
// System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT * UNIT));
// System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT * UNIT * UNIT));
// System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT * UNIT * UNIT * UNIT));
// System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT * UNIT * UNIT * UNIT * UNIT));
// }
}

View File

@@ -317,10 +317,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
return new Date[]{beginDate, endDate};
}
// /**
// * @param args
// * @throws ParseException
// */
// public static void main(String[] args) throws ParseException {
// System.out.println(formatDate(parseDate("2010/3/6")));
// System.out.println(getDate("yyyy年MM月dd日 E"));

View File

@@ -1,8 +1,6 @@
package com.jeesite.common.lang;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* 工作日计算工具类
@@ -109,28 +107,28 @@ public class WorkDayUtils {
return this.getDaysBetween(d1, d2) - this.getWorkingDay(d1, d2);
}
public static void main(String[] args) {
try {
String strDateStart = "2013-08-01";
String strDateEnd = "2014-08-31";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date_start = sdf.parse(strDateStart);
Date date_end = sdf.parse(strDateEnd);
WorkDayUtils app = new WorkDayUtils();
Calendar cal_start = Calendar.getInstance();
Calendar cal_end = Calendar.getInstance();
cal_start.setTime(date_start);
cal_end.setTime(date_end);
System.out.println("开始日:" + cal_start.get(Calendar.YEAR) + "-" + (cal_start.get(Calendar.MONTH) + 1)
+ "-" + cal_start.get(Calendar.DAY_OF_MONTH) + " " + app.getChineseWeek(cal_start));
System.out.println("结束日:" + cal_end.get(Calendar.YEAR) + "-" + (cal_end.get(Calendar.MONTH) + 1)
+ "-" + cal_end.get(Calendar.DAY_OF_MONTH) + " " + app.getChineseWeek(cal_end));
System.out.println("工作日:" + app.getWorkingDay(cal_start, cal_end));
System.out.println("休息日:" + app.getHolidays(cal_start, cal_end));
} catch (Exception e) {
e.printStackTrace();
}
}
// public static void main(String[] args) {
// try {
// String strDateStart = "2013-08-01";
// String strDateEnd = "2014-08-31";
//
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// Date date_start = sdf.parse(strDateStart);
// Date date_end = sdf.parse(strDateEnd);
// WorkDayUtils app = new WorkDayUtils();
// Calendar cal_start = Calendar.getInstance();
// Calendar cal_end = Calendar.getInstance();
// cal_start.setTime(date_start);
// cal_end.setTime(date_end);
// System.out.println("开始日:" + cal_start.get(Calendar.YEAR) + "-" + (cal_start.get(Calendar.MONTH) + 1)
// + "-" + cal_start.get(Calendar.DAY_OF_MONTH) + " " + app.getChineseWeek(cal_start));
// System.out.println("结束日:" + cal_end.get(Calendar.YEAR) + "-" + (cal_end.get(Calendar.MONTH) + 1)
// + "-" + cal_end.get(Calendar.DAY_OF_MONTH) + " " + app.getChineseWeek(cal_end));
// System.out.println("工作日:" + app.getWorkingDay(cal_start, cal_end));
// System.out.println("休息日:" + app.getHolidays(cal_start, cal_end));
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
}

View File

@@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.util.JSONPObject;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.collect.MapUtils;
/**
* 简单封装Jackson实现JSON String<->Java Object的Mapper.
@@ -248,32 +247,29 @@ public class JsonMapper extends ObjectMapper {
return result;
}
/**
* 测试
*/
public static void main(String[] args) {
List<Map<String, Object>> list = ListUtils.newArrayList();
Map<String, Object> map = MapUtils.newHashMap();
map.put("id", 1);
map.put("pId", -1);
map.put("name", "根节点");
list.add(map);
map = MapUtils.newHashMap();
map.put("id", 2);
map.put("pId", 1);
map.put("name", "你好");
map.put("open", true);
list.add(map);
String json = JsonMapper.toJson(list);
System.out.println(json);
List<Map<String, Object>> map2 = JsonMapper.fromJson(json, List.class);
System.out.println(map2);
Map<String, Object> map3 = JsonMapper.fromJson("{extendS1:{title:'站牌号',"
+ "sort:1,type:'text',maxlength:0,maxlength:30},extendS2:{title:'规模分类',"
+ "sort:2,type:'dict',dictType:'scope_category'}}", Map.class);
System.out.println(map3);
List<String> list2 = fromJson("[1,2]", List.class);
System.out.println(list2);
}
// public static void main(String[] args) {
// List<Map<String, Object>> list = ListUtils.newArrayList();
// Map<String, Object> map = MapUtils.newHashMap();
// map.put("id", 1);
// map.put("pId", -1);
// map.put("name", "根节点");
// list.add(map);
// map = MapUtils.newHashMap();
// map.put("id", 2);
// map.put("pId", 1);
// map.put("name", "你好");
// map.put("open", true);
// list.add(map);
// String json = JsonMapper.toJson(list);
// System.out.println(json);
// List<Map<String, Object>> map2 = JsonMapper.fromJson(json, List.class);
// System.out.println(map2);
// Map<String, Object> map3 = JsonMapper.fromJson("{extendS1:{title:'站牌号',"
// + "sort:1,type:'text',maxlength:0,maxlength:30},extendS2:{title:'规模分类',"
// + "sort:2,type:'dict',dictType:'scope_category'}}", Map.class);
// System.out.println(map3);
// List<String> list2 = fromJson("[1,2]", List.class);
// System.out.println(list2);
// }
}

View File

@@ -3,9 +3,7 @@
*/
package com.jeesite.common.mapper;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -25,9 +23,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.JavaType;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.collect.MapUtils;
import com.jeesite.common.io.FileUtils;
/**
* XML <-> Map、Object
@@ -269,38 +264,38 @@ public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{
return map;
}
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
File file = new File(FileUtils.getProjectPath()
+ "/../modules/core/src/main/resources/spring/spring-context-core.xml");
String xml = FileUtils.readFileToString(file, Charset.defaultCharset());
System.out.println(xmlToMap(xml, true));
System.out.println(xmlToMapWithAttr(xml, true));
XmlMapper m = XmlMapper.getInstance();
System.out.println(m.readValue(xml, List.class));
System.out.println(m.readValue(xml, Map.class));
List<Map<String, Object>> list = ListUtils.newArrayList();
Map<String, Object> map = MapUtils.newHashMap();
map.put("id", 1);
map.put("pId", -1);
map.put("name", "根节点");
list.add(map);
map = MapUtils.newHashMap();
map.put("id", 2);
map.put("pId", 1);
map.put("name", "你好");
map.put("open", true);
list.add(map);
String s = XmlMapper.getInstance().writeValueAsString(list);
System.out.println(s);
list = XmlMapper.getInstance().readValue(s, List.class);
System.out.println(list);
}
// public static void main(String[] args) throws Exception {
//
// File file = new File(FileUtils.getProjectPath()
// + "/../modules/core/src/main/resources/spring/spring-context-core.xml");
// String xml = FileUtils.readFileToString(file, Charset.defaultCharset());
//
// System.out.println(xmlToMap(xml, true));
// System.out.println(xmlToMapWithAttr(xml, true));
//
// XmlMapper m = XmlMapper.getInstance();
// System.out.println(m.readValue(xml, List.class));
// System.out.println(m.readValue(xml, Map.class));
//
// List<Map<String, Object>> list = ListUtils.newArrayList();
// Map<String, Object> map = MapUtils.newHashMap();
// map.put("id", 1);
// map.put("pId", -1);
// map.put("name", "根节点");
// list.add(map);
// map = MapUtils.newHashMap();
// map.put("id", 2);
// map.put("pId", 1);
// map.put("name", "你好");
// map.put("open", true);
// list.add(map);
//
// String s = XmlMapper.getInstance().writeValueAsString(list);
// System.out.println(s);
//
// list = XmlMapper.getInstance().readValue(s, List.class);
// System.out.println(list);
//
// }
}

View File

@@ -471,22 +471,22 @@ public class VideoUtils {
}
}
public static void main(String[] args) {
// VideoUtils.setFfmpegFile("D:/EcodeSVN/ecodedp/tools/video/ffmpeg-4.9/bin/ffmpeg.exe");
VideoUtils.setFfmpegFile("D:/EcodeSVN/ecodedp/tools/video/libav-10.6-win64/bin/avconv.exe");
VideoUtils.setMencoderFile("D:/EcodeSVN/ecodedp/tools/video/mencoder-4.9/mencoder.exe");
VideoUtils.setQtFaststartFile("D:/EcodeSVN/ecodedp/tools/video/qt-faststart/qt-faststart.exe");
final VideoUtils v = new VideoUtils("e:/Users/Administrator/Desktop/mp4/20150001.mp4");
// new Thread(new Runnable() {
// @Override
// public void run() {
System.out.println("img转换" + (v.cutPic()?"成功":"失败"));
System.out.println("file转换" + (v.convert()?"成功":"失败"));
// }
// }).start();
System.out.println("inputFile: " + v.getInputFile());
System.out.println("imageFile: " + v.getImgFile());
System.out.println("outputFile: " + v.getOutputFile());
}
// public static void main(String[] args) {
//// VideoUtils.setFfmpegFile("d:/tools/video/ffmpeg-4.9/bin/ffmpeg.exe");
// VideoUtils.setFfmpegFile("d:/tools/video/libav-10.6-win64/bin/avconv.exe");
// VideoUtils.setMencoderFile("d:/tools/video/mencoder-4.9/mencoder.exe");
// VideoUtils.setQtFaststartFile("d:/tools/video/qt-faststart/qt-faststart.exe");
// final VideoUtils v = new VideoUtils("e:/Users/Administrator/Desktop/mp4/20150001.mp4");
//// new Thread(new Runnable() {
//// @Override
//// public void run() {
// System.out.println("img转换" + (v.cutPic()?"成功":"失败"));
// System.out.println("file转换" + (v.convert()?"成功":"失败"));
//// }
//// }).start();
// System.out.println("inputFile: " + v.getInputFile());
// System.out.println("imageFile: " + v.getImgFile());
// System.out.println("outputFile: " + v.getOutputFile());
// }
}

View File

@@ -27,7 +27,6 @@ import java.util.Map;
import org.junit.Assert;
import com.jeesite.common.io.FileUtils;
import com.jeesite.common.text.DiffMatchPatch.Diff;
import com.jeesite.common.text.DiffMatchPatch.LinesToCharsResult;
import com.jeesite.common.text.DiffMatchPatch.Patch;
@@ -933,23 +932,23 @@ public class DiffMatchPatchTest {
Assert.fail(message);
}
public static void main(String[] args) {
// DiffMatchPatchTest d = new DiffMatchPatchTest();
// d.testDiffCleanupEfficiency();
// d.testDiffPrettyHtml();
String text1 = "花<b>一样</b>的你,花一样的我,花一样的年华,花一样的世界,花一样的未来。";
String text2 = "花<b>一</b>样的你,花一样的年华,花一样的我,花一样的未来,花一样的世界。";
DiffMatchPatch dmp = new DiffMatchPatch();
LinkedList<Diff> diffs = dmp.diff_main(text1, text2);
String result = dmp.diff_prettyHtml(diffs);
FileUtils.writeToFile("x:\\test.html", result, false);
System.out.println(result);
}
// public static void main(String[] args) {
//
//// DiffMatchPatchTest d = new DiffMatchPatchTest();
//// d.testDiffCleanupEfficiency();
//// d.testDiffPrettyHtml();
//
// String text1 = "花<b>一样</b>的你,花一样的我,花一样的年华,花一样的世界,花一样的未来。";
// String text2 = "花<b>一</b>样的你,花一样的年华,花一样的我,花一样的未来,花一样的世界。";
//
// DiffMatchPatch dmp = new DiffMatchPatch();
//
// LinkedList<Diff> diffs = dmp.diff_main(text1, text2);
// String result = dmp.diff_prettyHtml(diffs);
//
// FileUtils.writeToFile("x:\\test.html", result, false);
// System.out.println(result);
//
// }
}

View File

@@ -97,10 +97,10 @@ public class PinyinUtils {
return pybf.toString();
}
public static void main(String[] args) {
String str = "你好123世界abc,~!#$_Sdf";
// System.out.println(getPinyin(str));
System.out.println(getFirstSpell(str));
System.out.println(getFullSpell(str));
}
// public static void main(String[] args) {
// String str = "你好123世界abc,~!#$_Sdf";
//// System.out.println(getPinyin(str));
// System.out.println(getFirstSpell(str));
// System.out.println(getFullSpell(str));
// }
}

View File

@@ -212,23 +212,23 @@ public abstract class ExcelReader extends DefaultHandler {
*/
public abstract void getRows(int sheetIndex, int curRow, List<String> rowList);
/**
* 测试方法
*/
public static void main(String[] args) throws Exception {
String file = "E:/销售数据导入.xlsx";
ExcelReader reader = new ExcelReader() {
@Override
public void getRows(int sheetIndex, int curRow, List<String> rowList) {
System.out.println("Sheet:" + sheetIndex + ", Row:" + curRow + ", Data:" +rowList);
}
};
reader.process(file, 1);
}
// /**
// * 测试方法
// */
// public static void main(String[] args) throws Exception {
//
// String file = "E:/销售数据导入.xlsx";
//
// ExcelReader reader = new ExcelReader() {
// @Override
// public void getRows(int sheetIndex, int curRow, List<String> rowList) {
//
// System.out.println("Sheet:" + sheetIndex + ", Row:" + curRow + ", Data:" +rowList);
//
// }
// };
// reader.process(file, 1);
//
// }
}

View File

@@ -284,42 +284,42 @@ public abstract class ExcelWriter {
return buffer.toString();
}
/**
* 测试方法
*/
public static void main(String[] args) throws Exception {
String file = "E:/测试导出数据.xlsx";
ExcelWriter writer = new ExcelWriter() {
@Override
public void generate() throws Exception {
// 电子表格开始
this.beginSheet();
for (int rownum = 0; rownum < 100; rownum++) {
// 插入新行
this.insertRow(rownum);
// 建立新单元格,索引值从0开始,表示第一列
this.createCell(0, "" + rownum + "");
this.createCell(1, 34343.123456789);
this.createCell(2, "23.67%");
this.createCell(3, "12:12:23");
this.createCell(4, "2014-10-11 12:12:23");
this.createCell(5, "true");
this.createCell(6, "false");
// 结束行
this.endRow();
}
// 电子表格结束
this.endSheet();
}
};
writer.process(file);
}
// /**
// * 测试方法
// */
// public static void main(String[] args) throws Exception {
//
// String file = "E:/测试导出数据.xlsx";
//
// ExcelWriter writer = new ExcelWriter() {
// @Override
// public void generate() throws Exception {
//
// // 电子表格开始
// this.beginSheet();
//
// for (int rownum = 0; rownum < 100; rownum++) {
// // 插入新行
// this.insertRow(rownum);
//
// // 建立新单元格,索引值从0开始,表示第一列
// this.createCell(0, "第 " + rownum + " 行");
// this.createCell(1, 34343.123456789);
// this.createCell(2, "23.67%");
// this.createCell(3, "12:12:23");
// this.createCell(4, "2014-10-11 12:12:23");
// this.createCell(5, "true");
// this.createCell(6, "false");
//
// // 结束行
// this.endRow();
// }
//
// // 电子表格结束
// this.endSheet();
// }
// };
// writer.process(file);
// }
}

View File

@@ -5,7 +5,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -24,8 +23,6 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHeight;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTrPr;
import org.w3c.dom.Node;
import com.jeesite.common.codec.EncodeUtils;
/**
* 使用POI,进行Word相关的操作
* @author xuyu
@@ -229,70 +226,67 @@ public class WordExport {
}
}
/**
* @param args
*/
public static void main(String[] args) {
long startTime = System.currentTimeMillis();
WordExport changer = new WordExport();
String fileName = WordExport.class.getResource("Word模版.docx").getFile();
fileName = EncodeUtils.decodeUrl(fileName.substring(1));
System.out.println(fileName);
changer.setTemplate(fileName);
Map<String, String> content = new HashMap<String, String>();
content.put("Principles", "格式规范、标准统一、利于阅览");
content.put("Purpose", "规范会议操作、提高会议质量");
content.put("Scope", "公司会议、部门之间业务协调会议");
content.put("customerName", "**有限公司");
content.put("address", "机场路2号");
content.put("userNo", "3021170207");
content.put("tradeName", "水泥制造");
content.put("price1", "1.085");
content.put("price2", "0.906");
content.put("price3", "0.433");
content.put("numPrice", "0.675");
content.put("company_name", "**有限公司");
content.put("company_address", "机场路2号");
changer.replaceBookMark(content);
//替换表格标签
List<Map<String, String>> content2 = new ArrayList<Map<String, String>>();
Map<String, String> table1 = new HashMap<String, String>();
table1.put("MONTH", "*月份");
table1.put("SALE_DEP", "75分");
table1.put("TECH_CENTER", "80分");
table1.put("CUSTOMER_SERVICE", "85分");
table1.put("HUMAN_RESOURCES", "90分");
table1.put("FINANCIAL", "95分");
table1.put("WORKSHOP", "80分");
table1.put("TOTAL", "85分");
for (int i = 0; i < 3; i++) {
content2.add(table1);
}
changer.fillTableAtBookMark("Table", content2);
changer.fillTableAtBookMark("month", content2);
//表格中文本的替换
Map<String, String> table = new HashMap<String, String>();
table.put("CUSTOMER_NAME", "**有限公司");
table.put("ADDRESS", "机场路2号");
table.put("USER_NO", "3021170207");
table.put("tradeName", "水泥制造");
table.put("PRICE_1", "1.085");
table.put("PRICE_2", "0.906");
table.put("PRICE_3", "0.433");
table.put("NUM_PRICE", "0.675");
changer.replaceText(table, "Table2");
//保存替换后的WORD
changer.saveAs(fileName + "_out.docx");
System.out.println("time==" + (System.currentTimeMillis() - startTime));
}
// public static void main(String[] args) {
// long startTime = System.currentTimeMillis();
// WordExport changer = new WordExport();
// String fileName = WordExport.class.getResource("Word模版.docx").getFile();
// fileName = EncodeUtils.decodeUrl(fileName.substring(1));
// System.out.println(fileName);
//
// changer.setTemplate(fileName);
// Map<String, String> content = new HashMap<String, String>();
// content.put("Principles", "格式规范、标准统一、利于阅览");
// content.put("Purpose", "规范会议操作、提高会议质量");
// content.put("Scope", "公司会议、部门之间业务协调会议");
//
// content.put("customerName", "**有限公司");
// content.put("address", "机场路2号");
// content.put("userNo", "3021170207");
// content.put("tradeName", "水泥制造");
// content.put("price1", "1.085");
// content.put("price2", "0.906");
// content.put("price3", "0.433");
// content.put("numPrice", "0.675");
//
// content.put("company_name", "**有限公司");
// content.put("company_address", "机场路2号");
// changer.replaceBookMark(content);
//
// //替换表格标签
// List<Map<String, String>> content2 = new ArrayList<Map<String, String>>();
// Map<String, String> table1 = new HashMap<String, String>();
//
// table1.put("MONTH", "*月份");
// table1.put("SALE_DEP", "75分");
// table1.put("TECH_CENTER", "80分");
// table1.put("CUSTOMER_SERVICE", "85分");
// table1.put("HUMAN_RESOURCES", "90分");
// table1.put("FINANCIAL", "95分");
// table1.put("WORKSHOP", "80分");
// table1.put("TOTAL", "85分");
//
// for (int i = 0; i < 3; i++) {
// content2.add(table1);
// }
// changer.fillTableAtBookMark("Table", content2);
// changer.fillTableAtBookMark("month", content2);
//
// //表格中文本的替换
// Map<String, String> table = new HashMap<String, String>();
// table.put("CUSTOMER_NAME", "**有限公司");
// table.put("ADDRESS", "机场路2号");
// table.put("USER_NO", "3021170207");
// table.put("tradeName", "水泥制造");
// table.put("PRICE_1", "1.085");
// table.put("PRICE_2", "0.906");
// table.put("PRICE_3", "0.433");
// table.put("NUM_PRICE", "0.675");
// changer.replaceText(table, "Table2");
//
// //保存替换后的WORD
// changer.saveAs(fileName + "_out.docx");
// System.out.println("time==" + (System.currentTimeMillis() - startTime));
//
// }
}