List of usage examples for org.jdom2 JDOMException JDOMException
public JDOMException(String message, Throwable cause)
Exception
with the given message and wrap another Exception
. From source file:fr.amap.amapvox.io.tls.rsp.Rsp.java
License:Open Source License
public void read(final File rspFile) throws JDOMException, IOException { sxb = new SAXBuilder(); rxpList = new ArrayList<>(); //avoid loading of dtd file sxb.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); try {/* w w w .j a v a 2 s .com*/ document = sxb.build(new FileInputStream(rspFile)); root = document.getRootElement(); projectName = root.getAttributeValue("name"); Element scanPositions = root.getChild("scanpositions"); String folderScanPositions = scanPositions.getAttributeValue("fold"); List<Element> childrens = scanPositions.getChildren("scanposition"); popMatrix = extractMat4D(root.getChild("pop").getChildText("matrix")); //scan id int scanCount = 0; for (Element child : childrens) { Scans rxp = new Scans(); rxp.setName(child.getAttributeValue("name")); rxp.setFold(child.getAttributeValue("fold")); Element registeredElement = child.getChild("registered"); if (registeredElement != null) { if (Integer.valueOf(registeredElement.getText()) == 1) { Element singlescans = child.getChild("singlescans"); String singlescansFold = singlescans.getAttributeValue("fold"); Map<Integer, RxpScan> scanList = new HashMap<>(); List<Element> scans = singlescans.getChildren("scan"); Element sop = child.getChild("sop"); Matrix4d sopMatrix = extractMat4D(sop.getChildText("matrix")); rxp.setSopMatrix(sopMatrix); int compteur = 0; for (Element sc : scans) { RxpScan scan = new RxpScan(); scan.setName(sc.getAttributeValue("name")); scan.setFileName(sc.getChildText("file")); String rspFilePathOnly = rspFile.getAbsolutePath().substring(0, rspFile.getAbsolutePath().lastIndexOf(File.separator)); scan.setAbsolutePath(rspFilePathOnly + File.separator + folderScanPositions + File.separator + rxp.getFold() + File.separator + singlescansFold + File.separator + scan.getFileName()); scanList.put(scanCount, scan); if (scan.getName().contains(".mon")) { rxp.setRxpLiteFile(new File(scan.getAbsolutePath())); rxp.setScanLite(scan); } else { rxp.setScanFull(scan); } scan.setFile(new File(scan.getAbsolutePath())); scan.setSopMatrix(sopMatrix); compteur++; scanCount++; } rxp.setScanList(scanList); rxpList.add(rxp); } else { //logger.info("Scan "+ rxp.getName() +" skipped cause unregistered"); } } } } catch (JDOMException ex) { throw new JDOMException("error parsing or reading rsp: " + rspFile.getAbsolutePath(), ex); } catch (IOException ex) { throw new IOException("error parsing or reading rsp: " + rspFile.getAbsolutePath(), ex); } }
From source file:org.mycore.datamodel.ifs.MCRFile.java
License:Open Source License
public org.jdom2.Document getContentAsJDOM() throws MCRPersistenceException, IOException, org.jdom2.JDOMException { try {/*from w w w . jav a2s . c o m*/ return getContent().asXML(); } catch (SAXException e) { throw new JDOMException("Could not parse XML file.", e); } }