aboutsummaryrefslogtreecommitdiff
path: root/java/com/xagasoft/gats/GatsBoolean.java
blob: 7e5d21783418fe42c5bbf8f7005aaf8a566718c8 (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.xagasoft.gats;

import java.io.InputStream;
import java.io.OutputStream;

/**
 * Represents a boolean value.  This is probably the simplest of all Gats
 * objects.  It can be true or false.
 */
public class GatsBoolean extends GatsObject
{
	private boolean bValue = false;

	/**
	 * Construct a new GatsBoolean, the default value is false.
	 */
	public GatsBoolean()
	{
	}

	/**
	 * Construct a new GatsBoolean, specify the value.;
	 */
	public GatsBoolean( boolean bValue )
	{
		this.bValue = bValue;
	}

	/**
	 * Get the current value, either true or false.
	 */
	public boolean getValue()
	{
		return bValue;
	}

	/**
	 * Set the value.
	 */
	public void setValue( boolean bValue )
	{
		this.bValue = bValue;
	}

	public int getType()
	{
		return GatsObject.BOOLEAN;
	}

	public String toString()
	{
		return "" + bValue;
	}

	void read( InputStream is, char cType ) throws java.io.IOException
	{
		if( cType == '0' )
			bValue = false;
		else if( cType == '1' )
			bValue = true;
	}

	void write( OutputStream os ) throws java.io.IOException
	{
		if( bValue )
			os.write( (int)'1' );
		else
			os.write( (int)'0' );

	}
};