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


Java JsonNode.getRootNode方法代码示例

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


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

示例1: internalConvertFromPreviousVersion

import argo.jdom.JsonNode; //导入方法依赖的package包/类
@Override
protected JsonRootNode internalConvertFromPreviousVersion(JsonRootNode previousVersion) {
	try {
		JsonNode globalSettings = JsonNodeFactories.object(
				JsonNodeFactories.field("debug",
						JsonNodeFactories.object(
								JsonNodeFactories.field("level", JsonNodeFactories.string(Level.WARNING.toString()))
						)
				),
				JsonNodeFactories.field("tray_icon_enabled", JsonNodeFactories.booleanNode(true)),
				JsonNodeFactories.field("enabled_halt_by_key", JsonNodeFactories.booleanNode(true))
				);

		JsonNode newNode = JSONUtility.addChild(previousVersion, "global_settings", globalSettings);
		return newNode.getRootNode();
	} catch (Exception e) {
		LOGGER.log(Level.WARNING, "Unable to convert json from previous version " + getPreviousVersion(), e);
		return null;
	}
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:21,代码来源:Parser1_6.java

示例2: internalConvertFromPreviousVersion

import argo.jdom.JsonNode; //导入方法依赖的package包/类
@Override
protected JsonRootNode internalConvertFromPreviousVersion(JsonRootNode previousVersion) {
	try {
		JsonNode globalHotkeys = previousVersion.getNode("global_hotkey");
		JsonNode result = JSONUtility.removeChild(previousVersion, "global_hotkey");

		JsonNode globalSettings = JSONUtility.addChild(result.getNode("global_settings"), "global_hotkey", globalHotkeys);
		result = JSONUtility.replaceChild(result, "global_settings", globalSettings);
		result = JSONUtility.addChild(result, "ipc_settings", JsonNodeFactories.array(
				new Function<Language, JsonNode>(){
					@Override
					public JsonNode apply(Language l) {
						return JsonNodeFactories.object(
									JsonNodeFactories.field("name", JsonNodeFactories.string(l.toString())),
									JsonNodeFactories.field("launch_at_startup", JsonNodeFactories.booleanNode(true))
									);
					}
				}.map(Language.values())
			));

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

示例3: convertFromPreviousVersion

import argo.jdom.JsonNode; //导入方法依赖的package包/类
protected final JsonRootNode convertFromPreviousVersion(JsonRootNode previousVersion) {
	if (previousVersion != null && previousVersion.isStringValue("version")) {
		if (previousVersion.getStringValue("version").equals(getPreviousVersion())) {
			JsonRootNode output = internalConvertFromPreviousVersion(previousVersion);

			try {
				JsonNode convertedVersion = JSONUtility.replaceChild(output, "version", JsonNodeFactories.string(getVersion()));
				return convertedVersion.getRootNode();
			} catch (Exception e) {
				LOGGER.log(Level.WARNING, "Unable to modify version when converting versions " + getPreviousVersion() + " to " + getVersion(), e);
				return null;
			}
		}
	}
	LOGGER.warning("Invalid previous version " + getPreviousVersion() + " cannot "
			+ "be converted to this version " + getVersion() + ". Only accept previous version " + getPreviousVersion());
	return null;
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:19,代码来源:ConfigParser.java

示例4: internalConvertFromPreviousVersion

import argo.jdom.JsonNode; //导入方法依赖的package包/类
@Override
protected JsonRootNode internalConvertFromPreviousVersion(JsonRootNode previousVersion) {
	try {
		JsonNode replacing = previousVersion.getNode("task_groups");
		JsonNode output = JSONUtility.replaceChild(previousVersion, "task_groups", internalTaskGroupConversion(replacing));
		return output.getRootNode();
	} catch (Exception e) {
		LOGGER.log(Level.WARNING, "Unable to convert json from previous version " + getPreviousVersion(), e);
		return null;
	}
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:12,代码来源:Parser1_7.java

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


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