本文整理汇总了Java中org.jdom.Element.clone方法的典型用法代码示例。如果您正苦于以下问题:Java Element.clone方法的具体用法?Java Element.clone怎么用?Java Element.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdom.Element
的用法示例。
在下文中一共展示了Element.clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToFifthVersion
import org.jdom.Element; //导入方法依赖的package包/类
public static Element convertToFifthVersion(Element state) throws StudyUnrecognizedFormatException {
Element taskManagerElement = state.getChild(MAIN_ELEMENT);
Element courseElement = getChildWithName(taskManagerElement, COURSE).getChild(COURSE_TITLED);
final int courseId = getAsInt(courseElement, ID);
if (courseElement != null && courseId > 0) {
courseElement.setName(REMOTE_COURSE);
}
final Element adaptive = getChildWithName(courseElement, ADAPTIVE);
for (Element lesson : getChildList(courseElement, LESSONS)) {
for (Element task : getChildList(lesson, TASK_LIST)) {
final Element lastSubtaskIndex = getChildWithName(task, LAST_SUBTASK_INDEX, true); //could be broken by 3->4 migration
final Element adaptiveParams = getChildWithName(task, ADAPTIVE_TASK_PARAMETERS, true);
Element theoryTask = getChildWithName(task, THEORY_TAG, true);
if (theoryTask == null && adaptiveParams != null) {
theoryTask = getChildWithName(adaptiveParams, THEORY_TAG, true);
}
final boolean hasAdaptiveParams = adaptiveParams != null && !adaptiveParams.getChildren().isEmpty();
if (lastSubtaskIndex != null && Integer.valueOf(lastSubtaskIndex.getAttributeValue(VALUE)) != 0) {
task.setName(TASK_WITH_SUBTASKS);
}
else if (theoryTask != null && Boolean.valueOf(theoryTask.getAttributeValue(VALUE))) {
task.setName(THEORY_TASK);
}
else if (hasAdaptiveParams) {
task.setName(CHOICE_TASK);
final Element adaptiveParameters = adaptiveParams.getChildren().get(0);
for (Element element : adaptiveParameters.getChildren()) {
final Attribute name = element.getAttribute(NAME);
if (name != null && !THEORY_TAG.equals(name.getValue())) {
final Content elementCopy = element.clone();
task.addContent(elementCopy);
}
}
}
else if (Boolean.valueOf(adaptive.getAttributeValue(VALUE))) {
task.setName(CODE_TASK);
}
else {
task.setName(PYCHARM_TASK);
}
task.removeContent(adaptiveParams);
task.removeContent(theoryTask);
}
}
return state;
}