litesoft
Diff Revisions
947
vs
948
for /trunk/GWT_Sandbox/FormEngine/src/com/temp/shared/utils/SixBitCodec.java
|
@@ -8,39 +8,39 @@ |
8 |
8 |
|
* ('-'), and a period ('.'). |
9 |
9 |
|
*/ |
10 |
10 |
|
public class SixBitCodec { |
11 |
|
- |
public static char encode(int pValue) { |
12 |
|
- |
if (pValue < 0) { |
13 |
|
- |
throw new IllegalArgumentException("Negative int not supported"); |
|
11 |
+ |
public static char encode( int pValue ) { |
|
12 |
+ |
if ( pValue < 0 ) { |
|
13 |
+ |
throw new IllegalArgumentException( "Negative int not supported" ); |
14 |
14 |
|
} |
15 |
15 |
|
pValue = pValue & 63; |
16 |
|
- |
if (pValue < 10) { |
|
16 |
+ |
if ( pValue < 10 ) { |
17 |
17 |
|
return (char) ('0' + pValue); |
18 |
18 |
|
} |
19 |
|
- |
if ((pValue -= 10) < 26) { |
|
19 |
+ |
if ( (pValue -= 10) < 26 ) { |
20 |
20 |
|
return (char) ('A' + pValue); |
21 |
21 |
|
} |
22 |
|
- |
if ((pValue -= 26) < 26) { |
|
22 |
+ |
if ( (pValue -= 26) < 26 ) { |
23 |
23 |
|
return (char) ('a' + pValue); |
24 |
24 |
|
} |
25 |
25 |
|
return ((pValue -= 26) == 0) ? '-' : '.'; |
26 |
26 |
|
} |
27 |
27 |
|
|
28 |
|
- |
public static int decode(char pValue) { |
29 |
|
- |
if (('0' <= pValue) && (pValue <= '9')) { |
|
28 |
+ |
public static int decode( char pValue ) { |
|
29 |
+ |
if ( ('0' <= pValue) && (pValue <= '9') ) { |
30 |
30 |
|
return pValue - '0'; |
31 |
31 |
|
} |
32 |
|
- |
if (('A' <= pValue) && (pValue <= 'Z')) { |
|
32 |
+ |
if ( ('A' <= pValue) && (pValue <= 'Z') ) { |
33 |
33 |
|
return (pValue - 'A') + 10; |
34 |
34 |
|
} |
35 |
|
- |
if (('a' <= pValue) && (pValue <= 'z')) { |
|
35 |
+ |
if ( ('a' <= pValue) && (pValue <= 'z') ) { |
36 |
36 |
|
return (pValue - 'a') + 36; |
37 |
37 |
|
} |
38 |
|
- |
if (pValue == '-') { |
|
38 |
+ |
if ( pValue == '-' ) { |
39 |
39 |
|
return 62; |
40 |
40 |
|
} |
41 |
|
- |
if (pValue == '.') { |
|
41 |
+ |
if ( pValue == '.' ) { |
42 |
42 |
|
return 63; |
43 |
43 |
|
} |
44 |
|
- |
throw new IllegalArgumentException("Unacceptable character '" + pValue + "': " + (int) pValue); |
|
44 |
+ |
throw new IllegalArgumentException( "Unacceptable character '" + pValue + "': " + (int) pValue ); |
45 |
45 |
|
} |
46 |
46 |
|
} |