litesoft
@ 948
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / client / foundation / pavment / AbstractPlaceTokenizer.java
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 26 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 |
package com.temp.client.foundation.pavment; import com.google.gwt.place.shared.*; import java.util.*; /** * Token encoding and packing support for the Right part of the GWT History URL * Fragment * * @author georgs */ public abstract class AbstractPlaceTokenizer<T extends Place> extends IdTokenizer<T> { protected AbstractPlaceTokenizer( Object pPlaceId ) { super( pPlaceId ); } /** * Encode the passed Strings into a single String. * * @return "" if null passed OR no strings, individual nulls treated as "" */ protected String encode( String... strings ) { return encodePacked( PlaceTokenPackaging.pack( strings ) ); } /** * Encode the passed Strings into a single String. * * @return "" if null passed OR no strings, individual nulls treated as "" */ protected String encode( List<String> strings ) { return encodePacked( PlaceTokenPackaging.pack( strings ) ); } /** * Decode the passed String into multiple Strings. * * @return empty if "" or null passed OR the data can not be unpacked, * otherwise the list will be at least one string and no entries * will be null */ protected List<String> decode( String encoded ) { return decode( encoded, 0 ); } /** * Decode the passed String into multiple Strings. * * @return empty if minimumListSize < 1 AND (null or "" passed, OR the data * can not be unpacked) otherwise the list will be at least * minimumListSize (or 1 if minimumListSize < 1) and no entries will * be null. */ protected static List<String> decode( String encoded, int minimumListSize ) { return PlaceTokenPackaging.unpack( PlaceTokenCodecRegistry.decode( encoded ), minimumListSize ); } private String encodePacked( String packed ) { return PlaceTokenCodecRegistry.encode( packed ); } protected String toString( Object object ) { return (object != null) ? object.toString() : null; } } |