From d56af4807693e0e3b443f729b44d9aa8dcbb369d Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 21 Apr 2011 18:50:54 +0000 Subject: Well, dictionary may work... --- java/com/xagasoft/gats/GatsDictionary.java | 103 ++++++++++++++++++----------- java/com/xagasoft/gats/GatsObject.java | 2 +- 2 files changed, 67 insertions(+), 38 deletions(-) diff --git a/java/com/xagasoft/gats/GatsDictionary.java b/java/com/xagasoft/gats/GatsDictionary.java index cf6d390..95ecc45 100644 --- a/java/com/xagasoft/gats/GatsDictionary.java +++ b/java/com/xagasoft/gats/GatsDictionary.java @@ -5,80 +5,109 @@ 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 ) + 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 void clear() { - // TODO Auto-generated method stub - + public String toString() + { + return hValue.toString(); } - public boolean containsKey(Object arg0) { - // TODO Auto-generated method stub - return false; + public void clear() + { + hValue.clear(); } - public boolean containsValue(Object arg0) { - // TODO Auto-generated method stub - return false; + public boolean containsKey( Object arg0 ) + { + return hValue.containsKey( arg0 ); } - public Set> entrySet() { - // TODO Auto-generated method stub - return null; + public boolean containsValue( Object arg0 ) + { + return hValue.containsValue( arg0 ); } - public GatsObject get(Object arg0) { - // TODO Auto-generated method stub - return null; + public Set> entrySet() + { + return hValue.entrySet(); } - public boolean isEmpty() { - // TODO Auto-generated method stub - return false; + public GatsObject get( Object arg0 ) + { + return hValue.get( arg0 ); } - public Set keySet() { - // TODO Auto-generated method stub - return null; + public boolean isEmpty() + { + return hValue.isEmpty(); } - public GatsObject put(String arg0, GatsObject arg1) { - // TODO Auto-generated method stub - return null; + public Set keySet() + { + return hValue.keySet(); } - public void putAll(Map arg0) { - // TODO Auto-generated method stub - + public GatsObject put( String arg0, GatsObject arg1 ) + { + return hValue.put( arg0, arg1 ); } - public GatsObject remove(Object arg0) { - // TODO Auto-generated method stub - return null; + public void putAll( Map arg0 ) + { + hValue.putAll( arg0 ); } - public int size() { - // TODO Auto-generated method stub - return 0; + public GatsObject remove( Object arg0 ) + { + return hValue.remove( arg0 ); } - public Collection values() { - // TODO Auto-generated method stub - return null; + public int size() + { + return hValue.size(); + } + + public Collection values() + { + return hValue.values(); } }; diff --git a/java/com/xagasoft/gats/GatsObject.java b/java/com/xagasoft/gats/GatsObject.java index cb97a43..266a08f 100644 --- a/java/com/xagasoft/gats/GatsObject.java +++ b/java/com/xagasoft/gats/GatsObject.java @@ -41,7 +41,7 @@ public abstract class GatsObject break; case 'd': - // goRet = new GatsDictionary(); + goRet = new GatsDictionary(); break; case 'f': -- cgit v1.2.3