本文整理汇总了Java中org.codehaus.jackson.node.ArrayNode.size方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayNode.size方法的具体用法?Java ArrayNode.size怎么用?Java ArrayNode.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.jackson.node.ArrayNode
的用法示例。
在下文中一共展示了ArrayNode.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReadableBlogs
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
* @throws Exception
* in case of an error
*/
@Test(dependsOnMethods = { "testCreateEditBlog" })
public void getReadableBlogs() throws Exception {
ArrayNode array = doGetRequestAsJSONArray("/blogs.json?blogListType=READ&searchString="
+ searchString, username, password);
Assert.assertTrue(array.size() >= 1,
"The array must have at least one blog with the search string! array=" + array);
for (int i = 0; i < array.size(); i++) {
JsonNode blog = array.get(i);
if (LOG.isDebugEnabled()) {
LOG.debug("Checking blog=" + blog);
}
checkJSONBlogResult(blog, "blog[" + i + "]");
String title = blog.get("title").asText();
Assert.assertTrue(title.contains(searchString),
"Blog title must contain searchString! title=" + title + " searchString="
+ searchString);
}
}
示例2: extractCrosspostBlogs
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
* Extracts the crosspost blogs from an autosave and creates a JSON array.
*
* @param item
* the item that holds the note data
* @return the array
*/
private ArrayNode extractCrosspostBlogs(AutosaveNoteData item) {
ArrayNode result = JsonHelper.getSharedObjectMapper().createArrayNode();
if (item.getCrosspostBlogs() != null) {
for (BlogData b : item.getCrosspostBlogs()) {
String title = b.getTitle();
ObjectNode blog = BlogSearchHelper.createBlogSearchJSONResult(b.getId(),
b.getNameIdentifier(), title, false);
result.add(blog);
}
}
if (result.size() == 0) {
return null;
}
return result;
}
示例3: argumentsOn
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
protected static Map<String, String> argumentsOn(JsonNode node) {
Map<String, String> argValues = new HashMap<>();
JsonNode argsNode = node.get(ArgsKey);
if (argsNode == null) return argValues;
if (!argsNode.isArray()) {
System.err.println("invalid argument node, must be an array");
return argValues;
}
ArrayNode args = (ArrayNode)argsNode;
final int argCount = args.size();
for (int i=0; i<argCount; i++) {
String[] tuple = getArgs(args.get(i));
argValues.put(tuple[0], tuple[1]);
}
return argValues;
}
示例4: asArray
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
public static String[] asArray(JsonNode node)
{
if (node == null)
throw new IllegalArgumentException("Specified JsonNode is null");
if (node.isArray())
{
ArrayNode anode = (ArrayNode) node;
int nelements = anode.size();
String[] array = new String[nelements];
for (int i = 0; i < nelements; i++)
{
array[i] = anode.get(i).getTextValue();
}
return array;
}
else
{
return new String[] { node.getTextValue() };
}
}
示例5: getOperatorDependency
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
private static List<Integer>[] getOperatorDependency(ArrayNode operatorsJson)
{
Map<String, Integer> relationName2OperatorID = new HashMap<String, Integer>();
int numOperators = operatorsJson.size();
List<Integer>[] inputOperatorIDs = new ArrayList[numOperators];
for (int i = 0; i < numOperators; i++)
{
JsonNode operatorJson = operatorsJson.get(i);
if (!operatorJson.has("operator"))
continue;
OperatorType type =
OperatorType.valueOf(operatorJson.get("operator").getTextValue());
String outputName = operatorJson.get("output").getTextValue();
if (type.isTupleOperator())
{
inputOperatorIDs[i] =
getInputOperatorIDs(relationName2OperatorID, operatorJson);
relationName2OperatorID.put(outputName, i);
}
}
return inputOperatorIDs;
}
示例6: visitMappers
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
private static boolean visitMappers(ObjectNode jobNode,
OperatorVisitor visitorObj,
boolean reverse)
{
ArrayNode mappers = (ArrayNode) jobNode.get("map");
int si = (reverse ? mappers.size() - 1 : 0);
int ei = (reverse ? -1 : mappers.size());
// TODO Auto-generated method stub
for (int i = si; i != ei; i += increment(reverse))
{
if (!visitMapNode(jobNode, mappers.get(i), visitorObj, reverse))
return false;
}
return true;
}
示例7: checkTopLevelColumn
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
private static String checkTopLevelColumn(ObjectNode sourceOp,
JsonNode genExprNode)
{
String topColName = null;
if (!(genExprNode instanceof ObjectNode))
return null;
ObjectNode opNode = (ObjectNode) genExprNode;
if (opNode.get("function") == null
|| !opNode.get("function").getTextValue().equals("INPUT_PROJECTION"))
return null;
ArrayNode argsNode = (ArrayNode) opNode.get("arguments");
if (argsNode.size() != 1
|| ((topColName = findNamedColumn(argsNode)) == null)
&& (topColName = findIndexedColumn(sourceOp, argsNode)) == null)
return null;
return topColName;
}
示例8: extractAttachments
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
* Extracts the attachments from a note and creates a JSON array.
*
* @param item
* the item that holds the note data
* @return the array
*/
private ArrayNode extractAttachments(NoteData item) {
ArrayNode result = JsonHelper.getSharedObjectMapper().createArrayNode();
List<AttachmentData> attachments = item.getAttachments();
if (attachments != null) {
for (AttachmentData attachment : attachments) {
ObjectNode attach = CreateBlogPostFeHelper.createAttachmentJSONObject(attachment);
result.add(attach);
}
}
return result.size() == 0 ? null : result;
}
示例9: extractUsersToNotify
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
* Extracts the users to notify from a note and creates a JSON array.
*
* @param item
* the item that holds the note data
* @return the array
*/
private ArrayNode extractUsersToNotify(NoteData item) {
ArrayNode result = JsonHelper.getSharedObjectMapper().createArrayNode();
if (item.getNotifiedUsers() != null) {
for (DetailedUserData ul : item.getNotifiedUsers()) {
ObjectNode user = UserSearchHelper.createUserSearchJSONResult(ul,
ImageSizeType.MEDIUM);
result.add(user);
}
}
// add @@ mentions by building fake users
if (item.isMentionDiscussionAuthors()) {
result.add(UserSearchHelper.createUserSearchJSONResult(null, null,
MessageHelper.getText(getRequest(), "autosuggest.atat.discussion"), null,
NoteManagement.CONSTANT_MENTION_DISCUSSION_PARTICIPANTS));
}
if (item.isMentionTopicAuthors()) {
result.add(UserSearchHelper.createUserSearchJSONResult(null, null,
MessageHelper.getText(getRequest(), "autosuggest.atat.authors"), null,
NoteManagement.CONSTANT_MENTION_TOPIC_AUTHORS));
}
if (item.isMentionTopicReaders()) {
result.add(UserSearchHelper.createUserSearchJSONResult(null, null,
MessageHelper.getText(getRequest(), "autosuggest.atat.all"), null,
NoteManagement.CONSTANT_MENTION_TOPIC_READERS));
}
if (item.isMentionTopicManagers()) {
result.add(UserSearchHelper.createUserSearchJSONResult(null, null,
MessageHelper.getText(getRequest(), "autosuggest.atat.managers"), null,
NoteManagement.CONSTANT_MENTION_TOPIC_MANAGERS));
}
if (result.size() == 0) {
return null;
}
return result;
}
示例10: getUsers
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
* @throws Exception
* in case of an error
*/
@Test
public void getUsers() throws Exception {
ArrayNode array = doGetRequestAsJSONArray("/users.json", username, password);
Assert.assertTrue(array.size() > 0, "Must have at least on user!");
for (int i = 0; i < array.size(); i++) {
JsonNode user = array.get(i);
if (LOG.isDebugEnabled()) {
LOG.debug("Checking user=" + user);
}
checkJSONUserResult(user, "user[" + i + "]");
}
}
示例11: getManagerBlogs
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
* @throws Exception
* in case of an error
*/
@Test()
public void getManagerBlogs() throws Exception {
ArrayNode array = doGetRequestAsJSONArray("/blogs.json?blogListType=MANAGER", username,
password);
for (int i = 0; i < array.size(); i++) {
JsonNode blog = array.get(i);
if (LOG.isDebugEnabled()) {
LOG.debug("Checking blog=" + blog);
}
checkJSONBlogResult(blog, "blog[" + i + "]");
}
}
示例12: filterPosts
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
* @throws Exception
* in case something goes wrong
*/
@Test
public void filterPosts() throws Exception {
ArrayNode result = doGetRequestAsJSONArray("/filter/posts.json?maxCount=2",
getDefaultUsername(), getDefaultPassword());
Assert.assertEquals(result.size(), 2, "Result length must match!");
for (int i = 0; i < result.size(); i++) {
checkJSONDetailPostListItemResult(result.get(i), "result[" + i + "].post");
}
}
示例13: filterPosts
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
* @throws Exception
* in case something goes wrong
*/
@Test
public void filterPosts() throws Exception {
ArrayNode result = doGetRequestAsJSONArray("/filter/users.json?maxCount=2",
getDefaultUsername(), getDefaultPassword());
Assert.assertEquals(result.size(), 2, "Result length must match!");
for (int i = 0; i < result.size(); i++) {
checkJSONUserResult(result.get(i), "result[" + i + "]");
}
}
示例14: messageFromErrorNode
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
protected String messageFromErrorNode(JsonNode errorNode)
{
StringBuffer sb = new StringBuffer();
sb.append(errorNode.get("message").asText());
if (errorNode.has("details"))
{
JsonNode detailsNode = errorNode.get("details");
if (detailsNode.isArray())
{
ArrayNode detailsArray = (ArrayNode) detailsNode;
if (detailsArray.size() > 0)
{
sb.append(" ");
for (JsonNode detail : detailsArray)
{
sb.append("[");
sb.append(detail.asText());
sb.append("]");
}
}
}
else
{
sb.append("[");
sb.append(detailsNode.asText());
sb.append("]");
}
}
return sb.toString();
}
示例15: loadMappings
import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
private void loadMappings() {
ObjectNode ports = (ObjectNode) core.get("NetworkSettings")
.get("Ports");
Iterator<Entry<String, JsonNode>> it = ports.getFields();
while (it.hasNext()) {
Entry<String, JsonNode> element = it.next();
String key = element.getKey();
// strip /tcp /udp suffix?
if (ports.has(key)) {
String[] parts = key.split("/");
String port = null;
String protocol = "tcp";
if (parts.length > 1) {
port = parts[0];
protocol = parts[1];
} else {
port = key;
}
JsonNode value = element.getValue();
if (value instanceof ArrayNode) {
ArrayNode mappings = (ArrayNode) element.getValue();
if (mappings.size() == 0) {
System.err.println("Not mapped");
} else if (mappings.size() > 1) {
System.err.println("Warning, multiple mappings. I don't know what that means, ignoring others");
}
// String hostIp = hostname; //mappings.get(0).get("HostIp").asText();
String hostPort = mappings.get(0).get("HostPort").asText();
DockerServiceMapping ds = new DockerServiceMappingImpl(port, protocol,
hostPort, hostname);
this.mappings.put(port, ds);
}
}
}
}