@@ -47,6 +47,7 @@ public class StdKeyDeserializer extends KeyDeserializer
47
47
public final static int TYPE_URL = 14 ;
48
48
public final static int TYPE_CLASS = 15 ;
49
49
public final static int TYPE_CURRENCY = 16 ;
50
+ public final static int TYPE_BYTE_ARRAY = 17 ;
50
51
51
52
final protected int _kind ;
52
53
final protected Class <?> _keyClass ;
@@ -108,6 +109,8 @@ public static StdKeyDeserializer forType(Class<?> raw)
108
109
} else if (raw == Currency .class ) {
109
110
FromStringDeserializer <?> deser = FromStringDeserializer .findDeserializer (Currency .class );
110
111
return new StdKeyDeserializer (TYPE_CURRENCY , raw , deser );
112
+ } else if (raw == byte [].class ) {
113
+ kind = TYPE_BYTE_ARRAY ;
111
114
} else {
112
115
return null ;
113
116
}
@@ -204,26 +207,32 @@ protected Object _parse(String key, DeserializationContext ctxt) throws Exceptio
204
207
try {
205
208
return UUID .fromString (key );
206
209
} catch (Exception e ) {
207
- return ctxt . handleWeirdKey ( _keyClass , key , "problem: %s" , e . getMessage () );
210
+ return _weirdKey ( ctxt , key , e );
208
211
}
209
212
case TYPE_URI :
210
213
try {
211
214
return URI .create (key );
212
215
} catch (Exception e ) {
213
- return ctxt . handleWeirdKey ( _keyClass , key , "problem: %s" , e . getMessage () );
216
+ return _weirdKey ( ctxt , key , e );
214
217
}
215
218
case TYPE_URL :
216
219
try {
217
220
return new URL (key );
218
221
} catch (MalformedURLException e ) {
219
- return ctxt . handleWeirdKey ( _keyClass , key , "problem: %s" , e . getMessage () );
222
+ return _weirdKey ( ctxt , key , e );
220
223
}
221
224
case TYPE_CLASS :
222
225
try {
223
226
return ctxt .findClass (key );
224
227
} catch (Exception e ) {
225
228
return ctxt .handleWeirdKey (_keyClass , key , "unable to parse key as Class" );
226
229
}
230
+ case TYPE_BYTE_ARRAY :
231
+ try {
232
+ return ctxt .getConfig ().getBase64Variant ().decode (key );
233
+ } catch (Exception e ) {
234
+ return _weirdKey (ctxt , key , e );
235
+ }
227
236
default :
228
237
throw new IllegalStateException ("Internal error: unknown key type " +_keyClass );
229
238
}
@@ -247,6 +256,11 @@ protected double _parseDouble(String key) throws IllegalArgumentException {
247
256
return NumberInput .parseDouble (key );
248
257
}
249
258
259
+ // @since 2.9
260
+ protected Object _weirdKey (DeserializationContext ctxt , String key , Exception e ) throws IOException {
261
+ return ctxt .handleWeirdKey (_keyClass , key , "problem: %s" , e .getMessage ());
262
+ }
263
+
250
264
/*
251
265
/**********************************************************
252
266
/* First: the standard "String as String" deserializer
0 commit comments