You can use instance of, do a cast, and then contruct the right Value (or LongValue in the case of a Long/long) and then set a slot with that value.

Source code examples help, so here ya go:
    public static void insertFactFromTemplateNameAndSlotValueMap(Rete engine, Deftemplate t,
                        String slot, Object value, boolean asSymbol) throws Exception {
        Value v = null;
        if (value instanceof Long) {
            long l = ((Long) value).longValue();
            if (asSymbol) {
                v = new Value(l, RU.SYMBOL);
            } else {
                v = new LongValue(l);
            }
        }
        else if (value instanceof Integer) {
            int i = ((Integer) value).intValue();
            if (asSymbol) {
                v = new Value(i, RU.SYMBOL);
            } else {
                v = new Value(((Integer) value).intValue(), RU.LONG);
            }
        }
        else if (value instanceof String) {
            String s = ((String) value).toString();
            if (asSymbol) {
                v = new Value(s, RU.SYMBOL);
            } else {
                v = new Value(s, RU.STRING);
            }
        }

        Fact factToInsert = new Fact(t);
        factToInsert.setSlotValue(slot, v);
        engine.assertFact(factToInsert);
    }   

On 11/18/05, Yura <[EMAIL PROTECTED]> wrote:
Hi jess-users
 
Is there any way to convert Java object to one of the predefined Jess types (e.g. I need to convert Object which is actually Integer to RU.INTEGER).
 
Yuri

Reply via email to