How to change the "?" representation for a missing cell?

Hi forum,

how can I change the representation of missing cells in an output table?  By default, they are shown as "?"

I did not find something like a MissingValueRenderer.  The question mark string comes from MissingCell.toString(), correct?

I thought of maybe deriving MissingCell in order to override toString(), would this be feasible?

Thanks for all tips, Frank

Now after having tried this and that, I think I have understood the concept of the DataValueRenderers.  Each table column gets a renderer, suitable to the column's data type.  That's the reason why there is no "MissingValueRenderer", because a column with data type MissingValue wouldn't make that much sense ...

So each single renderer has to take care of the special case "MissingValue".  Either it is handled in some special adapted way for this renderer, or it uses just the fallback MissingValue.toString(), which returns "?"

So, I derived a new Renderer from DataValueRenderer, which handles DoubleValues just like the standard double renderer, but gives the empty string for MissingValue:

    @Override
    protected void setValue(Object value) {
        Object newValue = value;
        if (value instanceof DoubleValue) {
            newValue = NumberFormat.getInstance(Locale.US).format(
                    ((DoubleValue) value).getDoubleValue());
        }
        else if (value instanceof MissingValue) {
            newValue = "";
        }
        super.setValue(newValue);
    }

So, thanks for your attention, maybe it helps the one or the other who has the same issue.  I love answering my own questions ... ;)

1 Like

just marking as solved :-)