當前位置: 首頁>>代碼示例>>Java>>正文


Java ArrayNode類代碼示例

本文整理匯總了Java中org.codehaus.jackson.node.ArrayNode的典型用法代碼示例。如果您正苦於以下問題:Java ArrayNode類的具體用法?Java ArrayNode怎麽用?Java ArrayNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ArrayNode類屬於org.codehaus.jackson.node包,在下文中一共展示了ArrayNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createAuthLinkResponse

import org.codehaus.jackson.node.ArrayNode; //導入依賴的package包/類
public static String createAuthLinkResponse(){

        JsonNodeFactory f = JsonNodeFactory.instance ;
        ObjectNode loginResponse = f.objectNode();
        loginResponse.put("text","Authorization for SkyGiraffe to use Slack details is required.");
        ArrayNode attachments = loginResponse.putArray("attachments");
        ObjectNode att = f.objectNode();
        att.put("fallback", "Please authorize SkyGiraffe to access to your Slack details ...");
        att.put("pretext", "");
        att.put("title", "Please authorize..");
        att.put("title_link", Config.getPropertyValue("SLACK_AUTH_URL_DEV"));
        att.put("text","Once authorized and logged into SkyGiraffe try '/sg help' to see all commands");
        att.put("color", "#7CD197");

        attachments.add(att);
        return loginResponse.toString();

    }
 
開發者ID:skygiraffe,項目名稱:skygiraffe-slackbot,代碼行數:19,代碼來源:JsonUtil.java

示例2: getClusterAsJson

import org.codehaus.jackson.node.ArrayNode; //導入依賴的package包/類
@Path("list")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String   getClusterAsJson() throws Exception
{
    InstanceConfig      config = context.getExhibitor().getConfigManager().getConfig();

    ObjectNode          node = JsonNodeFactory.instance.objectNode();

    ArrayNode           serversNode = JsonNodeFactory.instance.arrayNode();
    ServerList          serverList = new ServerList(config.getString(StringConfigs.SERVERS_SPEC));
    for ( ServerSpec spec : serverList.getSpecs() )
    {
        serversNode.add(spec.getHostname());
    }
    node.put("servers", serversNode);
    node.put("port", config.getInt(IntConfigs.CLIENT_PORT));

    return JsonUtil.writeValueAsString(node);
}
 
開發者ID:dcos,項目名稱:exhibitor,代碼行數:21,代碼來源:ClusterResource.java

示例3: getCriteria

import org.codehaus.jackson.node.ArrayNode; //導入依賴的package包/類
public static Criteria getCriteria(ObjectNode rudeCriteria) throws Exception {
    Criteria criteria = new Criteria();
    if (rudeCriteria.has("criterions")) {
        ArrayNode criterions = (ArrayNode) rudeCriteria.get("criterions");
        if (criterions != null) {
            for (Iterator<JsonNode> it = criterions.iterator(); it.hasNext();) {
                criteria.addCriterion(parseCriterion((ObjectNode) it.next()));
            }
        }
    }

    if (rudeCriteria.has("orders")) {
        ArrayNode orders = (ArrayNode) rudeCriteria.get("orders");
        if (orders != null) {
            for (Iterator<JsonNode> it = orders.iterator(); it.hasNext();) {
                ObjectNode rudeCriterion = (ObjectNode) it.next();
                Order order = new Order(JsonUtils.getString(rudeCriterion, "property"), JsonUtils.getBoolean(rudeCriterion, "desc"));
                criteria.addOrder(order);
            }
        }
    }
    return criteria;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:24,代碼來源:CriterionUtils.java

示例4: 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;
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:23,代碼來源:CreateNoteWidget.java

示例5: 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);
    }

}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:26,代碼來源:BlogApiTest.java

示例6: createLoginLinkResponse

import org.codehaus.jackson.node.ArrayNode; //導入依賴的package包/類
/**
 * {
 "attachments": [
 {
 "fallback": "Please login into SkyGiraffe to continue ...",
 "pretext": "SkyGiraffe Login",
 "title": "Please login into SkyGiraffe to continue ...",
 "title_link": "https://sgbot-mobilityai.rhcloud.com/SGbot-1.0/skyg/login?key=",
 "text": "Once logged in try '/sg help' to see all commands",
 "color": "#7CD197"
 }
 ]
 }
 * @return
 */
public static String createLoginLinkResponse(String slackUserId, String email, String teamId){

    JsonNodeFactory f = JsonNodeFactory.instance ;
    ObjectNode loginResponse = f.objectNode();
    loginResponse.put("text","Login to SkyGiraffe is required.");
    ArrayNode attachments = loginResponse.putArray("attachments");
    ObjectNode att = f.objectNode();
    att.put("fallback", "Please login into SkyGiraffe to continue ...");
    att.put("pretext", "");
    att.put("title", "Please login..");
    att.put("title_link", Config.getPropertyValue("SGDS_LOGIN_URL_DEV")+slackUserId+"&EMAIL="+email+"&TEAMID="+teamId);
    att.put("text","Once logged in try '/sg help' to see all commands");
    att.put("color", "#7CD197");

    attachments.add(att);

    return loginResponse.toString();

}
 
開發者ID:skygiraffe,項目名稱:skygiraffe-slackbot,代碼行數:35,代碼來源:JsonUtil.java

示例7: 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;
    }
 
開發者ID:Comcast,項目名稱:pipeclamp,代碼行數:24,代碼來源:QAUtil.java

示例8: 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;
}
 
開發者ID:svemuri,項目名稱:CalcEngine,代碼行數:27,代碼來源:PerfProfiler.java

示例9: countersToJSON

import org.codehaus.jackson.node.ArrayNode; //導入依賴的package包/類
@Private
public JsonNode countersToJSON(Counters counters) {
  ObjectMapper mapper = new ObjectMapper();
  ArrayNode nodes = mapper.createArrayNode();
  if (counters != null) {
    for (CounterGroup counterGroup : counters) {
      ObjectNode groupNode = nodes.addObject();
      groupNode.put("NAME", counterGroup.getName());
      groupNode.put("DISPLAY_NAME", counterGroup.getDisplayName());
      ArrayNode countersNode = groupNode.putArray("COUNTERS");
      for (Counter counter : counterGroup) {
        ObjectNode counterNode = countersNode.addObject();
        counterNode.put("NAME", counter.getName());
        counterNode.put("DISPLAY_NAME", counter.getDisplayName());
        counterNode.put("VALUE", counter.getValue());
      }
    }
  }
  return nodes;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:JobHistoryEventHandler.java

示例10: orderCollection

import org.codehaus.jackson.node.ArrayNode; //導入依賴的package包/類
public ArrayNode orderCollection(Collection<Order> collection) {
    ArrayNode array = JsonNodeFactory.instance.arrayNode();
    for(Order param : collection){
        ObjectNode obj =  JsonNodeFactory.instance.objectNode();
        obj.put("orderId", param.getId() );
        obj.put("mile", param.getMilesage() );
        obj.put("price", param.getPrice() );
        obj.put("sold", param.getSold() );
        obj.put("carName", param.getCar().getName() );
        obj.put("carId", param.getCar().getId() );
        obj.put("modelId", param.getCar().getModel().getId() );
        obj.put("bodyId", param.getCar().getBody().getId() );
        obj.put("drivetype", param.getCar().getDriveType().getId());
        obj.put("engineId", param.getCar().getEngine().getId() );
        obj.put("transsmId", param.getCar().getTransmission().getId() );
        obj.put("data", param.getRelease().getTime());
        obj.put("userId", param.getUser().getId() );
        array.add(obj);
    }
    return array;
}
 
開發者ID:SergeyZhernovoy,項目名稱:Java-education,代碼行數:22,代碼來源:UpdateOrder.java

示例11: convert

import org.codehaus.jackson.node.ArrayNode; //導入依賴的package包/類
public ArrayNode convert(Collection<Order> collection) {

        ArrayNode array = JsonNodeFactory.instance.arrayNode();
        for(Order param : collection){

            ObjectNode order = JsonNodeFactory.instance.objectNode();
            order.put("orderId", param.getId() );
            order.put("mile", param.getMilesage() );
            order.put("price", param.getPrice() );
            if(param.getSold()){
                order.put("sold", "V" );
            } else {
                order.put("sold", "" );
            }
            order.put("carName", param.getCar().getName() );
            order.put("carId", param.getCar().getId() );

            GregorianCalendar calendar = new GregorianCalendar();
            calendar.setTimeInMillis(param.getRelease().getTime());
            //calendar.get(Calendar.YEAR);

            order.put("data", String.valueOf(calendar.get(Calendar.YEAR)));
            order.put("userId", param.getUser().getId() );
            array.add(order);
        }
        return array;

    }
 
開發者ID:SergeyZhernovoy,項目名稱:Java-education,代碼行數:29,代碼來源:FilterOrder.java

示例12: createEntitySearchJSONResult

import org.codehaus.jackson.node.ArrayNode; //導入依賴的package包/類
/**
 * Creates an array of JSON objects which hold details about the found users or groups.
 * 
 * @param list
 *            the search result to process
 * @param addSummary
 *            if true a summary JSON object will be added to the top of the array. The JSON
 *            object will be created with {@link #createSearchSummaryStatement(PageableList)} .
 * @param imageSize
 *            the size of the user logo to include in the image path, can be null to not include
 *            the image path into the JSON object. For groups no image will be included.
 * @return the JSON array with the details about the users
 */
public static ArrayNode createEntitySearchJSONResult(
        PageableList<CommunoteEntityData> list, boolean addSummary,
        ImageSizeType imageSize) {
    JsonNodeFactory nodeFactory = JsonHelper.getSharedObjectMapper()
            .getNodeFactory();
    ArrayNode result = nodeFactory.arrayNode();
    if (addSummary) {
        result.add(UserSearchHelper.createSearchSummaryStatement(list));
    }
    for (CommunoteEntityData item : list) {
        String imagePath = null;
        boolean isGroup = (item instanceof EntityGroupListItem);
        if (!isGroup && imageSize != null) {
            imagePath = ImageUrlHelper.buildUserImageUrl(item.getEntityId(), imageSize);
        }
        ObjectNode entry = createUserSearchJSONResult(item.getEntityId(),
                item.getShortDisplayName(), item.getDisplayName(),
                imagePath, item.getAlias());
        entry.put("isGroup", isGroup);
        result.add(entry);
    }
    return result;
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:37,代碼來源:UserSearchHelper.java

示例13: addBlogsToJsonResponse

import org.codehaus.jackson.node.ArrayNode; //導入依賴的package包/類
/**
 * Add the JSON objects of the blogs to the JSON response.
 * 
 * @param jsonResponse
 *            the response object to write to
 * @param list
 *            list to process
 * @param includeDescription
 *            whether to include the description
 * @param includeImagePath
 *            whether to include the path to the image
 */
private static void addBlogsToJsonResponse(ArrayNode jsonResponse,
        Collection<BlogData> list, boolean includeDescription, boolean includeImagePath) {
    for (BlogData item : list) {
        ObjectNode entry;
        if (includeDescription) {
            entry = BlogSearchHelper.createBlogSearchJSONResult(item.getId(),
                    item.getNameIdentifier(), item.getTitle(), item.getDescription(),
                    includeImagePath);
        } else {
            entry = BlogSearchHelper.createBlogSearchJSONResult(item.getId(),
                    item.getNameIdentifier(), item.getTitle(), includeImagePath);
        }
        jsonResponse.add(entry);
    }
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:28,代碼來源:BlogSearchHelper.java

示例14: exportChildrenToMetadata

import org.codehaus.jackson.node.ArrayNode; //導入依賴的package包/類
/**
 * Export the children of the topic to the response metadata as a JSON array
 * 
 * @param children
 *            the children to export
 */
private void exportChildrenToMetadata(List<DetailBlogListItem> children) {
    children = BlogManagementHelper.sortedBlogList(children);
    ArrayNode result = JsonHelper.getSharedObjectMapper().createArrayNode();
    for (DetailBlogListItem child : children) {
        result.add(BlogSearchHelper.createBlogSearchJSONResult(child.getId(),
                child.getNameIdentifier(), child.getTitle(), false));
    }
    this.setResponseMetadata("childTopics", result);
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:16,代碼來源:EditTopicStructureWidget.java

示例15: 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;
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:19,代碼來源:CreateNoteWidget.java


注:本文中的org.codehaus.jackson.node.ArrayNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。