/** @see com.pureinfo.dolphin.script.execute.IContext#getFormatterHandler(java.lang.String) */ public IFormatterHandler getFormatterHandler(String _sFormatterId) throws PureException { if (m_parent != null) { IFormatterHandler handler = m_parent.getFormatterHandler(_sFormatterId); if (handler != null) return handler; } // else FormatterMetadata metadata = FormatterHelper.getFormatter(_sFormatterId); if (metadata == null) return null; // else try { IFormatterHandler handler = (IFormatterHandler) Class.forName(metadata.getClassName()).newInstance(); handler.config(new HashMap(0)); return handler; } catch (Exception ex) { throw new PureException(ScriptExceptionTypes.ILLEGAL_FORMATTER_TYPE, _sFormatterId, ex); } }
public void testGetFormatterHandler() throws PureException { SimpleContext context = new SimpleContext(); IFormatterHandler handler = context.getFormatterHandler("html"); String sResult = handler.format("hello abc <a>"); assertEquals("hello abc <a>", sResult); }