Like what you see? Have a play with our trial version.

Versions Compared

Key

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

Anchor
top
 
 
top

View level converters must extend the abstract class com.hof.mi.interfaces.ConverterConfiguration UI and persistence is available through the normal UserInputParameters API. You can see the documentation on this API <here> here.

There are several required methods to implement The following methods need to be implemented in order to create a view level converter:

 

 

 

Anchor
getName
getName

public String getName()

...

 

Styleclass
ClasstopLink

top



 

Anchor
acceptsNativeType
acceptsNativeType

 

...

 

Below is an example of a TextToNumericConverter implementing this method:

Code Block
languagejava
themeEclipse
@Override
public boolean acceptsNativeType(int type) {
    if (type == UserInputParameters.TYPE_TEXT) {
        return true;
    } else {
        return false;
    }
}

 

 

...

Here's a simple TextToNumericConverter example using this method:
Code Block
languagejava
themeEclipse
@Override
public int getReturnType() {
    return UserInputParameters.TYPE_NUMERIC;
}

 

 

Styleclass
ClasstopLink

top

...

  • TYPE_NUMERIC

    • BigDecimal

    • BigInteger

    • Other basic Java numeric data types which extend Number

  • TYPE_DATE

    • java.util.Date

    • java.sql.Date

  • TYPE_TIMESTAMP

    • java.sql.Timestamp

 

This method may throw an exception if the data type conversion fails in a way which would indicate that the converter was set up incorrectly, but if the conversion fails for generic reasons such as the data type could not be rectified, or the value was null, then it is accepted to return null.


The Text The TextToNumericConverter example using this method:

 

Code Block
languagejava
themeEclipse
@Override
public Object convertObject(Object data) {
   if (data == null) return null;
   try {
      return new BigDecimal((String)data);
   }  catch (NumberFormatException e) {
      return null;
   }
}

 

 

Styleclass
ClasstopLink

top


Anchor
convertObjReverse
convertObjReverse

public Object convertObjectReverse(Object data) throws Exception

This method is used in order for Yellowfin to retrieve the initial values of a converted data set after-the-fact. It should perform the opposite conversion which was applied in convertObject and will receive an object of the type specified as the return type of this Converter.


 

Code Block
languagejava
themeEclipse
@Override
public Object convertObjectReverse(Object data) {
   if (data == null) return null;
   return data.toString();
}

 

 

Styleclass
ClasstopLink

top

 

 

 

Section
Column
width75

Previous topic: Converter overview

Column

Next topic: Data transformation extras