List of usage examples for org.jdom2 Attribute toString
@Override
public String toString()
String
representation of the Attribute
, suitable for debugging. From source file:de.herm_detlef.java.application.io.Import.java
License:Apache License
private static void createNode(Element child) { List<Element> children = child.getChildren(); if (children.isEmpty()) { switch (TAG.getValueOf(child.getName())) { case ID:/*from w w w. j a v a 2s. c o m*/ exerciseItem.setItemId(Integer.parseInt(child.getTextTrim())); break; case TEXT: { final String str = child.getTextTrim(); if (isQuestionPart) { exerciseItem.addQuestionText(str); } else if (isAnswerPart) { Attribute mark = child .getAttribute(ApplicationConstants.NAME_OF_XML_ATTRIBUTE_ANSWER_TEXT_MARK); if (mark != null) { try { exerciseItem.addAnswerText(str, mark.getBooleanValue()); } catch (DataConversionException e) { Utilities.showErrorMessage(e.getClass().getSimpleName(), e.getMessage()); assert false : String.format("DataConversionException: %s", mark.toString()); // TODO exerciseItem.addAnswerText(str, false); } } else { exerciseItem.addAnswerText(str, false); } } else if (isSolutionPart) { exerciseItem.addSolutionText(str); } break; } case CODE: if (isQuestionPart) { exerciseItem.addQuestionCode(child.getTextTrim()); } break; case TEXT2: if (isQuestionPart) { exerciseItem.addQuestionText2(child.getTextTrim()); } break; case CATALOG: // TODO empty catalog file break; default: assert false : String.format("%s", TAG.getValueOf(child.getName()).name()); // TODO } return; } for (Element aChild : children) { switch (TAG.getValueOf(aChild.getName())) { case ITEM: exerciseItem = new ExerciseItem(); exerciseItemList.add(exerciseItem); break; case QUESTION: signalQuestion(); break; case SINGLE_CHOICE_ANSWER: signalSingleChoiceAnswer(); exerciseItem.createSingleChoiceModel(); break; case MULTIPLE_CHOICE_ANSWER: signalMultipleChoiceAnswer(); exerciseItem.createMultipleChoiceModel(); break; case SOLUTION: signalSolution(); break; case ID: case TEXT: case CODE: case TEXT2: break; default: assert false : String.format("%s", TAG.getValueOf(aChild.getName()).name()); // TODO } createNode(aChild); } }