com.addthis.bundle.core.Bundle.setValue()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中com.addthis.bundle.core.Bundle.setValue()方法的一些代码示例,展示了Bundle.setValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.setValue()方法的具体详情如下:
包路径:com.addthis.bundle.core.Bundle
类名称:Bundle
方法名:setValue

Bundle.setValue介绍

暂无

代码示例

代码示例来源:origin: addthis/hydra

@Override
public void setValue(BundleField field, ValueObject value) throws BundleException {
  mergedBundle.setValue(field, value);
}

代码示例来源:origin: addthis/hydra

public boolean updateBundle(Bundle bundle) {
  for (FieldValue fv : list) {
    bundle.setValue(fv.field, fv.value);
  }
  return list.size() > 0;
}

代码示例来源:origin: addthis/hydra

private static Bundle cloneBundle(Bundle input) {
  Bundle output = input.createBundle();
  Iterator<BundleField> fieldIterator = input.getFormat().iterator();
  while (fieldIterator.hasNext()) {
    BundleField field = fieldIterator.next();
    output.setValue(field, input.getValue(field));
  }
  return output;
}

代码示例来源:origin: addthis/hydra

private void bundleSetValue(Bundle bundle, String field, String value) {
  BundleFormat format = bundleLog.getFormat();
  bundle.setValue(format.getField(field), ValueFactory.create(value));
}

代码示例来源:origin: addthis/hydra

private void bundleSetValue(Bundle bundle, String field, boolean value) {
  BundleFormat format = bundleLog.getFormat();
  bundle.setValue(format.getField(field), ValueFactory.create(value ? 1 : 0));
}

代码示例来源:origin: addthis/hydra

protected void mergeBundles(Bundle orig, Bundle nBundle) {
  for (BundleField bf : nBundle) {
    orig.setValue(orig.getFormat().getField(bf.getName()), nBundle.getValue(bf));
  }
}

代码示例来源:origin: addthis/hydra

public Bundle createBundle(BundleFactory factory) {
  Bundle bundle = factory.createBundle();
  for (FieldValue fv : list) {
    bundle.setValue(bundle.getFormat().getField(fv.field.getName()), fv.value);
  }
  return bundle;
}

代码示例来源:origin: addthis/hydra

protected Bundle makeAltBundle(Bundle bundle) {
  ListBundleFormat format = new ListBundleFormat();
  Bundle alt = new ListBundle(format);
  for (int i = 0; i < columns.length; i++) {
    BundleField field = format.getField(columns[i]);
    alt.setValue(field, bundle.getValue(bundle.getFormat().getField(columns[i])));
  }
  return alt;
}

代码示例来源:origin: addthis/hydra

private Bundle mapBundle(Bundle in) {
  Bundle out = output.createBundle();
  if (map.fields != null) {
    for (FieldFilter fieldFilter : map.fields) {
      fieldFilter.mapField(in, out);
    }
  } else {
    for (BundleField bundleField : in) {
      out.setValue(out.getFormat().getField(bundleField.getName()), in.getValue(bundleField));
    }
  }
  return out;
}

代码示例来源:origin: addthis/hydra

@Test
public void noErrorsShouldBeThrown() {
  // there is no map
  builder.process(bundle, emitter);
  // map not a map
  bundle.setValue(bundle.getFormat().getField("foo"), ValueFactory.create("notamap"));
  builder.process(bundle, emitter);
  verify(emitter, never()).emit(any());
}

代码示例来源:origin: addthis/hydra

@Test
public void emitOriginalNoMapField() throws IOException {
  bundle.setValue(bundle.getFormat().getField("bar"), ValueFactory.create("biz"));
  builder = Configs.decodeObject(StreamMapSplitBuilder.class, "field: foo, keyField: key, valueField: value, emitOriginal: false");
  builder.process(bundle, emitter);
  verify(emitter, never()).emit(any());;
}

代码示例来源:origin: addthis/hydra

@Test
public void kvBundle() {
  BundleFilterDebugPrint bf = new BundleFilterDebugPrint("", false, 100, 0).enableCacheOutput();
  ListBundleFormat bundleFormat = new ListBundleFormat();
  Bundle bundle = new ListBundle(bundleFormat);
  bundle.setValue(bundleFormat.getField("hello"), ValueFactory.create(1));
  bundle.setValue(bundleFormat.getField("world"), ValueFactory.create(1.0));
  bundle.setValue(bundleFormat.getField("foo"), null);
  bundle.setValue(bundleFormat.getField("dog"), ValueFactory.create("food"));
  bf.filter(bundle);
  assertEquals("{\"hello\" = 1 , \"world\" = 1.0 , \"foo\" = null , \"dog\" = \"food\"}",
         bf.getCacheOutput());
}

代码示例来源:origin: addthis/hydra

public DataTableHelper td(ValueObject val) {
  if (size() == 0) {
    tr();
  }
  BundleField field = getFormat().getField((currentColumn++) + "");
  if (val != null) {
    currentRow.setValue(field, val);
  }
  return this;
}

代码示例来源:origin: addthis/hydra

@Test
public void testMult() {
  BundleFilterNum bfn = new BundleFilterNum("c0,n3,*,v1,set", null);
  Bundle bundle = new ListBundle();
  bundle.setValue(bundle.getFormat().getField("c0"), ValueFactory.create(3));
  bundle.setValue(bundle.getFormat().getField("c1"), ValueFactory.create(4));
  bfn.filter(bundle);
  assertEquals("9", bundle.getValue(bundle.getFormat().getField("c1")).toString());
}

代码示例来源:origin: addthis/hydra

@Test
public void testAdd() {
  BundleFilterNum bfn = new BundleFilterNum("c0,n3,add,v1,set", null);
  Bundle bundle = new ListBundle();
  bundle.setValue(bundle.getFormat().getField("c0"), ValueFactory.create(3));
  bundle.setValue(bundle.getFormat().getField("c1"), ValueFactory.create(4));
  bfn.filter(bundle);
  assertEquals(bundle.getValue(bundle.getFormat().getField("c1")).toString(), "6");
}

代码示例来源:origin: addthis/hydra

@Test
public void testInsertArrayString() {
  BundleFilterNum bfn = new BundleFilterNum("c0,mean,v1,set", null);
  Bundle bundle = new ListBundle();
  bundle.setValue(bundle.getFormat().getField("c0"), ValueFactory.create("1,2,3,4,5"));
  bundle.setValue(bundle.getFormat().getField("c1"), ValueFactory.create(0.0));
  bfn.filter(bundle);
  assertEquals(ValueFactory.create(3.0), bundle.getValue(bundle.getFormat().getField("c1")));
}

代码示例来源:origin: addthis/hydra

@Test
public void testPop() {
  BundleFilterNum bfn = new BundleFilterNum("n1:2:3,pop,v0,set", null);
  Bundle bundle = new ListBundle();
  bundle.setValue(bundle.getFormat().getField("c1"), ValueFactory.create(-1));
  bfn.filter(bundle);
  assertEquals("2", bundle.getValue(bundle.getFormat().getField("c1")).toString());
}

代码示例来源:origin: addthis/hydra

@Test
public void testMean() {
  BundleFilterNum bfn = new BundleFilterNum("n2:3:5:7:11:13:17:19,mean,v0,set", null);
  Bundle bundle = new ListBundle();
  bundle.setValue(bundle.getFormat().getField("c1"), ValueFactory.create(-1));
  bfn.filter(bundle);
  assertEquals("9.625", bundle.getValue(bundle.getFormat().getField("c1")).toString());
}

代码示例来源:origin: addthis/hydra

@Test
public void testVariance() {
  BundleFilterNum bfn = new BundleFilterNum("n2:3:5:7:11:13:17:19,variance,v0,set", null);
  Bundle bundle = new ListBundle();
  bundle.setValue(bundle.getFormat().getField("c1"), ValueFactory.create(-1));
  bfn.filter(bundle);
  assertEquals("35.734375", bundle.getValue(bundle.getFormat().getField("c1")).toString());
}

代码示例来源:origin: addthis/hydra

@Test
public void testNumberFormatException() {
  BundleFilterNum bfn = new BundleFilterNum("c0,v1,set", null);
  Bundle bundle = new ListBundle();
  bundle.setValue(bundle.getFormat().getField("c0"), ValueFactory.create("hello"));
  boolean success = bfn.filter(bundle);
  assertFalse(success);
}

相关文章