public Object exec(List arguments) throws TemplateModelException { ObjectWrapper ow = env.getObjectWrapper(); BeansWrapper bw = ow instanceof BeansWrapper ? (BeansWrapper) ow : BeansWrapper.getDefaultInstance(); return bw.newInstance(cl, arguments); } }
public Object exec(List args) throws TemplateModelException { if (args.isEmpty()) { throw new TemplateModelException("This method must have at least one argument, the name of the class to instantiate."); } String classname = args.get(0).toString(); Class cl = null; try { cl = ClassUtil.forName(classname); } catch (Exception e) { throw new TemplateModelException(e.getMessage()); } BeansWrapper bw = BeansWrapper.getDefaultInstance(); Object obj = bw.newInstance(cl, args.subList(1, args.size())); return bw.wrap(obj); } }
private Object callConstructor(Class cl) throws _ObjectBuilderSettingEvaluationException { if (hasNoParameters()) { // No need to create ObjectWrapper try { return cl.newInstance(); } catch (Exception e) { throw new _ObjectBuilderSettingEvaluationException( "Failed to call " + cl.getName() + " 0-argument constructor", e); } } else { BeansWrapper ow = env.getObjectWrapper(); List/*<TemplateModel>*/ tmArgs = new ArrayList(positionalParamValues.size()); for (int i = 0; i < positionalParamValues.size(); i++) { try { tmArgs.add(ow.wrap(positionalParamValues.get(i))); } catch (TemplateModelException e) { throw new _ObjectBuilderSettingEvaluationException("Failed to wrap arg #" + (i + 1), e); } } try { return ow.newInstance(cl, tmArgs); } catch (Exception e) { throw new _ObjectBuilderSettingEvaluationException( "Failed to call " + cl.getName() + " constructor", e); } } }
public Object exec(List arguments) throws TemplateModelException { ObjectWrapper ow = env.getObjectWrapper(); BeansWrapper bw = ow instanceof BeansWrapper ? (BeansWrapper) ow : BeansWrapper.getDefaultInstance(); return bw.newInstance(cl, arguments); } }
public Object exec(List arguments) throws TemplateModelException { ObjectWrapper ow = env.getObjectWrapper(); BeansWrapper bw = ow instanceof BeansWrapper ? (BeansWrapper) ow : BeansWrapper.getDefaultInstance(); return bw.newInstance(cl, arguments); } }
public Object exec(List arguments) throws TemplateModelException { ObjectWrapper ow = env.getObjectWrapper(); BeansWrapper bw = ow instanceof BeansWrapper ? (BeansWrapper)ow : BeansWrapper.getDefaultInstance(); return bw.newInstance(cl, arguments); } }
public Object exec(List args) throws TemplateModelException { if (args.isEmpty()) { throw new TemplateModelException("This method must have at least one argument, the name of the class to instantiate."); } String classname = args.get(0).toString(); Class cl = null; try { cl = ClassUtil.forName(classname); } catch (Exception e) { throw new TemplateModelException(e.getMessage()); } BeansWrapper bw = BeansWrapper.getDefaultInstance(); Object obj = bw.newInstance(cl, args.subList(1, args.size())); return bw.wrap(obj); } }
public Object exec(List args) throws TemplateModelException { if (args.isEmpty()) { throw new TemplateModelException("This method must have at least one argument, the name of the class to instantiate."); } String classname = args.get(0).toString(); Class cl = null; try { cl = ClassUtil.forName(classname); } catch (Exception e) { throw new TemplateModelException(e.getMessage()); } BeansWrapper bw = BeansWrapper.getDefaultInstance(); Object obj = bw.newInstance(cl, args.subList(1, args.size())); return bw.wrap(obj); } }
public Object exec(List args) throws TemplateModelException { if (args.isEmpty()) { throw new TemplateModelException("This method must have at least one argument, the name of the class to instantiate."); } String classname = args.get(0).toString(); Class cl = null; try { cl = ClassUtil.forName(classname); } catch (Exception e) { throw new TemplateModelException(e.getMessage()); } BeansWrapper bw = BeansWrapper.getDefaultInstance(); Object obj = bw.newInstance(cl, args.subList(1, args.size())); return bw.wrap(obj); } }
private Object callConstructor(Class cl) throws _ObjectBuilderSettingEvaluationException { if (hasNoParameters()) { // No need to create ObjectWrapper try { return cl.newInstance(); } catch (Exception e) { throw new _ObjectBuilderSettingEvaluationException( "Failed to call " + cl.getName() + " 0-argument constructor", e); } } else { BeansWrapper ow = env.getObjectWrapper(); List/*<TemplateModel>*/ tmArgs = new ArrayList(positionalParamValues.size()); for (int i = 0; i < positionalParamValues.size(); i++) { try { tmArgs.add(ow.wrap(positionalParamValues.get(i))); } catch (TemplateModelException e) { throw new _ObjectBuilderSettingEvaluationException("Failed to wrap arg #" + (i + 1), e); } } try { return ow.newInstance(cl, tmArgs); } catch (Exception e) { throw new _ObjectBuilderSettingEvaluationException( "Failed to call " + cl.getName() + " constructor", e); } } }
private Object callConstructor(Class cl) throws _ObjectBuilderSettingEvaluationException { if (hasNoParameters()) { // No need to create ObjectWrapper try { return cl.newInstance(); } catch (Exception e) { throw new _ObjectBuilderSettingEvaluationException( "Failed to call " + cl.getName() + " 0-argument constructor", e); } } else { BeansWrapper ow = env.getObjectWrapper(); List/*<TemplateModel>*/ tmArgs = new ArrayList(positionalParamValues.size()); for (int i = 0; i < positionalParamValues.size(); i++) { try { tmArgs.add(ow.wrap(positionalParamValues.get(i))); } catch (TemplateModelException e) { throw new _ObjectBuilderSettingEvaluationException("Failed to wrap arg #" + (i + 1), e); } } try { return ow.newInstance(cl, tmArgs); } catch (Exception e) { throw new _ObjectBuilderSettingEvaluationException( "Failed to call " + cl.getName() + " constructor", e); } } }