List of usage examples for org.jdom2 Element getValue
@Override
public String getValue()
From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.experiments.SingleNucleotideVariantExperiment.java
License:Open Source License
public void loadDataFromFile(File editFile) throws InvalidRubioSeqParameterException { SAXBuilder saxBuilder = new SAXBuilder(); try {/*ww w . ja va2 s. co m*/ Document document = saxBuilder.build(editFile); Element configData = document.getRootElement(); Element genRef = configData.getChild(GENREF); if (validElement(genRef)) { this.setGenRefPath(Utils.getRUbioSeqFile(genRef.getValue())); } Element dbSnpAnnot = configData.getChild(DBSNPANNOT); if (validElement(dbSnpAnnot)) { this.setDbSnpAnnotPath(Utils.getRUbioSeqFile(dbSnpAnnot.getValue())); } Element genomes1000Annot = configData.getChild(GENOMES1000ANNOT); if (validElement(genomes1000Annot)) { this.setGenomes1000AnnotPath(Utils.getRUbioSeqFile(genomes1000Annot.getValue())); } Element indelAnnot = configData.getChild(INDELANNOT); if (validElement(indelAnnot)) { this.setIndelAnnotPath(Utils.getRUbioSeqFile(indelAnnot.getValue())); } Element intervals = configData.getChild(INTERVALS); if (validElement(intervals)) { this.setIntervalsPath(Utils.getRUbioSeqFile(intervals.getValue())); } for (Element knownIndels : configData.getChildren(KNOWNINDELS)) { if (validElement(knownIndels)) { KnownIndels kI = new KnownIndels(); kI.setFile(Utils.getRUbioSeqFile(knownIndels.getValue())); this.knownIndels.add(kI); } } Element plattform = configData.getChild(PLATTFORM); if (validElement(plattform)) { String plattformValue = plattform.getValue().toLowerCase(); if (plattformValue.equals("illumina")) { this.setPlattform(PlattformTech.ILLUMINA); } else if (plattformValue.equals("ion")) { this.setPlattform(PlattformTech.ION); } else if (plattformValue.equals("solid")) { this.setPlattform(PlattformTech.SOLID); } } Element checkCasava = configData.getChild(CHECKCASAVA); if (validElement(checkCasava)) { this.setCheckCasava(Integer.valueOf(checkCasava.getValue())); } Element dirOutBase = configData.getChild(DIROUTBASE); if (validElement(dirOutBase)) { this.setDirOutBase(Utils.getRUbioSeqFile(dirOutBase.getValue())); } Element projectId = configData.getChild(PROJECTID); if (validElement(projectId)) { this.setProjectId(projectId.getValue()); } Element userName = configData.getChild(USERNAME); if (validElement(userName)) { this.setUserName(userName.getValue()); } Element dataInDirpreProcess = configData.getChild(INDIRPREPROCESS); if (validElement(dataInDirpreProcess)) { this.setDataInDirpreProcess(Utils.getRUbioSeqFile(dataInDirpreProcess.getValue())); } for (Element sampleElement : configData.getChildren(SAMPLE)) { Sample newSample = new Sample(); Element sampleName = sampleElement.getChild(SAMPLE_NAME); if (validElement(sampleName)) { newSample.setSampleName(sampleName.getValue()); } Element sampleFiles = sampleElement.getChild(SAMPLE_FILES); if (validElement(sampleFiles)) { newSample.setSampleFiles(sampleFiles.getValue()); } Element sampleSuffix = sampleElement.getChild(SAMPLE_SUFFIX); if (validElement(sampleSuffix)) { newSample.setSampleSuffix(sampleSuffix.getValue()); } Element sampleType = sampleElement.getChild(SAMPLE_TYPE); if (validElement(sampleType)) { newSample.setSampleType( sampleType.getValue().equals("1") ? SampleType.SingleEnd : SampleType.PairedEnd); } this.getSamples().add(newSample); } Element callingType = configData.getChild(CALLYING_TYPE); if (validElement(callingType)) { String callingTypeValue = callingType.getValue().toUpperCase(); if (callingTypeValue.equals("SNP")) { this.setCallingType(CallingType.SNP); } else if (callingTypeValue.equals("INDEL")) { this.setCallingType(CallingType.INDEL); } else if (callingTypeValue.equals("BOTH")) { this.setCallingType(CallingType.BOTH); } } Element gATKoutputModeoutputMode = configData.getChild(GATKOUTPUTMODE); if (validElement(gATKoutputModeoutputMode)) { String gatkOutputModeValue = gATKoutputModeoutputMode.getValue().toUpperCase(); if (gatkOutputModeValue.equals("EMIT_VARIANTS_ONLY")) { this.setgATKoutputMode(GATKoutputMode.EMIT_VARIANTS_ONLY); } else if (gatkOutputModeValue.equals("EMIT_ALL_SITES")) { this.setgATKoutputMode(GATKoutputMode.EMIT_ALL_SITES); } else if (gatkOutputModeValue.equals("EMIT_ALL_CONFIDENT_SITES")) { this.setgATKoutputMode(GATKoutputMode.EMIT_ALL_CONFIDENT_SITES); } } Element rsFilter = configData.getChild(RSFILTER); if (validElement(rsFilter)) { this.setRsFilter(Integer.valueOf(rsFilter.getValue())); } Element rUbioSeq_Mode = configData.getChild(RUBIOSEQMODE); if (validElement(rUbioSeq_Mode)) { this.setrUbioSeqMode(Integer.valueOf(rUbioSeq_Mode.getValue())); } Element fastqc = configData.getChild(FASTQC); if (validElement(fastqc)) { this.setFastqc(Integer.valueOf(fastqc.getValue())); } Element vEPFlag = configData.getChild(VEPFLAG); if (validElement(vEPFlag)) { this.setvEPFlag(Integer.valueOf(vEPFlag.getValue())); } Element tCFlag = configData.getChild(TCFLAG); if (validElement(tCFlag)) { this.settCFlag(Integer.valueOf(tCFlag.getValue())); } Element mDFlag = configData.getChild(MDFLAG); if (validElement(mDFlag)) { this.setmDFlag(Integer.valueOf(mDFlag.getValue())); } Element standCallConf = configData.getChild(STANDCALLCONF); if (validElement(standCallConf)) { this.setStandCallConf(Double.valueOf(standCallConf.getValue())); } Element standEmitConf = configData.getChild(STANDEMITCONF); if (validElement(standEmitConf)) { this.setStandEmitConf(Double.valueOf(standEmitConf.getValue())); } Element queueSGEProject = configData.getChild(QUEUESGEPROJECT); if (validElement(queueSGEProject)) { this.setQueueSGEProject(queueSGEProject.getValue()); } Element vqsrBlock = configData.getChild(VQSRBLOCK); if (vqsrBlock != null) { this.setChoiceVqrsHardFilters(VQRSHardFiltersChoice.VQRS); Element mills = vqsrBlock.getChild(MILLS); if (validElement(mills)) { this.setvQSRblockMills(Utils.getRUbioSeqFile(mills.getValue())); } Element hapmap = vqsrBlock.getChild(HAPMAP); if (validElement(hapmap)) { this.setvQSRblockHapMAp(Utils.getRUbioSeqFile(hapmap.getValue())); } Element thousandg = vqsrBlock.getChild(THOUSANDG); if (validElement(thousandg)) { this.setvQSRblockThousandG(Utils.getRUbioSeqFile(thousandg.getValue())); } } Element hardFiltersBlock = configData.getChild(HFILTERS); if (hardFiltersBlock != null) { this.setChoiceVqrsHardFilters(VQRSHardFiltersChoice.HARDFILTERS); Element dpMin = hardFiltersBlock.getChild(DPMIN); if (validElement(dpMin)) { this.setdPmin(Integer.valueOf(dpMin.getValue())); } Element minQual = hardFiltersBlock.getChild(MINQUAL); if (validElement(minQual)) { this.setminQual(Integer.valueOf(minQual.getValue())); } Iterator<Element> hFilterNameSNP = hardFiltersBlock.getChildren(HFILTER_NAME_SNP).iterator(); Iterator<Element> hFilterRuleSNP = hardFiltersBlock.getChildren(HFILTER_RULE_SNP).iterator(); while (hFilterNameSNP.hasNext() && hFilterRuleSNP.hasNext()) { Element hFilterNameSNPElement = hFilterNameSNP.next(); Element hFilterRuleSNPElement = hFilterRuleSNP.next(); HardFilter newHardFilter = new HardFilter(); newHardFilter.setName(hFilterNameSNPElement.getValue()); newHardFilter.setRule(hFilterRuleSNPElement.getValue()); newHardFilter.setType(HFilterType.SNP); this.getHardFilters().add(newHardFilter); } Iterator<Element> hFilterNameINDEL = hardFiltersBlock.getChildren(HFILTER_NAME_INDEL).iterator(); Iterator<Element> hFilterRuleINDEL = hardFiltersBlock.getChildren(HFILTER_RULE_INDEL).iterator(); while (hFilterNameINDEL.hasNext() && hFilterRuleINDEL.hasNext()) { Element hFilterNameINDELElement = hFilterNameINDEL.next(); Element hFilterRuleINDELElement = hFilterRuleINDEL.next(); HardFilter newHardFilter = new HardFilter(); newHardFilter.setName(hFilterNameINDELElement.getValue()); newHardFilter.setRule(hFilterRuleINDELElement.getValue()); newHardFilter.setType(HFilterType.INDEL); this.getHardFilters().add(newHardFilter); } } } catch (JDOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { throw new InvalidRubioSeqParameterException(InvalidRubioSeqParameterException.DEFAULT_MESSAGE); } }
From source file:eu.himeros.hocr.XmlWordListExtractor.java
License:Open Source License
private void init(String inFileName, String outFileName) throws Exception { SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(inFileName); BufferedWriter bw = new BufferedWriter(new FileWriter(outFileName)); Element el = doc.getRootElement(); String s = el.getValue(); s = s.replaceAll("\n", " "); s = s.replaceAll(" +", " "); s = s.replace("- ", ""); s = s.replace(" ", "\n"); String[] ss = s.split("\n"); for (String item : ss) { item = item.replaceAll("[^\u0370-\u03FF\u1F00-\u1FFF]|[]", ""); if (item.length() < 1) continue; bw.write(item);/*from ww w. j a va 2 s . com*/ bw.newLine(); } bw.close(); }
From source file:fciencias.edatos.practica04.Catalogo.java
/** * Metodo que va iniciar Jdom para lectura y escritura de archivos XML * @param xmlOtroNombre elNombre original del archivo. * @throws JDOMException Excepcion de JDOM * @throws IOException Excepcion del sistema. *//*from w w w . j av a 2 s .c om*/ private void useJDOM(String baseDeDatos) throws JDOMException, IOException { SAXBuilder jdomBuilder = new SAXBuilder(); File inputFile = new File(baseDeDatos); Document jdomDocument = jdomBuilder.build(inputFile); Element firstElement = jdomDocument.getRootElement(); //Estos son los profesores for (Element elementProfesor : firstElement.getChildren()) { int[] salario = new int[12]; int c = 0; for (Element elementSalario : elementProfesor.getChildren()) { String salarioRealEnString = elementSalario.getValue(); int salarioRealMes = Integer.parseInt(salarioRealEnString); salario[c] = salarioRealMes; c++; } // System.out.println(Arrays.toString(salario)); String id = elementProfesor.getAttributeValue("id"); int id_int = Integer.parseInt(id); String nombre = elementProfesor.getAttributeValue("nombre"); String carreraString = elementProfesor.getAttributeValue("carrera"); Carrera carrera = Carrera.NO_CARRERA; if (carreraString.equals("MATEMATICAS")) { carrera = Carrera.MATEMATICAS; } else if (carreraString.equals("ACTUARIA")) { carrera = Carrera.ACTUARIA; } else if (carreraString.equals("FISICA")) { carrera = Carrera.FISICA; } else if (carreraString.equals("BIOLOGIA")) { carrera = Carrera.BIOLOGIA; } else if (carreraString.equals("CIENCIAS_DE_LA_COMPUTACION")) { carrera = Carrera.CIENCIAS_DE_LA_COMPUTACION; } else if (carreraString.equals("FISICA_BIOMEDICA")) { carrera = Carrera.FISICA_BIOMEDICA; } else if (carreraString.equals("CIENCIAS_DE_LA_TIERRA")) { carrera = Carrera.CIENCIAS_DE_LA_TIERRA; } String gradoString = elementProfesor.getAttributeValue("grado"); Grado grado = Grado.NO_GRADO; if (gradoString.equals("LICENCIADO")) { grado = Grado.LICENCIADO; } else if (gradoString.equals("MAESTRO")) { grado = Grado.MAESTRO; } else if (gradoString.equals("DOCTOR")) { grado = Grado.DOCTOR; } else if (gradoString.equals("ESPECIALISTA")) { grado = Grado.ESPECIALISTA; } Profesor profestorEnMemoria = null; profestorEnMemoria = new Profesor(id_int, nombre, carrera, grado, salario); @SuppressWarnings("unchecked") T prof = (T) profestorEnMemoria; listaProfesores.agregaFinal(prof); } }
From source file:fr.d4delta.launcher.Launcher.java
License:Open Source License
private void loadProperties(Element pom, Namespace namespace) { List<Element> properties; try {//from w w w .j ava2 s.c o m properties = pom.getChild("properties").getChildren(); for (Element e : properties) { String[] res = callback.addingPropertyNotification(e.getName(), Utils.substituteMaven(e.getValue())); if (res != null && res.length == 2) { System.setProperty(res[0], res[1]); } } } catch (NullPointerException ex) { } }
From source file:helpers.XMLParser.java
public static ParsedSingleXML parseSingleDoc(String xml) { ParsedSingleXML doc = null;/*from w ww. j av a 2 s . c om*/ try { SAXBuilder saxBuilder = new SAXBuilder(); Document document = saxBuilder.build(new StringReader(xml)); Element root = document.getRootElement(); List<Attribute> rootAttributes = root.getAttributes(); doc = new ParsedSingleXML(root.getName()); for (Attribute attr : rootAttributes) { doc.addAttr(attr.getName(), attr.getValue()); } XMLRow row; List<Element> rootChildren = root.getChildren(); List<Element> tempChildren; List<Attribute> tempAttributes; for (Element child : rootChildren) { tempChildren = child.getChildren(); row = new XMLRow(child.getName()); tempAttributes = child.getAttributes(); for (Attribute attr : tempAttributes) { row.addRootAttr(attr.getName(), attr.getValue()); } for (Element tChild : tempChildren) { row.addRowElement(tChild.getName(), tChild.getValue()); } doc.addRow(row); } } catch (JDOMException ex) { Logger.getLogger(XMLParser.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(XMLParser.class.getName()).log(Level.SEVERE, null, ex); } return doc; }
From source file:instanceXMLParser.Instance.java
public void buildINstanceJDom(String path) { //creating JDOM SAX parser SAXBuilder builder = new SAXBuilder(); //reading XML document Document xml = null;/*ww w . j a va 2s. com*/ try { xml = builder.build(new File(path)); } catch (JDOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } //getting root element from XML document Element root = xml.getRootElement(); List<Element> list = root.getChildren(); for (Element element : list) { List<Element> list1; if (element.getName().equals("board")) { list1 = element.getChildren(); for (Element element2 : list1) { if (element2.getName().equals("size_n")) {//size of the space size_n = Integer.parseInt(element2.getText()); } else if (element2.getName().equals("size_m")) {//size of the space size_m = Integer.parseInt(element2.getText()); //inizializzo matrice solo dop aver letto le due dimensioni //NOTA CHE SIZE_M E SIZE_N devono essere i primi elementi e in quell ordine! boardState = new CellLogicalState[size_n][size_m]; for (int j = 0; j < size_n; j++) { for (int k = 0; k < size_m; k++) { boardState[j][k] = new CellLogicalState(); } } } else if (element2.getName().equals("tile_state")) {//tile states int x, y, value; CellLogicalState state = new CellLogicalState(); String stateString; x = Integer.parseInt(element2.getAttribute("x").getValue()); y = Integer.parseInt(element2.getAttribute("y").getValue()); stateString = element2.getText(); if (stateString.equals("obstacle")) { state.setLocState(LocationState.Obstacle); } else if (stateString.equals("dirty")) { state.setLocState(LocationState.Dirty); value = 1; if (element2.getAttribute("value").getValue() != null) { value = Integer.parseInt(element2.getAttribute("value").getValue()); } state.setDirtyAmount(value); } boardState[x][y] = state; } } } else if (element.getName().equals("agent")) {//agent List<Element> list3 = element.getChildren(); for (Element element3 : list3) { if (element3.getName().equals("x")) { agentPos.setX(Integer.parseInt(element3.getValue())); } else if (element3.getName().equals("y")) { agentPos.setY(Integer.parseInt(element3.getValue())); } else if (element3.getName().equals("energy")) { energy = Double.parseDouble(element3.getValue()); } } } else if (element.getName().equals("base")) {//agent List<Element> list3 = element.getChildren(); for (Element element3 : list3) { if (element3.getName().equals("x")) { basePos.setX(Integer.parseInt(element3.getValue())); } else if (element3.getName().equals("y")) { basePos.setY(Integer.parseInt(element3.getValue())); } } } else if (element.getName().equals("action_costs")) {//agent List<Element> list3 = element.getChildren(); for (Element element3 : list3) { if (element3.getName().equals("up") || element3.getName().equals("left") || element3.getName().equals("down") || element3.getName().equals("right") || element3.getName().equals("suck")) { actionCosts.put(element3.getName(), Double.parseDouble(element3.getValue())); } } } } }
From source file:io.sitespeed.jenkins.xml.impl.XMLToPageTimingsJDOM.java
License:Open Source License
private Map<String, HashMap<String, String>> getMeasurements(Document doc) { List<Element> stats = doc.getRootElement().getChild("statistics").getChildren("statistic"); Map<String, HashMap<String, String>> data = new HashMap<String, HashMap<String, String>>(); for (Element statistic : stats) { String name = statistic.getChild("name").getValue(); HashMap<String, String> values = new HashMap<String, String>(); for (Element element : statistic.getChildren()) { if (!element.getName().equals("name")) { values.put(element.getName(), element.getValue()); }/* ww w . j av a2 s . co m*/ } data.put(name, values); } return data; }
From source file:io.sitespeed.jenkins.xml.impl.XMLToSummaryJDOM.java
License:Open Source License
public SiteSummary get(File summaryXML) throws IOException { final SAXBuilder b = new SAXBuilder(new XMLReaderSAX2Factory(false)); Document doc;//from w w w . j a v a 2 s.co m try { doc = b.build(summaryXML); } catch (JDOMException e) { throw new IOException(e); } Map<String, HashMap<String, String>> values = new HashMap<String, HashMap<String, String>>(); // TODO today the cache time is in seconds, probably should be converted to minutes? for (Element metric : doc.getRootElement().getChild("metrics").getChildren()) { String name = metric.getName(); name = fixBrowserKey(name); HashMap<String, String> the = new HashMap<String, String>(); for (Element valueType : metric.getChildren()) { the.put(valueType.getName(), valueType.getValue()); } values.put(name, the); } int pages = new Integer(doc.getRootElement().getChild("pages").getValue()); return new SiteSummary(values, pages); }
From source file:jgoose.IEC61850_GOOSE_ICD_file.java
License:Open Source License
void decodeGSEBlock(String GSEControlBlock_name) throws IEC61850_GOOSE_Exception { boolean found_GSEBlock = false; boolean found_APPID = false; boolean found_MACAddress = false; // Retrieves all elements named "GSE" within ConnectedAP in Communication section Filter<Element> elementFilter = new ElementFilter("GSE"); // Search for a GSE with a matching cbName for (Iterator<Element> GSE_IT = ConnectedAP_in_Comm_section.getDescendants(elementFilter); GSE_IT .hasNext();) {// w ww. j av a 2 s . c o m Element current_element = GSE_IT.next(); if (current_element.getAttributeValue("cbName").equals(GSEControlBlock_name)) { GSE_node = current_element; found_GSEBlock = true; } } if (found_GSEBlock == false) throw new IEC61850_GOOSE_Exception( "<GSE> Block with cbName: " + GSEControlBlock_name + " not found in <ConnectedAP> block"); gseldInst = GSE_node.getAttributeValue("ldInst"); // walks to the "Address" children Element GSE_Address = GSE_node.getChild("Address", root_namespace); List<Element> p_nodes_LIST = GSE_Address.getChildren("P", root_namespace); // Walks all P nodes to retrieve addressing data for (int position = 0; position < p_nodes_LIST.size(); position++) { if (p_nodes_LIST.get(position).getAttributeValue("type").contentEquals("APPID")) { gseAPPID = Integer.parseInt(p_nodes_LIST.get(position).getValue()); found_APPID = true; } if (p_nodes_LIST.get(position).getAttributeValue("type").contentEquals("MAC-Address")) { gseMACAddress = p_nodes_LIST.get(position).getValue(); found_MACAddress = true; } } if (found_APPID == false) throw new IEC61850_GOOSE_Exception( "<APPID> type not found in <GSE> Block with cbName:" + GSEControlBlock_name); if (found_MACAddress == false) throw new IEC61850_GOOSE_Exception( "<MAC-Address> type not found in <GSE> Block with cbName:" + GSEControlBlock_name); // Retrieves the maxtime Element GSE_Maxtime = GSE_node.getChild("MaxTime", root_namespace); if (GSE_Maxtime == null) //throw new IEC61850_GOOSE_Exception("<MaxTime> not found in <GSE> Block with cbName:" + GSEControlBlock_name); // If the value is not set in the ICD file, we set it to 0. gseMaxTime = 0; else gseMaxTime = Integer.parseInt(GSE_Maxtime.getValue()); // Retrieves the mintime Element GSE_Mintime = GSE_node.getChild("MinTime", root_namespace); if (GSE_Mintime == null) //throw new IEC61850_GOOSE_Exception("<MinTime> not found in <GSE> Block with cbName:" + GSEControlBlock_name); // If the value is not set in the ICD file, we set it to 0. gseMinTime = 0; else gseMinTime = Integer.parseInt(GSE_Mintime.getValue()); return; }
From source file:jmri.jmrit.vsdecoder.VSDecoderPreferences.java
License:Open Source License
public void load(org.jdom2.Element e) { if (e == null) { return;//from ww w. j a v a2 s.c om } org.jdom2.Attribute a; org.jdom2.Element c; if ((a = e.getAttribute("isAutoStartingEngine")) != null) { setAutoStartEngine(a.getValue().compareTo("true") == 0); } if ((a = e.getAttribute("isAutoLoadingDefaultVSDFile")) != null) { setAutoLoadDefaultVSDFile(a.getValue().compareTo("true") == 0); } if ((c = e.getChild("DefaultVSDFilePath")) != null) { setDefaultVSDFilePath(c.getValue()); } if ((c = e.getChild("DefaultVSDFileName")) != null) { setDefaultVSDFileName(c.getValue()); } if ((c = e.getChild("ListenerPosition")) != null) { _listenerPosition = new ListeningSpot(c); } else { _listenerPosition = new ListeningSpot(); } if ((c = e.getChild("AudioMode")) != null) { setAudioMode(c.getValue()); } }