[Title] modify validating configurations
authorSon Hyunjun <hj79.son@samsung.com>
Fri, 6 Apr 2012 09:10:24 +0000 (18:10 +0900)
committerSon Hyunjun <hj79.son@samsung.com>
Fri, 6 Apr 2012 09:10:24 +0000 (18:10 +0900)
[Type] Enhancement
[Module] Skin
[Priority] Minor
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]

Change-Id: Ie6899e38690470f613b8ed69359c581e32dda3d9

tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java

index 4b4a8fc66cac5d058aec2bf9423e6cd74b98f369..8ab3099d94aa1e3c839000cc8614ba7b5615eefb 100644 (file)
@@ -109,81 +109,107 @@ public class EmulatorConfig {
                        return;
                }
 
-               String uid = args.get( ArgsConstants.UID );
-               try {
-                       Integer.parseInt( uid );
-               } catch ( NumberFormatException e ) {
-                       String msg = ArgsConstants.UID + " argument is not numeric. : " + uid;
-                       throw new ConfigException( msg );
+               if( args.containsKey( ArgsConstants.UID ) ) {
+                       String uid = args.get( ArgsConstants.UID );
+                       try {
+                               Integer.parseInt( uid );
+                       } catch ( NumberFormatException e ) {
+                               String msg = ArgsConstants.UID + " argument is not numeric. : " + uid;
+                               throw new ConfigException( msg );
+                       }
                }
 
-               String serverPort = args.get( ArgsConstants.SERVER_PORT );
-               try {
-                       Integer.parseInt( serverPort );
-               } catch ( NumberFormatException e ) {
-                       String msg = ArgsConstants.SERVER_PORT + " argument is not numeric. : " + serverPort;
+               if( args.containsKey( ArgsConstants.SERVER_PORT ) ) {
+                       String serverPort = args.get( ArgsConstants.SERVER_PORT );
+                       try {
+                               Integer.parseInt( serverPort );
+                       } catch ( NumberFormatException e ) {
+                               String msg = ArgsConstants.SERVER_PORT + " argument is not numeric. : " + serverPort;
+                               throw new ConfigException( msg );
+                       }
+               }else {
+                       String msg = ArgsConstants.SERVER_PORT + " is required argument.";
                        throw new ConfigException( msg );
                }
 
-               String width = args.get( ArgsConstants.RESOLUTION_WIDTH );
-               try {
-                       Integer.parseInt( width );
-               } catch ( NumberFormatException e ) {
-                       String msg = ArgsConstants.RESOLUTION_WIDTH + " argument is not numeric. : " + width;
+               if( args.containsKey( ArgsConstants.RESOLUTION_WIDTH ) ) {
+                       String width = args.get( ArgsConstants.RESOLUTION_WIDTH );
+                       try {
+                               Integer.parseInt( width );
+                       } catch ( NumberFormatException e ) {
+                               String msg = ArgsConstants.RESOLUTION_WIDTH + " argument is not numeric. : " + width;
+                               throw new ConfigException( msg );
+                       }
+               }else {
+                       String msg = ArgsConstants.RESOLUTION_WIDTH + " is required argument.";
                        throw new ConfigException( msg );
                }
 
-               String height = args.get( ArgsConstants.RESOLUTION_HEIGHT );
-               try {
-                       Integer.parseInt( height );
-               } catch ( NumberFormatException e ) {
-                       String msg = ArgsConstants.RESOLUTION_HEIGHT + " argument is not numeric. : " + height;
+               if( args.containsKey( ArgsConstants.RESOLUTION_HEIGHT ) ) {
+                       String height = args.get( ArgsConstants.RESOLUTION_HEIGHT );
+                       try {
+                               Integer.parseInt( height );
+                       } catch ( NumberFormatException e ) {
+                               String msg = ArgsConstants.RESOLUTION_HEIGHT + " argument is not numeric. : " + height;
+                               throw new ConfigException( msg );
+                       }
+               }else {
+                       String msg = ArgsConstants.RESOLUTION_HEIGHT + " is required argument.";
                        throw new ConfigException( msg );
                }
 
        }
 
        public static void validateSkinProperties( Properties skinProperties ) throws ConfigException {
-               if ( null == skinProperties ) {
+               if ( null == skinProperties || 0 == skinProperties.size() ) {
                        return;
                }
 
-               String x = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_X );
-               try {
-                       Integer.parseInt( x );
-               } catch ( NumberFormatException e ) {
-                       String msg = SkinPropertiesConstants.WINDOW_X + " in .skin.properties is not numeric. : " + x;
-                       throw new ConfigException( msg );
+               if( skinProperties.containsKey( SkinPropertiesConstants.WINDOW_X ) ) {
+                       String x = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_X );
+                       
+                       try {
+                               Integer.parseInt( x );
+                       } catch ( NumberFormatException e ) {
+                               String msg = SkinPropertiesConstants.WINDOW_X + " in .skin.properties is not numeric. : " + x;
+                               throw new ConfigException( msg );
+                       }
                }
 
-               String y = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_Y );
-               try {
-                       Integer.parseInt( y );
-               } catch ( NumberFormatException e ) {
-                       String msg = SkinPropertiesConstants.WINDOW_Y + " in .skin.properties is not numeric. : " + y;
-                       throw new ConfigException( msg );
+               if( skinProperties.containsKey( SkinPropertiesConstants.WINDOW_Y ) ) {
+                       String y = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_Y );
+                       try {
+                               Integer.parseInt( y );
+                       } catch ( NumberFormatException e ) {
+                               String msg = SkinPropertiesConstants.WINDOW_Y + " in .skin.properties is not numeric. : " + y;
+                               throw new ConfigException( msg );
+                       }
                }
 
-               String rotation = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_ROTATION );
-               try {
-                       Integer.parseInt( rotation );
-               } catch ( NumberFormatException e ) {
-                       String msg = SkinPropertiesConstants.WINDOW_ROTATION + " in .skin.properties is not numeric. : " + rotation;
-                       throw new ConfigException( msg );
+               if( skinProperties.containsKey( SkinPropertiesConstants.WINDOW_ROTATION ) ) {
+                       String rotation = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_ROTATION );
+                       try {
+                               Integer.parseInt( rotation );
+                       } catch ( NumberFormatException e ) {
+                               String msg = SkinPropertiesConstants.WINDOW_ROTATION + " in .skin.properties is not numeric. : " + rotation;
+                               throw new ConfigException( msg );
+                       }
                }
 
-               String scale = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_SCALE );
-               try {
-                       Integer.parseInt( scale );
-               } catch ( NumberFormatException e ) {
-                       String msg = SkinPropertiesConstants.WINDOW_SCALE + " in .skin.properties is not numeric. : " + scale;
-                       throw new ConfigException( msg );
+               if( skinProperties.containsKey( SkinPropertiesConstants.WINDOW_SCALE ) ) {
+                       String scale = skinProperties.getProperty( SkinPropertiesConstants.WINDOW_SCALE );
+                       try {
+                               Integer.parseInt( scale );
+                       } catch ( NumberFormatException e ) {
+                               String msg = SkinPropertiesConstants.WINDOW_SCALE + " in .skin.properties is not numeric. : " + scale;
+                               throw new ConfigException( msg );
+                       }
                }
 
        }
 
        public static void validateSkinConfigProperties( Properties skinConfigProperties ) throws ConfigException {
-               if ( null == skinConfigProperties ) {
+               if ( null == skinConfigProperties || 0 == skinConfigProperties.size() ) {
                        return;
                }
        }