@Test public void testExec() throws TemplateModelException { System.out.println("exec"); LocalisedMessages instance = new LocalisedMessages("messages", Locale.ENGLISH); String expResult = "Generated from TESZT database table."; String result = (String) instance.exec(Arrays.asList(new SimpleScalar("generatedFrom"), new SimpleScalar("TESZT"))); assertEquals(expResult, result); }
@Override public Object exec(List arguments) throws TemplateModelException { if (arguments.size() < 1) { throw new TemplateModelException("Wrong number of arguments"); } String key = ((SimpleScalar) arguments.get(0)).getAsString(); if (key == null || key.isEmpty()) { throw new TemplateModelException("Invalid key value '" + key + "'"); } Object[] argsAll = arguments.toArray(); Object[] args = Arrays.copyOfRange(argsAll, 1, argsAll.length); return this.getMessage(key, args); }
LocalisedMessages implements TemplateMethodModelEx { @Override public Object exec(List arguments) throws TemplateModelException { if (arguments.size() < 1) { throw new TemplateModelException("Wrong number of arguments"); } String key = ((SimpleScalar) arguments.get(0)).getAsString(); if (key == null || key.isEmpty()) { throw new TemplateModelException("Invalid key value '" + key + "'"); } Object[] argsAll = arguments.toArray(); Object[] args = Arrays.copyOfRange(argsAll, 1, argsAll.length); return this.getMessage(key, args); } }
LocalisedMessages implements TemplateMethodModelEx { @Override public Object exec(List arguments) throws TemplateModelException { if (arguments.size() < 1) { throw new TemplateModelException("Wrong number of arguments"); } String key = ((SimpleScalar) arguments.get(0)).getAsString(); if (key == null || key.isEmpty()) { throw new TemplateModelException("Invalid key value '" + key + "'"); } Object[] argsAll = arguments.toArray(); Object[] args = Arrays.copyOfRange(argsAll, 1, argsAll.length); return this.getMessage(key, args); } LocalisedMessages(String bundleResourceName, Locale locale); }
LocalisedMessages implements TemplateMethodModelEx { @Override public Object exec(List arguments) throws TemplateModelException { if (arguments.size() < 1) { throw new TemplateModelException("Wrong number of arguments"); } String key = ((SimpleScalar) arguments.get(0)).getAsString(); if (key == null || key.isEmpty()) { throw new TemplateModelException("Invalid key value '" + key + "'"); } Object[] argsAll = arguments.toArray(); Object[] args = Arrays.copyOfRange(argsAll, 1, argsAll.length); return this.getMessage(key, args); } LocalisedMessages(String bundleResourceName, Locale locale); String getMessage(String key, Object... args); @Override Object exec(List arguments); }
LocalisedMessages implements TemplateMethodModelEx { @Override public Object exec(List arguments) throws TemplateModelException { if (arguments.size() < 1) { throw new TemplateModelException("Wrong number of arguments"); } String key = ((SimpleScalar) arguments.get(0)).getAsString(); if (key == null || key.isEmpty()) { throw new TemplateModelException("Invalid key value '" + key + "'"); } Object[] argsAll = arguments.toArray(); Object[] args = Arrays.copyOfRange(argsAll, 1, argsAll.length); return this.getMessage(key, args); } LocalisedMessages(String bundleResourceName, Locale locale); String getMessage(String key, Object... args); @Override Object exec(List arguments);  }