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 { private Hashtable hValue = new Hashtable(); 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> entrySet() { return hValue.entrySet(); } public GatsObject get( Object arg0 ) { return hValue.get( arg0 ); } public boolean isEmpty() { return hValue.isEmpty(); } public Set keySet() { return hValue.keySet(); } public GatsObject put( String arg0, GatsObject arg1 ) { return hValue.put( arg0, arg1 ); } public void putAll( Map arg0 ) { hValue.putAll( arg0 ); } public GatsObject remove( Object arg0 ) { return hValue.remove( arg0 ); } public int size() { return hValue.size(); } public Collection values() { return hValue.values(); } };