本文整理汇总了Java中com.fasterxml.jackson.databind.node.ObjectNode.withArray方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectNode.withArray方法的具体用法?Java ObjectNode.withArray怎么用?Java ObjectNode.withArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.node.ObjectNode
的用法示例。
在下文中一共展示了ObjectNode.withArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportFromEquellaPerItem
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
* The EQUELLA version of exportFrom
*
* @param offset
* @param itemsDir
* @param perItem
* @return
* @throws Exception
*/
protected Integer[] exportFromEquellaPerItem(int offset, File itemsDir, Function<ObjectNode, Void> perItem)
throws Exception
{
ImmutableMap<String, ?> params = ImmutableMap.of("start", offset, "info", "export", "length", 50, "showall",
true);
ObjectNode results = searchRequests.search(searchRequests.searchRequest("", "modified").parameters(params));
int available = results.get("available").asInt();
int length = results.get("length").asInt();
for( JsonNode entityJson : results.withArray("results") )
{
ObjectNode entity = (ObjectNode) entityJson;
perItem.apply(entity);
}
return new Integer[]{offset + length, available};
}
示例2: exportFrom
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
* The EPS version of exportFrom
*
* @param offset
* @param itemsDir
* @param perItem
* @return
* @throws Exception
*/
protected String exportFrom(String offset, File itemsDir, Function<ObjectNode, Void> perItem) throws Exception
{
ImmutableMap<String, ?> params = ImmutableMap.of("info", "export", "scrollid", offset);
ObjectNode results = searchRequests.scan(searchRequests.successfulRequest().parameters(params));
if( !results.withArray("results").has(0) )
{
return null;
}
for( JsonNode entityJson : results.withArray("results") )
{
ObjectNode entity = (ObjectNode) entityJson;
perItem.apply(entity);
}
return results.has("scrollId") ? results.get("scrollId").asText() : null;
}
示例3: saveFiles
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
protected void saveFiles(final ItemId itemId, File filesDir) throws IOException
{
ObjectNode files = itemRequests.listFiles(itemId);
ArrayNode fileList = files.withArray("files");
if( fileList.size() > 0 )
{
filesDir.mkdirs();
for( JsonNode file : fileList )
{
final String name = file.get("name").asText();
ByteSource src = new ByteSource()
{
@Override
public InputStream openStream() throws IOException
{
return itemRequests.file(itemRequests.successfulRequest(), itemId, name).body().asInputStream();
}
};
File destFile = new File(filesDir, name);
destFile.getParentFile().mkdirs();
src.copyTo(Files.asByteSink(destFile));
}
}
}
示例4: importTaskStatus
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public static ObjectNode importTaskStatus(String uuid, char status, Date started, Date due,
Collection<String> accepted)
{
ObjectNode ns = importStatus(uuid, status);
ns.put("started", ISO8601Utils.format(started));
ns.put("due", due != null ? ISO8601Utils.format(due) : null);
ArrayNode users = ns.withArray("acceptedUsers");
for( String user : accepted )
{
users.add(user);
}
return ns;
}
示例5: exportGroups
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void exportGroups() throws Exception
{
File groupsDir = getGroupDir();
groupsDir.mkdirs();
ObjectNode results = groupRequests.export();
for( JsonNode userJson : results.withArray("results") )
{
File userFile = new File(groupsDir, userJson.get("id").asText() + ".json");
MAPPER.writeValue(userFile, userJson);
}
}
示例6: exportRoles
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void exportRoles() throws Exception
{
File rolesDir = getRoleDir();
rolesDir.mkdirs();
ObjectNode results = roleRequests.export();
for( JsonNode userJson : results.withArray("results") )
{
File userFile = new File(rolesDir, userJson.get("id").asText() + ".json");
MAPPER.writeValue(userFile, userJson);
}
}
示例7: exportEntities
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void exportEntities(String name, BaseEntityRequests req) throws Exception
{
File entityDir = new File(baseDir, name);
entityDir.mkdirs();
ObjectNode results = req.listForExport();
for( JsonNode entityJson : results.withArray("results") )
{
ObjectNode entity = (ObjectNode) entityJson;
String id = req.getId(entity);
File file = new File(entityDir, id + ".json");
MAPPER.writeValue(file, entity);
}
ObjectNode acls = req.listAcls();
MAPPER.writeValue(getEntityAclsFile(entityDir), acls);
}
示例8: exportUsers
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void exportUsers() throws Exception
{
File usersDir = getUserDir();
usersDir.mkdirs();
ObjectNode results = userRequests.export();
for( JsonNode userJson : results.withArray("results") )
{
File userFile = new File(usersDir, userJson.get("id").asText() + ".json");
MAPPER.writeValue(userFile, userJson);
}
}