com.alibaba.fastjson.JSONArray#remove ( )源码实例Demo

下面列出了com.alibaba.fastjson.JSONArray#remove ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Jpom   文件: OutGivingProjectEditController.java
@RequestMapping(value = "editProject", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@Feature(method = MethodFeature.EDIT)
public String editProject(String id) {
    setAttribute("type", "add");
    OutGivingModel outGivingModel;
    if (StrUtil.isNotEmpty(id)) {
        outGivingModel = outGivingServer.getItem(id);
        if (outGivingModel != null) {
            setAttribute("item", outGivingModel);
            setAttribute("type", "edit");
        }
    }
    // 运行模式
    JSONArray runModes = (JSONArray) JSONArray.toJSON(RunMode.values());
    runModes.remove(RunMode.File.name());
    //
    setAttribute("runModes", runModes);
    //
    JSONArray afterOpt = BaseEnum.toJSONArray(AfterOpt.class);
    setAttribute("afterOpt", afterOpt);
    // 权限
    List<NodeModel> nodeModels = nodeService.list();
    setAttribute("nodeModels", nodeModels);
    //
    String reqId = nodeService.cacheNodeList(nodeModels);
    setAttribute("reqId", reqId);

    // 白名单
    List<String> jsonArray = serverWhitelistServer.getOutGiving();
    setAttribute("whitelistDirectory", jsonArray);
    return "outgiving/editProject";
}
 
源代码2 项目: Jpom   文件: EditProjectController.java
/**
 * 修改项目页面
 *
 * @param id 项目Id
 * @return json
 */
@RequestMapping(value = "editProject", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@Feature(method = MethodFeature.EDIT)
public String editProject(String id) {
    JSONObject projectInfo = projectInfoService.getItem(getNode(), id);

    // 白名单
    List<String> jsonArray = whitelistDirectoryService.getProjectDirectory(getNode());
    setAttribute("whitelistDirectory", jsonArray);

    setAttribute("item", projectInfo);
    // 运行模式
    JSONArray runModes = (JSONArray) JSONArray.toJSON(RunMode.values());
    if (projectInfo != null) {
        try {
            String runMode = projectInfo.getString("runMode");
            RunMode mode = RunMode.valueOf(runMode);
            if (mode != RunMode.File) {
                // java 项目不能转换为file,可能有未结束的进程
                runModes.remove(RunMode.File.name());
            }
        } catch (Exception ignored) {
        }
    }
    setAttribute("runModes", runModes);
    //
    List<String> hashSet = projectInfoService.getAllGroup(getNode());
    if (hashSet.isEmpty()) {
        hashSet.add("默认");
    }
    setAttribute("groups", hashSet);
    //jdk
    JSONArray array = projectInfoService.getJdkList(getNode(), getRequest());
    setAttribute("jdkArray", array);
    return "node/manage/editProject";
}
 
源代码3 项目: EasyML   文件: ChartsResource.java
@POST
@Path("/getChartParams")
@Produces(MediaType.APPLICATION_JSON)
public String getChartParams(@FormParam("filePath") String path, @FormParam("dataType") String type,@FormParam("columns") List<String> columns,@FormParam("chartType")String chartType) throws Exception{
	ChartService chartService = new ChartService();
	String paramsStr = chartService.getChartParams(chartType);
	JSONObject paramObj = JSON.parseObject(paramsStr);
	JSONArray controlArr = paramObj.getJSONArray("controls");
	System.out.println(controlArr.toJSONString());
	for(int i=0;i<controlArr.size();i++)
	{
		JSONObject conObj = controlArr.getJSONObject(i);
		String contType = conObj.getString("control_type");
		if(contType.equals("select"))
		{
			String value = conObj.getString("value");
			if(value.equals(""))
			{
				StringBuffer buf = new StringBuffer();
				for(int j=0;j<columns.size();j++)
				{
					if(j == columns.size()-1)
						buf.append(columns.get(j));
					else
						buf.append(columns.get(j)+",");
				}
				conObj.put("value", buf.toString());
				controlArr.remove(i);
				controlArr.add(i, conObj);
			}
		}
	}
	paramObj.put("controls", controlArr);
	System.out.println(paramObj.toJSONString());
	return paramObj.toJSONString();
}
 
源代码4 项目: voj   文件: DiscussionService.java
/**
 * 移除JSONArray对象中的一个值.
 * 为了修复JSONArray自带contains方法的Bug.
 * 使用场景: 从Vote列表中移除某个用户的UID.
 * @param jsonArray - 待移除值的JSONArray对象
 * @param value - 待移除的值
 */
private void remove(JSONArray jsonArray, long value) {
	for ( int i = 0; i < jsonArray.size(); ++ i ) {
		if ( jsonArray.getLong(i) == value ) {
			jsonArray.remove(i);
		}
	}
}
 
源代码5 项目: FanXin-based-HuanXin   文件: SocialMainAdapter.java
/**
 * 
 * 取消点赞
 * 
 */
public void cancelGood(String sID, TextView tv_good, JSONArray jsons,
		LinearLayout ll_goodmembers_temp, View view, int cSize) {

	// 即时改变当前UI
	for (int i = 0; i < jsons.size(); i++) {
		JSONObject json = jsons.getJSONObject(i);
		if (json.getString("userID").equals(myuserID)) {
			jsons.remove(i);
		}
	}
	setGoodTextClick(tv_good, jsons, ll_goodmembers_temp, view, cSize);
	Map<String, String> map = new HashMap<String, String>();
	map.put("sID", sID);
	map.put("userID", myuserID);

	SocialApiTask task = new SocialApiTask(context, Constant.URL_SOCIAL_GOOD_CANCEL,
			map);
	task.getData(new DataCallBack() {

		@Override
		public void onDataCallBack(JSONObject data) {
			// dialog.dismiss();
			if (data == null) {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----ERROR");
				return;
			}
			int code = data.getInteger("code");
			if (code == 1000) {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----SUCCESS");
			} else {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----ERROR_2");

			}
		}
	});

}
 
源代码6 项目: FanXin-based-HuanXin   文件: SocialMainAdapter.java
private void deleteComment(String userID, final int postion, String scID,
		int type, TextView ctextView, final JSONArray cjsons, View view,
		int goodSize) {

	if (scID == null) {
		scID = "LOCAL";
	}
	;
	String tag = cjsons.getJSONObject(postion).getString("tag");
	if (tag == null) {
		tag = String.valueOf(System.currentTimeMillis());
	}
	// 更新UI
	cjsons.remove(postion);
	setCommentTextClick(ctextView, cjsons, view, goodSize);
	// 更新服务器
	Map<String, String> map = new HashMap<String, String>();
	map.put("scID", scID);
	map.put("userID", myuserID);
	map.put("tag", tag);
	SocialApiTask task = new SocialApiTask(context, Constant.URL_SOCIAL_DELETE_COMMENT,
			map);
	task.getData(new DataCallBack() {

		@Override
		public void onDataCallBack(JSONObject data) {
			// dialog.dismiss();
			if (data == null) {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----ERROR");
				return;
			}
			int code = data.getInteger("code");
			if (code == 1000) {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----SUCCESS");
			} else {
				Log.e("hideCommentEditText()-->>>>",
						"hideCommentEditText()-----ERROR_2");

			}
		}
	});

}
 
/**
 * 
 * 取消点赞
 * 
 */
public void cancelGood(String sID, TextView tv_good, JSONArray jsons,
        LinearLayout ll_goodmembers_temp, View view, int cSize) {

    // 即时改变当前UI
    for (int i = 0; i < jsons.size(); i++) {
        JSONObject json = jsons.getJSONObject(i);
        if (json.getString("userID").equals(myuserID)) {
            jsons.remove(i);
        }
    }
    setGoodTextClick(tv_good, jsons, ll_goodmembers_temp, view, cSize);
    Map<String, String> map = new HashMap<String, String>();
    map.put("sID", sID);
    map.put("userID", myuserID);

    SocialApiTask task = new SocialApiTask(context,
            Constant.URL_SOCIAL_GOOD_CANCEL, map);
    task.getData(new DataCallBack() {

        @Override
        public void onDataCallBack(JSONObject data) {
            // dialog.dismiss();
            if (data == null) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR");
                return;
            }
            int code = data.getInteger("code");
            if (code == 1000) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----SUCCESS");
            } else {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR_2");

            }
        }
    });

}
 
private void deleteComment(String userID, final int postion, String scID,
        int type, TextView ctextView, final JSONArray cjsons, View view,
        int goodSize) {

    if (scID == null) {
        scID = "LOCAL";
    }
    ;
    String tag = cjsons.getJSONObject(postion).getString("tag");
    if (tag == null) {
        tag = String.valueOf(System.currentTimeMillis());
    }
    // 更新UI
    cjsons.remove(postion);
    setCommentTextClick(ctextView, cjsons, view, goodSize);
    // 更新服务器
    Map<String, String> map = new HashMap<String, String>();
    map.put("scID", scID);
    map.put("userID", myuserID);
    map.put("tag", tag);
    SocialApiTask task = new SocialApiTask(context,
            Constant.URL_SOCIAL_DELETE_COMMENT, map);
    task.getData(new DataCallBack() {

        @Override
        public void onDataCallBack(JSONObject data) {
            // dialog.dismiss();
            if (data == null) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR");
                return;
            }
            int code = data.getInteger("code");
            if (code == 1000) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----SUCCESS");
            } else {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR_2");

            }
        }
    });

}
 
private void deleteComment(String userID, final int postion, String scID,
        int type, TextView ctextView, final JSONArray cjsons, View view,
        int goodSize) {

    if (scID == null) {
        scID = "LOCAL";
    }
    ;
    String tag = cjsons.getJSONObject(postion).getString("tag");
    if (tag == null) {
        tag = String.valueOf(System.currentTimeMillis());
    }
    // 更新UI
    cjsons.remove(postion);
    setCommentTextClick(ctextView, cjsons, view, goodSize);
    // 更新服务器
    Map<String, String> map = new HashMap<String, String>();
    map.put("scID", scID);
    map.put("userID", myuserID);
    map.put("tag", tag);
    SocialApiTask task = new SocialApiTask(SocialDetailActivity.this,
            Constant.URL_SOCIAL_DELETE_COMMENT, map);
    task.getData(new DataCallBack() {

        @Override
        public void onDataCallBack(JSONObject data) {
            // dialog.dismiss();
            if (data == null) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR");
                return;
            }
            int code = data.getInteger("code");
            if (code == 1000) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----SUCCESS");
            } else {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR_2");

            }
        }
    });

}
 
/**
 * 
 * 取消点赞
 * 
 */
public void cancelGood(String sID, TextView tv_good, JSONArray jsons,
        LinearLayout ll_goodmembers_temp, View view, int cSize) {

    // 即时改变当前UI
    for (int i = 0; i < jsons.size(); i++) {
        JSONObject json = jsons.getJSONObject(i);
        if (json.getString("userID").equals(myuserID)) {
            jsons.remove(i);
        }
    }
    setGoodTextClick(tv_good, jsons, ll_goodmembers_temp, view, cSize);
    Map<String, String> map = new HashMap<String, String>();
    map.put("sID", sID);
    map.put("userID", myuserID);

    SocialApiTask task = new SocialApiTask(SocialDetailActivity.this,
            Constant.URL_SOCIAL_GOOD_CANCEL, map);
    task.getData(new DataCallBack() {

        @Override
        public void onDataCallBack(JSONObject data) {
            // dialog.dismiss();
            if (data == null) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR");
                return;
            }
            int code = data.getInteger("code");
            if (code == 1000) {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----SUCCESS");
            } else {
                Log.e("hideCommentEditText()-->>>>",
                        "hideCommentEditText()-----ERROR_2");

            }
        }
    });

}