Anchor | ||||
---|---|---|---|---|
|
カスタムフォーマッターは、「com.hof.mi.interfaces.CustomFormatter」classの実装です。このclassには、以下の関数を実装しなくてはいけません。
- public abstract String getName();
- public abstract boolean acceptsNativeType(int type);
- public abstract String render(Object value, int renderType) throws Exception;
これらのメソッドは、必要に応じて上書きすることができます。
- public boolean returnsHtml();
- public boolean compareConditionalAgainstFormattedValue();
...
関数定義
public abstract String getName();
...
Code Block | ||
---|---|---|
| ||
public String getName() { return "My Formatter"; } |
...
public abstract boolean acceptsNativeType(int type);
このメソッドは、フォーマッターが与えられたデータ型のフィールドをサポートする場合にtrueを返し、それ以外にはfalseを返します。サポートされている型の一覧は、付録に掲載されています。
例1:
Code Block | ||
---|---|---|
| ||
public boolean acceptsNativeType(int type) { //accept text and numeric data if (type == TYPE_TEXT || type == TYPE_NUMERIC) { return true; } else { //don't allow any other types return false; } } |
例2:
Code Block | ||
---|---|---|
| ||
public boolean acceptsNativeType(int type) { // we can handle any type return true; } |
public abstract String render(Object value, int renderType) throws Exception;
...
Code Block | ||
---|---|---|
| ||
public String render(Object value, int renderType) throws Exception { if (value == null) return null if (renderType == RENDER_LINK) // Render the value for a drill-through link. // In this case you almost always want to return a generic // representation of the value. return value.toString(); } // Return the formatted value return "Value: " + value.toString(); } |
...
public boolean returnsHtml();
...
この関数は、このフォーマッターを使用するフィールドが条件付き書式と書式設定された値を比較する必要がある場合はtrue、それ以外の場合はfalseを返します。デフォルトでは、この関数はfalseを返します。
...
前項:フォーマッターの前提条件
...
...
...
width | 30% |
---|
後項:HTMLの組み込み
...