@@ -908,7 +908,7 @@ public JsonSerializer<?> handleSecondaryContextualization(JsonSerializer<?> ser,
908
908
909
909
/*
910
910
/********************************************************
911
- /* Convenience methods
911
+ /* Convenience methods for serializing using default methods
912
912
/********************************************************
913
913
*/
914
914
@@ -919,8 +919,7 @@ public JsonSerializer<?> handleSecondaryContextualization(JsonSerializer<?> ser,
919
919
* field values are best handled calling
920
920
* {@link #defaultSerializeField} instead.
921
921
*/
922
- public final void defaultSerializeValue (Object value , JsonGenerator jgen )
923
- throws IOException , JsonProcessingException
922
+ public final void defaultSerializeValue (Object value , JsonGenerator jgen ) throws IOException
924
923
{
925
924
if (value == null ) {
926
925
if (_stdNullValueSerializer ) { // minor perf optimization
@@ -940,7 +939,7 @@ public final void defaultSerializeValue(Object value, JsonGenerator jgen)
940
939
* null) using standard serializer locating functionality.
941
940
*/
942
941
public final void defaultSerializeField (String fieldName , Object value , JsonGenerator jgen )
943
- throws IOException , JsonProcessingException
942
+ throws IOException
944
943
{
945
944
jgen .writeFieldName (fieldName );
946
945
if (value == null ) {
@@ -958,12 +957,6 @@ public final void defaultSerializeField(String fieldName, Object value, JsonGene
958
957
}
959
958
}
960
959
961
- /*
962
- /**********************************************************
963
- /* Convenience methods
964
- /**********************************************************
965
- */
966
-
967
960
/**
968
961
* Method that will handle serialization of Date(-like) values, using
969
962
* {@link SerializationConfig} settings to determine expected serialization
@@ -972,7 +965,7 @@ public final void defaultSerializeField(String fieldName, Object value, JsonGene
972
965
* Java convention (and not date-only values like in SQL)
973
966
*/
974
967
public final void defaultSerializeDateValue (long timestamp , JsonGenerator jgen )
975
- throws IOException , JsonProcessingException
968
+ throws IOException
976
969
{
977
970
// [JACKSON-87]: Support both numeric timestamps and textual
978
971
if (isEnabled (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS )) {
@@ -990,7 +983,7 @@ public final void defaultSerializeDateValue(long timestamp, JsonGenerator jgen)
990
983
* Java convention (and not date-only values like in SQL)
991
984
*/
992
985
public final void defaultSerializeDateValue (Date date , JsonGenerator jgen )
993
- throws IOException , JsonProcessingException
986
+ throws IOException
994
987
{
995
988
// [JACKSON-87]: Support both numeric timestamps and textual
996
989
if (isEnabled (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS )) {
@@ -1006,7 +999,7 @@ public final void defaultSerializeDateValue(Date date, JsonGenerator jgen)
1006
999
* value (and if using textual representation, configured date format)
1007
1000
*/
1008
1001
public void defaultSerializeDateKey (long timestamp , JsonGenerator jgen )
1009
- throws IOException , JsonProcessingException
1002
+ throws IOException
1010
1003
{
1011
1004
if (isEnabled (SerializationFeature .WRITE_DATE_KEYS_AS_TIMESTAMPS )) {
1012
1005
jgen .writeFieldName (String .valueOf (timestamp ));
@@ -1020,18 +1013,16 @@ public void defaultSerializeDateKey(long timestamp, JsonGenerator jgen)
1020
1013
* based on {@link SerializationFeature#WRITE_DATE_KEYS_AS_TIMESTAMPS}
1021
1014
* value (and if using textual representation, configured date format)
1022
1015
*/
1023
- public void defaultSerializeDateKey (Date date , JsonGenerator jgen )
1024
- throws IOException , JsonProcessingException
1016
+ public void defaultSerializeDateKey (Date date , JsonGenerator jgen ) throws IOException
1025
1017
{
1026
1018
if (isEnabled (SerializationFeature .WRITE_DATE_KEYS_AS_TIMESTAMPS )) {
1027
1019
jgen .writeFieldName (String .valueOf (date .getTime ()));
1028
1020
} else {
1029
1021
jgen .writeFieldName (_dateFormat ().format (date ));
1030
1022
}
1031
1023
}
1032
-
1033
- public final void defaultSerializeNull (JsonGenerator jgen )
1034
- throws IOException , JsonProcessingException
1024
+
1025
+ public final void defaultSerializeNull (JsonGenerator jgen ) throws IOException
1035
1026
{
1036
1027
if (_stdNullValueSerializer ) { // minor perf optimization
1037
1028
jgen .writeNull ();
@@ -1040,12 +1031,28 @@ public final void defaultSerializeNull(JsonGenerator jgen)
1040
1031
}
1041
1032
}
1042
1033
1034
+ /*
1035
+ /********************************************************
1036
+ /* Error reporting
1037
+ /********************************************************
1038
+ */
1039
+
1040
+ /**
1041
+ * @since 2.6
1042
+ */
1043
+ public JsonMappingException mappingException (String message , Object ... args ) {
1044
+ if (args != null && args .length > 0 ) {
1045
+ message = String .format (message , args );
1046
+ }
1047
+ return new JsonMappingException (message );
1048
+ }
1049
+
1043
1050
/*
1044
1051
/********************************************************
1045
1052
/* Helper methods
1046
1053
/********************************************************
1047
1054
*/
1048
-
1055
+
1049
1056
protected void _reportIncompatibleRootType (Object value , JavaType rootType )
1050
1057
throws IOException , JsonProcessingException
1051
1058
{
@@ -1099,7 +1106,7 @@ protected JsonSerializer<Object> _findExplicitUntypedSerializer(Class<?> runtime
1099
1106
/* serializers
1100
1107
/**********************************************************
1101
1108
*/
1102
-
1109
+
1103
1110
/**
1104
1111
* Method that will try to construct a value serializer; and if
1105
1112
* one is successfully created, cache it for reuse.
0 commit comments