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