Subversion Repository Public Repository

litesoft

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
package org.litesoft.codec;

import org.litesoft.commonfoundation.charstreams.*;
import org.litesoft.commonfoundation.annotations.*;

public class PrimitiveBooleanCodec
{
    public static final PrimitiveBooleanCodec INSTANCE = new PrimitiveBooleanCodec();

    private PrimitiveBooleanCodec()
    {
    }

    public void encode( @NotNull CharSink pCharSink, boolean pValue )
    {
        pCharSink.add( pValue ? 'T' : 'F' );
    }

    public boolean decode( @NotNull CharSource pCharSource )
    {
        char zChar = pCharSource.getRequired();
        switch ( zChar )
        {
            case 'T':
                return true;
            case 'F':
                return false;
            default:
                throw new IllegalArgumentException( "Unacceptable character '" + zChar + "': " + (int) zChar );
        }
    }
}

Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/codec/PrimitiveBooleanCodec.java

Diff revisions: vs.
Revision Author Commited Message
942 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 23:41:46 +0000

Extracting commonfoundation

939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

831 GeorgeS picture GeorgeS Fri 31 Aug, 2012 22:39:56 +0000