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


Java Element.clone方法代码示例

本文整理汇总了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;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:47,代码来源:StudySerializationUtils.java


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