本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
}