@@ -14,15 +14,71 @@ public abstract class ReaderWriterModifier
1414{
1515 // // Reader handling
1616
17+ /**
18+ * Method called after {@link ValueReader} to use has been constructed, but
19+ * before it is to be used for the first time. Method may either return that
20+ * reader as-is, or construct a different {@link ValueReader} and return that
21+ * to be used.
22+ *<p>
23+ * This method is often used to create a new {@link ValueReader} that needs to
24+ * delegate to the original reader for some uses, but not all.
25+ *
26+ * @param readContext Context that may be used to access configuration
27+ * @param type Type of values to read
28+ * @param defaultReader {@link ValueReader} that is to be used
29+ *
30+ * @return either {@code defaultReader} as-is, or an alternate {@link ValueReader} to use.
31+ */
1732 public ValueReader modifyValueReader (JSONReader readContext ,
1833 Class <?> type , ValueReader defaultReader ) {
19- return null ;
34+ return defaultReader ;
2035 }
2136
2237 // // Writer handling
2338
39+ /**
40+ * Method called after {@link ValueWriter} to use has been constructed, but
41+ * before it is to be used for the first time. Method may either return that
42+ * writer as-is, or construct a different {@link ValueWriter} and return that
43+ * to be used.
44+ *<p>
45+ * Note that this method is NOT called for non-POJO JDK "standard" values that
46+ * jackson-jr supports (such as {@link java.lang.Number}s, {@link java.lang.String}
47+ * and {@link java.net.URL}); for these types, {@link #overrideStandardValueWriter}
48+ * is called instead.
49+ *<p>
50+ * This method is often used to create a new {@link ValueReader} that needs to
51+ * delegate to the original reader for some uses, but not all.
52+ *
53+ * @param writeContext Context that may be used to access configuration
54+ * @param type Type of values to write
55+ * @param defaultWriter {@link ValueReader} that is to be used
56+ *
57+ * @return either {@code defaultReader} as-is, or an alternate {@link ValueWriter} to use;
58+ * must not return {@code null}.
59+ */
2460 public ValueWriter modifyValueWriter (JSONWriter writeContext ,
2561 Class <?> type , ValueWriter defaultWriter ) {
62+ return defaultWriter ;
63+ }
64+
65+ /**
66+ * Method called instead of {@link #modifyValueWriter} for set of non-POJO
67+ * "standard" JDK types that do not have matching {@link ValueWriter} and are
68+ * normally directly serialized by {@link JSONWriter} itself.
69+ * Handler may either return {@code null} to indicate "no override" or return
70+ * custom {@link ValueWriter} to use.
71+ *
72+ * @param writeContext Context that may be used to access configuration
73+ * @param type Type of values to write
74+ * @param stdTypeId Internal identifier of standard type (not usually useful,
75+ * but could potentially be used for delegating)
76+ *
77+ * @return {@code null} if no override should occur, or {@link ValueWriter}
78+ * to use.
79+ */
80+ public ValueWriter overrideStandardValueWriter (JSONWriter writeContext ,
81+ Class <?> type , int stdTypeId ) {
2682 return null ;
2783 }
2884}
0 commit comments