List of usage examples for org.dom4j.io SAXReader SAXReader
public SAXReader()
From source file:com.fxdigital.manager.SoftInfoImpl.java
/** * ??/*from ww w. j av a 2 s .c o m*/ * * @return */ public String getSoftVersion() { String version = null; String path = getPath(); if (path == null) { return "?"; } File f = new File(path); SAXReader reader = new SAXReader(); try { Document doc = reader.read(f); Element root = doc.getRootElement(); version = root.attributeValue("version"); version = "V" + version; } catch (Exception e) { e.printStackTrace(); } if (version == null) version = "V1.0"; return version; }
From source file:com.fxdigital.manager.SoftInfoImpl.java
/** * ??//w w w . ja v a 2s. c o m * * @return */ public String getLicenseTime() { String time = null; String path = getPath(); if (path == null) { return "?"; } File f = new File(path); SAXReader reader = new SAXReader(); try { Document doc = reader.read(f); Element root = doc.getRootElement(); time = root.attributeValue("SerialNumber"); } catch (Exception e) { e.printStackTrace(); } if (time != null && time.length() >= 14) { time = time.substring(0, 4) + "-" + time.substring(4, 6) + "-" + time.substring(6, 8) + " " + time.substring(8, 10) + ":" + time.substring(10, 12) + ":" + time.substring(12, 14); } return time; }
From source file:com.gi.desktop.maptool.dialog.MapServiceConfDialog.java
License:Open Source License
@SuppressWarnings("unchecked") private void loadAgsSchema() { JFileChooser dialog = getJFileChooserAgsSchema(); int val = dialog.showOpenDialog(this); if (val == JFileChooser.APPROVE_OPTION) { File agsSchema = dialog.getSelectedFile(); try {// w w w .ja va 2 s.c o m FileInputStream in = new FileInputStream(agsSchema); SAXReader saxReader = new SAXReader(); Document document = saxReader.read(in); Element root = document.getRootElement(); Element eTileCacheInfo = root.element("TileCacheInfo"); Element eTileOrigin = eTileCacheInfo.element("TileOrigin"); this.jTextFieldOriginX.setText(eTileOrigin.elementText("X")); this.jTextFieldOriginY.setText(eTileOrigin.elementText("Y")); this.jTextFieldWidth.setText(eTileCacheInfo.elementText("TileCols")); this.jTextFieldHeight.setText(eTileCacheInfo.elementText("TileRows")); jListLevelsModel.removeAllElements(); Element eLODInfos = eTileCacheInfo.element("LODInfos"); for (Iterator iLODInfos = eLODInfos.elementIterator(); iLODInfos.hasNext();) { Element eLODInfo = (Element) iLODInfos.next(); TileLodInfo tileLodInfo = new TileLodInfo(); tileLodInfo.setLevel(Integer.valueOf(eLODInfo.elementText("LevelID"))); tileLodInfo.setScale(Double.valueOf(eLODInfo.elementText("Scale"))); tileLodInfo.setResolution(Double.valueOf(eLODInfo.elementText("Resolution"))); LodItem item = new LodItem(); item.setTileLodInfo(tileLodInfo); jListLevelsModel.addElement(item); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "Load Error!"); } } }
From source file:com.github.autoprimer3.AutoPrimer3Config.java
License:Open Source License
public void readGenomeXmlFile(File xml) throws IOException, DocumentException { SAXReader reader = new SAXReader(); Document doc = reader.read(xml); buildsAndTables.setDasGenomeXmlDocument(doc); buildsAndTables.readDasGenomeXmlDocument(); setBuildToDescription(buildsAndTables.getBuildToDescription()); setBuildToMapMaster(buildsAndTables.getBuildToMapMaster()); }
From source file:com.github.autoprimer3.AutoPrimer3Config.java
License:Open Source License
public Document getBuildXmlDocument(String build, Boolean forceRefresh) throws DocumentException, MalformedURLException, IOException { SAXReader reader = new SAXReader(); File f = getBuildXmlFile(build); if (!f.exists() || forceRefresh) { Document dasXml = buildsAndTables.getTableXmlDocument(build); writeTableXmlFile(dasXml, build); }/*from www. j a v a 2s. c o m*/ return reader.read(f); }
From source file:com.github.autoprimer3.AutoPrimer3Config.java
License:Open Source License
public LinkedHashSet<String> readTableFile(File xml) throws DocumentException { SAXReader reader = new SAXReader(); Document dasXml = reader.read(xml); return readTableFile(dasXml); }
From source file:com.github.autoprimer3.AutoPrimer3Config.java
License:Open Source License
public LinkedHashSet<String> readTableFile(File xml, String category) throws DocumentException, MalformedURLException { SAXReader reader = new SAXReader(); Document dasXml = reader.read(xml); return readTableFile(dasXml, category); }
From source file:com.github.autoprimer3.GetUcscBuildsAndTables.java
License:Open Source License
public void connectToUcsc() throws DocumentException, MalformedURLException { SAXReader reader = new SAXReader(); URL url = new URL("http://genome.ucsc.edu/cgi-bin/das/dsn"); //URL url = new URL("http://genome-euro.ucsc.edu/cgi-bin/das/dsn"); dasGenomeXml = reader.read(url);//from ww w.j ava 2 s. c om readDasGenomeXmlDocument(); }
From source file:com.github.autoprimer3.GetUcscBuildsAndTables.java
License:Open Source License
public Document getTableXmlDocument(String build) throws DocumentException, MalformedURLException { SAXReader reader = new SAXReader(); URL url = new URL("http://genome.ucsc.edu/cgi-bin/das/" + build + "/types"); Document dasXml;/*from ww w . ja v a 2s . co m*/ dasXml = reader.read(url); return dasXml; }
From source file:com.github.autoprimer3.GetUcscBuildsAndTables.java
License:Open Source License
public String retrieveSequence(String build, String chrom, Integer start, Integer end) throws DocumentException, MalformedURLException { if (buildToDescription.isEmpty()) { this.connectToUcsc(); }/*from w w w. j a v a 2 s .c o m*/ if (!buildToMapMaster.containsKey(build)) { return null; } else { StringBuilder dna = new StringBuilder(); URL genomeUrl = new URL( buildToMapMaster.get(build) + "/dna?segment=" + chrom + ":" + (start + 1) + "," + end); SAXReader reader = new SAXReader(); Document dasXml; dasXml = reader.read(genomeUrl); Element root = dasXml.getRootElement(); for (Iterator i = root.elementIterator("SEQUENCE"); i.hasNext();) { Element dsn = (Element) i.next(); Element seq = dsn.element("DNA"); String text = seq.getText().replaceAll("\n", ""); dna.append(text); //dna.append(seq.getText()); } return dna.toString(); } }