protected T newResultObject() { return Classes.newInstance(resultType); }
public static <T> Method getAccessorMethod(Class<T> aClass, String... aMaybeNames) { Set<String> _names = new LinkedHashSet<String>(); for (String _s : aMaybeNames) { String _suffix = removeHyphensAndUpperCaseFirstLetters(_s); for (String _prefix : ACCESSOR_PREFIXES) { _names.add(_prefix + _suffix); } } for (String _s : ACCESSOR_PREFIXES) { _names.add(_s); } return getMethod(aClass, _names, false); }
public static <T> T newDynamicProxy(Class<T> aClass) { if (Iterable.class.isAssignableFrom(aClass)) { return newListBasedProxy(aClass); } else { return newMapBasedProxy(aClass); } }
public static <T> T newInstance(Class<T> aClass) { try { if (aClass.isInterface()) { return (T) newDynamicProxy(aClass); } else { return (T) aClass.newInstance(); } } catch (Exception anExc) { throw new ParsingException(anExc); } }
private Method getMethod(Class<?> aContextType, String... aMaybeNames) { Method _m = Classes.getMutatorMethod(aContextType, aMaybeNames); Class<?>[] _params = _m.getParameterTypes(); if ((_params.length == 1) || (Classes.MAGIC_SET.equals(_m.getName()) && _params.length==2)) { return _m; } else { throw new NoSuitableMethodException("Mutator method " + aContextType.getSimpleName() + "." + _m.getName() + " should accept 1 param, but wants " + _params.length); } } }
String _classname = (aContextClass.isAnonymousClass() || aContextClass.isSynthetic() || aContextClass.getName().matches(".*\\$Proxy.*")) ? asString(aContextClass, aContextClass.getInterfaces()) : aContextClass.getName();
public ValueSetter(ConverterRegistry aConverters, Class<?> aContextType, Class<?> aValueType, String... aMaybeNames) { setter = getMethod(aContextType, aMaybeNames); getter = Classes.getAccessorMethod(aContextType, aMaybeNames); if (getter != null) { if (aValueType != null) { converter = aConverters.getConverter(aValueType); } else { converter = aConverters.getConverter(getter.getReturnType()); } } else { if (aValueType != null) { converter = aConverters.getConverter(aValueType); } else { converter = aConverters.getConverter(setter.getParameterTypes()[0]); } } twoArgSetter = (setter.getParameterTypes().length == 2); }
private T newContextObject() { try { if (type.isInterface()) { return (T) Classes.newDynamicProxy(type); } else { return (T) type.newInstance(); } } catch (Exception anExc) { throw new ParsingException(anExc); } }
public static <T> Method getMutatorMethod(Class<T> aContextClass, String... aMaybeNames) { Set<String> _names = new LinkedHashSet<String>(); for (String _s : aMaybeNames) { String _suffix = removeHyphensAndUpperCaseFirstLetters(_s); for (String _prefix : MUTATOR_PREFIXES) { _names.add(_prefix + _suffix); } } for (String _s : MUTATOR_PREFIXES) { _names.add(_s); } _names.add(MAGIC_SET); // always look for the magic set method for dynamic proxies return getMethod(aContextClass, _names, true); }
public TagHandler<?> moveDown(String aQName, Attributes anAttributes, Context aCtx) { try { if (modelType != null) { R _model = Classes.newInstance(modelType); aCtx.push(_model); } if (attributes != null) attributes.handle(aCtx, aCtx.peek(), anAttributes); return this; } catch (ParsingException anExc) { throw anExc; } catch (Exception anExc) { throw new ParsingException(anExc); } }