当前位置: 首页>>代码示例>>Java>>正文


Java JsonNode.getArrayNode方法代码示例

本文整理汇总了Java中argo.jdom.JsonNode.getArrayNode方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.getArrayNode方法的具体用法?Java JsonNode.getArrayNode怎么用?Java JsonNode.getArrayNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在argo.jdom.JsonNode的用法示例。


在下文中一共展示了JsonNode.getArrayNode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseJSON

import argo.jdom.JsonNode; //导入方法依赖的package包/类
/**
 * Construct a new object from a json node.
 *
 * @param node json node to parse
 * @return the new object with content parsed, or null if cannot parse.
 */
public static TaskActivation parseJSON(JsonNode node) {
	try {
		List<JsonNode> hotkeysNode = node.getArrayNode("hotkey");
		List<JsonNode> mouseGestureNode = node.getArrayNode("mouse_gesture");

		Set<KeyChain> keyChains = new HashSet<>();
		for (JsonNode hotkeyNode : hotkeysNode) {
			KeyChain newKeyChain = KeyChain.parseJSON(hotkeyNode.getArrayNode());
			if (newKeyChain == null) {
				LOGGER.log(Level.WARNING, "Cannot parse key chain " + hotkeyNode);
			} else {
				keyChains.add(newKeyChain);
			}
		}

		Set<MouseGesture> gestures = MouseGesture.parseJSON(mouseGestureNode);
		TaskActivation output = TaskActivation.newBuilder().withHotKeys(keyChains).withMouseGestures(gestures).build();
		return output;
	} catch (Exception e) {
		LOGGER.log(Level.WARNING, "Exception while parsing task activation.", e);
		return null;
	}
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:30,代码来源:TaskActivation.java

示例2: parseJSON

import argo.jdom.JsonNode; //导入方法依赖的package包/类
public static TaskGroup parseJSON(DynamicCompilerManager factory, JsonNode node) {
	try {
		TaskGroup output = new TaskGroup("");
		String name = node.getStringValue("name");
		output.name = name;

		for (JsonNode task : node.getArrayNode("tasks")) {
			UserDefinedAction action = UserDefinedAction.parseJSON(factory, task);
			if (action != null) {
				output.tasks.add(action);
			}
		}

		output.enabled = node.getBooleanValue("enabled");

		return output;
	} catch (Exception e) {
		Logger.getLogger(TaskGroup.class.getName()).log(Level.WARNING, "Exception parsing task group from JSON", e);
		return null;
	}
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:22,代码来源:TaskGroup.java

示例3: internalTaskConversion

import argo.jdom.JsonNode; //导入方法依赖的package包/类
private JsonNode internalTaskConversion(JsonNode tasks) {
	UsageStatistics reference = new UsageStatistics();

	List<JsonNode> converted = new ArrayList<>();
	for (JsonNode child : tasks.getArrayNode()) {
		converted.add(JSONUtility.addChild(child, "statistics", reference.jsonize()));
	}
	return JsonNodeFactories.array(converted);
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:10,代码来源:Parser1_7.java

示例4: internalTaskGroupConversion

import argo.jdom.JsonNode; //导入方法依赖的package包/类
private JsonNode internalTaskGroupConversion(JsonNode node) {
	List<JsonNode> converted = new ArrayList<>();
	for (JsonNode child : node.getArrayNode()) {
		JsonNode tasksNode = child.getNode("tasks");
		converted.add(JSONUtility.replaceChild(child, "tasks", internalTaskConversion(tasksNode)));
	}
	return JsonNodeFactories.array(converted);
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:9,代码来源:Parser1_7.java

示例5: process

import argo.jdom.JsonNode; //导入方法依赖的package包/类
@Override
public boolean process(String type, long id, JsonNode content) throws InterruptedException {
	String action = content.getStringValue("action");
	List<JsonNode> parameterNodes = content.getArrayNode("parameters");
	List<String> params = new Function<JsonNode, String>(){
		@Override
		public String apply(JsonNode d) {
			return d.getStringValue();
		}}.map(parameterNodes);

	if (action.equals("get")) {
		if (params.size() == 2) {
			return constructSuccessfulMessage(type, id, SharedVariables.getVar(params.get(0), params.get(1)));
		} else {
			return failure(type, id, "Invalid parameter length " + params.size());
		}
	} else if (action.equals("set")) {
		if (params.size() == 3) {
			return constructSuccessfulMessage(type, id, SharedVariables.setVar(params.get(0), params.get(1), params.get(2)));
		} else {
			return failure(type, id, "Invalid parameter length " + params.size());
		}
	} else if (action.equals("del")) {
		if (params.size() == 2) {
			return constructSuccessfulMessage(type, id, SharedVariables.delVar(params.get(0), params.get(1)));
		} else {
			return failure(type, id, "Invalid parameter length " + params.size());
		}
	}

	return failure(type, id, "Unsupported action " + action);
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:33,代码来源:SharedMemoryProcessor.java

示例6: internalConvertFromPreviousVersion

import argo.jdom.JsonNode; //导入方法依赖的package包/类
@Override
protected JsonRootNode internalConvertFromPreviousVersion(JsonRootNode previousVersion) {
	try {
		// Add mouse gesture activation to global hotkey
		JsonNode globalSettings = previousVersion.getNode("global_settings");
		JsonNode globalHotkey = globalSettings.getNode("global_hotkey");

		globalHotkey = JSONUtility.addChild(
							globalHotkey,
							"mouse_gesture_activation",
							JsonNodeFactories.number(KeyEvent.VK_SHIFT));

		globalSettings = JSONUtility.replaceChild(globalSettings, "global_hotkey", globalHotkey);

		JsonNode output = JSONUtility.replaceChild(previousVersion, "global_settings", globalSettings).getRootNode();

		// Modify hotkey into activation
		List<JsonNode> taskGroups = output.getArrayNode("task_groups");
		List<JsonNode> convertedTaskGroup = new ArrayList<>();
		for (JsonNode group : taskGroups) {
			List<JsonNode> tasks = group.getArrayNode("tasks");
			List<JsonNode> convertedTasks = new ArrayList<>();
			for (JsonNode task : tasks) {
				JsonNode hotkey = task.getNode("hotkey");
				JsonNode activation = JsonNodeFactories.object(
						JsonNodeFactories.field("hotkey", hotkey),
						JsonNodeFactories.field("mouse_gesture", JsonNodeFactories.array()));

				task = JSONUtility.addChild(task, "activation", activation);
				convertedTasks.add(task);
			}


			group = JSONUtility.replaceChild(group, "tasks", JsonNodeFactories.array(convertedTasks));
			convertedTaskGroup.add(group);
		}
		output = JSONUtility.replaceChild(output, "task_groups", JsonNodeFactories.array(convertedTaskGroup));

		return output.getRootNode();
	} catch (Exception e) {
		LOGGER.log(Level.WARNING, "Unable to convert json from previous version " + getPreviousVersion(), e);
		return null;
	}
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:45,代码来源:Parser2_0.java

示例7: process

import argo.jdom.JsonNode; //导入方法依赖的package包/类
@Override
public boolean process(String type, long id, JsonNode content) {
	if (!verifyMessageContent(content)) {
		getLogger().warning("Error in verifying message content " + content);
		return false;
	}

	String device = content.getStringValue("device");
	String action = content.getStringValue("action");
	List<JsonNode> paramNodes = content.getArrayNode("parameters"); // Unused

	if (IpcMessageType.identify(type) == IpcMessageType.SYSTEM_HOST) {
		if (action.equals("keep_alive")) {
			return success(type, id);
		}
	} else if (IpcMessageType.identify(type) == IpcMessageType.SYSTEM_CLIENT) {
		if (action.equals("identify")) {
			if (paramNodes.size() != 2) {
				getLogger().warning("Unexpected identity to have " + paramNodes.size() + " parameters.");
				return false;
			}

			String name;
			JsonNode nameNode = paramNodes.get(0);
			if (!nameNode.isStringValue()) {
				getLogger().warning("Identity must be a string.");
				return false;
			}

			int port;
			JsonNode portNode = paramNodes.get(1);
			if (!portNode.isStringValue()) {
				getLogger().warning("Port number must be a parsable string.");
				return false;
			} else {
				try {
					port = Integer.parseInt(portNode.getStringValue());
				} catch (NumberFormatException e) {
					getLogger().warning("Port number must be a number.");
					return false;
				}
			}

			name = nameNode.getStringValue();
			TaskProcessorManager.identifyProcessor(name, port, holder.getTaskProcessor());
			return success(type, id);
		}
	}

	getLogger().warning("Unsupported operation [" + device + ", " + action + "]");
	return false;
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:53,代码来源:SystemRequestProcessor.java


注:本文中的argo.jdom.JsonNode.getArrayNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。