litesoft
@ 804
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 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.codec; import org.litesoft.charstreams.*; import org.litesoft.core.annotations.*; import org.litesoft.core.typeutils.*; import org.litesoft.memobeansupport.*; /** * Convert Memoable value to/from a self-terminating string representation */ public class MemoableTypedTerminatingCodec<T extends Memoable<T>> extends AbstractTypedTerminatingCodec<T> { private T mDefaultInstance; public MemoableTypedTerminatingCodec( T pDefaultInstance ) { Objects.assertNotNull( "DefaultInstance", mDefaultInstance = pDefaultInstance ); } @Override protected @NotNull void encodeNonNull( CharSink pCharSink, T pValue ) { pCharSink.add( NOT_NULL_FOLLOWS_AS_CHAR ); // This is needed as the first subfield of the Value could be a null and that would confuse the Null checker pValue.toMemo( pCharSink ); } @Override protected @NotNull T decodeNonNull( CharSource pCharSource ) { if ( NOT_NULL_FOLLOWS_AS_CHAR != pCharSource.getRequired() ) // This is needed as the first subfield of the Value could be a null and that would confuse the Null checker { throw new IllegalArgumentException( "Malformed Memoable protocol" ); } return mDefaultInstance.fromMemo( pCharSource ); } } |
Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/codec/MemoableTypedTerminatingCodec.java
Revision | Author | Commited | Message |
---|---|---|---|
804 Diff | GeorgeS | Wed 15 Aug, 2012 12:48:51 +0000 | |
779 Diff | GeorgeS | Mon 16 Jul, 2012 04:34:33 +0000 | |
773 Diff | GeorgeS | Sun 15 Jul, 2012 22:39:12 +0000 | |
772 Diff | GeorgeS | Sun 15 Jul, 2012 16:55:51 +0000 | ! |
768 Diff | GeorgeS | Sat 14 Jul, 2012 22:48:34 +0000 | ! |
767 Diff | GeorgeS | Sat 14 Jul, 2012 18:19:39 +0000 | |
766 Diff | GeorgeS | Sat 14 Jul, 2012 16:38:04 +0000 | ! |
490 Diff | GeorgeS | Fri 09 Sep, 2011 18:11:40 +0000 | Encoding |
50 Diff | GeorgeS | Tue 13 Apr, 2010 11:51:38 +0000 | |
49 | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |