@@ -685,7 +685,8 @@ public Date parseDate(String dateStr) throws IllegalArgumentException
685
685
DateFormat df = getDateFormat ();
686
686
return df .parse (dateStr );
687
687
} catch (ParseException e ) {
688
- throw new IllegalArgumentException ("Failed to parse Date value '" +dateStr +"': " +e .getMessage ());
688
+ throw new IllegalArgumentException (String .format (
689
+ "Failed to parse Date value '%s': %s" , dateStr , e .getMessage ()));
689
690
}
690
691
}
691
692
@@ -826,7 +827,9 @@ public JsonMappingException mappingException(Class<?> targetClass) {
826
827
}
827
828
828
829
public JsonMappingException mappingException (Class <?> targetClass , JsonToken token ) {
829
- return JsonMappingException .from (_parser , "Can not deserialize instance of " +_calcName (targetClass )+" out of " +token +" token" );
830
+ return JsonMappingException .from (_parser ,
831
+ String .format ("Can not deserialize instance of %s out of %s token" ,
832
+ _calcName (targetClass ), token ));
830
833
}
831
834
832
835
/**
@@ -844,23 +847,12 @@ public JsonMappingException mappingException(String message) {
844
847
*/
845
848
public JsonMappingException instantiationException (Class <?> instClass , Throwable t ) {
846
849
return JsonMappingException .from (_parser ,
847
- "Can not construct instance of " + instClass .getName ()+ ", problem: " + t .getMessage (), t );
850
+ String . format ( "Can not construct instance of %s, problem: %s" , instClass .getName (), t .getMessage () ), t );
848
851
}
849
852
850
853
public JsonMappingException instantiationException (Class <?> instClass , String msg ) {
851
- return JsonMappingException .from (_parser , "Can not construct instance of " +instClass .getName ()+", problem: " +msg );
852
- }
853
-
854
- /**
855
- * Method that will construct an exception suitable for throwing when
856
- * some String values are acceptable, but the one encountered is not.
857
- *
858
- *
859
- * @deprecated Since 2.1 should use variant that takes value
860
- */
861
- @ Deprecated
862
- public JsonMappingException weirdStringException (Class <?> instClass , String msg ) {
863
- return weirdStringException (null , instClass , msg );
854
+ return JsonMappingException .from (_parser ,
855
+ String .format ("Can not construct instance of %s, problem: %s" , instClass .getName (), msg ));
864
856
}
865
857
866
858
/**
@@ -875,26 +867,19 @@ public JsonMappingException weirdStringException(Class<?> instClass, String msg)
875
867
*/
876
868
public JsonMappingException weirdStringException (String value , Class <?> instClass , String msg ) {
877
869
return InvalidFormatException .from (_parser ,
878
- "Can not construct instance of " +instClass .getName ()+" from String value '" +_valueDesc ()+"': " +msg ,
870
+ String .format ("Can not construct instance of %s from String value '%s': %s" ,
871
+ instClass .getName (), _valueDesc (), msg ),
879
872
value , instClass );
880
873
}
881
874
882
- /**
883
- * Helper method for constructing exception to indicate that input JSON
884
- * Number was not suitable for deserializing into given type.
885
- */
886
- @ Deprecated
887
- public JsonMappingException weirdNumberException (Class <?> instClass , String msg ) {
888
- return weirdStringException (null , instClass , msg );
889
- }
890
-
891
875
/**
892
876
* Helper method for constructing exception to indicate that input JSON
893
877
* Number was not suitable for deserializing into given target type.
894
878
*/
895
879
public JsonMappingException weirdNumberException (Number value , Class <?> instClass , String msg ) {
896
880
return InvalidFormatException .from (_parser ,
897
- "Can not construct instance of " +instClass .getName ()+" from number value (" +_valueDesc ()+"): " +msg ,
881
+ String .format ("Can not construct instance of %s from number value (%s): %s" ,
882
+ instClass .getName (), _valueDesc (), msg ),
898
883
null , instClass );
899
884
}
900
885
@@ -905,7 +890,8 @@ public JsonMappingException weirdNumberException(Number value, Class<?> instClas
905
890
*/
906
891
public JsonMappingException weirdKeyException (Class <?> keyClass , String keyValue , String msg ) {
907
892
return InvalidFormatException .from (_parser ,
908
- "Can not construct Map key of type " +keyClass .getName ()+" from String \" " +_desc (keyValue )+"\" : " +msg ,
893
+ String .format ("Can not construct Map key of type %s from String \" %s\" : " ,
894
+ keyClass .getName (), _desc (keyValue ), msg ),
909
895
keyValue , keyClass );
910
896
}
911
897
@@ -914,7 +900,8 @@ public JsonMappingException weirdKeyException(Class<?> keyClass, String keyValue
914
900
* token.
915
901
*/
916
902
public JsonMappingException wrongTokenException (JsonParser p , JsonToken expToken , String msg0 ) {
917
- String msg = "Unexpected token (" +p .getCurrentToken ()+"), expected " +expToken ;
903
+ String msg = String .format ("Unexpected token (%s), expected %s" ,
904
+ p .getCurrentToken (), expToken );
918
905
if (msg0 != null ) {
919
906
msg = msg + ": " +msg0 ;
920
907
}
0 commit comments