@Test public void testWithExtras() { LinkFormater lf = new LinkFormater("/bs/carman/edit?id={0}", "user") { @Override public Object[] getParams(Object context, Object value) { Object[] args = new Object[1]; args[0] = "111"; return args; } @Override public String getTaskbarTitle(Object context, Object value) { return "用户 - 张三"; } @Override public String getWinId(Object context, Object value) { return "user111"; } }; Object r = lf.format(null, "张三"); Assert.assertEquals( "<a href=\"/bs/carman/edit?id=111\" class=\"bc-link\" data-mtype=\"user\" data-title=\"用户 - 张三\" data-mid=\"user111\">张三</a>", r); }
public Object format(Object context, Object value) { if (!this.isLinkable(context, value)) { return value != null ? value.toString() : ""; } Object _value; if (value instanceof Formater) { _value = ((Formater<?>) value).format(context, value); } else { _value = value; } String label = this.getLinkText(context, value); if (label != null && label.length() > 0) { Object[] params = getParams(context, _value); String href = MessageFormat.format(this.urlPattern, params); return buildLinkHtml(label, href, this.getTaskbarTitle(context, value), this.moduleKey, this.getWinId(context, value)); } else { return "&nbsp;"; } }
LinkFormater extends AbstractFormater<Object> implements ExportText { public Object format(Object context, Object value) { if (!this.isLinkable(context, value)) { return value != null ? value.toString() : ""; } Object _value; if (value instanceof Formater) { _value = ((Formater<?>) value).format(context, value); } else { _value = value; } String label = this.getLinkText(context, value); if (label != null && label.length() > 0) { Object[] params = getParams(context, _value); String href = MessageFormat.format(this.urlPattern, params); return buildLinkHtml(label, href, this.getTaskbarTitle(context, value), this.moduleKey, this.getWinId(context, value)); } else { return "&nbsp;"; } } }
LinkFormater extends AbstractFormater<Object> implements ExportText { public Object format(Object context, Object value) { if (!this.isLinkable(context, value)) { return value != null ? value.toString() : ""; } Object _value; if (value instanceof Formater) { _value = ((Formater<?>) value).format(context, value); } else { _value = value; } String label = this.getLinkText(context, value); if (label != null && label.length() > 0) { Object[] params = getParams(context, _value); String href = MessageFormat.format(this.urlPattern, params); return buildLinkHtml(label, href, this.getTaskbarTitle(context, value), this.moduleKey, this.getWinId(context, value)); } else { return "&nbsp;"; } } LinkFormater();  LinkFormater(String urlPattern, String moduleKey); }
LinkFormater extends AbstractFormater<Object> implements ExportText { public Object format(Object context, Object value) { if (!this.isLinkable(context, value)) { return value != null ? value.toString() : ""; } Object _value; if (value instanceof Formater) { _value = ((Formater<?>) value).format(context, value); } else { _value = value; } String label = this.getLinkText(context, value); if (label != null && label.length() > 0) { Object[] params = getParams(context, _value); String href = MessageFormat.format(this.urlPattern, params); return buildLinkHtml(label, href, this.getTaskbarTitle(context, value), this.moduleKey, this.getWinId(context, value)); } else { return "&nbsp;"; } } LinkFormater();  LinkFormater(String urlPattern, String moduleKey); Object format(Object context, Object value); static String buildLinkHtml(String label, String href, String title, String mtype, String mid); abstract Object[] getParams(Object context, Object value); String getLinkText(Object context, Object value); String getExportText(Object context, Object value); String getTaskbarTitle(Object context, Object value); String getWinId(Object context, Object value); }
LinkFormater extends AbstractFormater<Object> implements ExportText { public Object format(Object context, Object value) { if (!this.isLinkable(context, value)) { return value != null ? value.toString() : ""; } Object _value; if (value instanceof Formater) { _value = ((Formater<?>) value).format(context, value); } else { _value = value; } String label = this.getLinkText(context, value); if (label != null && label.length() > 0) { Object[] params = getParams(context, _value); String href = MessageFormat.format(this.urlPattern, params); return buildLinkHtml(label, href, this.getTaskbarTitle(context, value), this.moduleKey, this.getWinId(context, value)); } else { return "&nbsp;"; } } LinkFormater();  LinkFormater(String urlPattern, String moduleKey); Object format(Object context, Object value); static String buildLinkHtml(String label, String href, String title, String mtype, String mid); abstract Object[] getParams(Object context, Object value); String getLinkText(Object context, Object value); String getExportText(Object context, Object value); String getTaskbarTitle(Object context, Object value); String getWinId(Object context, Object value);  }