本文整理汇总了Java中com.addthis.bundle.core.Bundle.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.setValue方法的具体用法?Java Bundle.setValue怎么用?Java Bundle.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.addthis.bundle.core.Bundle
的用法示例。
在下文中一共展示了Bundle.setValue方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendColumn
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
public void appendColumn(Bundle bundle, ValueObject value) {
if (value == null) {
// bundles measure non-null values in getCount()
// so appending a null cannot append a column
throw new IllegalArgumentException("cannot append a null column value");
}
checkBinding(bundle);
BundleField field = null;
if (bundle.getCount() < fields.length) {
field = fields[bundle.getCount()];
} else {
BundleField[] newFields = new BundleField[fields.length + 1];
System.arraycopy(fields, 0, newFields, 0, fields.length);
newFields[newFields.length - 1] = bundle.getFormat().getField(Integer.toString(fields.length));
fields = newFields;
field = fields[fields.length - 1];
}
bundle.setValue(field, value);
}
示例2: testBundleColumnBinder1
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
@Test
public void testBundleColumnBinder1() {
Bundle b1 = new ListBundle();
BundleColumnBinder binder = new BundleColumnBinder(b1);
b1.setValue(b1.getFormat().getField("abc"), ValueFactory.create("def"));
b1.setValue(b1.getFormat().getField("ghi"), ValueFactory.create("jkl"));
b1.setValue(b1.getFormat().getField("mno"), ValueFactory.create("pqr"));
assertEquals(binder.getColumn(b1, 1), ValueFactory.create("jkl"));
assertEquals(binder.getColumn(b1, 2), ValueFactory.create("pqr"));
assertEquals(binder.getColumn(b1, 0), ValueFactory.create("def"));
assertEquals(binder.getColumn(b1, 3), null);
Bundle b2 = new ListBundle((ListBundleFormat) b1.getFormat());
b2.setValue(b2.getFormat().getField("abc"), ValueFactory.create("def"));
b2.setValue(b2.getFormat().getField("ghi"), ValueFactory.create("jkl"));
b2.setValue(b2.getFormat().getField("mno"), ValueFactory.create("pqr"));
assertEquals(binder.getColumn(b2, 1), ValueFactory.create("jkl"));
assertEquals(binder.getColumn(b2, 2), ValueFactory.create("pqr"));
assertEquals(binder.getColumn(b2, 0), ValueFactory.create("def"));
assertEquals(binder.getColumn(b2, 3), null);
}
示例3: setColumn
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
/** */
public void setColumn(Bundle bundle, int column, ValueObject value) {
checkBinding(bundle);
if (column >= fields.length) {
throw new RuntimeException("invalid column");
}
bundle.setValue(fields[column], value);
}
示例4: setAndFilterBundle
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
@Override protected void setAndFilterBundle(Bundle bundle, SimpleCopyFilter filter) {
BundleField b = bundle.getFormat().getField("b");
bundle.setValue(b, ValueFactory.createMap());
filter.filter(bundle);
filter.filter(bundle);
filter.filter(bundle);
ValueMap subB = bundle.getValue(b).asMap();
assertEquals("good", subB.get("sub-b").asMap().get("codec").toString());
}
示例5: setKeyFromValue
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
@Test
public void setKeyFromValue() throws Exception {
SimpleCopyFilter filter = Configs.decodeObject(SimpleCopyFilter.class, "from.const: foobar, to: MAP/mykey");
Bundle b = new ListBundle();
ValueMap map = ValueFactory.createMap();
b.setValue(b.getFormat().getField("MAP"), map);
b.setValue(b.getFormat().getField("MYFIELD"), ValueFactory.create("blah"));
filter.filter(b);
assertEquals("foobar", map.get("mykey").asNative());
}
示例6: replaceKeyFromValue
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
@Test
public void replaceKeyFromValue() throws Exception {
SimpleCopyFilter filter = Configs.decodeObject(SimpleCopyFilter.class, "from.const:foobar, to:MAP.mykey");
Bundle b = new ListBundle();
ValueMap map = ValueFactory.createMap();
map.put("mykey",ValueFactory.create("abc"));
b.setValue(b.getFormat().getField("MAP"), map);
b.setValue(b.getFormat().getField("MYFIELD"), ValueFactory.create("blah"));
filter.filter(b);
assertEquals("foobar", map.get("mykey").asNative());
}
示例7: setAndFilterBundle
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
@Override protected void setAndFilterBundle(Bundle bundle, SimpleCopyFilter filter) {
BundleField a = bundle.getFormat().getField("a");
BundleField b = bundle.getFormat().getField("b");
bundle.setValue(a, ValueFactory.createValueArray(ImmutableList.of("SANDWICH")));
bundle.setValue(b, ValueFactory.createMap());
filter.filter(bundle);
filter.filter(bundle);
filter.filter(bundle);
assertEquals("SANDWICH", bundle.getValue(b).asMap().get("sub-b").toString());
}
示例8: setKey
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
@Test
public void setKey() throws Exception {
SimpleCopyFilter filter = Configs.decodeObject(SimpleCopyFilter.class, "from: MYFIELD, to: MAP.mykey");
Bundle b = new ListBundle();
ValueMap map = ValueFactory.createMap();
b.setValue(b.getFormat().getField("MAP"), map);
b.setValue(b.getFormat().getField("MYFIELD"), ValueFactory.create("foobar"));
filter.filter(b);
assertEquals("foobar", map.get("mykey").asNative());
}
示例9: replaceKey
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
@Test
public void replaceKey() throws Exception {
SimpleCopyFilter filter = Configs.decodeObject(SimpleCopyFilter.class, "from: MYFIELD, to: MAP.mykey");
Bundle b = new ListBundle();
ValueMap map = ValueFactory.createMap();
map.put("mykey",ValueFactory.create("abc"));
b.setValue(b.getFormat().getField("MAP"), map);
b.setValue(b.getFormat().getField("MYFIELD"), ValueFactory.create("foobar"));
filter.filter(b);
assertEquals("foobar", map.get("mykey").asNative());
}
示例10: notMap
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
@Test(expected = Exception.class)
public void notMap() throws Exception {
SimpleCopyFilter filter = Configs.decodeObject(SimpleCopyFilter.class, "from: MYFIELD, to:MAP.mykey");
Bundle b = new ListBundle();
b.setValue(b.getFormat().getField("MYFIELD"), ValueFactory.create("blah"));
filter.filter(b);
}
示例11: setAndFilterBundle
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
protected void setAndFilterBundle(Bundle bundle, SimpleCopyFilter filter) {
BundleField a = bundle.getFormat().getField("a");
BundleField b = bundle.getFormat().getField("b");
bundle.setValue(a, ValueFactory.create("SANDWICH"));
filter.filter(bundle);
filter.filter(bundle);
filter.filter(bundle);
assertEquals("SANDWICH", bundle.getValue(b).toString());
}
示例12: setValue
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
@Override public void setValue(Bundle bundle, @Nullable ValueObject value) {
bundle.setValue(field, value);
}
示例13: setValue
import com.addthis.bundle.core.Bundle; //导入方法依赖的package包/类
@Override public void setValue(Bundle bundle, @Nullable ValueObject value) {
BundleField field = checkAndGet(bundle);
bundle.setValue(field, value);
}