From df747e08f76d41d5b7119956ed4973a943c2aee8 Mon Sep 17 00:00:00 2001 From: lixiangrong Date: Wed, 24 Feb 2016 09:53:51 +0800 Subject: [PATCH] 2016-02-24 commit --- pom.xml | 6 +++ .../java/osc/git/eh3/readlogs/IReadLogs.java | 8 ++++ src/main/java/osc/git/eh3/test/DirList.java | 38 +++++++++++++++++++ src/main/java/osc/git/eh3/test/TestCode.java | 32 ++++++++++------ 4 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 src/main/java/osc/git/eh3/readlogs/IReadLogs.java create mode 100644 src/main/java/osc/git/eh3/test/DirList.java diff --git a/pom.xml b/pom.xml index acb2941..b4fc8bd 100644 --- a/pom.xml +++ b/pom.xml @@ -88,6 +88,12 @@ 2.4 jdk15 + + + com.caucho + hessian + 4.0.38 + useful-code diff --git a/src/main/java/osc/git/eh3/readlogs/IReadLogs.java b/src/main/java/osc/git/eh3/readlogs/IReadLogs.java new file mode 100644 index 0000000..1442984 --- /dev/null +++ b/src/main/java/osc/git/eh3/readlogs/IReadLogs.java @@ -0,0 +1,8 @@ +package osc.git.eh3.readlogs; + +import java.util.Date; +import java.util.List; + +public interface IReadLogs { + public String readFile(Date startDate, Date endDate, List mapids); +} \ No newline at end of file diff --git a/src/main/java/osc/git/eh3/test/DirList.java b/src/main/java/osc/git/eh3/test/DirList.java new file mode 100644 index 0000000..5126943 --- /dev/null +++ b/src/main/java/osc/git/eh3/test/DirList.java @@ -0,0 +1,38 @@ +package osc.git.eh3.test; + +import java.io.File; +import java.io.FilenameFilter; + +public class DirList { + /** + * @param args + * The file pattern that need to be matched. + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + File path = new File("D://"); + String arg = "dsp_impclk_15"; + String[] list; + if (arg.length() == 0) + list = path.list(); + else + list = path.list(new DirFilter(arg)); + for (int i = 0; i < list.length; ++i) { + System.out.println(list[i]); + } + } +} + +class DirFilter implements FilenameFilter { + String afn; + + DirFilter(String afn) { + this.afn = afn; + } + + public boolean accept(File dir, String name) { + // Strip path information. + String f = new File(name).getName(); + return f.indexOf(afn) != -1; + } +} \ No newline at end of file diff --git a/src/main/java/osc/git/eh3/test/TestCode.java b/src/main/java/osc/git/eh3/test/TestCode.java index ca55048..d2b32d9 100644 --- a/src/main/java/osc/git/eh3/test/TestCode.java +++ b/src/main/java/osc/git/eh3/test/TestCode.java @@ -1,17 +1,13 @@ package osc.git.eh3.test; import java.text.ParseException; -import java.text.ParsePosition; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; + +import com.caucho.hessian.client.HessianProxyFactory; import net.sf.json.JSONArray; -import net.sf.json.JSONObject; +import osc.git.eh3.readlogs.IReadLogs; public class TestCode { @@ -79,12 +75,26 @@ public class TestCode { // String str = "http://www.test.com"; // System.out.println(str.replace("http://www.", "").replace("www.", "")); - SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); - SimpleDateFormat sdf = new SimpleDateFormat("HH"); - String str = "23:59:59"; - System.out.println(sdf.format(formatter.parse(str))); +// SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); +// SimpleDateFormat sdf = new SimpleDateFormat("HH"); +// String str = "23:59:59"; +// System.out.println(sdf.format(formatter.parse(str))); + // Spring Hessian代理Servelet +// String url = "http://localhost:8080/sync-logs/remote/readlogs"; +// HessianProxyFactory factory = new HessianProxyFactory(); +// +// IReadLogs readLogs = (IReadLogs) factory.create(IReadLogs.class, url); +// JSONArray result = JSONArray.fromObject(readLogs.readFile("2016-02-22 15:00:00", "00000000000000")); +// System.out.println(result); + + + JSONArray jonsArr = new JSONArray(); + JSONArray arr = new JSONArray(); + jonsArr = JSONArray.fromObject("[ { 'category': 2, 'clks': 4, 'cost': 13, 'createtime': null, 'creativeid': 'cf0714f4-8b92-41f2-a843-19c94fe3af74', 'downloads': 0, 'flag': 0, 'imprs': 5, 'regists': 0, 'time': null } ]"); + arr.addAll(JSONArray.toCollection(jonsArr)); + System.out.println(arr); } public static Long parseDate(String s) {