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

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) { // public static void main(String[] args) {
//
String s = "hello word!"; // String s = "hello word!";
System.out.println(s); // System.out.println(s);
//
String k = genKeyString(); // String k = genKeyString();
System.out.println(k); // System.out.println(k);
String ss = encode(s, k); // String ss = encode(s, k);
System.out.println(ss); // System.out.println(ss);
String sss = decode(ss, k); // String sss = decode(ss, k);
System.out.println(sss); // System.out.println(sss);
//
} // }
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -125,35 +125,32 @@ public class ZxingUtils {
return null; return null;
} }
/** // public static void main(String[] args) {
* @param args //
*/ // // 条形码
public static void main(String[] args) { // String imgPath = "target\\zxing_EAN13.png";
// String contents = "6923450657713";
// 条形码 // int width = 105, height = 50;
String imgPath = "target\\zxing_EAN13.png"; //
String contents = "6923450657713"; // ZxingUtils.encode(contents, width, height, imgPath);
int width = 105, height = 50; // System.out.println("finished zxing EAN-13 encode.");
//
ZxingUtils.encode(contents, width, height, imgPath); // String decodeContent = ZxingUtils.decode(imgPath);
System.out.println("finished zxing EAN-13 encode."); // System.out.println("解码内容如下:" + decodeContent);
// System.out.println("finished zxing EAN-13 decode.");
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;
String imgPath2 = "target\\zxing.png"; //
String contents2 = "Hello Gem, welcome to Zxing!" + "\nBlog [ http://thinkgem.iteye.com ]" + "\nEMail [ thinkgem@163.com ]"; // ZxingUtils.encode2(contents2, width2, height2, imgPath2);
int width2 = 300, height2 = 300; // System.out.println("finished zxing encode.");
//
ZxingUtils.encode2(contents2, width2, height2, imgPath2); // String decodeContent2 = ZxingUtils.decode2(imgPath2);
System.out.println("finished zxing encode."); // System.out.println("解码内容如下:" + decodeContent2);
// System.out.println("finished zxing decode.");
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"; return String.format(formatStr, (size)) + "B";
} }
public static void main(String[] args) { // public static void main(String[] args) {
System.out.println(ByteUtils.formatByteSize(1023)); // System.out.println(ByteUtils.formatByteSize(1023));
System.out.println(ByteUtils.formatByteSize(1L * UNIT)); // System.out.println(ByteUtils.formatByteSize(1L * UNIT));
System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT)); // System.out.println(ByteUtils.formatByteSize(1L * UNIT * UNIT));
System.out.println(ByteUtils.formatByteSize(1L * UNIT * 1023)); // System.out.println(ByteUtils.formatByteSize(1L * UNIT * 1023));
System.out.println(ByteUtils.formatByteSize(1L * 1023 * 1023 * 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));
System.out.println(ByteUtils.formatByteSize(1L * UNIT * 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));
System.out.println(ByteUtils.formatByteSize(1L * UNIT * 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}; return new Date[]{beginDate, endDate};
} }
// /**
// * @param args
// * @throws ParseException
// */
// public static void main(String[] args) throws ParseException { // public static void main(String[] args) throws ParseException {
// System.out.println(formatDate(parseDate("2010/3/6"))); // System.out.println(formatDate(parseDate("2010/3/6")));
// System.out.println(getDate("yyyy年MM月dd日 E")); // System.out.println(getDate("yyyy年MM月dd日 E"));

View File

@@ -1,8 +1,6 @@
package com.jeesite.common.lang; package com.jeesite.common.lang;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
/** /**
* 工作日计算工具类 * 工作日计算工具类
@@ -109,28 +107,28 @@ public class WorkDayUtils {
return this.getDaysBetween(d1, d2) - this.getWorkingDay(d1, d2); return this.getDaysBetween(d1, d2) - this.getWorkingDay(d1, d2);
} }
public static void main(String[] args) { // public static void main(String[] args) {
try { // try {
String strDateStart = "2013-08-01"; // String strDateStart = "2013-08-01";
String strDateEnd = "2014-08-31"; // String strDateEnd = "2014-08-31";
//
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date_start = sdf.parse(strDateStart); // Date date_start = sdf.parse(strDateStart);
Date date_end = sdf.parse(strDateEnd); // Date date_end = sdf.parse(strDateEnd);
WorkDayUtils app = new WorkDayUtils(); // WorkDayUtils app = new WorkDayUtils();
Calendar cal_start = Calendar.getInstance(); // Calendar cal_start = Calendar.getInstance();
Calendar cal_end = Calendar.getInstance(); // Calendar cal_end = Calendar.getInstance();
cal_start.setTime(date_start); // cal_start.setTime(date_start);
cal_end.setTime(date_end); // cal_end.setTime(date_end);
System.out.println("开始日:" + cal_start.get(Calendar.YEAR) + "-" + (cal_start.get(Calendar.MONTH) + 1) // 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)); // + "-" + 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) // 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)); // + "-" + cal_end.get(Calendar.DAY_OF_MONTH) + " " + app.getChineseWeek(cal_end));
System.out.println("工作日:" + app.getWorkingDay(cal_start, cal_end)); // System.out.println("工作日:" + app.getWorkingDay(cal_start, cal_end));
System.out.println("休息日:" + app.getHolidays(cal_start, cal_end)); // System.out.println("休息日:" + app.getHolidays(cal_start, cal_end));
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // 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.databind.util.JSONPObject;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
import com.jeesite.common.collect.ListUtils; import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.collect.MapUtils;
/** /**
* 简单封装Jackson实现JSON String<->Java Object的Mapper. * 简单封装Jackson实现JSON String<->Java Object的Mapper.
@@ -248,32 +247,29 @@ public class JsonMapper extends ObjectMapper {
return result; return result;
} }
/** // public static void main(String[] args) {
* 测试 // List<Map<String, Object>> list = ListUtils.newArrayList();
*/ // Map<String, Object> map = MapUtils.newHashMap();
public static void main(String[] args) { // map.put("id", 1);
List<Map<String, Object>> list = ListUtils.newArrayList(); // map.put("pId", -1);
Map<String, Object> map = MapUtils.newHashMap(); // map.put("name", "根节点");
map.put("id", 1); // list.add(map);
map.put("pId", -1); // map = MapUtils.newHashMap();
map.put("name", "根节点"); // map.put("id", 2);
list.add(map); // map.put("pId", 1);
map = MapUtils.newHashMap(); // map.put("name", "你好");
map.put("id", 2); // map.put("open", true);
map.put("pId", 1); // list.add(map);
map.put("name", "你好"); // String json = JsonMapper.toJson(list);
map.put("open", true); // System.out.println(json);
list.add(map); // List<Map<String, Object>> map2 = JsonMapper.fromJson(json, List.class);
String json = JsonMapper.toJson(list); // System.out.println(map2);
System.out.println(json); // Map<String, Object> map3 = JsonMapper.fromJson("{extendS1:{title:'站牌号',"
List<Map<String, Object>> map2 = JsonMapper.fromJson(json, List.class); // + "sort:1,type:'text',maxlength:0,maxlength:30},extendS2:{title:'规模分类',"
System.out.println(map2); // + "sort:2,type:'dict',dictType:'scope_category'}}", Map.class);
Map<String, Object> map3 = JsonMapper.fromJson("{extendS1:{title:'站牌号'," // System.out.println(map3);
+ "sort:1,type:'text',maxlength:0,maxlength:30},extendS2:{title:'规模分类'," // List<String> list2 = fromJson("[1,2]", List.class);
+ "sort:2,type:'dict',dictType:'scope_category'}}", Map.class); // System.out.println(list2);
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; package com.jeesite.common.mapper;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -25,9 +23,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.JavaType; 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 * XML <-> Map、Object
@@ -269,38 +264,38 @@ public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{
return map; return map;
} }
@SuppressWarnings("unchecked") // public static void main(String[] args) throws Exception {
public static void main(String[] args) throws Exception { //
// File file = new File(FileUtils.getProjectPath()
File file = new File(FileUtils.getProjectPath() // + "/../modules/core/src/main/resources/spring/spring-context-core.xml");
+ "/../modules/core/src/main/resources/spring/spring-context-core.xml"); // String xml = FileUtils.readFileToString(file, Charset.defaultCharset());
String xml = FileUtils.readFileToString(file, Charset.defaultCharset()); //
// System.out.println(xmlToMap(xml, true));
System.out.println(xmlToMap(xml, true)); // System.out.println(xmlToMapWithAttr(xml, true));
System.out.println(xmlToMapWithAttr(xml, true)); //
// XmlMapper m = XmlMapper.getInstance();
XmlMapper m = XmlMapper.getInstance(); // System.out.println(m.readValue(xml, List.class));
System.out.println(m.readValue(xml, List.class)); // System.out.println(m.readValue(xml, Map.class));
System.out.println(m.readValue(xml, Map.class)); //
// List<Map<String, Object>> list = ListUtils.newArrayList();
List<Map<String, Object>> list = ListUtils.newArrayList(); // Map<String, Object> map = MapUtils.newHashMap();
Map<String, Object> map = MapUtils.newHashMap(); // map.put("id", 1);
map.put("id", 1); // map.put("pId", -1);
map.put("pId", -1); // map.put("name", "根节点");
map.put("name", "根节点"); // list.add(map);
list.add(map); // map = MapUtils.newHashMap();
map = MapUtils.newHashMap(); // map.put("id", 2);
map.put("id", 2); // map.put("pId", 1);
map.put("pId", 1); // map.put("name", "你好");
map.put("name", "你好"); // map.put("open", true);
map.put("open", true); // list.add(map);
list.add(map); //
// String s = XmlMapper.getInstance().writeValueAsString(list);
String s = XmlMapper.getInstance().writeValueAsString(list); // System.out.println(s);
System.out.println(s); //
// list = XmlMapper.getInstance().readValue(s, List.class);
list = XmlMapper.getInstance().readValue(s, List.class); // System.out.println(list);
System.out.println(list); //
// }
}
} }

View File

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

View File

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

View File

@@ -97,10 +97,10 @@ public class PinyinUtils {
return pybf.toString(); return pybf.toString();
} }
public static void main(String[] args) { // public static void main(String[] args) {
String str = "你好123世界abc,~!#$_Sdf"; // String str = "你好123世界abc,~!#$_Sdf";
// System.out.println(getPinyin(str)); //// System.out.println(getPinyin(str));
System.out.println(getFirstSpell(str)); // System.out.println(getFirstSpell(str));
System.out.println(getFullSpell(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 abstract void getRows(int sheetIndex, int curRow, List<String> rowList);
/** // /**
* 测试方法 // * 测试方法
*/ // */
public static void main(String[] args) throws Exception { // public static void main(String[] args) throws Exception {
//
String file = "E:/销售数据导入.xlsx"; // String file = "E:/销售数据导入.xlsx";
//
ExcelReader reader = new ExcelReader() { // ExcelReader reader = new ExcelReader() {
@Override // @Override
public void getRows(int sheetIndex, int curRow, List<String> rowList) { // public void getRows(int sheetIndex, int curRow, List<String> rowList) {
//
System.out.println("Sheet:" + sheetIndex + ", Row:" + curRow + ", Data:" +rowList); // System.out.println("Sheet:" + sheetIndex + ", Row:" + curRow + ", Data:" +rowList);
//
} // }
}; // };
reader.process(file, 1); // reader.process(file, 1);
//
} // }
} }

View File

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

View File

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