本文整理匯總了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;
}