litesoft
Diff Revisions
779
vs
834
for /trunk/Java/core/Anywhere/src/org/litesoft/codec/AbstractTypedTerminatingCodec.java
|
@@ -6,7 +6,6 @@ |
6 |
6 |
|
public abstract class AbstractTypedTerminatingCodec<T> implements TypedTerminatingCodec<T> |
7 |
7 |
|
{ |
8 |
8 |
|
protected static final char NULL_AS_CHAR = SixBitCodec.NOT_USED_NOT; |
9 |
|
- |
protected static final char NOT_NULL_FOLLOWS_AS_CHAR = SixBitCodec.NOT_USED_FOLLOWS; |
10 |
9 |
|
|
11 |
10 |
|
@Override |
12 |
11 |
|
public final @NotNull String encode( @Nullable T pValue ) |
|
@@ -33,12 +32,16 @@ |
33 |
32 |
|
public final @Nullable T decode( @NotNull CharSequence pValue ) |
34 |
33 |
|
{ |
35 |
34 |
|
CharSource zCharSource = new CharSourceFromSequence( pValue ); |
36 |
|
- |
T zDecoded = decode( zCharSource ); |
37 |
|
- |
if ( zCharSource.anyRemaining() ) |
|
35 |
+ |
return validateConsumed( pValue, zCharSource, decode( zCharSource ) ); |
|
36 |
+ |
} |
|
37 |
+ |
|
|
38 |
+ |
protected T validateConsumed( CharSequence pValue, CharSource pCharSource, T pDecoded ) |
|
39 |
+ |
{ |
|
40 |
+ |
if ( pCharSource.anyRemaining() ) |
38 |
41 |
|
{ |
39 |
|
- |
throw new IllegalArgumentException( "Extraneous character(s) starting at " + zCharSource.getNextOffset() + " in: " + pValue ); |
|
42 |
+ |
throw new IllegalArgumentException( "Extraneous character(s) starting at " + pCharSource.getNextOffset() + " in: " + pValue ); |
40 |
43 |
|
} |
41 |
|
- |
return zDecoded; |
|
44 |
+ |
return pDecoded; |
42 |
45 |
|
} |
43 |
46 |
|
|
44 |
47 |
|
@Override |