litesoft
@ 948
litesoft / trunk / GWT_Sandbox / MultiModule / foundation / src / org / litesoft / sandbox / multimodule / foundation / client / support / LuckyIdCodec.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
package org.litesoft.sandbox.multimodule.foundation.client.support; public class LuckyIdCodec { public static String encode( Long luckyId ) { return (luckyId == null) ? null : Long.toOctalString( luckyId + Integer.MAX_VALUE ); } public static Long decode( String luckyId ) { if ( luckyId != null ) { if ( (luckyId = luckyId.trim()).length() != 0 ) { try { return Long.parseLong( luckyId, 8 ) - Integer.MAX_VALUE; } catch ( NumberFormatException e ) { // Ignore... } } } return null; } } |