Search in sources :

Example 26 with Dict

use of cn.hutool.core.lang.Dict in project Jpom by dromara.

the class DbExtConfig method parse.

public static DbExtConfig parse(InputStream inputStream) {
    Dict dict = YamlUtil.load(inputStream, Dict.class);
    Object db = dict.get("db");
    StringWriter writer = new StringWriter();
    YamlUtil.dump(db, writer);
    ByteArrayInputStream byteArrayInputStream = IoUtil.toStream(writer.toString(), CharsetUtil.CHARSET_UTF_8);
    return YamlUtil.load(byteArrayInputStream, DbExtConfig.class);
}
Also used : StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) Dict(cn.hutool.core.lang.Dict)

Example 27 with Dict

use of cn.hutool.core.lang.Dict in project hutool by dromara.

the class ConsoleLog method log.

// ------------------------------------------------------------------------- Log
@Override
public void log(String fqcn, Level level, Throwable t, String format, Object... arguments) {
    // fqcn 无效
    if (false == isEnabled(level)) {
        return;
    }
    final Dict dict = Dict.create().set("date", DateUtil.now()).set("level", level.toString()).set("name", this.name).set("msg", StrUtil.format(format, arguments));
    final String logMsg = StrUtil.format(logFormat, dict);
    // WARN以上级别打印至System.err
    if (level.ordinal() >= Level.WARN.ordinal()) {
        Console.error(t, logMsg);
    } else {
        Console.log(t, logMsg);
    }
}
Also used : Dict(cn.hutool.core.lang.Dict)

Example 28 with Dict

use of cn.hutool.core.lang.Dict in project hutool by dromara.

the class ExpressionUtilTest method rhinoTest.

@Test
public void rhinoTest() {
    ExpressionEngine engine = new RhinoEngine();
    final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
    final Object eval = engine.eval("a-(b-c)", dict);
    Assert.assertEquals(-143.8, (double) eval, 2);
}
Also used : Dict(cn.hutool.core.lang.Dict) RhinoEngine(cn.hutool.extra.expression.engine.rhino.RhinoEngine) Test(org.junit.Test)

Example 29 with Dict

use of cn.hutool.core.lang.Dict in project hutool by dromara.

the class ExpressionUtilTest method mvelTest.

@Test
public void mvelTest() {
    ExpressionEngine engine = new MvelEngine();
    final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
    final Object eval = engine.eval("a-(b-c)", dict);
    Assert.assertEquals(-143.8, (double) eval, 2);
}
Also used : MvelEngine(cn.hutool.extra.expression.engine.mvel.MvelEngine) Dict(cn.hutool.core.lang.Dict) Test(org.junit.Test)

Example 30 with Dict

use of cn.hutool.core.lang.Dict in project hutool by dromara.

the class ExpressionUtilTest method jfireELTest.

@Test
public void jfireELTest() {
    ExpressionEngine engine = new JfireELEngine();
    final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
    final Object eval = engine.eval("a-(b-c)", dict);
    Assert.assertEquals(-143.8, (double) eval, 2);
}
Also used : Dict(cn.hutool.core.lang.Dict) JfireELEngine(cn.hutool.extra.expression.engine.jfireel.JfireELEngine) Test(org.junit.Test)

Aggregations

Dict (cn.hutool.core.lang.Dict)32 Test (org.junit.Test)24 File (java.io.File)4 FileWriter (java.io.FileWriter)3 Writer (java.io.Writer)3 ArrayList (java.util.ArrayList)3 BaseTest (cn.e3mall.common.freemarker.BaseTest)2 JexlEngine (cn.hutool.extra.expression.engine.jexl.JexlEngine)2 JfireELEngine (cn.hutool.extra.expression.engine.jfireel.JfireELEngine)2 MvelEngine (cn.hutool.extra.expression.engine.mvel.MvelEngine)2 RhinoEngine (cn.hutool.extra.expression.engine.rhino.RhinoEngine)2 SpELEngine (cn.hutool.extra.expression.engine.spel.SpELEngine)2 Configuration (freemarker.template.Configuration)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 StringWriter (java.io.StringWriter)2 Date (java.util.Date)2 List (java.util.List)2 Map (java.util.Map)2 Props (org.febit.wit.util.Props)2 Item (cn.e3mall.common.base.entity.Item)1