List of usage examples for org.jdom2 Attribute getBooleanValue
public boolean getBooleanValue() throws DataConversionException
DataConversionException
if a conversion can't be performed. From source file:ca.nrc.cadc.uws.JobListReader.java
License:Open Source License
private List<JobRef> parseJobList(Document doc) throws ParseException, DataConversionException { Element root = doc.getRootElement(); List<Element> children = root.getChildren(); Iterator<Element> childIterator = children.iterator(); List<JobRef> jobs = new ArrayList<JobRef>(); Element next = null;// w w w . ja va2 s .co m JobRef jobRef = null; ExecutionPhase executionPhase = null; Date creationTime = null; Attribute nil = null; String runID = null; String ownerID = null; while (childIterator.hasNext()) { next = childIterator.next(); String jobID = next.getAttributeValue("id"); Element phaseElement = next.getChild(JobAttribute.EXECUTION_PHASE.getAttributeName(), UWS.NS); String phase = phaseElement.getValue(); executionPhase = ExecutionPhase.valueOf(phase); Element creationTimeElement = next.getChild(JobAttribute.CREATION_TIME.getAttributeName(), UWS.NS); String time = creationTimeElement.getValue(); creationTime = dateFormat.parse(time); Element runIDElement = next.getChild(JobAttribute.RUN_ID.getAttributeName(), UWS.NS); nil = runIDElement.getAttribute("nil", UWS.XSI_NS); if (nil != null && nil.getBooleanValue()) runID = null; else runID = runIDElement.getTextTrim(); Element ownerIDElement = next.getChild(JobAttribute.OWNER_ID.getAttributeName(), UWS.NS); ownerID = ownerIDElement.getTextTrim(); jobRef = new JobRef(jobID, executionPhase, creationTime, runID, ownerID); jobs.add(jobRef); } return jobs; }
From source file:ca.nrc.cadc.uws.JobReader.java
License:Open Source License
private String parseStringContent(Element e) throws DataConversionException { if (e == null) return null; Attribute nil = e.getAttribute("nil", UWS.XSI_NS); if (nil != null && nil.getBooleanValue()) return null; return e.getTextTrim(); }
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); } }
From source file:de.openVJJ.InputComponents.java
License:Open Source License
public static void load(String fileName) { try {//ww w . j av a 2s. com Document document = new SAXBuilder().build(fileName); Element rootElement = document.getRootElement(); if (rootElement.getName() != ROOT_ELEMET_NAME) { System.err.println("is notan Open-VJJ Project"); return; } Element gpuElement = rootElement.getChild(GPU_ELEMENT_NAME); if (gpuElement != null) { Attribute gpuActiv = gpuElement.getAttribute(GPU_ACTIV_ATTRIBUTE_NAME); if (gpuActiv != null) { useGPU = gpuActiv.getBooleanValue(); } } removeAll(); Element components = rootElement.getChild(COMPONENTS_ELEMENT_NAME); List<Element> elements = components.getChildren(COMPONENT_ELEMENT_NAME); for (Element rootComponente : elements) { addComponent((ImagePublisher) loadComponent(rootComponente)); } } catch (JDOMException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }