@@ -518,13 +518,27 @@ public static String initializeUserOverridesAsString()
518518 public static Map initializeExtensions ()
519519 { return getExtensions ( null ); }
520520
521- public static String initializeStringPropertyVar (String propKey , String dflt )
521+ public static String initializeStringPropertyVar (String propKey , String dflt , Validator < String > validator )
522522 {
523- String out = getUnspecifiedUserProperty ( propKey , null );
524- if (out == null ) out = dflt ;
525- return out ;
523+ String out = getUnspecifiedUserProperty ( propKey , null );
524+ try
525+ {
526+ if (out == null ) out = dflt ;
527+ else if (validator != null ) out = validator .validate (out );
528+ return out ;
529+ }
530+ catch (InvalidConfigException ice )
531+ {
532+ logger .log (MLevel .WARNING , "'" + out + "' is not a legal value for property '" + propKey +
533+ "'. Using default value: " + dflt , ice );
534+ return dflt ;
535+ }
526536 }
527537
538+ public static String initializeStringPropertyVar (String propKey , String dflt )
539+ { return initializeStringPropertyVar (propKey , dflt , null ); }
540+
541+
528542 public static int initializeIntPropertyVar (String propKey , int dflt )
529543 {
530544 boolean set = false ;
@@ -535,13 +549,13 @@ public static int initializeIntPropertyVar(String propKey, int dflt)
535549 {
536550 try
537551 {
538- out = Integer .parseInt ( outStr .trim () );
552+ out = Integer .parseInt ( outStr .trim () );
539553 set = true ;
540554 }
541555 catch (NumberFormatException e )
542556 {
543- logger .info ( "'" + outStr + "' is not a legal value for property '" + propKey +
544- "'. Using default value: " + dflt );
557+ logger .log ( MLevel . WARNING , "'" + outStr + "' is not a legal value for property '" + propKey +
558+ "'. Using default value: " + dflt , e );
545559 }
546560 }
547561
@@ -567,8 +581,8 @@ public static boolean initializeBooleanPropertyVar(String propKey, boolean dflt)
567581 }
568582 catch (IllegalArgumentException e )
569583 {
570- logger .info ( "'" + outStr + "' is not a legal value for property '" + propKey +
571- "'. Using default value: " + dflt );
584+ logger .log ( MLevel . WARNING , "'" + outStr + "' is not a legal value for property '" + propKey +
585+ "'. Using default value: " + dflt , e );
572586 }
573587 }
574588
0 commit comments