本文整理匯總了Java中org.jdom.Element.setName方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.setName方法的具體用法?Java Element.setName怎麽用?Java Element.setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdom.Element
的用法示例。
在下文中一共展示了Element.setName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertToSecondVersion
import org.jdom.Element; //導入方法依賴的package包/類
public static Element convertToSecondVersion(Element element) throws StudyUnrecognizedFormatException {
final Element oldCourseElement = element.getChild(COURSE_ELEMENT);
Element state = new Element(MAIN_ELEMENT);
Element course = addChildWithName(state, COURSE, oldCourseElement.clone());
course.setName(COURSE_TITLED);
Element author = getChildWithName(course, AUTHOR);
String authorString = author.getAttributeValue(VALUE);
course.removeContent(author);
String[] names = authorString.split(" ", 2);
Element authorElement = new Element(AUTHOR_TITLED);
addChildWithName(authorElement, FIRST_NAME, names[0]);
addChildWithName(authorElement, SECOND_NAME, names.length == 1 ? "" : names[1]);
addChildList(course, AUTHORS, Collections.singletonList(authorElement));
Element courseDirectoryElement = getChildWithName(course, RESOURCE_PATH);
renameElement(courseDirectoryElement, COURSE_DIRECTORY);
for (Element lesson : getChildList(course, LESSONS)) {
incrementIndex(lesson);
for (Element task : getChildList(lesson, TASK_LIST)) {
incrementIndex(task);
Map<String, Element> taskFiles = getChildMap(task, TASK_FILES);
for (Element taskFile : taskFiles.values()) {
renameElement(getChildWithName(taskFile, TASK_WINDOWS), ANSWER_PLACEHOLDERS);
for (Element placeholder : getChildList(taskFile, ANSWER_PLACEHOLDERS)) {
placeholder.setName(ANSWER_PLACEHOLDER);
Element initialState = new Element(MY_INITIAL_STATE);
addChildWithName(placeholder, INITIAL_STATE, initialState);
addChildWithName(initialState, MY_LINE, getChildWithName(placeholder, MY_INITIAL_LINE).getAttributeValue(VALUE));
addChildWithName(initialState, MY_START, getChildWithName(placeholder, MY_INITIAL_START).getAttributeValue(VALUE));
addChildWithName(initialState, MY_LENGTH, getChildWithName(placeholder, MY_INITIAL_LENGTH).getAttributeValue(VALUE));
}
}
}
}
element.removeContent();
element.addContent(state);
return element;
}
示例2: 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;
}