|
@@ -1,71 +1,71 @@ |
1 |
|
- |
package org.litesoft.GWT.client.pavsupport; |
2 |
|
- |
|
3 |
|
- |
import org.litesoft.codec.*; |
4 |
|
- |
import org.litesoft.core.util.*; |
5 |
|
- |
|
6 |
|
- |
import com.google.gwt.place.shared.*; |
7 |
|
- |
|
8 |
|
- |
import java.util.*; |
9 |
|
- |
|
10 |
|
- |
public abstract class IdTokenizer<T extends Place> implements PlaceTokenizer<T>, |
11 |
|
- |
HasPlaceId { |
12 |
|
- |
private String mPlaceId; |
13 |
|
- |
|
14 |
|
- |
protected IdTokenizer( Object pPlaceId ) { |
15 |
|
- |
mPlaceId = pPlaceId.toString(); |
16 |
|
- |
} |
17 |
|
- |
|
18 |
|
- |
@Override |
19 |
|
- |
public String getPlaceId() { |
20 |
|
- |
return mPlaceId; |
21 |
|
- |
} |
22 |
|
- |
|
23 |
|
- |
/** |
24 |
|
- |
* Encode the passed Strings into a single String. |
25 |
|
- |
* |
26 |
|
- |
* @return "" if null passed OR no strings, individual nulls treated as "" |
27 |
|
- |
*/ |
28 |
|
- |
protected String encode( String... strings ) { |
29 |
|
- |
return encodePacked( MultiStringPackaging.pack( strings ) ); |
30 |
|
- |
} |
31 |
|
- |
|
32 |
|
- |
/** |
33 |
|
- |
* Encode the passed Strings into a single String. |
34 |
|
- |
* |
35 |
|
- |
* @return "" if null passed OR no strings, individual nulls treated as "" |
36 |
|
- |
*/ |
37 |
|
- |
protected String encode( List<String> strings ) { |
38 |
|
- |
return encodePacked( MultiStringPackaging.pack( strings ) ); |
39 |
|
- |
} |
40 |
|
- |
|
41 |
|
- |
/** |
42 |
|
- |
* Decode the passed String into multiple Strings. |
43 |
|
- |
* |
44 |
|
- |
* @return empty if "" or null passed OR the data can not be unpacked, |
45 |
|
- |
* otherwise the list will be at least one string and no entries |
46 |
|
- |
* will be null |
47 |
|
- |
*/ |
48 |
|
- |
protected List<String> decode( String encoded ) { |
49 |
|
- |
return decode( encoded, 0 ); |
50 |
|
- |
} |
51 |
|
- |
|
52 |
|
- |
/** |
53 |
|
- |
* Decode the passed String into multiple Strings. |
54 |
|
- |
* |
55 |
|
- |
* @return empty if minimumListSize < 1 AND (null or "" passed, OR the data |
56 |
|
- |
* can not be unpacked) otherwise the list will be at least |
57 |
|
- |
* minimumListSize (or 1 if minimumListSize < 1) and no entries will |
58 |
|
- |
* be null. |
59 |
|
- |
*/ |
60 |
|
- |
protected static List<String> decode( String encoded, int minimumListSize ) { |
61 |
|
- |
return MultiStringPackaging.unpack( VersioningCodec.INSTANCE.decode( encoded ), minimumListSize ); |
62 |
|
- |
} |
63 |
|
- |
|
64 |
|
- |
private String encodePacked( String packed ) { |
65 |
|
- |
return VersioningCodec.INSTANCE.encode( packed ); |
66 |
|
- |
} |
67 |
|
- |
|
68 |
|
- |
protected String toString( Object object ) { |
69 |
|
- |
return (object != null) ? object.toString() : null; |
70 |
|
- |
} |
71 |
|
- |
} |
|
1 |
+ |
package org.litesoft.GWT.client.pavsupport; |
|
2 |
+ |
|
|
3 |
+ |
import org.litesoft.codec.*; |
|
4 |
+ |
import org.litesoft.core.util.*; |
|
5 |
+ |
|
|
6 |
+ |
import com.google.gwt.place.shared.*; |
|
7 |
+ |
|
|
8 |
+ |
import java.util.*; |
|
9 |
+ |
|
|
10 |
+ |
public abstract class IdTokenizer<T extends Place> implements PlaceTokenizer<T>, |
|
11 |
+ |
HasPlaceId { |
|
12 |
+ |
private String mPlaceId; |
|
13 |
+ |
|
|
14 |
+ |
protected IdTokenizer( Object pPlaceId ) { |
|
15 |
+ |
mPlaceId = pPlaceId.toString(); |
|
16 |
+ |
} |
|
17 |
+ |
|
|
18 |
+ |
@Override |
|
19 |
+ |
public String getPlaceId() { |
|
20 |
+ |
return mPlaceId; |
|
21 |
+ |
} |
|
22 |
+ |
|
|
23 |
+ |
/** |
|
24 |
+ |
* Encode the passed Strings into a single String. |
|
25 |
+ |
* |
|
26 |
+ |
* @return "" if null passed OR no strings, individual nulls treated as "" |
|
27 |
+ |
*/ |
|
28 |
+ |
protected String encode( String... strings ) { |
|
29 |
+ |
return encodePacked( MultiStringPackaging.pack( strings ) ); |
|
30 |
+ |
} |
|
31 |
+ |
|
|
32 |
+ |
/** |
|
33 |
+ |
* Encode the passed Strings into a single String. |
|
34 |
+ |
* |
|
35 |
+ |
* @return "" if null passed OR no strings, individual nulls treated as "" |
|
36 |
+ |
*/ |
|
37 |
+ |
protected String encode( List<String> strings ) { |
|
38 |
+ |
return encodePacked( MultiStringPackaging.pack( strings ) ); |
|
39 |
+ |
} |
|
40 |
+ |
|
|
41 |
+ |
/** |
|
42 |
+ |
* Decode the passed String into multiple Strings. |
|
43 |
+ |
* |
|
44 |
+ |
* @return empty if "" or null passed OR the data can not be unpacked, |
|
45 |
+ |
* otherwise the list will be at least one string and no entries |
|
46 |
+ |
* will be null |
|
47 |
+ |
*/ |
|
48 |
+ |
protected List<String> decode( String encoded ) { |
|
49 |
+ |
return decode( encoded, 0 ); |
|
50 |
+ |
} |
|
51 |
+ |
|
|
52 |
+ |
/** |
|
53 |
+ |
* Decode the passed String into multiple Strings. |
|
54 |
+ |
* |
|
55 |
+ |
* @return empty if minimumListSize < 1 AND (null or "" passed, OR the data |
|
56 |
+ |
* can not be unpacked) otherwise the list will be at least |
|
57 |
+ |
* minimumListSize (or 1 if minimumListSize < 1) and no entries will |
|
58 |
+ |
* be null. |
|
59 |
+ |
*/ |
|
60 |
+ |
protected static List<String> decode( String encoded, int minimumListSize ) { |
|
61 |
+ |
return MultiStringPackaging.unpack( VersioningCodec.INSTANCE.decode( encoded ), minimumListSize ); |
|
62 |
+ |
} |
|
63 |
+ |
|
|
64 |
+ |
private String encodePacked( String packed ) { |
|
65 |
+ |
return VersioningCodec.INSTANCE.encode( packed ); |
|
66 |
+ |
} |
|
67 |
+ |
|
|
68 |
+ |
protected String toString( Object object ) { |
|
69 |
+ |
return (object != null) ? object.toString() : null; |
|
70 |
+ |
} |
|
71 |
+ |
} |