jiapeng 8 years ago
parent
commit
81e338045d

+ 2 - 2
jfwAptOrm/src/main/java/org/jfw/apt/orm/core/enums/DE.java

@ -6,8 +6,8 @@ import org.jfw.apt.orm.core.defaultImpl.*;
6 6
public enum DE {
7 7
	invalid_de(AbstractColumnHandler.class, null, false,false,false, false, null, null),
8 8
9
	boolean_de(BooleanHandler.class, "CHAR",false,true,true,true,null,null),
10
	Boolean_de(WBooleanHandler.class, "CHAR", true,true,true,true,null,null),
9
	boolean_de(BooleanHandler.class, "CHAR(1)",false,true,true,true,null,null),
10
	Boolean_de(WBooleanHandler.class, "CHAR(1)", true,true,true,true,null,null),
11 11
	
12 12
	byte_de(ByteHandler.class, "BYTE",false,true,true,true,null,null),
13 13
	Byte_de(WByteHandler.class,"BYTE",true,true,true,true,null,null),

+ 61 - 12
jfwUtil/src/main/java/org/jfw/util/auth/AuthUtil.java

@ -1,7 +1,6 @@
1 1
package org.jfw.util.auth;
2 2
3 3
import java.util.Arrays;
4
import java.util.Random;
5 4
6 5
import org.jfw.util.codec.Base64;
7 6
@ -27,6 +26,46 @@ public final class AuthUtil {
27 26
		int ind = auth % 32;
28 27
		return 0 != (auths[bIndex] & AUTH_BIT[ind]);
29 28
	}
29
	
30
	public static int[] compress(int[] auths){
31
		if(auths==null || auths.length ==0  ) return new int[]{0};		
32
		 Arrays.sort(auths);
33
		int max = auths[auths.length-1];
34
		int bIndex = max>>5;
35
		int[] ret = new int[bIndex+1];
36
		Arrays.fill(ret,0);
37
		for(int auth:auths){
38
			int ind = auth % 32;
39
			ret[bIndex] = ret[bIndex] | AUTH_BIT[ind];
40
		}
41
		return ret;
42
	}
43
	
44
	public static int[] unCompress(int[] auths){
45
		if(auths==null || auths.length ==0  ) return new int[]{0};		
46
		int[] ret = new int[16];
47
		int ina = 0;
48
		int max = auths.length*32;
49
		for(int i = 1 ; i <= max;){
50
			int bIndex = i >> 5;
51
			int ind = i % 32;
52
			if( 0 != (auths[bIndex] & AUTH_BIT[ind])){
53
				if(ina>= ret.length){
54
					int[] nret = new int[ret.length*2];
55
					System.arraycopy(ret,0,nret, 0,ret.length);
56
					ret = nret;
57
				}
58
				ret[ina]= i;
59
				++ina;
60
			}
61
		}
62
		if(ret.length> ina) {
63
			int[] nret = new int[ina];
64
			System.arraycopy(ret,0,nret, 0,ina);
65
			return nret;
66
		}
67
		return ret;
68
	}
30 69
31 70
	public static int[] grant(int[] auths, int auth) {
32 71
		if (auth < 1)
@ -141,18 +180,28 @@ public final class AuthUtil {
141 180
	}
142 181
	
143 182
	public static void main(String main[]) {
144
		System.out.println(System.currentTimeMillis());
145
		int[] iss = new int[100];
146
		for (int i = 0; i < iss.length; ++i)
147
		{
148
			iss[i] = (new Random()).nextInt();
149
		}
150
		byte[] bs = conver(iss);
151
		int[] ins = conver(bs);
152
		for (int ii = 0; ii < ins.length; ++ii) {
153
			System.out.println("" + iss[ii] + ":" + ins[ii]);
183
//		System.out.println(System.currentTimeMillis());
184
//		int[] iss = new int[100];
185
//		for (int i = 0; i < iss.length; ++i)
186
//		{
187
//			iss[i] = (new Random()).nextInt();
188
//		}
189
//		byte[] bs = conver(iss);
190
//		int[] ins = conver(bs);
191
//		for (int ii = 0; ii < ins.length; ++ii) {
192
//			System.out.println("" + iss[ii] + ":" + ins[ii]);
193
//		}
194
//		System.out.println(System.currentTimeMillis());
195
		
196
		
197
		int[] ii = new int[5];
198
		for(int i = 0 ; i < ii.length;++i){
199
			ii[i]=5-i;
154 200
		}
155
		System.out.println(System.currentTimeMillis());
201
		for(int i = 0 ; i < ii.length;++i) System.out.println(ii[i]);
202
		
203
		Arrays.sort(ii);
204
		for(int i = 0 ; i < ii.length;++i) System.out.println(ii[i]);
156 205
	}
157 206
158 207
}