list) {
44 | return join(list, DEFAULT_JOIN_SEPARATOR);
45 | }
46 |
47 | /**
48 | * 将list中所有元素以separator分隔符拼接返回
49 | *
50 | *
51 | * join(null, '#') = "";
52 | * join({}, '#') = "";
53 | * join({a,b,c}, ' ') = "abc";
54 | * join({a,b,c}, '#') = "a#b#c";
55 | *
56 | *
57 | * @param list
58 | * @param separator
59 | * @return list中所有元素以separator分隔符拼接返回。若list为空或长度为0返回""
60 | */
61 | public static String join(List list, char separator) {
62 | return join(list, separator + "");
63 | }
64 |
65 | /**
66 | * 将list中所有元素以separator分隔符拼接返回,separator为空则采用默认分隔符","
67 | *
68 | *
69 | * join(null, "#") = "";
70 | * join({}, "#$") = "";
71 | * join({a,b,c}, null) = "a,b,c";
72 | * join({a,b,c}, "") = "abc";
73 | * join({a,b,c}, "#") = "a#b#c";
74 | * join({a,b,c}, "#$") = "a#$b#$c";
75 | *
76 | *
77 | * @param list
78 | * @param separator
79 | * @return list中所有元素以separator分隔符拼接返回。若list为空或长度为0返回""
80 | */
81 | public static String join(List list, String separator) {
82 | if (isEmpty(list)) {
83 | return "";
84 | }
85 | if (separator == null) {
86 | separator = DEFAULT_JOIN_SEPARATOR;
87 | }
88 |
89 | StringBuilder joinStr = new StringBuilder();
90 | for (int i = 0; i < list.size(); i++) {
91 | joinStr.append(list.get(i));
92 | if (i != list.size() - 1) {
93 | joinStr.append(separator);
94 | }
95 | }
96 |
97 | return joinStr.toString();
98 | }
99 |
100 | /**
101 | * 向sourceList中新增不重复元素
102 | *
103 | * @param
104 | * @param sourceList
105 | * @param entry
106 | * @return 若entry在sourceList已经存在,返回false;否则新增并返回true 注意此函数不能保证源sourceList中元素不重复。
107 | */
108 | public static boolean addDistinctEntry(List sourceList, V entry) {
109 | return (sourceList != null && !sourceList.contains(entry)) ? sourceList.add(entry) : false;
110 | }
111 |
112 | /**
113 | * 向sourceList中插入包含在entryList而不包含在sourceList中的元素
114 | *
115 | * @param
116 | * @param sourceList
117 | * @param entryList
118 | * @return 向sourceList插入的元素个数 注意此函数不能保证源sourceList中元素不重复。
119 | */
120 | public static int addDistinctList(List sourceList, List entryList) {
121 | if (sourceList == null || isEmpty(entryList)) {
122 | return 0;
123 | }
124 |
125 | int sourceCount = sourceList.size();
126 | for (V entry : entryList)
127 | if (!sourceList.contains(entry)) {
128 | sourceList.add(entry);
129 | }
130 |
131 | return sourceList.size() - sourceCount;
132 | }
133 |
134 | /**
135 | * 去除list中重复的元素
136 | *
137 | * @param
138 | * @param sourceList
139 | * @return 去除元素的个数
140 | */
141 | public static int distinctList(List sourceList) {
142 | if (isEmpty(sourceList)) {
143 | return 0;
144 | }
145 |
146 | int sourceCount = sourceList.size();
147 | int sourceListSize = sourceList.size();
148 | for (int i = 0; i < sourceListSize; i++)
149 | for (int j = (i + 1); j < sourceListSize; j++) {
150 | if (sourceList.get(i).equals(sourceList.get(j))) {
151 | sourceList.remove(j);
152 | sourceListSize = sourceList.size();
153 | j--;
154 | }
155 | }
156 |
157 | return sourceCount - sourceList.size();
158 | }
159 |
160 | /**
161 | * 向list中新增非null value
162 | *
163 | * @param sourceList
164 | * @param value
165 | * @return 若add成功,返回true,否则返回false
166 | *
167 | * - 若sourceList为null,返回false,否则
168 | * - 若value为null,返回false,否则
169 | * - {@link List#add(Object)} 返回true
170 | *
171 | */
172 | public static boolean addListNotNullValue(List sourceList, V value) {
173 | return (sourceList != null && value != null) ? sourceList.add(value) : false;
174 | }
175 |
176 | /**
177 | * 参考{@link ArrayUtils#getLast(Object[], Object, Object, boolean)} defaultValue为null, isCircle为true
178 | */
179 | @SuppressWarnings("unchecked")
180 | public static V getLast(List sourceList, V value) {
181 | return (sourceList == null) ? null : (V)ArrayUtils.getLast(sourceList.toArray(), value, true);
182 | }
183 |
184 | /**
185 | * 参考{@link ArrayUtils#getNext(Object[], Object, Object, boolean)} defaultValue为null, isCircle为true
186 | */
187 | @SuppressWarnings("unchecked")
188 | public static V getNext(List sourceList, V value) {
189 | return (sourceList == null) ? null : (V)ArrayUtils.getNext(sourceList.toArray(), value, true);
190 | }
191 |
192 | /**
193 | * 将list倒置
194 | *
195 | * @param
196 | * @param sourceList
197 | * @return
198 | */
199 | public static List invertList(List sourceList) {
200 | if (isEmpty(sourceList)) {
201 | return sourceList;
202 | }
203 |
204 | List invertList = new ArrayList(sourceList.size());
205 | for (int i = sourceList.size() - 1; i >= 0; i--) {
206 | invertList.add(sourceList.get(i));
207 | }
208 | return invertList;
209 | }
210 | }
211 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/.svn/text-base/ObjectUtils.java.svn-base:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common;
2 |
3 | /**
4 | * Object工具类
5 | *
6 | * @author Trinea 2011-10-24 下午08:21:11
7 | */
8 | public class ObjectUtils {
9 |
10 | /**
11 | * 比较两个对象是否相等
12 | *
13 | * @param actual
14 | * @param expected
15 | * @return
16 | *
17 | * - 若两个对象都为null,则返回true
18 | * - 若{@code actual}对象不为null,则调用{@code actual}对象相应的{@link Object#equals(Object)}函数进行判断,返回判断结果
19 | *
20 | * @see
21 | *
22 | * - 对于基本类实现了{@link Object#equals(Object)}的话都会先判断类型是否匹配,类型不匹配返回false,可参考{@link String#equals(Object)}
23 | * - 关于如何利用此函数比较自定义对象可下载源代码,参考测试代码中的{@link ObjectUtilsTest#testIsEquals()}
24 | *
25 | */
26 | public static boolean isEquals(Object actual, Object expected) {
27 | return actual == null ? expected == null : actual.equals(expected);
28 | }
29 |
30 | /**
31 | * long数组转换成Long数组
32 | *
33 | * @param source
34 | * @return
35 | */
36 | public static Long[] transformLongArray(long[] source) {
37 | Long[] destin = new Long[source.length];
38 | for (int i = 0; i < source.length; i++) {
39 | destin[i] = source[i];
40 | }
41 | return destin;
42 | }
43 |
44 | /**
45 | * Long数组转换成long数组
46 | *
47 | * @param source
48 | * @return
49 | */
50 | public static long[] transformLongArray(Long[] source) {
51 | long[] destin = new long[source.length];
52 | for (int i = 0; i < source.length; i++) {
53 | destin[i] = source[i];
54 | }
55 | return destin;
56 | }
57 |
58 | /**
59 | * int数组转换成Integer数组
60 | *
61 | * @param source
62 | * @return
63 | */
64 | public static Integer[] transformIntArray(int[] source) {
65 | Integer[] destin = new Integer[source.length];
66 | for (int i = 0; i < source.length; i++) {
67 | destin[i] = source[i];
68 | }
69 | return destin;
70 | }
71 |
72 | /**
73 | * Integer数组转换成int数组
74 | *
75 | * @param source
76 | * @return
77 | */
78 | public static int[] transformIntArray(Integer[] source) {
79 | int[] destin = new int[source.length];
80 | for (int i = 0; i < source.length; i++) {
81 | destin[i] = source[i];
82 | }
83 | return destin;
84 | }
85 |
86 | /**
87 | * 比较两个值的大小
88 | *
90 | * 关于比较的结果
91 | *
92 | * - v1大于v2返回1
93 | * - v1等于v2返回0
94 | * - v1小于v2返回-1
95 | *
96 | * 关于比较的规则
97 | *
98 | * - 若v1为null,v2为null,则相等
99 | * - 若v1为null,v2不为null,则v1小于v2
100 | * - 若v1不为null,v2为null,则v1大于v2
101 | * - 若v1、v2均不为null,则利用v1的{@link Comparable#compareTo(Object)}判断,参数为v2
102 | *
103 | *
104 | * @param v1
105 | * @param v2
106 | * @return
107 | */
108 | @SuppressWarnings({"unchecked", "rawtypes"})
109 | public static int compare(V v1, V v2) {
110 | return v1 == null ? (v2 == null ? 0 : -1) : (v2 == null ? 1 : ((Comparable)v1).compareTo(v2));
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/.svn/text-base/RandomUtils.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common;
9 |
10 | import java.util.Random;
11 |
12 | /**
13 | * 随机数工具类
14 | *
15 | * @author Trinea 2012-5-12 下午01:37:48
16 | */
17 | public class RandomUtils {
18 |
19 | public static final String NUMBERS_AND_LETTERS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
20 | public static final String NUMBERS = "0123456789";
21 | public static final String LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
22 | public static final String CAPITAL_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
23 | public static final String LOWER_CASE_LETTERS = "abcdefghijklmnopqrstuvwxyz";
24 |
25 | /**
26 | * 得到固定长度的随机字符串,字符串由数字和大小写字母混合组成
27 | *
28 | * @param length 长度
29 | * @return
30 | * @see 见{@link StringUtils#getRandom(String source, int length)}
31 | */
32 | public static String getRandomNumbersAndLetters(int length) {
33 | return getRandom(NUMBERS_AND_LETTERS, length);
34 | }
35 |
36 | /**
37 | * 得到固定长度的随机字符串,字符串由数字混合组成
38 | *
39 | * @param length 长度
40 | * @return
41 | * @see 见{@link StringUtils#getRandom(String source, int length)}
42 | */
43 | public static String getRandomNumbers(int length) {
44 | return getRandom(NUMBERS, length);
45 | }
46 |
47 | /**
48 | * 得到固定长度的随机字符串,字符串由大小写字母混合组成
49 | *
50 | * @param length 长度
51 | * @return
52 | * @see 见{@link StringUtils#getRandom(String source, int length)}
53 | */
54 | public static String getRandomLetters(int length) {
55 | return getRandom(LETTERS, length);
56 | }
57 |
58 | /**
59 | * 得到固定长度的随机字符串,字符串由大写字母混合组成
60 | *
61 | * @param length 长度
62 | * @return
63 | * @see 见{@link StringUtils#getRandom(String source, int length)}
64 | */
65 | public static String getRandomCapitalLetters(int length) {
66 | return getRandom(CAPITAL_LETTERS, length);
67 | }
68 |
69 | /**
70 | * 得到固定长度的随机字符串,字符串由小写字母混合组成
71 | *
72 | * @param length 长度
73 | * @return
74 | * @see 见{@link StringUtils#getRandom(String source, int length)}
75 | */
76 | public static String getRandomLowerCaseLetters(int length) {
77 | return getRandom(LOWER_CASE_LETTERS, length);
78 | }
79 |
80 | /**
81 | * 得到固定长度的随机字符串,字符串由source中字符混合组成
82 | *
83 | * @param source 源字符串
84 | * @param length 长度
85 | * @return
86 | *
87 | * - 若source为null或为空字符串,返回null
88 | * - 否则见{@link StringUtils#getRandom(char[] sourceChar, int length)}
89 | *
90 | */
91 | public static String getRandom(String source, int length) {
92 | return StringUtils.isEmpty(source) ? null : getRandom(source.toCharArray(), length);
93 | }
94 |
95 | /**
96 | * 得到固定长度的随机字符串,字符串由sourceChar中字符混合组成
97 | *
98 | * @param sourceChar 源字符数组
99 | * @param length 长度
100 | * @return
101 | *
102 | * - 若sourceChar为null或长度为0,返回null
103 | * - 若length小于0,返回null
104 | *
105 | */
106 | public static String getRandom(char[] sourceChar, int length) {
107 | if (sourceChar == null || sourceChar.length == 0 || length < 0) {
108 | return null;
109 | }
110 |
111 | StringBuilder str = new StringBuilder(length);
112 | Random random = new Random();
113 | for (int i = 0; i < length; i++) {
114 | str.append(sourceChar[random.nextInt(sourceChar.length)]);
115 | }
116 | return str.toString();
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/.svn/text-base/SerializeUtils.java.svn-base:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.FileNotFoundException;
5 | import java.io.FileOutputStream;
6 | import java.io.IOException;
7 | import java.io.ObjectInputStream;
8 | import java.io.ObjectOutputStream;
9 |
10 | /**
11 | * 序列化工具类
12 | *
13 | * @author Trinea 2012-5-14 下午04:22:24
14 | */
15 | public class SerializeUtils {
16 |
17 | /**
18 | * 反序列化
19 | *
20 | * @param filePath 序列化文件路径
21 | * @return 得到的对象
22 | */
23 | public static Object deserialization(String filePath) {
24 | ObjectInputStream in = null;
25 | try {
26 | in = new ObjectInputStream(new FileInputStream(filePath));
27 | Object o = in.readObject();
28 | in.close();
29 | return o;
30 | } catch (FileNotFoundException e) {
31 | throw new RuntimeException("FileNotFoundException occurred. ", e);
32 | } catch (ClassNotFoundException e) {
33 | throw new RuntimeException("ClassNotFoundException occurred. ", e);
34 | } catch (IOException e) {
35 | throw new RuntimeException("IOException occurred. ", e);
36 | } finally {
37 | if (in != null) {
38 | try {
39 | in.close();
40 | } catch (IOException e) {
41 | throw new RuntimeException("IOException occurred. ", e);
42 | }
43 | }
44 | }
45 | }
46 |
47 | /**
48 | * 序列化
49 | *
50 | * @param filePath 序列化文件路径
51 | * @param obj 序列化的对象
52 | * @return
53 | */
54 | public static void serialization(String filePath, Object obj) {
55 | ObjectOutputStream out = null;
56 | try {
57 | out = new ObjectOutputStream(new FileOutputStream(filePath));
58 | out.writeObject(obj);
59 | out.close();
60 | } catch (FileNotFoundException e) {
61 | throw new RuntimeException("FileNotFoundException occurred. ", e);
62 | } catch (IOException e) {
63 | throw new RuntimeException("IOException occurred. ", e);
64 | } finally {
65 | if (out != null) {
66 | try {
67 | out.close();
68 | } catch (IOException e) {
69 | throw new RuntimeException("IOException occurred. ", e);
70 | }
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/ArrayUtils.java:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common;
2 |
3 | /**
4 | * 数组工具类
5 | *
6 | * - 继承自{@link org.apache.commons.lang3.ArrayUtils}
7 | * - {@link ArrayUtils#getLast(Object[], Object, Object, boolean)}得到array中某个元素(从前到后第一次匹配)的前一个元素
8 | * - {@link ArrayUtils#getNext(Object[], Object, Object, boolean)}得到array中某个元素(从前到后第一次匹配)的后一个元素
9 | *
10 | *
11 | * @author Trinea 2011-10-24 下午08:21:11
12 | */
13 | public class ArrayUtils extends org.apache.commons.lang3.ArrayUtils {
14 |
15 | /**
16 | * 得到array中某个元素(从前到后第一次匹配)的前一个元素
17 | *
18 | * - 若数组为空,返回defaultValue
19 | * - 若数组中未找到value,返回defaultValue
20 | * - 若找到了value并且不为第一个元素,返回该元素的前一个元素
21 | * - 若找到了value并且为第一个元素,isCircle为true时,返回数组最后一个元素;isCircle为false时,返回defaultValue
22 | *
23 | *
24 | * @param
25 | * @param sourceArray 源array
26 | * @param value 待查找值,若value为null同样适用,会查找第一个为null的值
27 | * @param defaultValue 默认返回值
28 | * @param isCircle 是否是圆
29 | * @return
30 | */
31 | public static V getLast(V[] sourceArray, V value, V defaultValue, boolean isCircle) {
32 | if (isEmpty(sourceArray)) {
33 | return defaultValue;
34 | }
35 |
36 | int currentPosition = -1;
37 | for (int i = 0; i < sourceArray.length; i++) {
38 | if (ObjectUtils.isEquals(value, sourceArray[i])) {
39 | currentPosition = i;
40 | break;
41 | }
42 | }
43 | if (currentPosition == -1) {
44 | return defaultValue;
45 | }
46 |
47 | if (currentPosition == 0) {
48 | return isCircle ? sourceArray[sourceArray.length - 1] : defaultValue;
49 | }
50 | return sourceArray[currentPosition - 1];
51 | }
52 |
53 | /**
54 | * 得到array中某个元素(从前到后第一次匹配)的后一个元素
55 | *
56 | * - 若数组为空,返回defaultValue
57 | * - 若数组中未找到value,返回defaultValue
58 | * - 若找到了value并且不为最后一个元素,返回该元素的下一个元素
59 | * - 若找到了value并且为最后一个元素,isCircle为true时,返回数组第一个元素;isCircle为false时,返回defaultValue
60 | *
61 | *
62 | * @param
63 | * @param sourceArray 源array
64 | * @param value 待查找值,若value为null同样适用,会查找第一个为null的值
65 | * @param defaultValue 默认返回值
66 | * @param isCircle 是否是圆
67 | * @return
68 | */
69 | public static V getNext(V[] sourceArray, V value, V defaultValue, boolean isCircle) {
70 | if (isEmpty(sourceArray)) {
71 | return defaultValue;
72 | }
73 |
74 | int currentPosition = -1;
75 | for (int i = 0; i < sourceArray.length; i++) {
76 | if (ObjectUtils.isEquals(value, sourceArray[i])) {
77 | currentPosition = i;
78 | break;
79 | }
80 | }
81 | if (currentPosition == -1) {
82 | return defaultValue;
83 | }
84 |
85 | if (currentPosition == sourceArray.length - 1) {
86 | return isCircle ? sourceArray[0] : defaultValue;
87 | }
88 | return sourceArray[currentPosition + 1];
89 | }
90 |
91 | /**
92 | * 参考{@link ArrayUtils#getLast(Object[], Object, Object, boolean)} defaultValue为null
93 | */
94 | public static V getLast(V[] sourceArray, V value, boolean isCircle) {
95 | return getLast(sourceArray, value, null, isCircle);
96 | }
97 |
98 | /**
99 | * 参考{@link ArrayUtils#getNext(Object[], Object, Object, boolean)} defaultValue为null
100 | */
101 | public static V getNext(V[] sourceArray, V value, boolean isCircle) {
102 | return getNext(sourceArray, value, null, isCircle);
103 | }
104 |
105 | /**
106 | * 参考{@link ArrayUtils#getLast(Object[], Object, Object, boolean)} Object为Long
107 | */
108 | public static long getLast(long[] sourceArray, long value, long defaultValue, boolean isCircle) {
109 | if (sourceArray.length == 0) {
110 | throw new IllegalArgumentException("The length of source array must be greater than 0.");
111 | }
112 |
113 | Long[] array = ObjectUtils.transformLongArray(sourceArray);
114 | return getLast(array, value, defaultValue, isCircle);
115 |
116 | }
117 |
118 | /**
119 | * 参考{@link ArrayUtils#getNext(Object[], Object, Object, boolean)} Object为Long
120 | */
121 | public static long getNext(long[] sourceArray, long value, long defaultValue, boolean isCircle) {
122 | if (sourceArray.length == 0) {
123 | throw new IllegalArgumentException("The length of source array must be greater than 0.");
124 | }
125 |
126 | Long[] array = ObjectUtils.transformLongArray(sourceArray);
127 | return getNext(array, value, defaultValue, isCircle);
128 | }
129 |
130 | /**
131 | * 参考{@link ArrayUtils#getLast(Object[], Object, Object, boolean)} Object为Integer
132 | */
133 | public static int getLast(int[] sourceArray, int value, int defaultValue, boolean isCircle) {
134 | if (sourceArray.length == 0) {
135 | throw new IllegalArgumentException("The length of source array must be greater than 0.");
136 | }
137 |
138 | Integer[] array = ObjectUtils.transformIntArray(sourceArray);
139 | return getLast(array, value, defaultValue, isCircle);
140 |
141 | }
142 |
143 | /**
144 | * 参考{@link ArrayUtils#getNext(Object[], Object, Object, boolean)} Object为Integer
145 | */
146 | public static int getNext(int[] sourceArray, int value, int defaultValue, boolean isCircle) {
147 | if (sourceArray.length == 0) {
148 | throw new IllegalArgumentException("The length of source array must be greater than 0.");
149 | }
150 |
151 | Integer[] array = ObjectUtils.transformIntArray(sourceArray);
152 | return getNext(array, value, defaultValue, isCircle);
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/ObjectUtils.java:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common;
2 |
3 | /**
4 | * Object工具类
5 | *
6 | * @author Trinea 2011-10-24 下午08:21:11
7 | */
8 | public class ObjectUtils {
9 |
10 | /**
11 | * 比较两个对象是否相等
12 | *
13 | * @param actual
14 | * @param expected
15 | * @return
16 | *
17 | * - 若两个对象都为null,则返回true
18 | * - 若{@code actual}对象不为null,则调用{@code actual}对象相应的{@link Object#equals(Object)}函数进行判断,返回判断结果
19 | *
20 | * @see
21 | *
22 | * - 对于基本类实现了{@link Object#equals(Object)}的话都会先判断类型是否匹配,类型不匹配返回false,可参考{@link String#equals(Object)}
23 | * - 关于如何利用此函数比较自定义对象可下载源代码,参考测试代码中的{@link ObjectUtilsTest#testIsEquals()}
24 | *
25 | */
26 | public static boolean isEquals(Object actual, Object expected) {
27 | return actual == null ? expected == null : actual.equals(expected);
28 | }
29 |
30 | /**
31 | * long数组转换成Long数组
32 | *
33 | * @param source
34 | * @return
35 | */
36 | public static Long[] transformLongArray(long[] source) {
37 | Long[] destin = new Long[source.length];
38 | for (int i = 0; i < source.length; i++) {
39 | destin[i] = source[i];
40 | }
41 | return destin;
42 | }
43 |
44 | /**
45 | * Long数组转换成long数组
46 | *
47 | * @param source
48 | * @return
49 | */
50 | public static long[] transformLongArray(Long[] source) {
51 | long[] destin = new long[source.length];
52 | for (int i = 0; i < source.length; i++) {
53 | destin[i] = source[i];
54 | }
55 | return destin;
56 | }
57 |
58 | /**
59 | * int数组转换成Integer数组
60 | *
61 | * @param source
62 | * @return
63 | */
64 | public static Integer[] transformIntArray(int[] source) {
65 | Integer[] destin = new Integer[source.length];
66 | for (int i = 0; i < source.length; i++) {
67 | destin[i] = source[i];
68 | }
69 | return destin;
70 | }
71 |
72 | /**
73 | * Integer数组转换成int数组
74 | *
75 | * @param source
76 | * @return
77 | */
78 | public static int[] transformIntArray(Integer[] source) {
79 | int[] destin = new int[source.length];
80 | for (int i = 0; i < source.length; i++) {
81 | destin[i] = source[i];
82 | }
83 | return destin;
84 | }
85 |
86 | /**
87 | * 比较两个值的大小
88 | *
90 | * 关于比较的结果
91 | *
92 | * - v1大于v2返回1
93 | * - v1等于v2返回0
94 | * - v1小于v2返回-1
95 | *
96 | * 关于比较的规则
97 | *
98 | * - 若v1为null,v2为null,则相等
99 | * - 若v1为null,v2不为null,则v1小于v2
100 | * - 若v1不为null,v2为null,则v1大于v2
101 | * - 若v1、v2均不为null,则利用v1的{@link Comparable#compareTo(Object)}判断,参数为v2
102 | *
103 | *
104 | * @param v1
105 | * @param v2
106 | * @return
107 | */
108 | @SuppressWarnings({"unchecked", "rawtypes"})
109 | public static int compare(V v1, V v2) {
110 | return v1 == null ? (v2 == null ? 0 : -1) : (v2 == null ? 1 : ((Comparable)v1).compareTo(v2));
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/RandomUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common;
9 |
10 | import java.util.Random;
11 |
12 | /**
13 | * 随机数工具类
14 | *
15 | * @author Trinea 2012-5-12 下午01:37:48
16 | */
17 | public class RandomUtils {
18 |
19 | public static final String NUMBERS_AND_LETTERS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
20 | public static final String NUMBERS = "0123456789";
21 | public static final String LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
22 | public static final String CAPITAL_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
23 | public static final String LOWER_CASE_LETTERS = "abcdefghijklmnopqrstuvwxyz";
24 |
25 | /**
26 | * 得到固定长度的随机字符串,字符串由数字和大小写字母混合组成
27 | *
28 | * @param length 长度
29 | * @return
30 | * @see 见{@link StringUtils#getRandom(String source, int length)}
31 | */
32 | public static String getRandomNumbersAndLetters(int length) {
33 | return getRandom(NUMBERS_AND_LETTERS, length);
34 | }
35 |
36 | /**
37 | * 得到固定长度的随机字符串,字符串由数字混合组成
38 | *
39 | * @param length 长度
40 | * @return
41 | * @see 见{@link StringUtils#getRandom(String source, int length)}
42 | */
43 | public static String getRandomNumbers(int length) {
44 | return getRandom(NUMBERS, length);
45 | }
46 |
47 | /**
48 | * 得到固定长度的随机字符串,字符串由大小写字母混合组成
49 | *
50 | * @param length 长度
51 | * @return
52 | * @see 见{@link StringUtils#getRandom(String source, int length)}
53 | */
54 | public static String getRandomLetters(int length) {
55 | return getRandom(LETTERS, length);
56 | }
57 |
58 | /**
59 | * 得到固定长度的随机字符串,字符串由大写字母混合组成
60 | *
61 | * @param length 长度
62 | * @return
63 | * @see 见{@link StringUtils#getRandom(String source, int length)}
64 | */
65 | public static String getRandomCapitalLetters(int length) {
66 | return getRandom(CAPITAL_LETTERS, length);
67 | }
68 |
69 | /**
70 | * 得到固定长度的随机字符串,字符串由小写字母混合组成
71 | *
72 | * @param length 长度
73 | * @return
74 | * @see 见{@link StringUtils#getRandom(String source, int length)}
75 | */
76 | public static String getRandomLowerCaseLetters(int length) {
77 | return getRandom(LOWER_CASE_LETTERS, length);
78 | }
79 |
80 | /**
81 | * 得到固定长度的随机字符串,字符串由source中字符混合组成
82 | *
83 | * @param source 源字符串
84 | * @param length 长度
85 | * @return
86 | *
87 | * - 若source为null或为空字符串,返回null
88 | * - 否则见{@link StringUtils#getRandom(char[] sourceChar, int length)}
89 | *
90 | */
91 | public static String getRandom(String source, int length) {
92 | return StringUtils.isEmpty(source) ? null : getRandom(source.toCharArray(), length);
93 | }
94 |
95 | /**
96 | * 得到固定长度的随机字符串,字符串由sourceChar中字符混合组成
97 | *
98 | * @param sourceChar 源字符数组
99 | * @param length 长度
100 | * @return
101 | *
102 | * - 若sourceChar为null或长度为0,返回null
103 | * - 若length小于0,返回null
104 | *
105 | */
106 | public static String getRandom(char[] sourceChar, int length) {
107 | if (sourceChar == null || sourceChar.length == 0 || length < 0) {
108 | return null;
109 | }
110 |
111 | StringBuilder str = new StringBuilder(length);
112 | Random random = new Random();
113 | for (int i = 0; i < length; i++) {
114 | str.append(sourceChar[random.nextInt(sourceChar.length)]);
115 | }
116 | return str.toString();
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/SerializeUtils.java:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.FileNotFoundException;
5 | import java.io.FileOutputStream;
6 | import java.io.IOException;
7 | import java.io.ObjectInputStream;
8 | import java.io.ObjectOutputStream;
9 |
10 | /**
11 | * 序列化工具类
12 | *
13 | * @author Trinea 2012-5-14 下午04:22:24
14 | */
15 | public class SerializeUtils {
16 |
17 | /**
18 | * 反序列化
19 | *
20 | * @param filePath 序列化文件路径
21 | * @return 得到的对象
22 | */
23 | public static Object deserialization(String filePath) {
24 | ObjectInputStream in = null;
25 | try {
26 | in = new ObjectInputStream(new FileInputStream(filePath));
27 | Object o = in.readObject();
28 | in.close();
29 | return o;
30 | } catch (FileNotFoundException e) {
31 | throw new RuntimeException("FileNotFoundException occurred. ", e);
32 | } catch (ClassNotFoundException e) {
33 | throw new RuntimeException("ClassNotFoundException occurred. ", e);
34 | } catch (IOException e) {
35 | throw new RuntimeException("IOException occurred. ", e);
36 | } finally {
37 | if (in != null) {
38 | try {
39 | in.close();
40 | } catch (IOException e) {
41 | throw new RuntimeException("IOException occurred. ", e);
42 | }
43 | }
44 | }
45 | }
46 |
47 | /**
48 | * 序列化
49 | *
50 | * @param filePath 序列化文件路径
51 | * @param obj 序列化的对象
52 | * @return
53 | */
54 | public static void serialization(String filePath, Object obj) {
55 | ObjectOutputStream out = null;
56 | try {
57 | out = new ObjectOutputStream(new FileOutputStream(filePath));
58 | out.writeObject(obj);
59 | out.close();
60 | } catch (FileNotFoundException e) {
61 | throw new RuntimeException("FileNotFoundException occurred. ", e);
62 | } catch (IOException e) {
63 | throw new RuntimeException("IOException occurred. ", e);
64 | } finally {
65 | if (out != null) {
66 | try {
67 | out.close();
68 | } catch (IOException e) {
69 | throw new RuntimeException("IOException occurred. ", e);
70 | }
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/entity/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 65
4 | /svn/!svn/ver/4/trunk/src/main/java/com/trinea/java/common/entity
5 | END
6 | CacheObject.java
7 | K 25
8 | svn:wc:ra_dav:version-url
9 | V 83
10 | /svn/!svn/ver/11/trunk/src/main/java/com/trinea/java/common/entity/CacheObject.java
11 | END
12 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/entity/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/entity/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/main/java/com/trinea/java/common/entity
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-05-16T17:02:01.806238Z
11 | 4
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | CacheObject.java
30 | file
31 | 11
32 |
33 |
34 |
35 | 2012-07-10T09:15:14.000000Z
36 | 37f237047312a4a836c4f564e42c6072
37 | 2012-07-11T13:48:34.171547Z
38 | 11
39 | trinea1989@gmail.com
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 3118
62 |
63 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/entity/.svn/text-base/CacheObject.java.svn-base:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.trinea.java.common.ObjectUtils;
6 |
7 | /**
8 | * 缓存中的数据
9 | *
10 | * @author Trinea 2011-12-23 上午01:27:06
11 | */
12 | public class CacheObject implements Serializable, Comparable> {
13 |
14 | private static final long serialVersionUID = 1L;
15 |
16 | /** 对象进入缓存时间 **/
17 | protected long enterTime;
18 | /** 对象上次使用时间, 即上次被get的时间 **/
19 | protected long lastUsedTime;
20 | /** 对象使用次数, get一次表示被使用一次 **/
21 | protected long usedCount;
22 | /** 对象优先级 **/
23 | protected int priority;
24 |
25 | /** 对象是否已经过期 **/
26 | protected boolean isExpired;
27 | /** 对象是否永不过期 **/
28 | protected boolean isForever;
29 |
30 | /** 对象数据 **/
31 | protected V data;
32 |
33 | public CacheObject(){
34 | this.enterTime = System.currentTimeMillis();
35 | this.lastUsedTime = System.currentTimeMillis();
36 | this.usedCount = 0;
37 | this.priority = 0;
38 | this.isExpired = false;
39 | this.isForever = true;
40 | }
41 |
42 | public CacheObject(V data){
43 | this();
44 | this.data = data;
45 | }
46 |
47 | public long getEnterTime() {
48 | return enterTime;
49 | }
50 |
51 | public void setEnterTime(long enterTime) {
52 | this.enterTime = enterTime;
53 | }
54 |
55 | public long getLastUsedTime() {
56 | return lastUsedTime;
57 | }
58 |
59 | public void setLastUsedTime(long lastUsedTime) {
60 | this.lastUsedTime = lastUsedTime;
61 | }
62 |
63 | public long getUsedCount() {
64 | return usedCount;
65 | }
66 |
67 | public void setUsedCount(long usedCount) {
68 | this.usedCount = usedCount;
69 | }
70 |
71 | public int getPriority() {
72 | return priority;
73 | }
74 |
75 | public void setPriority(int priority) {
76 | this.priority = priority;
77 | }
78 |
79 | public boolean isExpired() {
80 | return isExpired;
81 | }
82 |
83 | public void setExpired(boolean isExpired) {
84 | this.isExpired = isExpired;
85 | }
86 |
87 | public boolean isForever() {
88 | return isForever;
89 | }
90 |
91 | public void setForever(boolean isForever) {
92 | this.isForever = isForever;
93 | }
94 |
95 | public V getData() {
96 | return data;
97 | }
98 |
99 | public void setData(V data) {
100 | this.data = data;
101 | }
102 |
103 | /**
104 | * 仅对data字段进行比较
105 | *
106 | * @param o
107 | * @return
108 | */
109 | @Override
110 | public int compareTo(CacheObject o) {
111 | return o == null ? 1 : ObjectUtils.compare(this.getData(), o.getData());
112 | }
113 |
114 | @SuppressWarnings("unchecked")
115 | public boolean equals(Object o) {
116 | if (o == null) {
117 | return false;
118 | }
119 |
120 | CacheObject obj = (CacheObject)(o);
121 | return (ObjectUtils.isEquals(this.getData(), obj.getData()) && this.getEnterTime() == obj.getEnterTime()
122 | && this.getPriority() == obj.getPriority() && this.isExpired == obj.isExpired && this.isForever == obj.isForever);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/entity/CacheObject.java:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.trinea.java.common.ObjectUtils;
6 |
7 | /**
8 | * 缓存中的数据
9 | *
10 | * @author Trinea 2011-12-23 上午01:27:06
11 | */
12 | public class CacheObject implements Serializable, Comparable> {
13 |
14 | private static final long serialVersionUID = 1L;
15 |
16 | /** 对象进入缓存时间 **/
17 | protected long enterTime;
18 | /** 对象上次使用时间, 即上次被get的时间 **/
19 | protected long lastUsedTime;
20 | /** 对象使用次数, get一次表示被使用一次 **/
21 | protected long usedCount;
22 | /** 对象优先级 **/
23 | protected int priority;
24 |
25 | /** 对象是否已经过期 **/
26 | protected boolean isExpired;
27 | /** 对象是否永不过期 **/
28 | protected boolean isForever;
29 |
30 | /** 对象数据 **/
31 | protected V data;
32 |
33 | public CacheObject(){
34 | this.enterTime = System.currentTimeMillis();
35 | this.lastUsedTime = System.currentTimeMillis();
36 | this.usedCount = 0;
37 | this.priority = 0;
38 | this.isExpired = false;
39 | this.isForever = true;
40 | }
41 |
42 | public CacheObject(V data){
43 | this();
44 | this.data = data;
45 | }
46 |
47 | public long getEnterTime() {
48 | return enterTime;
49 | }
50 |
51 | public void setEnterTime(long enterTime) {
52 | this.enterTime = enterTime;
53 | }
54 |
55 | public long getLastUsedTime() {
56 | return lastUsedTime;
57 | }
58 |
59 | public void setLastUsedTime(long lastUsedTime) {
60 | this.lastUsedTime = lastUsedTime;
61 | }
62 |
63 | public long getUsedCount() {
64 | return usedCount;
65 | }
66 |
67 | public void setUsedCount(long usedCount) {
68 | this.usedCount = usedCount;
69 | }
70 |
71 | public int getPriority() {
72 | return priority;
73 | }
74 |
75 | public void setPriority(int priority) {
76 | this.priority = priority;
77 | }
78 |
79 | public boolean isExpired() {
80 | return isExpired;
81 | }
82 |
83 | public void setExpired(boolean isExpired) {
84 | this.isExpired = isExpired;
85 | }
86 |
87 | public boolean isForever() {
88 | return isForever;
89 | }
90 |
91 | public void setForever(boolean isForever) {
92 | this.isForever = isForever;
93 | }
94 |
95 | public V getData() {
96 | return data;
97 | }
98 |
99 | public void setData(V data) {
100 | this.data = data;
101 | }
102 |
103 | /**
104 | * 仅对data字段进行比较
105 | *
106 | * @param o
107 | * @return
108 | */
109 | @Override
110 | public int compareTo(CacheObject o) {
111 | return o == null ? 1 : ObjectUtils.compare(this.getData(), o.getData());
112 | }
113 |
114 | @SuppressWarnings("unchecked")
115 | public boolean equals(Object o) {
116 | if (o == null) {
117 | return false;
118 | }
119 |
120 | CacheObject obj = (CacheObject)(o);
121 | return (ObjectUtils.isEquals(this.getData(), obj.getData()) && this.getEnterTime() == obj.getEnterTime()
122 | && this.getPriority() == obj.getPriority() && this.isExpired == obj.isExpired && this.isForever == obj.isForever);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/service/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 66
4 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/service
5 | END
6 | Cache.java
7 | K 25
8 | svn:wc:ra_dav:version-url
9 | V 78
10 | /svn/!svn/ver/12/trunk/src/main/java/com/trinea/java/common/service/Cache.java
11 | END
12 | CacheFullRemoveType.java
13 | K 25
14 | svn:wc:ra_dav:version-url
15 | V 91
16 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/service/CacheFullRemoveType.java
17 | END
18 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/service/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/service/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/main/java/com/trinea/java/common/service
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-06-18T07:22:39.904159Z
11 | 8
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | Cache.java
30 | file
31 | 12
32 |
33 |
34 |
35 | 2012-07-12T15:01:18.000000Z
36 | 80354d77cf07a22045ab51186c0d08ce
37 | 2012-07-12T15:33:55.265795Z
38 | 12
39 | trinea1989@gmail.com
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 1897
62 |
63 | CacheFullRemoveType.java
64 | file
65 |
66 |
67 |
68 |
69 | 2012-06-18T05:49:18.000000Z
70 | d02bf1131bff6897beb2421ceadf069c
71 | 2012-06-18T07:22:39.904159Z
72 | 8
73 | trinea1989@gmail.com
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | 699
96 |
97 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/service/.svn/text-base/Cache.java.svn-base:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common.service;
2 |
3 | import java.util.Collection;
4 | import java.util.Map;
5 | import java.util.Set;
6 |
7 | import com.trinea.java.common.entity.CacheObject;
8 |
9 | /**
10 | * 小型缓存
11 | *
12 | * @author Trinea 2011-12-23 上午01:46:01
13 | */
14 | public interface Cache {
15 |
16 | /**
17 | * 得到缓存中元素个数
18 | *
19 | * @return
20 | */
21 | public int getSize();
22 |
23 | /**
24 | * 从缓存中获取元素
25 | *
26 | * @param key
27 | * @return
28 | */
29 | public CacheObject get(K key);
30 |
31 | /**
32 | * 向缓存中添加元素
33 | *
34 | * @param key key
35 | * @param value 元素值
36 | * @return
37 | */
38 | public CacheObject put(K key, V value);
39 |
40 | /**
41 | * 向缓存中添加元素
42 | *
43 | * @param key key
44 | * @param obj 元素
45 | * @return
46 | */
47 | public CacheObject put(K key, CacheObject obj);
48 |
49 | /**
50 | * 将cache2中的所有元素复制到当前cache
51 | *
52 | * @param cache2
53 | */
54 | public void putAll(Cache cache2);
55 |
56 | /**
57 | * 缓存中某个key是否存在
58 | *
59 | * @param key
60 | * @return
61 | */
62 | public boolean containsKey(K key);
63 |
64 | /**
65 | * 从缓存中删除某个元素
66 | *
67 | * @param key
68 | * @return 删除的元素
69 | */
70 | public CacheObject remove(K key);
71 |
72 | /**
73 | * 清空缓存
74 | */
75 | public void clear();
76 |
77 | /**
78 | * 得到缓存命中率
79 | *
80 | * @return
81 | */
82 | public double getHitRate();
83 |
84 | /**
85 | * 缓存中key的集合
86 | *
87 | * @return
88 | */
89 | public Set keySet();
90 |
91 | /**
92 | * 缓存中元素的集合
93 | *
94 | * @return
95 | */
96 | public Set>> entrySet();
97 |
98 | /**
99 | * 缓存中元素值的集合
100 | *
101 | * @return
102 | */
103 | public Collection> values();
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/service/.svn/text-base/CacheFullRemoveType.java.svn-base:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common.service;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.trinea.java.common.entity.CacheObject;
6 |
7 | /**
8 | * 缓存满时删除数据的类型
9 | *
10 | * @author Trinea 2011-12-26 下午11:40:39
11 | */
12 | public interface CacheFullRemoveType extends Serializable {
13 |
14 | /**
15 | * 比较两个数据
16 | *
17 | *
18 | * 关于比较的结果
19 | * - obj1大于obj2返回1
20 | * - obj1等于obj2返回0
21 | * - obj1小于obj2返回-1
22 | *
23 | *
24 | * @param obj1 数据1
25 | * @param obj2 数据2
26 | * @return
27 | */
28 | public int compare(CacheObject obj1, CacheObject obj2);
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/service/Cache.java:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common.service;
2 |
3 | import java.util.Collection;
4 | import java.util.Map;
5 | import java.util.Set;
6 |
7 | import com.trinea.java.common.entity.CacheObject;
8 |
9 | /**
10 | * 小型缓存
11 | *
12 | * @author Trinea 2011-12-23 上午01:46:01
13 | */
14 | public interface Cache {
15 |
16 | /**
17 | * 得到缓存中元素个数
18 | *
19 | * @return
20 | */
21 | public int getSize();
22 |
23 | /**
24 | * 从缓存中获取元素
25 | *
26 | * @param key
27 | * @return
28 | */
29 | public CacheObject get(K key);
30 |
31 | /**
32 | * 向缓存中添加元素
33 | *
34 | * @param key key
35 | * @param value 元素值
36 | * @return
37 | */
38 | public CacheObject put(K key, V value);
39 |
40 | /**
41 | * 向缓存中添加元素
42 | *
43 | * @param key key
44 | * @param value 元素
45 | * @return
46 | */
47 | public CacheObject put(K key, CacheObject value);
48 |
49 | /**
50 | * 将cache2中的所有元素复制到当前cache
51 | *
52 | * @param cache2
53 | */
54 | public void putAll(Cache cache2);
55 |
56 | /**
57 | * 缓存中某个key是否存在
58 | *
59 | * @param key
60 | * @return
61 | */
62 | public boolean containsKey(K key);
63 |
64 | /**
65 | * 从缓存中删除某个元素
66 | *
67 | * @param key
68 | * @return 删除的元素
69 | */
70 | public CacheObject remove(K key);
71 |
72 | /**
73 | * 清空缓存
74 | */
75 | public void clear();
76 |
77 | /**
78 | * 得到缓存命中率
79 | *
80 | * @return
81 | */
82 | public double getHitRate();
83 |
84 | /**
85 | * 缓存中key的集合
86 | *
87 | * @return
88 | */
89 | public Set keySet();
90 |
91 | /**
92 | * 缓存中元素的集合
93 | *
94 | * @return
95 | */
96 | public Set>> entrySet();
97 |
98 | /**
99 | * 缓存中元素值的集合
100 | *
101 | * @return
102 | */
103 | public Collection> values();
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/service/CacheFullRemoveType.java:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common.service;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.trinea.java.common.entity.CacheObject;
6 |
7 | /**
8 | * 缓存满时删除数据的类型
9 | *
10 | * @author Trinea 2011-12-26 下午11:40:39
11 | */
12 | public interface CacheFullRemoveType extends Serializable {
13 |
14 | /**
15 | * 比较两个数据
16 | *
17 | *
18 | * 关于比较的结果
19 | * - obj1大于obj2返回1
20 | * - obj1等于obj2返回0
21 | * - obj1小于obj2返回-1
22 | *
23 | *
24 | * @param obj1 数据1
25 | * @param obj2 数据2
26 | * @return
27 | */
28 | public int compare(CacheObject obj1, CacheObject obj2);
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 71
4 | /svn/!svn/ver/10/trunk/src/main/java/com/trinea/java/common/serviceImpl
5 | END
6 | RemoveTypeEnterTimeLast.java
7 | K 25
8 | svn:wc:ra_dav:version-url
9 | V 99
10 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeEnterTimeLast.java
11 | END
12 | RemoveTypePriorityHigh.java
13 | K 25
14 | svn:wc:ra_dav:version-url
15 | V 98
16 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypePriorityHigh.java
17 | END
18 | RemoveTypeDataSmall.java
19 | K 25
20 | svn:wc:ra_dav:version-url
21 | V 95
22 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeDataSmall.java
23 | END
24 | RemoveTypeUsedCountSmall.java
25 | K 25
26 | svn:wc:ra_dav:version-url
27 | V 100
28 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeUsedCountSmall.java
29 | END
30 | RemoveTypePriorityLow.java
31 | K 25
32 | svn:wc:ra_dav:version-url
33 | V 97
34 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypePriorityLow.java
35 | END
36 | RemoveTypeEnterTimeFirst.java
37 | K 25
38 | svn:wc:ra_dav:version-url
39 | V 100
40 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeEnterTimeFirst.java
41 | END
42 | AutoGetDataCache.java
43 | K 25
44 | svn:wc:ra_dav:version-url
45 | V 93
46 | /svn/!svn/ver/11/trunk/src/main/java/com/trinea/java/common/serviceImpl/AutoGetDataCache.java
47 | END
48 | RemoveTypeLastUsedTimeLast.java
49 | K 25
50 | svn:wc:ra_dav:version-url
51 | V 102
52 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeLastUsedTimeLast.java
53 | END
54 | RemoveTypeDataBig.java
55 | K 25
56 | svn:wc:ra_dav:version-url
57 | V 93
58 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeDataBig.java
59 | END
60 | RemoveTypeLastUsedTimeFirst.java
61 | K 25
62 | svn:wc:ra_dav:version-url
63 | V 103
64 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeLastUsedTimeFirst.java
65 | END
66 | RemoveTypeUsedCountBig.java
67 | K 25
68 | svn:wc:ra_dav:version-url
69 | V 98
70 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeUsedCountBig.java
71 | END
72 | SimpleCache.java
73 | K 25
74 | svn:wc:ra_dav:version-url
75 | V 88
76 | /svn/!svn/ver/12/trunk/src/main/java/com/trinea/java/common/serviceImpl/SimpleCache.java
77 | END
78 | RemoveTypeNotRemove.java
79 | K 25
80 | svn:wc:ra_dav:version-url
81 | V 95
82 | /svn/!svn/ver/8/trunk/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeNotRemove.java
83 | END
84 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/main/java/com/trinea/java/common/serviceImpl
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-06-18T08:01:26.393143Z
11 | 10
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | RemoveTypeEnterTimeLast.java
30 | file
31 |
32 |
33 |
34 |
35 | 2012-06-18T05:49:18.000000Z
36 | a193fa3c32a8a2aa33c26f0e7e232b63
37 | 2012-06-18T07:22:39.904159Z
38 | 8
39 | trinea1989@gmail.com
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 996
62 |
63 | RemoveTypePriorityHigh.java
64 | file
65 |
66 |
67 |
68 |
69 | 2012-06-18T05:49:18.000000Z
70 | 49740dc0539c517e31feba87813276ae
71 | 2012-06-18T07:22:39.904159Z
72 | 8
73 | trinea1989@gmail.com
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | 988
96 |
97 | RemoveTypeDataSmall.java
98 | file
99 |
100 |
101 |
102 |
103 | 2012-06-18T05:49:18.000000Z
104 | cbdfd07dbd82faba90e413654327c224
105 | 2012-06-18T07:22:39.904159Z
106 | 8
107 | trinea1989@gmail.com
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | 961
130 |
131 | RemoveTypeUsedCountSmall.java
132 | file
133 |
134 |
135 |
136 |
137 | 2012-06-18T05:49:18.000000Z
138 | 84a5852126ffe51e3f691b875c4d910e
139 | 2012-06-18T07:22:39.904159Z
140 | 8
141 | trinea1989@gmail.com
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 | 1014
164 |
165 | RemoveTypePriorityLow.java
166 | file
167 |
168 |
169 |
170 |
171 | 2012-06-18T05:49:18.000000Z
172 | f5fa28d4e226f52658951be4b952f4ea
173 | 2012-06-18T07:22:39.904159Z
174 | 8
175 | trinea1989@gmail.com
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 | 987
198 |
199 | RemoveTypeEnterTimeFirst.java
200 | file
201 |
202 |
203 |
204 |
205 | 2012-06-18T05:49:18.000000Z
206 | a608c9cfa4855f070340a3a3535f3176
207 | 2012-06-18T07:22:39.904159Z
208 | 8
209 | trinea1989@gmail.com
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 | 997
232 |
233 | AutoGetDataCache.java
234 | file
235 | 11
236 |
237 |
238 |
239 | 2012-07-10T09:21:38.000000Z
240 | 3b98b3191fbaac5491eec2ca88277d66
241 | 2012-07-11T13:48:34.171547Z
242 | 11
243 | trinea1989@gmail.com
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 | 16191
266 |
267 | RemoveTypeLastUsedTimeLast.java
268 | file
269 |
270 |
271 |
272 |
273 | 2012-06-18T05:49:18.000000Z
274 | 112f080e0cbb4ae8bb2f03241bc7c27c
275 | 2012-06-18T07:22:39.904159Z
276 | 8
277 | trinea1989@gmail.com
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 | 1040
300 |
301 | RemoveTypeDataBig.java
302 | file
303 |
304 |
305 |
306 |
307 | 2012-06-18T05:49:18.000000Z
308 | b2f28d328b625cfc984941f59e51f721
309 | 2012-06-18T07:22:39.904159Z
310 | 8
311 | trinea1989@gmail.com
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 | 959
334 |
335 | RemoveTypeLastUsedTimeFirst.java
336 | file
337 |
338 |
339 |
340 |
341 | 2012-06-18T05:49:18.000000Z
342 | 4ac81b630a7cdb2732209ad894a86051
343 | 2012-06-18T07:22:39.904159Z
344 | 8
345 | trinea1989@gmail.com
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 | 1041
368 |
369 | RemoveTypeUsedCountBig.java
370 | file
371 |
372 |
373 |
374 |
375 | 2012-06-18T05:49:18.000000Z
376 | 109ae63cc0e40aaee3727df39e416d64
377 | 2012-06-18T07:22:39.904159Z
378 | 8
379 | trinea1989@gmail.com
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 | 1012
402 |
403 | SimpleCache.java
404 | file
405 | 12
406 |
407 |
408 |
409 | 2012-07-12T15:01:20.000000Z
410 | c6bc3923dab31c232f73120b487565cd
411 | 2012-07-12T15:33:55.265795Z
412 | 12
413 | trinea1989@gmail.com
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 | 15040
436 |
437 | RemoveTypeNotRemove.java
438 | file
439 |
440 |
441 |
442 |
443 | 2012-06-18T05:49:18.000000Z
444 | cfad42ea2191d500296737e256db123a
445 | 2012-06-18T07:22:39.904159Z
446 | 8
447 | trinea1989@gmail.com
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 | 855
470 |
471 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypeDataBig.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.ObjectUtils;
11 | import com.trinea.java.common.entity.CacheObject;
12 | import com.trinea.java.common.service.CacheFullRemoveType;
13 |
14 | /**
15 | * 缓存满时删除数据的类型--对象值大先删除
16 | *
17 | * @author Trinea 2012-5-10 上午01:15:50
18 | */
19 | public class RemoveTypeDataBig implements CacheFullRemoveType {
20 |
21 | private static final long serialVersionUID = 1L;
22 |
23 | @Override
24 | public int compare(CacheObject obj1, CacheObject obj2) {
25 | return ObjectUtils.compare(obj2.getData(), obj1.getData());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypeDataSmall.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.ObjectUtils;
11 | import com.trinea.java.common.entity.CacheObject;
12 | import com.trinea.java.common.service.CacheFullRemoveType;
13 |
14 | /**
15 | * 缓存满时删除数据的类型--对象值小先删除
16 | *
17 | * @author Trinea 2012-5-10 上午01:15:50
18 | */
19 | public class RemoveTypeDataSmall implements CacheFullRemoveType {
20 |
21 | private static final long serialVersionUID = 1L;
22 |
23 | @Override
24 | public int compare(CacheObject obj1, CacheObject obj2) {
25 | return ObjectUtils.compare(obj1.getData(), obj2.getData());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypeEnterTimeFirst.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象进入缓存时间先进入先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeEnterTimeFirst implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj1.getEnterTime() > obj2.getEnterTime()) ? 1 : ((obj1.getEnterTime() == obj2.getEnterTime()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypeEnterTimeLast.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象进入缓存时间后进入先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeEnterTimeLast implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj2.getEnterTime() > obj1.getEnterTime()) ? 1 : ((obj2.getEnterTime() == obj1.getEnterTime()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypeLastUsedTimeFirst.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象上次使用时间(即上次被get的时间),先使用先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeLastUsedTimeFirst implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj1.getLastUsedTime() > obj2.getLastUsedTime()) ? 1 : ((obj1.getLastUsedTime() == obj2.getLastUsedTime()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypeLastUsedTimeLast.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象上次使用时间(即上次被get的时间),后使用先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeLastUsedTimeLast implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj2.getLastUsedTime() > obj1.getLastUsedTime()) ? 1 : ((obj2.getLastUsedTime() == obj1.getLastUsedTime()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypeNotRemove.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--不删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeNotRemove implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return 0;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypePriorityHigh.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象优先级,优先级高先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypePriorityHigh implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj2.getPriority() > obj1.getPriority()) ? 1 : ((obj2.getPriority() == obj1.getPriority()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypePriorityLow.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象优先级,优先级低先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypePriorityLow implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj1.getPriority() > obj2.getPriority()) ? 1 : ((obj1.getPriority() == obj2.getPriority()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypeUsedCountBig.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象使用次数(即被get的次数),使用多先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeUsedCountBig implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj2.getUsedCount() > obj1.getUsedCount()) ? 1 : ((obj2.getUsedCount() == obj1.getUsedCount()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/.svn/text-base/RemoveTypeUsedCountSmall.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象使用次数(即被get的次数),使用少先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeUsedCountSmall implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj1.getUsedCount() > obj2.getUsedCount()) ? 1 : ((obj1.getUsedCount() == obj2.getUsedCount()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeDataBig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.ObjectUtils;
11 | import com.trinea.java.common.entity.CacheObject;
12 | import com.trinea.java.common.service.CacheFullRemoveType;
13 |
14 | /**
15 | * 缓存满时删除数据的类型--对象值大先删除
16 | *
17 | * @author Trinea 2012-5-10 上午01:15:50
18 | */
19 | public class RemoveTypeDataBig implements CacheFullRemoveType {
20 |
21 | private static final long serialVersionUID = 1L;
22 |
23 | @Override
24 | public int compare(CacheObject obj1, CacheObject obj2) {
25 | return ObjectUtils.compare(obj2.getData(), obj1.getData());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeDataSmall.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.ObjectUtils;
11 | import com.trinea.java.common.entity.CacheObject;
12 | import com.trinea.java.common.service.CacheFullRemoveType;
13 |
14 | /**
15 | * 缓存满时删除数据的类型--对象值小先删除
16 | *
17 | * @author Trinea 2012-5-10 上午01:15:50
18 | */
19 | public class RemoveTypeDataSmall implements CacheFullRemoveType {
20 |
21 | private static final long serialVersionUID = 1L;
22 |
23 | @Override
24 | public int compare(CacheObject obj1, CacheObject obj2) {
25 | return ObjectUtils.compare(obj1.getData(), obj2.getData());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeEnterTimeFirst.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象进入缓存时间先进入先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeEnterTimeFirst implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj1.getEnterTime() > obj2.getEnterTime()) ? 1 : ((obj1.getEnterTime() == obj2.getEnterTime()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeEnterTimeLast.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象进入缓存时间后进入先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeEnterTimeLast implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj2.getEnterTime() > obj1.getEnterTime()) ? 1 : ((obj2.getEnterTime() == obj1.getEnterTime()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeLastUsedTimeFirst.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象上次使用时间(即上次被get的时间),先使用先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeLastUsedTimeFirst implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj1.getLastUsedTime() > obj2.getLastUsedTime()) ? 1 : ((obj1.getLastUsedTime() == obj2.getLastUsedTime()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeLastUsedTimeLast.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象上次使用时间(即上次被get的时间),后使用先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeLastUsedTimeLast implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj2.getLastUsedTime() > obj1.getLastUsedTime()) ? 1 : ((obj2.getLastUsedTime() == obj1.getLastUsedTime()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeNotRemove.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--不删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeNotRemove implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return 0;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypePriorityHigh.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象优先级,优先级高先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypePriorityHigh implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj2.getPriority() > obj1.getPriority()) ? 1 : ((obj2.getPriority() == obj1.getPriority()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypePriorityLow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象优先级,优先级低先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypePriorityLow implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj1.getPriority() > obj2.getPriority()) ? 1 : ((obj1.getPriority() == obj2.getPriority()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeUsedCountBig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象使用次数(即被get的次数),使用多先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeUsedCountBig implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj2.getUsedCount() > obj1.getUsedCount()) ? 1 : ((obj2.getUsedCount() == obj1.getUsedCount()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/trinea/java/common/serviceImpl/RemoveTypeUsedCountSmall.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.serviceImpl;
9 |
10 | import com.trinea.java.common.entity.CacheObject;
11 | import com.trinea.java.common.service.CacheFullRemoveType;
12 |
13 | /**
14 | * 缓存满时删除数据的类型--对象使用次数(即被get的次数),使用少先删除
15 | *
16 | * @author Trinea 2012-5-10 上午01:15:50
17 | */
18 | public class RemoveTypeUsedCountSmall implements CacheFullRemoveType {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | @Override
23 | public int compare(CacheObject obj1, CacheObject obj2) {
24 | return (obj1.getUsedCount() > obj2.getUsedCount()) ? 1 : ((obj1.getUsedCount() == obj2.getUsedCount()) ? 0 : -1);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 30
4 | /svn/!svn/ver/9/trunk/src/test
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/test
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-06-18T07:55:00.164283Z
11 | 9
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | java
30 | dir
31 |
32 |
--------------------------------------------------------------------------------
/src/test/java/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 35
4 | /svn/!svn/ver/9/trunk/src/test/java
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/test/java
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-06-18T07:55:00.164283Z
11 | 9
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | com
30 | dir
31 |
32 |
--------------------------------------------------------------------------------
/src/test/java/com/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 39
4 | /svn/!svn/ver/9/trunk/src/test/java/com
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/com/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/com/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/test/java/com
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-06-18T07:55:00.164283Z
11 | 9
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | trinea
30 | dir
31 |
32 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 46
4 | /svn/!svn/ver/9/trunk/src/test/java/com/trinea
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/test/java/com/trinea
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-06-18T07:55:00.164283Z
11 | 9
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | java
30 | dir
31 |
32 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 51
4 | /svn/!svn/ver/9/trunk/src/test/java/com/trinea/java
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/test/java/com/trinea/java
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-06-18T07:55:00.164283Z
11 | 9
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | common
30 | dir
31 |
32 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 58
4 | /svn/!svn/ver/9/trunk/src/test/java/com/trinea/java/common
5 | END
6 | ArrayUtilsTest.java
7 | K 25
8 | svn:wc:ra_dav:version-url
9 | V 79
10 | /svn/!svn/ver/11/trunk/src/test/java/com/trinea/java/common/ArrayUtilsTest.java
11 | END
12 | HttpUtilsTest.java
13 | K 25
14 | svn:wc:ra_dav:version-url
15 | V 77
16 | /svn/!svn/ver/4/trunk/src/test/java/com/trinea/java/common/HttpUtilsTest.java
17 | END
18 | FileUtilsTest.java
19 | K 25
20 | svn:wc:ra_dav:version-url
21 | V 78
22 | /svn/!svn/ver/11/trunk/src/test/java/com/trinea/java/common/FileUtilsTest.java
23 | END
24 | RandomsUtilsTest.java
25 | K 25
26 | svn:wc:ra_dav:version-url
27 | V 80
28 | /svn/!svn/ver/3/trunk/src/test/java/com/trinea/java/common/RandomsUtilsTest.java
29 | END
30 | ObjectUtilsTest.java
31 | K 25
32 | svn:wc:ra_dav:version-url
33 | V 79
34 | /svn/!svn/ver/4/trunk/src/test/java/com/trinea/java/common/ObjectUtilsTest.java
35 | END
36 | StringUtilsTest.java
37 | K 25
38 | svn:wc:ra_dav:version-url
39 | V 80
40 | /svn/!svn/ver/11/trunk/src/test/java/com/trinea/java/common/StringUtilsTest.java
41 | END
42 | SerializeUtilsTest.java
43 | K 25
44 | svn:wc:ra_dav:version-url
45 | V 82
46 | /svn/!svn/ver/4/trunk/src/test/java/com/trinea/java/common/SerializeUtilsTest.java
47 | END
48 | JSONUtilsTest.java
49 | K 25
50 | svn:wc:ra_dav:version-url
51 | V 77
52 | /svn/!svn/ver/4/trunk/src/test/java/com/trinea/java/common/JSONUtilsTest.java
53 | END
54 | JUnitTestUtils.java
55 | K 25
56 | svn:wc:ra_dav:version-url
57 | V 78
58 | /svn/!svn/ver/3/trunk/src/test/java/com/trinea/java/common/JUnitTestUtils.java
59 | END
60 | ListUtilsTest.java
61 | K 25
62 | svn:wc:ra_dav:version-url
63 | V 77
64 | /svn/!svn/ver/4/trunk/src/test/java/com/trinea/java/common/ListUtilsTest.java
65 | END
66 | MapUtilsTest.java
67 | K 25
68 | svn:wc:ra_dav:version-url
69 | V 76
70 | /svn/!svn/ver/3/trunk/src/test/java/com/trinea/java/common/MapUtilsTest.java
71 | END
72 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/test/java/com/trinea/java/common
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-06-18T07:55:00.164283Z
11 | 9
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | ArrayUtilsTest.java
30 | file
31 | 11
32 |
33 |
34 |
35 | 2012-06-26T11:56:00.000000Z
36 | 041f745e3fbe0ac291a73dbc3a3f704d
37 | 2012-07-11T13:48:34.171547Z
38 | 11
39 | trinea1989@gmail.com
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 7794
62 |
63 | HttpUtilsTest.java
64 | file
65 |
66 |
67 |
68 |
69 | 2012-05-12T09:21:04.000000Z
70 | 24426aa32e67aa2f46c8b81e166804f3
71 | 2012-05-16T17:02:01.806238Z
72 | 4
73 | trinea1989@gmail.com
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | 16743
96 |
97 | utils
98 | dir
99 |
100 | FileUtilsTest.java
101 | file
102 | 11
103 |
104 |
105 |
106 | 2012-06-30T15:26:24.000000Z
107 | a320d05310e7df163dbc66b8b27b654d
108 | 2012-07-11T13:48:34.171547Z
109 | 11
110 | trinea1989@gmail.com
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 | 9113
133 |
134 | serviceImpl
135 | dir
136 |
137 | RandomsUtilsTest.java
138 | file
139 |
140 |
141 |
142 |
143 | 2012-05-12T06:44:48.000000Z
144 | 2d0a8a3f7f5c4c55eded26dc1f6635d6
145 | 2012-05-12T08:37:32.309386Z
146 | 3
147 | trinea1989@gmail.com
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 | 3858
170 |
171 | ObjectUtilsTest.java
172 | file
173 |
174 |
175 |
176 |
177 | 2012-05-12T09:10:20.000000Z
178 | 23fac0b3bb9cac04433ec077028e38a5
179 | 2012-05-16T17:02:01.806238Z
180 | 4
181 | trinea1989@gmail.com
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 | 8610
204 |
205 | StringUtilsTest.java
206 | file
207 | 11
208 |
209 |
210 |
211 | 2012-06-27T16:12:20.000000Z
212 | d7abf19cb30bacd5d9fc9bdd74ff1889
213 | 2012-07-11T13:48:34.171547Z
214 | 11
215 | trinea1989@gmail.com
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 | 8221
238 |
239 | SerializeUtilsTest.java
240 | file
241 |
242 |
243 |
244 |
245 | 2012-05-16T16:53:30.000000Z
246 | 622f6e4874078694895a31dbad9054d1
247 | 2012-05-16T17:02:01.806238Z
248 | 4
249 | trinea1989@gmail.com
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 | 5149
272 |
273 | JSONUtilsTest.java
274 | file
275 |
276 |
277 |
278 |
279 | 2012-05-16T16:52:38.000000Z
280 | 0a0547e8fc6996903aa85b18ef274fd2
281 | 2012-05-16T17:02:01.806238Z
282 | 4
283 | trinea1989@gmail.com
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 | 14620
306 |
307 | JUnitTestUtils.java
308 | file
309 |
310 |
311 |
312 |
313 | 2012-05-11T05:33:14.000000Z
314 | 2335222c06156d68d3b1fce66b83cc7d
315 | 2012-05-12T08:37:32.309386Z
316 | 3
317 | trinea1989@gmail.com
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 | 1730
340 |
341 | ListUtilsTest.java
342 | file
343 |
344 |
345 |
346 |
347 | 2012-05-12T08:41:10.000000Z
348 | f9e529b9873c49809cb00379d06e1c97
349 | 2012-05-16T17:02:01.806238Z
350 | 4
351 | trinea1989@gmail.com
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 | 6180
374 |
375 | MapUtilsTest.java
376 | file
377 |
378 |
379 |
380 |
381 | 2012-05-12T08:34:44.000000Z
382 | 87c9f1bc0e67cf4c51f7360e8eeb0adb
383 | 2012-05-12T08:37:32.309386Z
384 | 3
385 | trinea1989@gmail.com
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 | 9272
408 |
409 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/.svn/text-base/JUnitTestUtils.java.svn-base:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common;
2 |
3 | import java.util.Iterator;
4 | import java.util.Map;
5 |
6 | /**
7 | * 类JUnit扩展
8 | *
9 | * @author Trinea 2011-9-19 下午11:13:13
10 | */
11 | public class JUnitTestUtils {
12 |
13 | /**
14 | * 若actual与expecteds中之一相等便返回true,否则返回false
15 | *
16 | * @param actual
17 | * @param expecteds
18 | * @return
19 | */
20 | public static boolean assertEquals(String actual, String... expecteds) {
21 | for (String expected : expecteds) {
22 | if (actual.equals(expected)) {
23 | return true;
24 | }
25 | }
26 | return false;
27 | }
28 |
29 | /**
30 | * 比较两个map
31 | *
32 | * @param actual
33 | * @param expected
34 | * @return
35 | */
36 | @SuppressWarnings("rawtypes")
37 | public static boolean assertEquals(Map actual, Map expected) {
38 | if (actual == null || expected == null) {
39 | return (actual == null && expected == null);
40 | }
41 | if (actual.size() == 0 || expected.size() == 0) {
42 | return (actual.size() == 0 && expected.size() == 0);
43 | }
44 | if (actual.size() == expected.size()) {
45 | Iterator actualIterator = actual.entrySet().iterator();
46 | while (actualIterator.hasNext()) {
47 | Map.Entry entry = (Map.Entry)actualIterator.next();
48 | if (entry.getValue() != null) {
49 | if (!entry.getValue().equals(expected.get(entry.getKey()))) {
50 | return false;
51 | }
52 | } else if (expected.get(entry.getKey()) != null) {
53 | return false;
54 | }
55 | }
56 | return true;
57 | }
58 | return false;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/.svn/text-base/ListUtilsTest.java.svn-base:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import junit.framework.TestCase;
7 |
8 | public class ListUtilsTest extends TestCase {
9 |
10 | protected void setUp() throws Exception {
11 | super.setUp();
12 | ListUtils listUtils = new ListUtils();
13 | assertTrue(listUtils != null);
14 | }
15 |
16 | protected void tearDown() throws Exception {
17 | super.tearDown();
18 | }
19 |
20 | public void testIsEmpty() {
21 | assertTrue(ListUtils.isEmpty(null));
22 | List sourceList = new ArrayList();
23 | assertTrue(ListUtils.isEmpty(sourceList));
24 | sourceList.add("A");
25 | assertFalse(ListUtils.isEmpty(sourceList));
26 | }
27 |
28 | public void testJoinListOfString() {
29 | assertEquals(ListUtils.join(null), "");
30 |
31 | List sourceList = new ArrayList();
32 | assertEquals(ListUtils.join(sourceList), "");
33 |
34 | sourceList.add("a");
35 | sourceList.add("b");
36 | assertEquals(ListUtils.join(sourceList), "a,b");
37 | }
38 |
39 | public void testJoinListOfStringChar() {
40 |
41 | assertEquals(ListUtils.join(null, '#'), "");
42 |
43 | List sourceList = new ArrayList();
44 | assertEquals(ListUtils.join(sourceList, '#'), "");
45 |
46 | sourceList.add("a");
47 | sourceList.add("b");
48 | assertEquals(ListUtils.join(sourceList, '#'), "a#b");
49 | sourceList.add("c");
50 | assertEquals(ListUtils.join(sourceList, '#'), "a#b#c");
51 | assertEquals(ListUtils.join(sourceList, ' '), "a b c");
52 | }
53 |
54 | public void testJoinListOfStringString() {
55 |
56 | assertEquals(ListUtils.join(null, null), "");
57 | assertEquals(ListUtils.join(null, "#"), "");
58 |
59 | List sourceList = new ArrayList();
60 | assertEquals(ListUtils.join(sourceList, "#"), "");
61 | assertEquals(ListUtils.join(sourceList, null), "");
62 |
63 | sourceList.add("a");
64 | sourceList.add("b");
65 | assertEquals(ListUtils.join(sourceList, "#"), "a#b");
66 | sourceList.add("c");
67 | assertEquals(ListUtils.join(sourceList, null), "a,b,c");
68 | assertEquals(ListUtils.join(sourceList, "#"), "a#b#c");
69 | assertEquals(ListUtils.join(sourceList, ""), "abc");
70 | assertEquals(ListUtils.join(sourceList, "#s"), "a#sb#sc");
71 | }
72 |
73 | public void testAddDistinctEntry() {
74 | assertFalse(ListUtils.addDistinctEntry(null, null));
75 |
76 | List sourceList = new ArrayList();
77 | assertTrue(ListUtils.addDistinctEntry(sourceList, "a"));
78 | assertTrue(ListUtils.addDistinctEntry(sourceList, "b"));
79 | assertTrue(sourceList.size() == 2);
80 | assertFalse(ListUtils.addDistinctEntry(sourceList, "a"));
81 | assertTrue(sourceList.size() == 2);
82 | }
83 |
84 | public void testAddDistinctList() {
85 | assertEquals(ListUtils.addDistinctList(null, null), 0);
86 |
87 | List sourceList = new ArrayList();
88 | List entryList = new ArrayList();
89 | assertEquals(ListUtils.addDistinctList(sourceList, null), 0);
90 | assertEquals(ListUtils.addDistinctList(sourceList, entryList), 0);
91 |
92 | sourceList.add("a");
93 | sourceList.add("b");
94 | entryList.add("C");
95 | entryList.add("b");
96 | assertEquals(ListUtils.addDistinctList(sourceList, entryList), 1);
97 | assertEquals(ListUtils.addDistinctList(sourceList, entryList), 0);
98 | }
99 |
100 | public void testDistinctList() {
101 | assertEquals(ListUtils.distinctList(null), 0);
102 |
103 | List sourceList = new ArrayList();
104 | assertEquals(ListUtils.distinctList(sourceList), 0);
105 |
106 | sourceList.add("a");
107 | sourceList.add("b");
108 | assertEquals(ListUtils.distinctList(sourceList), 0);
109 | sourceList.add("a");
110 | sourceList.add("b");
111 | assertEquals(ListUtils.distinctList(sourceList), 2);
112 | sourceList.add("a");
113 | sourceList.add("b");
114 | assertEquals(ListUtils.distinctList(sourceList), 2);
115 | sourceList.add("C");
116 | sourceList.add("b");
117 | assertEquals(ListUtils.distinctList(sourceList), 1);
118 | sourceList.add("D");
119 | sourceList.add("E");
120 | sourceList.add("F");
121 | assertEquals(ListUtils.distinctList(sourceList), 0);
122 | }
123 |
124 | public void testAddListNotNullValue() {
125 | assertFalse(ListUtils.addListNotNullValue(null, null));
126 |
127 | List sourceList = new ArrayList();
128 | assertFalse(ListUtils.addListNotNullValue(sourceList, null));
129 | assertTrue(ListUtils.addListNotNullValue(sourceList, "aa"));
130 | }
131 |
132 | public void testGetLast() {
133 | assertNull(ListUtils.getLast(null, "b"));
134 |
135 | List sourceList = new ArrayList();
136 | sourceList.add("a");
137 | sourceList.add("b");
138 | sourceList.add("c");
139 | sourceList.add("d");
140 | sourceList.add("e");
141 |
142 | assertEquals(ListUtils.getLast(sourceList, "b"), "a");
143 | assertEquals(ListUtils.getLast(sourceList, "a"), "e");
144 | }
145 |
146 | public void testGetNext() {
147 | assertNull(ListUtils.getNext(null, "b"));
148 |
149 | List sourceList = new ArrayList();
150 | sourceList.add("a");
151 | sourceList.add("b");
152 | sourceList.add("c");
153 | sourceList.add("d");
154 | sourceList.add("e");
155 |
156 | assertEquals(ListUtils.getNext(sourceList, "b"), "c");
157 | assertEquals(ListUtils.getNext(sourceList, "e"), "a");
158 | }
159 |
160 | public void testInvertList() {
161 | List sourceList = new ArrayList();
162 | List invertList = ListUtils.invertList(sourceList);
163 | assertTrue(invertList.size() == 0);
164 | sourceList.add("a");
165 | sourceList.add("b");
166 | sourceList.add("c");
167 | sourceList.add("d");
168 | sourceList.add("e");
169 | invertList = ListUtils.invertList(sourceList);
170 | int sourceSize = sourceList.size();
171 | assertEquals(sourceSize, invertList.size());
172 | for (int i = 0; i < sourceSize; i++) {
173 | assertEquals(sourceList.get(i), invertList.get(sourceSize - 1 - i));
174 | }
175 | }
176 | }
177 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/.svn/text-base/RandomsUtilsTest.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common;
9 |
10 | import junit.framework.TestCase;
11 |
12 | public class RandomsUtilsTest extends TestCase {
13 |
14 | protected void setUp() throws Exception {
15 | RandomUtils randomUtils = new RandomUtils();
16 | assertNotNull(randomUtils);
17 | super.setUp();
18 | }
19 |
20 | protected void tearDown() throws Exception {
21 | super.tearDown();
22 | }
23 |
24 | public void testGetRandomNumbersAndLetters() {
25 | assertTrue(RandomUtils.getRandomNumbersAndLetters(1).length() == 1);
26 | assertTrue(RandomUtils.getRandomNumbersAndLetters(2).length() == 2);
27 | assertTrue(RandomUtils.getRandomNumbersAndLetters(5).length() == 5);
28 | assertTrue(RandomUtils.getRandomNumbersAndLetters(9).length() == 9);
29 | assertTrue(RandomUtils.getRandomNumbersAndLetters(13).length() == 13);
30 | assertTrue(RandomUtils.getRandomNumbersAndLetters(25).length() == 25);
31 | assertTrue(RandomUtils.getRandomNumbersAndLetters(46).length() == 46);
32 | assertTrue(RandomUtils.getRandomNumbersAndLetters(67).length() == 67);
33 | }
34 |
35 | public void testGetRandomNumbers() {
36 | assertTrue(RandomUtils.getRandomNumbers(1).length() == 1);
37 | assertTrue(RandomUtils.getRandomNumbers(2).length() == 2);
38 | assertTrue(RandomUtils.getRandomNumbers(5).length() == 5);
39 | assertTrue(RandomUtils.getRandomNumbers(9).length() == 9);
40 | assertTrue(RandomUtils.getRandomNumbers(13).length() == 13);
41 | assertTrue(RandomUtils.getRandomNumbers(25).length() == 25);
42 | assertTrue(RandomUtils.getRandomNumbers(46).length() == 46);
43 | assertTrue(RandomUtils.getRandomNumbers(67).length() == 67);
44 | }
45 |
46 | public void testGetRandomLetters() {
47 | assertTrue(RandomUtils.getRandomLetters(1).length() == 1);
48 | assertTrue(RandomUtils.getRandomLetters(2).length() == 2);
49 | assertTrue(RandomUtils.getRandomLetters(5).length() == 5);
50 | assertTrue(RandomUtils.getRandomLetters(9).length() == 9);
51 | assertTrue(RandomUtils.getRandomLetters(13).length() == 13);
52 | assertTrue(RandomUtils.getRandomLetters(25).length() == 25);
53 | assertTrue(RandomUtils.getRandomLetters(46).length() == 46);
54 | assertTrue(RandomUtils.getRandomLetters(67).length() == 67);
55 | }
56 |
57 | public void testGetRandomCapitalLetters() {
58 | assertTrue(RandomUtils.getRandomCapitalLetters(1).length() == 1);
59 | assertTrue(RandomUtils.getRandomCapitalLetters(46).length() == 46);
60 | }
61 |
62 | public void testGetRandomLowerCaseLetters() {
63 | assertTrue(RandomUtils.getRandomLowerCaseLetters(1).length() == 1);
64 | assertTrue(RandomUtils.getRandomLowerCaseLetters(46).length() == 46);
65 | }
66 |
67 | public void testGetRandomStringInt() {
68 | String source = null;
69 | assertNull(RandomUtils.getRandom(source, -1));
70 | assertNull(RandomUtils.getRandom("", -1));
71 | assertNull(RandomUtils.getRandom("", 1));
72 | assertTrue(RandomUtils.getRandom("qqq", 46).length() == 46);
73 | }
74 |
75 | public void testGetRandomCharArrayInt() {
76 | char[] source = null;
77 | assertNull(RandomUtils.getRandom(source, -1));
78 | assertNull(RandomUtils.getRandom(new char[0], -1));
79 | assertNull(RandomUtils.getRandom(new char[0], 1));
80 | assertNull(RandomUtils.getRandom(new char[] {'a'}, -1));
81 | assertTrue(RandomUtils.getRandom(new char[] {'a'}, 1).length() == 1);
82 | assertTrue(RandomUtils.getRandom(new char[] {'a', 'b'}, 46).length() == 46);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/.svn/text-base/SerializeUtilsTest.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common;
9 |
10 | import java.io.Serializable;
11 | import java.util.LinkedHashMap;
12 | import java.util.Map;
13 |
14 | import junit.framework.TestCase;
15 |
16 | /**
17 | * 类SerializeUtilsTest.java的实现描述:TODO 类实现描述
18 | *
19 | * @author Trinea 2012-5-15 下午12:46:14
20 | */
21 | public class SerializeUtilsTest extends TestCase {
22 |
23 | private static final String BASE_DIR = "C:\\Users\\Trinea\\Desktop\\temp\\JavaCommonTest\\SerializeUtilsTest\\";
24 |
25 | protected void setUp() throws Exception {
26 | assertTrue(FileUtils.makeFolder(BASE_DIR));
27 | }
28 |
29 | protected void tearDown() throws Exception {
30 | super.tearDown();
31 | }
32 |
33 | @SuppressWarnings("unchecked")
34 | public void testSerializationAndDeserialization() {
35 | // 未实现serialize接口的类
36 | ClassNotImplSerialize classNotImplSerialize = new ClassNotImplSerialize(100, "user1");
37 | String user1File = BASE_DIR + "user1.obj";
38 | assertTrue(FileUtils.deleteFile((user1File)));
39 | try {
40 | SerializeUtils.serialization("", classNotImplSerialize);
41 | assertTrue(false);
42 | } catch (Exception e) {
43 | assertTrue(true);
44 | }
45 | try {
46 | SerializeUtils.serialization(user1File, classNotImplSerialize);
47 | assertTrue(false);
48 | } catch (Exception e) {
49 | assertTrue(true);
50 | }
51 | try {
52 | SerializeUtils.deserialization("");
53 | assertTrue(false);
54 | } catch (Exception e) {
55 | assertTrue(true);
56 | }
57 | try {
58 | SerializeUtils.deserialization(user1File);
59 | assertTrue(false);
60 | } catch (Exception e) {
61 | assertTrue(true);
62 | }
63 |
64 | // 实现serialize接口的类
65 | ClassImplSerialize classImplSerialize = new ClassImplSerialize(100, "user1");
66 | String user2File = BASE_DIR + "user2.obj";
67 | assertTrue(FileUtils.deleteFile((user2File)));
68 | try {
69 | SerializeUtils.serialization(user2File, classImplSerialize);
70 | assertTrue(true);
71 | } catch (Exception e) {
72 | assertTrue(false);
73 | }
74 | try {
75 | ClassImplSerialize classImplSerialize2 = (ClassImplSerialize)SerializeUtils.deserialization(user2File);
76 | assertNotNull(classImplSerialize2);
77 | assertTrue(classImplSerialize.getUserName().equals(classImplSerialize2.getUserName()));
78 | assertTrue(classImplSerialize.getUserId() == classImplSerialize2.getUserId());
79 | } catch (Exception e) {
80 | assertTrue(false);
81 | }
82 |
83 | // 容器序列化
84 | Map inMap = new LinkedHashMap();
85 | String mapFile = BASE_DIR + "map.obj";
86 | int entityCount = 1000;
87 | for (int i = 0; i < entityCount; i++) {
88 | ClassImplSerialize o = new ClassImplSerialize(i, "user" + i);
89 | inMap.put(Integer.toString(i), o);
90 | }
91 | SerializeUtils.serialization(mapFile, inMap);
92 | Map outMap = (Map)SerializeUtils.deserialization(mapFile);
93 | assertEquals(inMap.size(), outMap.size());
94 | for (int i = 0; i < inMap.size(); i++) {
95 | ClassImplSerialize o1 = inMap.get(Integer.toString(i));
96 | ClassImplSerialize o2 = outMap.get(Integer.toString(i));
97 | assertTrue(o1.getUserName().equals(o2.getUserName()));
98 | assertTrue(o1.getUserId() == o2.getUserId());
99 | }
100 | }
101 |
102 | public class ClassNotImplSerialize {
103 |
104 | @SuppressWarnings("unused")
105 | private long userId;
106 | @SuppressWarnings("unused")
107 | private String userName;
108 |
109 | public ClassNotImplSerialize(long userId, String userName){
110 | this.userId = userId;
111 | this.userName = userName;
112 | }
113 | }
114 |
115 | public static class ClassImplSerialize implements Serializable {
116 |
117 | private static final long serialVersionUID = 88940079192401092L;
118 | private long userId;
119 | private String userName;
120 |
121 | public ClassImplSerialize(){
122 | this.userId = 1;
123 | this.userName = "defaultUser";
124 | }
125 |
126 | public ClassImplSerialize(long userId, String userName){
127 | this.userId = userId;
128 | this.userName = userName;
129 | }
130 |
131 | public long getUserId() {
132 | return userId;
133 | }
134 |
135 | public void setUserId(long userId) {
136 | this.userId = userId;
137 | }
138 |
139 | public String getUserName() {
140 | return userName;
141 | }
142 |
143 | public void setUserName(String userName) {
144 | this.userName = userName;
145 | }
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/JUnitTestUtils.java:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common;
2 |
3 | import java.util.Iterator;
4 | import java.util.Map;
5 |
6 | /**
7 | * 类JUnit扩展
8 | *
9 | * @author Trinea 2011-9-19 下午11:13:13
10 | */
11 | public class JUnitTestUtils {
12 |
13 | /**
14 | * 若actual与expecteds中之一相等便返回true,否则返回false
15 | *
16 | * @param actual
17 | * @param expecteds
18 | * @return
19 | */
20 | public static boolean assertEquals(String actual, String... expecteds) {
21 | for (String expected : expecteds) {
22 | if (actual.equals(expected)) {
23 | return true;
24 | }
25 | }
26 | return false;
27 | }
28 |
29 | /**
30 | * 比较两个map
31 | *
32 | * @param actual
33 | * @param expected
34 | * @return
35 | */
36 | @SuppressWarnings("rawtypes")
37 | public static boolean assertEquals(Map actual, Map expected) {
38 | if (actual == null || expected == null) {
39 | return (actual == null && expected == null);
40 | }
41 | if (actual.size() == 0 || expected.size() == 0) {
42 | return (actual.size() == 0 && expected.size() == 0);
43 | }
44 | if (actual.size() == expected.size()) {
45 | Iterator actualIterator = actual.entrySet().iterator();
46 | while (actualIterator.hasNext()) {
47 | Map.Entry entry = (Map.Entry)actualIterator.next();
48 | if (entry.getValue() != null) {
49 | if (!entry.getValue().equals(expected.get(entry.getKey()))) {
50 | return false;
51 | }
52 | } else if (expected.get(entry.getKey()) != null) {
53 | return false;
54 | }
55 | }
56 | return true;
57 | }
58 | return false;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/RandomsUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common;
9 |
10 | import junit.framework.TestCase;
11 |
12 | public class RandomsUtilsTest extends TestCase {
13 |
14 | protected void setUp() throws Exception {
15 | RandomUtils randomUtils = new RandomUtils();
16 | assertNotNull(randomUtils);
17 | super.setUp();
18 | }
19 |
20 | protected void tearDown() throws Exception {
21 | super.tearDown();
22 | }
23 |
24 | public void testGetRandomNumbersAndLetters() {
25 | assertTrue(RandomUtils.getRandomNumbersAndLetters(1).length() == 1);
26 | assertTrue(RandomUtils.getRandomNumbersAndLetters(2).length() == 2);
27 | assertTrue(RandomUtils.getRandomNumbersAndLetters(5).length() == 5);
28 | assertTrue(RandomUtils.getRandomNumbersAndLetters(9).length() == 9);
29 | assertTrue(RandomUtils.getRandomNumbersAndLetters(13).length() == 13);
30 | assertTrue(RandomUtils.getRandomNumbersAndLetters(25).length() == 25);
31 | assertTrue(RandomUtils.getRandomNumbersAndLetters(46).length() == 46);
32 | assertTrue(RandomUtils.getRandomNumbersAndLetters(67).length() == 67);
33 | }
34 |
35 | public void testGetRandomNumbers() {
36 | assertTrue(RandomUtils.getRandomNumbers(1).length() == 1);
37 | assertTrue(RandomUtils.getRandomNumbers(2).length() == 2);
38 | assertTrue(RandomUtils.getRandomNumbers(5).length() == 5);
39 | assertTrue(RandomUtils.getRandomNumbers(9).length() == 9);
40 | assertTrue(RandomUtils.getRandomNumbers(13).length() == 13);
41 | assertTrue(RandomUtils.getRandomNumbers(25).length() == 25);
42 | assertTrue(RandomUtils.getRandomNumbers(46).length() == 46);
43 | assertTrue(RandomUtils.getRandomNumbers(67).length() == 67);
44 | }
45 |
46 | public void testGetRandomLetters() {
47 | assertTrue(RandomUtils.getRandomLetters(1).length() == 1);
48 | assertTrue(RandomUtils.getRandomLetters(2).length() == 2);
49 | assertTrue(RandomUtils.getRandomLetters(5).length() == 5);
50 | assertTrue(RandomUtils.getRandomLetters(9).length() == 9);
51 | assertTrue(RandomUtils.getRandomLetters(13).length() == 13);
52 | assertTrue(RandomUtils.getRandomLetters(25).length() == 25);
53 | assertTrue(RandomUtils.getRandomLetters(46).length() == 46);
54 | assertTrue(RandomUtils.getRandomLetters(67).length() == 67);
55 | }
56 |
57 | public void testGetRandomCapitalLetters() {
58 | assertTrue(RandomUtils.getRandomCapitalLetters(1).length() == 1);
59 | assertTrue(RandomUtils.getRandomCapitalLetters(46).length() == 46);
60 | }
61 |
62 | public void testGetRandomLowerCaseLetters() {
63 | assertTrue(RandomUtils.getRandomLowerCaseLetters(1).length() == 1);
64 | assertTrue(RandomUtils.getRandomLowerCaseLetters(46).length() == 46);
65 | }
66 |
67 | public void testGetRandomStringInt() {
68 | String source = null;
69 | assertNull(RandomUtils.getRandom(source, -1));
70 | assertNull(RandomUtils.getRandom("", -1));
71 | assertNull(RandomUtils.getRandom("", 1));
72 | assertTrue(RandomUtils.getRandom("qqq", 46).length() == 46);
73 | }
74 |
75 | public void testGetRandomCharArrayInt() {
76 | char[] source = null;
77 | assertNull(RandomUtils.getRandom(source, -1));
78 | assertNull(RandomUtils.getRandom(new char[0], -1));
79 | assertNull(RandomUtils.getRandom(new char[0], 1));
80 | assertNull(RandomUtils.getRandom(new char[] {'a'}, -1));
81 | assertTrue(RandomUtils.getRandom(new char[] {'a'}, 1).length() == 1);
82 | assertTrue(RandomUtils.getRandom(new char[] {'a', 'b'}, 46).length() == 46);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/SerializeUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common;
9 |
10 | import java.io.Serializable;
11 | import java.util.LinkedHashMap;
12 | import java.util.Map;
13 |
14 | import junit.framework.TestCase;
15 |
16 | /**
17 | * 类SerializeUtilsTest.java的实现描述:TODO 类实现描述
18 | *
19 | * @author Trinea 2012-5-15 下午12:46:14
20 | */
21 | public class SerializeUtilsTest extends TestCase {
22 |
23 | private static final String BASE_DIR = "C:\\Users\\Trinea\\Desktop\\temp\\JavaCommonTest\\SerializeUtilsTest\\";
24 |
25 | protected void setUp() throws Exception {
26 | assertTrue(FileUtils.makeFolder(BASE_DIR));
27 | }
28 |
29 | protected void tearDown() throws Exception {
30 | super.tearDown();
31 | }
32 |
33 | @SuppressWarnings("unchecked")
34 | public void testSerializationAndDeserialization() {
35 | // 未实现serialize接口的类
36 | ClassNotImplSerialize classNotImplSerialize = new ClassNotImplSerialize(100, "user1");
37 | String user1File = BASE_DIR + "user1.obj";
38 | assertTrue(FileUtils.deleteFile((user1File)));
39 | try {
40 | SerializeUtils.serialization("", classNotImplSerialize);
41 | assertTrue(false);
42 | } catch (Exception e) {
43 | assertTrue(true);
44 | }
45 | try {
46 | SerializeUtils.serialization(user1File, classNotImplSerialize);
47 | assertTrue(false);
48 | } catch (Exception e) {
49 | assertTrue(true);
50 | }
51 | try {
52 | SerializeUtils.deserialization("");
53 | assertTrue(false);
54 | } catch (Exception e) {
55 | assertTrue(true);
56 | }
57 | try {
58 | SerializeUtils.deserialization(user1File);
59 | assertTrue(false);
60 | } catch (Exception e) {
61 | assertTrue(true);
62 | }
63 |
64 | // 实现serialize接口的类
65 | ClassImplSerialize classImplSerialize = new ClassImplSerialize(100, "user1");
66 | String user2File = BASE_DIR + "user2.obj";
67 | assertTrue(FileUtils.deleteFile((user2File)));
68 | try {
69 | SerializeUtils.serialization(user2File, classImplSerialize);
70 | assertTrue(true);
71 | } catch (Exception e) {
72 | assertTrue(false);
73 | }
74 | try {
75 | ClassImplSerialize classImplSerialize2 = (ClassImplSerialize)SerializeUtils.deserialization(user2File);
76 | assertNotNull(classImplSerialize2);
77 | assertTrue(classImplSerialize.getUserName().equals(classImplSerialize2.getUserName()));
78 | assertTrue(classImplSerialize.getUserId() == classImplSerialize2.getUserId());
79 | } catch (Exception e) {
80 | assertTrue(false);
81 | }
82 |
83 | // 容器序列化
84 | Map inMap = new LinkedHashMap();
85 | String mapFile = BASE_DIR + "map.obj";
86 | int entityCount = 1000;
87 | for (int i = 0; i < entityCount; i++) {
88 | ClassImplSerialize o = new ClassImplSerialize(i, "user" + i);
89 | inMap.put(Integer.toString(i), o);
90 | }
91 | SerializeUtils.serialization(mapFile, inMap);
92 | Map outMap = (Map)SerializeUtils.deserialization(mapFile);
93 | assertEquals(inMap.size(), outMap.size());
94 | for (int i = 0; i < inMap.size(); i++) {
95 | ClassImplSerialize o1 = inMap.get(Integer.toString(i));
96 | ClassImplSerialize o2 = outMap.get(Integer.toString(i));
97 | assertTrue(o1.getUserName().equals(o2.getUserName()));
98 | assertTrue(o1.getUserId() == o2.getUserId());
99 | }
100 | }
101 |
102 | public class ClassNotImplSerialize {
103 |
104 | @SuppressWarnings("unused")
105 | private long userId;
106 | @SuppressWarnings("unused")
107 | private String userName;
108 |
109 | public ClassNotImplSerialize(long userId, String userName){
110 | this.userId = userId;
111 | this.userName = userName;
112 | }
113 | }
114 |
115 | public static class ClassImplSerialize implements Serializable {
116 |
117 | private static final long serialVersionUID = 88940079192401092L;
118 | private long userId;
119 | private String userName;
120 |
121 | public ClassImplSerialize(){
122 | this.userId = 1;
123 | this.userName = "defaultUser";
124 | }
125 |
126 | public ClassImplSerialize(long userId, String userName){
127 | this.userId = userId;
128 | this.userName = userName;
129 | }
130 |
131 | public long getUserId() {
132 | return userId;
133 | }
134 |
135 | public void setUserId(long userId) {
136 | this.userId = userId;
137 | }
138 |
139 | public String getUserName() {
140 | return userName;
141 | }
142 |
143 | public void setUserName(String userName) {
144 | this.userName = userName;
145 | }
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/serviceImpl/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 70
4 | /svn/!svn/ver/9/trunk/src/test/java/com/trinea/java/common/serviceImpl
5 | END
6 | AutoGetDataCacheTest.java
7 | K 25
8 | svn:wc:ra_dav:version-url
9 | V 97
10 | /svn/!svn/ver/11/trunk/src/test/java/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest.java
11 | END
12 | CacheFullRemoveTypeTest.java
13 | K 25
14 | svn:wc:ra_dav:version-url
15 | V 99
16 | /svn/!svn/ver/4/trunk/src/test/java/com/trinea/java/common/serviceImpl/CacheFullRemoveTypeTest.java
17 | END
18 | AutoGetDataCacheDemo.java
19 | K 25
20 | svn:wc:ra_dav:version-url
21 | V 97
22 | /svn/!svn/ver/11/trunk/src/test/java/com/trinea/java/common/serviceImpl/AutoGetDataCacheDemo.java
23 | END
24 | SimpleCacheTest.java
25 | K 25
26 | svn:wc:ra_dav:version-url
27 | V 92
28 | /svn/!svn/ver/11/trunk/src/test/java/com/trinea/java/common/serviceImpl/SimpleCacheTest.java
29 | END
30 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/serviceImpl/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/serviceImpl/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/test/java/com/trinea/java/common/serviceImpl
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-06-18T07:55:00.164283Z
11 | 9
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | AutoGetDataCacheTest.java
30 | file
31 | 11
32 |
33 |
34 |
35 | 2012-07-10T09:18:06.000000Z
36 | 532772ff71dc02d0800c40eab195c776
37 | 2012-07-11T13:48:34.171547Z
38 | 11
39 | trinea1989@gmail.com
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 8628
62 |
63 | CacheFullRemoveTypeTest.java
64 | file
65 |
66 |
67 |
68 |
69 | 2012-05-12T08:58:36.000000Z
70 | 431e0feba3ac063b92cc685e9eb3933b
71 | 2012-05-16T17:02:01.806238Z
72 | 4
73 | trinea1989@gmail.com
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | 7740
96 |
97 | AutoGetDataCacheDemo.java
98 | file
99 | 11
100 |
101 |
102 |
103 | 2012-07-10T08:40:08.000000Z
104 | 5517c75a447289c7a5a9c617e91f64bd
105 | 2012-07-11T13:48:34.171547Z
106 | 11
107 | trinea1989@gmail.com
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | 3202
130 |
131 | SimpleCacheTest.java
132 | file
133 | 11
134 |
135 |
136 |
137 | 2012-07-10T09:18:20.000000Z
138 | 7937bfbb90bd4c65b16c8b929a360725
139 | 2012-07-11T13:48:34.171547Z
140 | 11
141 | trinea1989@gmail.com
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 | 16508
164 |
165 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/serviceImpl/.svn/text-base/AutoGetDataCacheDemo.java.svn-base:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common.serviceImpl;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | import junit.framework.TestCase;
8 |
9 | import com.trinea.java.common.entity.CacheObject;
10 | import com.trinea.java.common.serviceImpl.AutoGetDataCache.OnGetDataListener;
11 |
12 | /**
13 | * AutoGetDataCache使用示例
14 | *
15 | * @author Trinea 2012-6-18 下午02:14:16
16 | */
17 | public class AutoGetDataCacheDemo extends TestCase {
18 |
19 | private static String[] data = {"data1", "data2", "data3", "data4", "data5", "data6", "data7",
20 | "data8", "data9", "data10", "data11", "data12", "data13", "data14", "data15", "data16", "data17", "data18",
21 | "data19", "data20" };
22 | private static ArrayList keyList = new ArrayList();
23 | private static Map dataSource = new HashMap();
24 | private static int index = 0;
25 |
26 | /**
27 | * 初始化数据源
28 | */
29 | public static void initDataSource() {
30 | for (int i = 0; i < data.length; i++) {
31 | String temp = Integer.toString(i);
32 | dataSource.put(temp, data[i]);
33 | keyList.add(temp);
34 | }
35 | }
36 |
37 | /**
38 | * 从数据源中获取数据
39 | *
40 | * @return
41 | */
42 | public static String getSlowResponseData() {
43 | try {
44 | Thread.sleep(2000);
45 | } catch (InterruptedException e) {
46 | e.printStackTrace();
47 | }
48 | return dataSource.get(Integer.toString((index++) % keyList.size()));
49 | }
50 |
51 | public static void main(String[] args) {
52 | initDataSource();
53 |
54 | // 缓存定义,在OnGetDataListener中定义获取数据的接口
55 | AutoGetDataCache cache = null;
56 | cache = new AutoGetDataCache(new OnGetDataListener() {
57 |
58 | private static final long serialVersionUID = 1L;
59 |
60 | @Override
61 | public CacheObject onGetData(String key) {
62 | CacheObject o = new CacheObject();
63 | o.setData(getSlowResponseData());
64 | return o;
65 | }
66 | }, 5, -1,
67 | new RemoveTypeEnterTimeFirst());
68 |
69 | int count = 10;
70 | long start = 0, end = 0;
71 | start = System.currentTimeMillis();
72 | for (int i = 0; i < count; i++) {
73 | System.out.print(cache.get(Integer.toString(i), keyList).getData() + " ");
74 | }
75 | end = System.currentTimeMillis();
76 | System.out.println();
77 | System.out.println("缓存后用时(ms):" + (end - start) + "。缓存命中率为" + cache.getHitRate() + "(" + cache.getHitCount()
78 | + "/" + (cache.getHitCount() + cache.getMissCount()) + ")");
79 |
80 | start = System.currentTimeMillis();
81 | for (int i = 0; i < count; i++) {
82 | System.out.print(getSlowResponseData() + " ");
83 | }
84 | end = System.currentTimeMillis();
85 | System.out.println();
86 | System.out.println("缓存前用时(ms):" + (end - start));
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/serviceImpl/AutoGetDataCacheDemo.java:
--------------------------------------------------------------------------------
1 | package com.trinea.java.common.serviceImpl;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | import junit.framework.TestCase;
8 |
9 | import com.trinea.java.common.entity.CacheObject;
10 | import com.trinea.java.common.serviceImpl.AutoGetDataCache.OnGetDataListener;
11 |
12 | /**
13 | * AutoGetDataCache使用示例
14 | *
15 | * @author Trinea 2012-6-18 下午02:14:16
16 | */
17 | public class AutoGetDataCacheDemo extends TestCase {
18 |
19 | private static String[] data = {"data1", "data2", "data3", "data4", "data5", "data6", "data7",
20 | "data8", "data9", "data10", "data11", "data12", "data13", "data14", "data15", "data16", "data17", "data18",
21 | "data19", "data20" };
22 | private static ArrayList keyList = new ArrayList();
23 | private static Map dataSource = new HashMap();
24 | private static int index = 0;
25 |
26 | /**
27 | * 初始化数据源
28 | */
29 | public static void initDataSource() {
30 | for (int i = 0; i < data.length; i++) {
31 | String temp = Integer.toString(i);
32 | dataSource.put(temp, data[i]);
33 | keyList.add(temp);
34 | }
35 | }
36 |
37 | /**
38 | * 从数据源中获取数据
39 | *
40 | * @return
41 | */
42 | public static String getSlowResponseData() {
43 | try {
44 | Thread.sleep(2000);
45 | } catch (InterruptedException e) {
46 | e.printStackTrace();
47 | }
48 | return dataSource.get(Integer.toString((index++) % keyList.size()));
49 | }
50 |
51 | public static void main(String[] args) {
52 | initDataSource();
53 |
54 | // 缓存定义,在OnGetDataListener中定义获取数据的接口
55 | AutoGetDataCache cache = null;
56 | cache = new AutoGetDataCache(new OnGetDataListener() {
57 |
58 | private static final long serialVersionUID = 1L;
59 |
60 | @Override
61 | public CacheObject onGetData(String key) {
62 | CacheObject o = new CacheObject();
63 | o.setData(getSlowResponseData());
64 | return o;
65 | }
66 | }, 5, -1,
67 | new RemoveTypeEnterTimeFirst());
68 |
69 | int count = 10;
70 | long start = 0, end = 0;
71 | start = System.currentTimeMillis();
72 | for (int i = 0; i < count; i++) {
73 | System.out.print(cache.get(Integer.toString(i), keyList).getData() + " ");
74 | }
75 | end = System.currentTimeMillis();
76 | System.out.println();
77 | System.out.println("缓存后用时(ms):" + (end - start) + "。缓存命中率为" + cache.getHitRate() + "(" + cache.getHitCount()
78 | + "/" + (cache.getHitCount() + cache.getMissCount()) + ")");
79 |
80 | start = System.currentTimeMillis();
81 | for (int i = 0; i < count; i++) {
82 | System.out.print(getSlowResponseData() + " ");
83 | }
84 | end = System.currentTimeMillis();
85 | System.out.println();
86 | System.out.println("缓存前用时(ms):" + (end - start));
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/utils/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 64
4 | /svn/!svn/ver/2/trunk/src/test/java/com/trinea/java/common/utils
5 | END
6 | SleepUtils.java
7 | K 25
8 | svn:wc:ra_dav:version-url
9 | V 80
10 | /svn/!svn/ver/2/trunk/src/test/java/com/trinea/java/common/utils/SleepUtils.java
11 | END
12 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/utils/.svn/dir-prop-base:
--------------------------------------------------------------------------------
1 | K 14
2 | bugtraq:number
3 | V 4
4 | true
5 | END
6 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/utils/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 10
5 | https://trinea-java-common.googlecode.com/svn/trunk/src/test/java/com/trinea/java/common/utils
6 | https://trinea-java-common.googlecode.com/svn
7 |
8 |
9 |
10 | 2012-05-08T13:24:10.691726Z
11 | 2
12 | trinea1989@gmail.com
13 | has-props
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | faea5b58-39a8-aa54-3254-73ee4c527f77
28 |
29 | SleepUtils.java
30 | file
31 |
32 |
33 |
34 |
35 | 2012-05-06T08:51:16.000000Z
36 | dc3502a54bb34ac6b63575553a82e2b8
37 | 2012-05-08T13:24:10.691726Z
38 | 2
39 | trinea1989@gmail.com
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 1105
62 |
63 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/utils/.svn/text-base/SleepUtils.java.svn-base:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.utils;
9 |
10 | /**
11 | * slepp一段时间
12 | *
13 | * @author Trinea 2012-3-26 下午02:08:44
14 | */
15 | public class SleepUtils {
16 |
17 | /** 默认sleep时间 **/
18 | public static long DEFAULT_SLEEP_TIME = 100;
19 |
20 | /** 默认中等sleep时间 **/
21 | public static long DEFAULT_MIDDLE_SLEEP_TIME = 300;
22 |
23 | /** 采用默认sleep时间 {@link SleepUtils#DEFAULT_SLEEP_TIME} **/
24 | public static void sleep() {
25 | sleep(DEFAULT_SLEEP_TIME);
26 | }
27 |
28 | /**
29 | * sleep一段时间
30 | *
31 | * @param mills 毫秒
32 | */
33 | public static void sleep(long mills) {
34 | try {
35 | Thread.sleep(mills);
36 | } catch (InterruptedException e) {
37 | e.printStackTrace();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/test/java/com/trinea/java/common/utils/SleepUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Trinea.com All right reserved. This software is the
3 | * confidential and proprietary information of Trinea.com ("Confidential
4 | * Information"). You shall not disclose such Confidential Information and shall
5 | * use it only in accordance with the terms of the license agreement you entered
6 | * into with Trinea.com.
7 | */
8 | package com.trinea.java.common.utils;
9 |
10 | /**
11 | * slepp一段时间
12 | *
13 | * @author Trinea 2012-3-26 下午02:08:44
14 | */
15 | public class SleepUtils {
16 |
17 | /** 默认sleep时间 **/
18 | public static long DEFAULT_SLEEP_TIME = 100;
19 |
20 | /** 默认中等sleep时间 **/
21 | public static long DEFAULT_MIDDLE_SLEEP_TIME = 300;
22 |
23 | /** 采用默认sleep时间 {@link SleepUtils#DEFAULT_SLEEP_TIME} **/
24 | public static void sleep() {
25 | sleep(DEFAULT_SLEEP_TIME);
26 | }
27 |
28 | /**
29 | * sleep一段时间
30 | *
31 | * @param mills 毫秒
32 | */
33 | public static void sleep(long mills) {
34 | try {
35 | Thread.sleep(mills);
36 | } catch (InterruptedException e) {
37 | e.printStackTrace();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/target/JavaCommon-2.0.3-jar-with-dependencies.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/JavaCommon-2.0.3-jar-with-dependencies.jar
--------------------------------------------------------------------------------
/target/JavaCommon-2.0.3-sources.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/JavaCommon-2.0.3-sources.jar
--------------------------------------------------------------------------------
/target/JavaCommon-2.0.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/JavaCommon-2.0.3.jar
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/ArrayUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/ArrayUtils.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/FileUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/FileUtils.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/HttpUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/HttpUtils.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/JSONUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/JSONUtils.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/ListUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/ListUtils.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/MapUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/MapUtils.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/ObjectUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/ObjectUtils.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/RandomUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/RandomUtils.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/SerializeUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/SerializeUtils.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/StringUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/StringUtils.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/entity/CacheObject.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/entity/CacheObject.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/service/Cache.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/service/Cache.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/service/CacheFullRemoveType.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/service/CacheFullRemoveType.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/AutoGetDataCache$GetDataThread.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/AutoGetDataCache$GetDataThread.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/AutoGetDataCache$OnGetDataListener.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/AutoGetDataCache$OnGetDataListener.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/AutoGetDataCache.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/AutoGetDataCache.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeDataBig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeDataBig.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeDataSmall.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeDataSmall.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeEnterTimeFirst.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeEnterTimeFirst.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeEnterTimeLast.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeEnterTimeLast.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeLastUsedTimeFirst.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeLastUsedTimeFirst.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeLastUsedTimeLast.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeLastUsedTimeLast.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeNotRemove.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeNotRemove.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypePriorityHigh.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypePriorityHigh.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypePriorityLow.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypePriorityLow.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeUsedCountBig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeUsedCountBig.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeUsedCountSmall.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/RemoveTypeUsedCountSmall.class
--------------------------------------------------------------------------------
/target/classes/com/trinea/java/common/serviceImpl/SimpleCache.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/classes/com/trinea/java/common/serviceImpl/SimpleCache.class
--------------------------------------------------------------------------------
/target/maven-archiver/pom.properties:
--------------------------------------------------------------------------------
1 | #Generated by Maven
2 | #Sat Jul 14 21:26:38 CST 2012
3 | version=2.0.3
4 | groupId=com.trinea.java.common
5 | artifactId=JavaCommon
6 |
--------------------------------------------------------------------------------
/target/surefire-reports/TEST-com.trinea.java.common.SerializeUtilsTest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/target/surefire-reports/TEST-com.trinea.java.common.serviceImpl.AutoGetDataCacheTest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/target/surefire-reports/TEST-com.trinea.java.common.serviceImpl.CacheFullRemoveTypeTest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.ArrayUtilsTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.ArrayUtilsTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.FileUtilsTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.FileUtilsTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.063 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.HttpUtilsTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.HttpUtilsTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 28, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.997 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.JSONUtilsTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.JSONUtilsTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.042 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.ListUtilsTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.ListUtilsTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.025 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.MapUtilsTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.MapUtilsTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.ObjectUtilsTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.ObjectUtilsTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.RandomsUtilsTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.RandomsUtilsTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.SerializeUtilsTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.SerializeUtilsTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.286 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.StringUtilsTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.StringUtilsTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.03 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.serviceImpl.AutoGetDataCacheTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.serviceImpl.AutoGetDataCacheTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.402 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.serviceImpl.CacheFullRemoveTypeTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.serviceImpl.CacheFullRemoveTypeTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec
5 |
--------------------------------------------------------------------------------
/target/surefire-reports/com.trinea.java.common.serviceImpl.SimpleCacheTest.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | Test set: com.trinea.java.common.serviceImpl.SimpleCacheTest
3 | -------------------------------------------------------------------------------
4 | Tests run: 23, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.77 sec
5 |
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/ArrayUtilsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/ArrayUtilsTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/FileUtilsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/FileUtilsTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/HttpUtilsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/HttpUtilsTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/JSONUtilsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/JSONUtilsTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/JUnitTestUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/JUnitTestUtils.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/ListUtilsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/ListUtilsTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/MapUtilsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/MapUtilsTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/ObjectUtilsTest$1TestClass.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/ObjectUtilsTest$1TestClass.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/ObjectUtilsTest$1TestClassWithEqualFun.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/ObjectUtilsTest$1TestClassWithEqualFun.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/ObjectUtilsTest$1User.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/ObjectUtilsTest$1User.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/ObjectUtilsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/ObjectUtilsTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/RandomsUtilsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/RandomsUtilsTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/SerializeUtilsTest$ClassImplSerialize.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/SerializeUtilsTest$ClassImplSerialize.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/SerializeUtilsTest$ClassNotImplSerialize.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/SerializeUtilsTest$ClassNotImplSerialize.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/SerializeUtilsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/SerializeUtilsTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/StringUtilsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/StringUtilsTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheDemo$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheDemo$1.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheDemo.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$1.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$2.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$3.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$4.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$4.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$5.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$5.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$6.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$6.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$7.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest$7.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/AutoGetDataCacheTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/CacheFullRemoveTypeTest$TestClass.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/CacheFullRemoveTypeTest$TestClass.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/CacheFullRemoveTypeTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/CacheFullRemoveTypeTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/serviceImpl/SimpleCacheTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/serviceImpl/SimpleCacheTest.class
--------------------------------------------------------------------------------
/target/test-classes/com/trinea/java/common/utils/SleepUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Trinea/java-common/fcace4784b5703d419c0dc5a5300a1b12dbd19e7/target/test-classes/com/trinea/java/common/utils/SleepUtils.class
--------------------------------------------------------------------------------