From 1dbbf711979031c338694407d25758574beaf833 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 13 Feb 2012 16:55:37 +0000 Subject: Consistancy is best, so all the get helpers throw an exception if they can't find their object. --- java/com/xagasoft/gats/GatsDictionary.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'java/com/xagasoft/gats') diff --git a/java/com/xagasoft/gats/GatsDictionary.java b/java/com/xagasoft/gats/GatsDictionary.java index 3517b68..b04f02c 100644 --- a/java/com/xagasoft/gats/GatsDictionary.java +++ b/java/com/xagasoft/gats/GatsDictionary.java @@ -203,9 +203,12 @@ public class GatsDictionary extends GatsObject implements Map * key specified does not appear in the GatsDictionary or is not the correct * type you will get the expected exception. */ - public GatsDictionary getDict( String key ) + public GatsDictionary getDict( String key ) throws KeyNotFoundException { - return (GatsDictionary)hValue.get( key ); + GatsDictionary ret = (GatsDictionary)hValue.get( key ); + if( ret == null ) + throw new KeyNotFoundException( this, key ); + return ret; } /** @@ -214,9 +217,12 @@ public class GatsDictionary extends GatsObject implements Map * key specified does not appear in the GatsDictionary or is not the correct * type you will get the expected exception. */ - public GatsList getList( String key ) + public GatsList getList( String key ) throws KeyNotFoundException { - return (GatsList)hValue.get( key ); + GatsList ret = (GatsList)hValue.get( key ); + if( ret == null ) + throw new KeyNotFoundException( this, key ); + return ret; } public void putAll( Map src ) -- cgit v1.2.3