Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Anchor
top
top

 



カスタムフォーマッターは、「com.hof.mi.interfaces.CustomFormatter」classの実装です。このclassには、以下の関数を実装しなくてはいけません。



これらのメソッドは、必要に応じて上書きすることができます。

...




関数定義

public abstract String getName();

...

Code Block
languagejava
public String getName() {
   return "My Formatter";
}

 

...





public abstract boolean acceptsNativeType(int type);

このメソッドは、フォーマッターが与えられたデータ型のフィールドをサポートする場合にtrueを返し、それ以外にはfalseを返します。サポートされている型の一覧は、付録に掲載されています。 



例1:

Code Block
languagejava
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
languagejava
public boolean acceptsNativeType(int type) {
 
// we can handle any type
return true;
}

 



public abstract String render(Object value, int renderType) throws Exception;

...

Code Block
languagejava
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を返します。

 

 

...



前項:フォーマッターの前提条件

...

...

 

...

width30%

後項:HTMLの組み込み

...