protected Class<?> findClass(String className, MyTokenizer tokens) { try { return ClassUtil.findClass(className); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw _problem(tokens, "Can not locate class '"+className+"', problem: "+e.getMessage()); } }
@Override public JavaType typeFromId(String id) { /* 30-Jan-2010, tatu: Most ids are basic class names; so let's first * check if any generics info is added; and only then ask factory * to do translation when necessary */ if (id.indexOf('<') > 0) { JavaType t = TypeFactory.fromCanonical(id); // note: may want to try combining with specialization (esp for EnumMap) return t; } try { Class<?> cls = ClassUtil.findClass(id); return _typeFactory.constructSpecializedType(_baseType, cls); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Invalid type id '"+id+"' (for id type 'Id.class'): no such class found"); } catch (Exception e) { throw new IllegalArgumentException("Invalid type id '"+id+"' (for id type 'Id.class'): "+e.getMessage(), e); } }
@Override public Class<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken curr = jp.getCurrentToken(); // Currently will only accept if given simple class name if (curr == JsonToken.VALUE_STRING) { String className = jp.getText(); try { return ClassUtil.findClass(className); } catch (ClassNotFoundException e) { throw ctxt.instantiationException(_valueClass, e); } } throw ctxt.mappingException(_valueClass, curr); } }
protected Class<?> findClass(String className, MyTokenizer tokens) { try { return ClassUtil.findClass(className); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw _problem(tokens, "Can not locate class '"+className+"', problem: "+e.getMessage()); } }
@Override public JavaType typeFromId(String id) { /* 30-Jan-2010, tatu: Most ids are basic class names; so let's first * check if any generics info is added; and only then ask factory * to do translation when necessary */ if (id.indexOf('<') > 0) { JavaType t = TypeFactory.fromCanonical(id); // note: may want to try combining with specialization (esp for EnumMap) return t; } try { Class<?> cls = ClassUtil.findClass(id); return _typeFactory.constructSpecializedType(_baseType, cls); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Invalid type id '"+id+"' (for id type 'Id.class'): no such class found"); } catch (Exception e) { throw new IllegalArgumentException("Invalid type id '"+id+"' (for id type 'Id.class'): "+e.getMessage(), e); } }
protected Class<?> findClass(String className, MyTokenizer tokens) { try { return ClassUtil.findClass(className); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw _problem(tokens, "Can not locate class '"+className+"', problem: "+e.getMessage()); } }
@Override public JavaType typeFromId(String id) { /* 30-Jan-2010, tatu: Most ids are basic class names; so let's first * check if any generics info is added; and only then ask factory * to do translation when necessary */ if (id.indexOf('<') > 0) { JavaType t = TypeFactory.fromCanonical(id); // note: may want to try combining with specialization (esp for EnumMap) return t; } try { Class<?> cls = ClassUtil.findClass(id); return _typeFactory.constructSpecializedType(_baseType, cls); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Invalid type id '"+id+"' (for id type 'Id.class'): no such class found"); } catch (Exception e) { throw new IllegalArgumentException("Invalid type id '"+id+"' (for id type 'Id.class'): "+e.getMessage(), e); } }
@Override public Class<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken curr = jp.getCurrentToken(); // Currently will only accept if given simple class name if (curr == JsonToken.VALUE_STRING) { String className = jp.getText(); try { return ClassUtil.findClass(className); } catch (ClassNotFoundException e) { throw ctxt.instantiationException(_valueClass, e); } } throw ctxt.mappingException(_valueClass, curr); } }