Subversion Repository Public Repository

litesoft

Diff Revisions 814 vs 834 for /trunk/Java/core/Anywhere/src/org/litesoft/codec/MemoableTypedTerminatingCodec.java

Diff revisions: vs.
  @@ -21,18 +21,18 @@
21 21 @Override
22 22 protected @NotNull void encodeNonNull( CharSink pCharSink, T pValue )
23 23 {
24 - 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
25 - pValue.toMemento( pCharSink );
24 + CharSink zCharSink = new CharSinkToString();
25 + pValue.toMemento( zCharSink );
26 + String zEncodedAsString = zCharSink.toString();
27 + StringTypedTerminatingCodec.INSTANCE.encodeNonNull( pCharSink, zEncodedAsString );
26 28 }
27 29
28 30 @Override
29 31 protected @NotNull T decodeNonNull( CharSource pCharSource )
30 32 {
31 - 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
32 - {
33 - throw new IllegalArgumentException( "Malformed Mementoable protocol" );
34 - }
35 - return mDefaultInstance.fromMemento( pCharSource );
33 + String zEncodedAsString = StringTypedTerminatingCodec.INSTANCE.decodeNonNull( pCharSource );
34 + CharSource zCharSource = new CharSourceFromSequence( zEncodedAsString );
35 + return validateConsumed( zEncodedAsString, zCharSource, mDefaultInstance.fromMemento( zCharSource ) );
36 36 }
37 37 }
38 38