当前位置: 首页>>代码示例>>Java>>正文


Java ValueFactory.newMap方法代码示例

本文整理汇总了Java中org.msgpack.value.ValueFactory.newMap方法的典型用法代码示例。如果您正苦于以下问题:Java ValueFactory.newMap方法的具体用法?Java ValueFactory.newMap怎么用?Java ValueFactory.newMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.msgpack.value.ValueFactory的用法示例。


在下文中一共展示了ValueFactory.newMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitMap_DropColumns

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visitMap_DropColumns()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "drop_columns:",
            "  - {name: $.json1.k1.k1}",
            "  - {name: $.json1.k2}");
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .add("json2", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k1":{"k1":"v"},"k2":{"k2":"v"}}
    Value k1 = ValueFactory.newString("k1");
    Value k2 = ValueFactory.newString("k2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newMap(k1, v),
            k2, ValueFactory.newMap(k2, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k1\":{}}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:26,代码来源:TestJsonVisitor.java

示例2: visitMap_AddColumns

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visitMap_AddColumns()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "add_columns:",
            "  - {name: $.json1.k3.k3, type: string, default: v}",
            "  - {name: $.json1.k4, src: $.json1.k2}");
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .add("json2", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k1":{"k1":"v"},"k2":{"k2":"v"}}
    Value k1 = ValueFactory.newString("k1");
    Value k2 = ValueFactory.newString("k2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newMap(k1, v),
            k2, ValueFactory.newMap(k2, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k1\":{\"k1\":\"v\"},\"k2\":{\"k2\":\"v\"},\"k3\":{\"k3\":\"v\"},\"k4\":{\"k2\":\"v\"}}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:26,代码来源:TestJsonVisitor.java

示例3: visitMap_dropColumnsUsingBracketNotation

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visitMap_dropColumnsUsingBracketNotation()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "drop_columns:",
            "  - {name: \"$['json1']['k1']['k1']\"}",
            "  - {name: \"$['json1']['k2']\"}");
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .add("json2", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k1":{"k1":"v"},"k2":{"k2":"v"}}
    Value k1 = ValueFactory.newString("k1");
    Value k2 = ValueFactory.newString("k2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newMap(k1, v),
            k2, ValueFactory.newMap(k2, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k1\":{}}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:26,代码来源:TestJsonVisitor.java

示例4: visitMap_addColumnsUsingBracketNotation

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visitMap_addColumnsUsingBracketNotation()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "add_columns:",
            "  - {name: \"$['json1']['k3']['k3']\", type: string, default: v}",
            "  - {name: \"$['json1']['k4']\", src: \"$['json1']['k2']\"}");
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .add("json2", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k1":{"k1":"v"},"k2":{"k2":"v"}}
    Value k1 = ValueFactory.newString("k1");
    Value k2 = ValueFactory.newString("k2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newMap(k1, v),
            k2, ValueFactory.newMap(k2, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k1\":{\"k1\":\"v\"},\"k2\":{\"k2\":\"v\"},\"k3\":{\"k3\":\"v\"},\"k4\":{\"k2\":\"v\"}}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:26,代码来源:TestJsonVisitor.java

示例5: visitMap_columnsUsingBracketNotation

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visitMap_columnsUsingBracketNotation()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "columns:",
            "  - {name: \"$['json1']['k1']\"}",
            "  - {name: \"$['json1']['k2']['k2']\"}",
            "  - {name: \"$['json1']['k3']['k3']\", type: string, default: v}",
            "  - {name: \"$['json1']['k4']\", src: \"$['json1']['k2']\"}");
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k1":{"k1":"v"},"k2":{"k1":"v","k2":"v"}}
    Value k1 = ValueFactory.newString("k1");
    Value k2 = ValueFactory.newString("k2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newMap(k1, v),
            k2, ValueFactory.newMap(k2, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k1\":{\"k1\":\"v\"},\"k2\":{\"k2\":\"v\"},\"k3\":{\"k3\":\"v\"},\"k4\":{\"k2\":\"v\"}}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:27,代码来源:TestJsonVisitor.java

示例6: visitArray_dropColumnsUsingBracketNotation

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visitArray_dropColumnsUsingBracketNotation()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "drop_columns:",
            "  - {name: \"$['json1']['k1'][0]['k1']\"}",
            "  - {name: \"$['json1']['k2'][*]\"}"); // ending with [*] is allowed for drop_columns, but not for others
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .add("json2", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k1":[{"k1":"v"}[,"k2":["v","v"]}
    Value k1 = ValueFactory.newString("k1");
    Value k2 = ValueFactory.newString("k2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newArray(ValueFactory.newMap(k1, v)),
            k2, ValueFactory.newArray(v, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k1\":[{}],\"k2\":[]}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:26,代码来源:TestJsonVisitor.java

示例7: visitArray_addColumnsUsingBracketNotation

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visitArray_addColumnsUsingBracketNotation()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "add_columns:",
            "  - {name: \"$['json1']['k1'][1]\", src: \"$['json1']['k1'][0]\"}",
            "  - {name: \"$['json1']['k3'][0]['k3']\", type: string, default: v}");
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .add("json2", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k1":[{"k1":"v"}],"k2":["v","v"]}
    Value k1 = ValueFactory.newString("k1");
    Value k2 = ValueFactory.newString("k2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newArray(ValueFactory.newMap(k1, v)),
            k2, ValueFactory.newArray(v, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k1\":[{\"k1\":\"v\"},{\"k1\":\"v\"}],\"k2\":[\"v\",\"v\"],\"k3\":[{\"k3\":\"v\"}]}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:26,代码来源:TestJsonVisitor.java

示例8: visitArray_columnsUsingBracketNotation

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visitArray_columnsUsingBracketNotation()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "columns:",
            "  - {name: \"$['json1']['k1'][1]\", src: \"$['json1']['k1'][0]\"}",
            "  - {name: \"$['json1']['k2'][0]\"}",
            "  - {name: \"$['json1']['k3'][0]['k3']\", type: string, default: v}");
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k1":[{"k1":"v"},"v"],"k2":["v","v"]}
    Value k1 = ValueFactory.newString("k1");
    Value k2 = ValueFactory.newString("k2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newArray(ValueFactory.newMap(k1, v), v),
            k2, ValueFactory.newArray(v, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k1\":[{\"k1\":\"v\"}],\"k2\":[\"v\"],\"k3\":[{\"k3\":\"v\"}]}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:26,代码来源:TestJsonVisitor.java

示例9: visit_withDotAndBracket

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visit_withDotAndBracket()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "columns:",
            " - {name: \"$.json1['k_1']\"}",
            " - {name: \"$.json1['k_1'][0]['k_1']\"}",
            " - {name: \"$['json1']['k_2']\"}",
            " - {name: \"$['json1']['k_2']['k_2']\"}");
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k.1":[{"k.1":"v"}], "k.2":{"k.2":"v"}}
    Value k1 = ValueFactory.newString("k_1");
    Value k2 = ValueFactory.newString("k_2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newArray(ValueFactory.newMap(k1, v)),
            k2, ValueFactory.newMap(k2, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k_1\":[{\"k_1\":\"v\"}],\"k_2\":{\"k_2\":\"v\"}}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:27,代码来源:TestJsonVisitor.java

示例10: visit_withSingleQuotesAndDoubleQuotes

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visit_withSingleQuotesAndDoubleQuotes()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "columns:",
            " - {name: \"$['json1']['k_1']\", src: \"$['json1']['k.1']\"}",
            " - {name: '$[\"json1\"][\"k_1\"][0][\"k_1\"]', src: '$[\"json1\"][\"k_1\"][0][\"k.1\"]'}",
            " - {name: '$[\"json1\"][\"k_2\"]', src: '$[\"json1\"][\"k.2\"]'}",
            " - {name: '$[\"json1\"][\"k_2\"][\"k_2\"]', src: '$[\"json1\"][\"k_2\"][\"k.2\"]'}");
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k.1":[{"k.1":"v"}], "k.2":{"k.2":"v"}}
    Value k1 = ValueFactory.newString("k.1");
    Value k2 = ValueFactory.newString("k.2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newArray(ValueFactory.newMap(k1, v)),
            k2, ValueFactory.newMap(k2, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k_1\":[{\"k_1\":\"v\"}],\"k_2\":{\"k_2\":\"v\"}}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:27,代码来源:TestJsonVisitor.java

示例11: visit_withComplexRename

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visit_withComplexRename()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "columns:",
            " - {name: \"$.json1['k____1']\", src: \"$.json1['k.-=+1']\"}",
            " - {name: \"$.json1['k____1'][0]['k____1']\", src: \"$.json1['k____1'][0]['k.-=+1']\"}",
            " - {name: \"$['json1']['k_2']\", src: \"$['json1']['k.2']\"}",
            " - {name: \"$['json1']['k_2']['k_2']\", src: \"$['json1']['k_2']['k.2']\"}");
    Schema inputSchema = Schema.builder()
            .add("json1", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k.1":[{"k.1":"v"}], "k.2":{"k.2":"v"}}
    Value k1 = ValueFactory.newString("k.-=+1");
    Value k2 = ValueFactory.newString("k.2");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(
            k1, ValueFactory.newArray(ValueFactory.newMap(k1, v)),
            k2, ValueFactory.newMap(k2, v));

    MapValue visited = subject.visit("$['json1']", map).asMapValue();
    assertEquals("{\"k____1\":[{\"k____1\":\"v\"}],\"k_2\":{\"k_2\":\"v\"}}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:27,代码来源:TestJsonVisitor.java

示例12: visit_withColumnNameIncludingSingleQuotes

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Test
public void visit_withColumnNameIncludingSingleQuotes()
{
    PluginTask task = taskFromYamlString(
            "type: column",
            "columns:",
            " - {name: \"$['\\\\'json1']['k1']\"}");
    Schema inputSchema = Schema.builder()
            .add("'json1", JSON)
            .build();
    JsonVisitor subject = jsonVisitor(task, inputSchema);

    // {"k1":"v"}
    Value k1 = ValueFactory.newString("k1");
    Value v = ValueFactory.newString("v");
    Value map = ValueFactory.newMap(k1, v);

    MapValue visited = subject.visit("$['\\'json1']", map).asMapValue();
    assertEquals("{\"k1\":\"v\"}", visited.toString());
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:21,代码来源:TestJsonVisitor.java

示例13: createResource

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Before
public void createResource()
{
    Value[] kvs = new Value[2];
    kvs[0] = ValueFactory.newString("k");
    kvs[1] = ValueFactory.newString("v");
    value = ValueFactory.newMap(kvs);
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-parser-jsonpath,代码行数:9,代码来源:TestJsonCast.java

示例14: createResource

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Before
public void createResource()
{
    jruby = new ScriptingContainer();
    thrown = new DataException("any");
    Value[] kvs = new Value[2];
    kvs[0] = ValueFactory.newString("k");
    kvs[1] = ValueFactory.newString("v");
    mapValue = ValueFactory.newMap(kvs);
    parser = new TimestampParser(jruby, "%Y-%m-%d %H:%M:%S.%N", DateTimeZone.UTC);
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-parser-jsonpath,代码行数:12,代码来源:TestColumnCaster.java

示例15: visitObjectWithPair

import org.msgpack.value.ValueFactory; //导入方法依赖的package包/类
@Override
public Value visitObjectWithPair(JSONParser.ObjectWithPairContext ctx)
{
    Map<Value, Value> map = new HashMap<>();

    for (JSONParser.PairContext pair : ctx.pair()) {
        Value key = ValueFactory.newString(trimQuote(pair.STRING().getText()));
        Value value = visit(pair.value());
        map.put(key, value);
    }
    return ValueFactory.newMap(map);
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-filter-build_json,代码行数:13,代码来源:BuildJsonParseTreeVisitor.java


注:本文中的org.msgpack.value.ValueFactory.newMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。