本文整理汇总了Java中com.jcabi.dynamo.Table.put方法的典型用法代码示例。如果您正苦于以下问题:Java Table.put方法的具体用法?Java Table.put怎么用?Java Table.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jcabi.dynamo.Table
的用法示例。
在下文中一共展示了Table.put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: item
import com.jcabi.dynamo.Table; //导入方法依赖的package包/类
/**
* The item to work with.
* @return Item to work with
* @throws Exception If some problem inside
*/
private static Item item() throws Exception {
final Region region = new MkRegion(
new H2Data().with(
"domains",
new String[] {"domain"},
"owner", "usage", "total"
)
);
final Table table = region.table("domains");
table.put(
new Attributes()
.with("domain", "yegor256.com")
.with("owner", new AttributeValue("yegor256"))
.with("usage", new AttributeValue("<usage/>"))
.with("total", new AttributeValue().withN("0"))
);
return table.frame()
.where("domain", "yegor256.com")
.iterator().next();
}
示例2: storesAndReadsSingleAttribute
import com.jcabi.dynamo.Table; //导入方法依赖的package包/类
/**
* MkRegion can store and read items.
* @throws Exception If some problem inside
*/
@Test
public void storesAndReadsSingleAttribute() throws Exception {
final String table = "ideas";
final String key = "number";
final String attr = "total";
final Region region = new MkRegion(
new H2Data().with(table, new String[] {key}, attr)
);
final Table tbl = region.table(table);
tbl.put(
new Attributes()
.with(key, "32443")
.with(attr, "0")
);
final Item item = tbl.frame().iterator().next();
item.put(
attr,
new AttributeValueUpdate().withValue(
new AttributeValue().withN("2")
).withAction(AttributeAction.PUT)
);
MatcherAssert.assertThat(item.get(attr).getN(), Matchers.equalTo("2"));
}
示例3: storesAndReadsAttributes
import com.jcabi.dynamo.Table; //导入方法依赖的package包/类
/**
* MkRegion can store and read items.
* @throws Exception If some problem inside
*/
@Test
public void storesAndReadsAttributes() throws Exception {
final String name = "users";
final String key = "id";
final String attr = "description";
final String nattr = "thenumber";
final Region region = new MkRegion(
new H2Data().with(name, new String[] {key}, attr, nattr)
);
final Table table = region.table(name);
table.put(
new Attributes()
.with(key, "32443")
.with(attr, "first value to \n\t€ save")
.with(nattr, "150")
);
final Item item = table.frame().iterator().next();
MatcherAssert.assertThat(item.has(attr), Matchers.is(true));
MatcherAssert.assertThat(
item.get(attr).getS(),
Matchers.containsString("\n\t\u20ac save")
);
item.put(
attr,
new AttributeValueUpdate().withValue(
new AttributeValue("this is another value")
)
);
MatcherAssert.assertThat(
item.get(attr).getS(),
Matchers.containsString("another value")
);
MatcherAssert.assertThat(
item.get(nattr).getN(),
Matchers.endsWith("50")
);
}