aboutsummaryrefslogtreecommitdiff
path: root/java/com/xagasoft/gats/GatsDictionary.java
blob: 0ad4c780ccfeddf64eb9ae23cead7792722535f3 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package com.xagasoft.gats;

import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.Hashtable;

public class GatsDictionary extends GatsObject implements Map<String,GatsObject>
{
	private Hashtable<String, GatsObject> hValue =
		new Hashtable<String, GatsObject>();

	public GatsDictionary()
	{
	}

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

	public void read( InputStream is, char cType ) throws java.io.IOException
	{
		for(;;)
		{
			GatsObject objKey = GatsObject.read( is );
			if( objKey == null )
				break;
			if( objKey.getType() != GatsObject.STRING )
				throw new java.io.IOException("bleh");
			put( objKey.toString(), GatsObject.read( is ) );
		}
	}

	public void write( OutputStream os ) throws java.io.IOException
	{
		os.write( (int)'d' );
		for( String sKey : hValue.keySet() )
		{
			new GatsString( sKey ).write( os );
			hValue.get( sKey ).write( os );
		}
		os.write( (int)'e' );
	}

	public String toString()
	{
		return hValue.toString();
	}

	public void clear() 
	{
		hValue.clear();
	}

	public boolean containsKey( Object arg0 )
	{
		return hValue.containsKey( arg0 );
	}

	public boolean containsValue( Object arg0 )
	{
		return hValue.containsValue( arg0 );
	}

	public Set<java.util.Map.Entry<String, GatsObject>> entrySet()
	{
		return hValue.entrySet();
	}

	public GatsObject get( Object arg0 )
	{
		return hValue.get( arg0 );
	}

	public boolean isEmpty()
	{
		return hValue.isEmpty();
	}

	public Set<String> keySet()
	{
		return hValue.keySet();
	}

	public GatsObject put( String arg0, GatsObject arg1 )
	{
		return hValue.put( arg0, arg1 );
	}

	public GatsObject put( String key, long val )
	{
		return hValue.put( key, new GatsInteger( val ) );
	}

	public GatsObject put( String key, double val )
	{
		return hValue.put( key, new GatsFloat( val ) );
	}

	public GatsObject put( String key, boolean val )
	{
		return hValue.put( key, new GatsBoolean( val ) );
	}

	public GatsObject put( String key, String val )
	{
		return hValue.put( key, new GatsString( val ) );
	}

	public long getInt( String key )
	{
		return ((GatsInteger)hValue.get( key )).getValue();
	}

	public double getFloat( String key )
	{
		return ((GatsFloat)hValue.get( key )).getValue();
	}

	public boolean getBool( String key )
	{
		return ((GatsBoolean)hValue.get( key )).getValue();
	}

	public byte[] getString( String key )
	{
		return ((GatsString)hValue.get( key )).getValue();
	}

	public GatsDictionary getDict( String key )
	{
		return (GatsDictionary)hValue.get( key );
	}

	public GatsList getList( String key )
	{
		return (GatsList)hValue.get( key );
	}


	public void putAll( Map<? extends String, ? extends GatsObject> arg0 )
	{
		hValue.putAll( arg0 );
	}

	public GatsObject remove( Object arg0 )
	{
		return hValue.remove( arg0 );
	}

	public int size()
	{
		return hValue.size();
	}

	public Collection<GatsObject> values()
	{
		return hValue.values();
	}
};