List of usage examples for org.dom4j Element elementIterator
Iterator<Element> elementIterator();
From source file:au.gov.ansto.bragg.process.parse.Parse.java
License:Open Source License
protected static List<OutConfiguration> getOutConfigurationList(final Element element, final String parentName) throws DocumentException { // List<?> list = element.selectNodes("*"); List<OutConfiguration> portList = new LinkedList<OutConfiguration>(); for (Iterator<?> iter = element.elementIterator(); iter.hasNext();) { Element item = (Element) iter.next(); portList.add((OutConfiguration) getPortConfiguration(item, "out", parentName)); }/* w ww . j a va 2 s .co m*/ return portList; }
From source file:au.gov.ansto.bragg.process.parse.Parse.java
License:Open Source License
protected static List<VarConfiguration> getVarConfigurationList(final Element element, final String parentName) throws DocumentException { List<VarConfiguration> portList = new LinkedList<VarConfiguration>(); for (Iterator<?> iter = element.elementIterator(); iter.hasNext();) { Element item = (Element) iter.next(); portList.add((VarConfiguration) getPortConfiguration(item, "var", parentName)); }/*from w w w . j a va2 s . c om*/ return portList; }
From source file:au.gov.ansto.bragg.process.parse.Parse.java
License:Open Source License
protected static List<ConnectorConfiguration> getConnectorConfigurationList(final Element element, final String parentName) throws DocumentException { List<ConnectorConfiguration> connectorList = new LinkedList<ConnectorConfiguration>(); for (Iterator<?> iter = element.elementIterator(); iter.hasNext();) { Element item = (Element) iter.next(); connectorList.add((ConnectorConfiguration) getConnectorConfiguration(item, parentName)); }/* ww w. j ava2 s .co m*/ return connectorList; }
From source file:au.gov.ansto.bragg.process.parse.Parse.java
License:Open Source License
protected static List<AgentConfiguration> getAgentConfigurationList(final Element element) { List<AgentConfiguration> agentConfigurationList = new ArrayList<AgentConfiguration>(); for (Iterator<?> iter = element.elementIterator(); iter.hasNext();) { Element item = (Element) iter.next(); agentConfigurationList.add((AgentConfiguration) getAgentConfiguration(item)); }/*from ww w . j a v a 2s .c o m*/ return agentConfigurationList; }
From source file:bio.pih.genoogle.io.XMLConfigurationReader.java
/** * @return {@link List} of {@link AbstractSequenceDataBank} that are * configured in the XML file./*w w w .j a v a2 s . c o m*/ */ @SuppressWarnings("unchecked") public static List<AbstractSequenceDataBank> getDataBanks() throws IOException, InvalidConfigurationException { Element rootElement = doc.getRootElement(); Element databanks = rootElement.element("databanks"); if (databanks == null) { return null; } List<AbstractSequenceDataBank> sequenceDataBanks = Lists.newLinkedList(); Iterator<AbstractSimpleSequenceDataBank> databankIterator = databanks.elementIterator(); while (databankIterator.hasNext()) { AbstractSequenceDataBank databank = getDatabank((Element) databankIterator.next(), null); if (databank == null) { return null; } sequenceDataBanks.add(databank); } return sequenceDataBanks; }
From source file:bio.pih.genoogle.io.XMLConfigurationReader.java
private static AbstractSequenceDataBank getDatabank(Element e, AbstractDatabankCollection<? extends AbstractSimpleSequenceDataBank> parent) throws IOException, InvalidConfigurationException { String name = e.attributeValue("name"); String path = readPath(e.attributeValue("path")); String mask = e.attributeValue("mask"); String lowComplexityFilterString = e.attributeValue("low-complexity-filter"); String type = e.attributeValue("type"); String remoteSimilarity = e.attributeValue("remoteSimilarity"); boolean remoteSimilarityDatabank = false; if (remoteSimilarity != null) { remoteSimilarityDatabank = Boolean.parseBoolean(remoteSimilarity); }//from w w w. j a va 2 s.c o m String subSequenceLengthString = e.attributeValue("sub-sequence-length"); int subSequenceLength; if (parent != null) { subSequenceLength = parent.getSubSequenceLength(); } else { subSequenceLength = Integer.parseInt(subSequenceLengthString); } if (name == null) { throw new InvalidConfigurationException("Missing attribute name in element " + e.getName()); } if (path == null) { throw new InvalidConfigurationException("Missing attribute path in element " + e.getName()); } if (path.equals(name)) { throw new InvalidConfigurationException("It is not possible to have a FASTA file (" + path + ") with the same name (" + name + ") of the data base."); } if ((parent != null) && path.equals(parent.getName())) { throw new InvalidConfigurationException("It is not possible to have a FASTA (" + path + ") file with the same name (" + parent.getName() + ") of the its parent data bank."); } int lowComplexityFilter = -1; if (lowComplexityFilterString != null) { lowComplexityFilter = Integer.parseInt(lowComplexityFilterString); } Alphabet alphabet = DNAAlphabet.SINGLETON; if (type != null) { if (type.toLowerCase().equals("dna")) { alphabet = DNAAlphabet.SINGLETON; } else if (type.toLowerCase().equals("rna")) { alphabet = RNAAlphabet.SINGLETON; } else if (type.toLowerCase().equals("protein")) { alphabet = AminoAcidAlphabet.SINGLETON; } else { throw new InvalidConfigurationException("Sequences type: " + type + " is invalid."); } } else { if (parent != null) { alphabet = parent.getAlphabet(); } } if (e.getName().trim().equals("split-databanks")) { String numberOfSubDatabanksAttr = e.attributeValue("number-of-sub-databanks"); if (numberOfSubDatabanksAttr == null) { throw new RuntimeException("Missing atribute 'number-of-sub-databanks' in the databank " + name); } int size = Integer.parseInt(numberOfSubDatabanksAttr); SplittedDatabankCollection splittedSequenceDatabank = new SplittedDatabankCollection(name, alphabet, new File(Genoogle.getHome(), path), subSequenceLength, size, mask); splittedSequenceDatabank.setLowComplexityFilter(lowComplexityFilter); Iterator databankIterator = e.elementIterator(); while (databankIterator.hasNext()) { try { IndexedSequenceDataBank databank = (IndexedSequenceDataBank) getDatabank( (Element) databankIterator.next(), splittedSequenceDatabank); if (databank == null) { return null; } splittedSequenceDatabank.addDatabank(databank); } catch (DuplicateDatabankException e1) { logger.fatal("Duplicate databanks named " + e1.getDatabankName() + " defined in " + e1.getDatabankName(), e1); return null; } } return splittedSequenceDatabank; } else if (e.getName().trim().equals("databank")) { File file = new File(path); try { if (remoteSimilarityDatabank == false) { return new IndexedSequenceDataBank(name, alphabet, subSequenceLength, mask, file, parent); } else { return new RemoteSimilaritySequenceDataBank(name, alphabet, subSequenceLength, file, parent); } } catch (ValueOutOfBoundsException e1) { logger.fatal("Error creating IndexedDNASequenceDataBank.", e1); } return null; } logger.error("Unknow element name " + e.getName()); return null; }
From source file:br.com.atus.util.CEPWebService.java
@SuppressWarnings("rawtypes") public CEPWebService(String cep) { try {/*from w w w . ja va2 s.c o m*/ URL url = new URL("http://cep.republicavirtual.com.br/web_cep.php?cep=" + cep + "&formato=xml"); Document document = getDocumento(url); Element root = document.getRootElement(); for (Iterator i = root.elementIterator(); i.hasNext();) { Element element = (Element) i.next(); if (element.getQualifiedName().equals("uf")) setEstado(element.getText()); if (element.getQualifiedName().equals("cidade")) setCidade(element.getText()); if (element.getQualifiedName().equals("bairro")) setBairro(element.getText()); if (element.getQualifiedName().equals("tipo_logradouro")) setTipoLogradouro(element.getText()); if (element.getQualifiedName().equals("logradouro")) setLogradouro(element.getText()); if (element.getQualifiedName().equals("resultado")) setResultado(Integer.parseInt(element.getText())); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:br.com.cgcop.utilitarios.CEPWebService.java
public void consultar(String cep) throws MalformedURLException, DocumentException { URL url = new URL("http://cep.republicavirtual.com.br/web_cep.php?cep=" + cep + "&formato=xml"); Document document = getDocumento(url); Element root = document.getRootElement(); for (Iterator i = root.elementIterator(); i.hasNext();) { Element element = (Element) i.next(); if (element.getQualifiedName().equals("uf")) { setEstado(element.getText()); }/*from w ww.jav a2s .co m*/ if (element.getQualifiedName().equals("cidade")) { setCidade(element.getText()); } if (element.getQualifiedName().equals("bairro")) { setBairro(element.getText()); } if (element.getQualifiedName().equals("tipo_logradouro")) { setTipoLogradouro(element.getText()); } if (element.getQualifiedName().equals("logradouro")) { setLogradouro(element.getText()); } if (element.getQualifiedName().equals("resultado")) { setResultado(Integer.parseInt(element.getText())); } } }
From source file:br.com.sistemapetshop.util.CepWebService.java
@SuppressWarnings("rawtypes") public CepWebService(String cep) { try {//from w ww . ja v a 2 s .c o m URL url = new URL("http://cep.republicavirtual.com.br/web_cep.php?cep=" + cep + "&formato=xml"); Document document = getDocumento(url); Element root = document.getRootElement(); for (Iterator i = root.elementIterator(); i.hasNext();) { Element element = (Element) i.next(); if (element.getQualifiedName().equals("uf")) { setEstado(element.getText()); } if (element.getQualifiedName().equals("cidade")) { setCidade(element.getText()); } if (element.getQualifiedName().equals("bairro")) { setBairro(element.getText()); } if (element.getQualifiedName().equals("tipo_logradouro")) { setTipoLogradouro(element.getText()); } if (element.getQualifiedName().equals("logradouro")) { setLogradouro(element.getText()); } if (element.getQualifiedName().equals("resultado")) { setResultado(Integer.parseInt(element.getText())); } } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:br.com.ufra.cep.service.CepWebService.java
public CepWebService(String cep) { try {//ww w .j a v a 2s.co m URL url = new URL("http://cep.republicavirtual.com.br/web_cep.php?cep=" + cep + "&formato=xml"); Document document = getDocumento(url); Element root = document.getRootElement(); for (Iterator i = root.elementIterator(); i.hasNext();) { Element element = (Element) i.next(); if (element.getQualifiedName().equals("estado")) { setEstado(element.getText()); } if (element.getQualifiedName().equals("cidade")) { setCidade(element.getText()); } if (element.getQualifiedName().equals("bairro")) { setBairro(element.getText()); } if (element.getQualifiedName().equals("tipo_logradouro")) { setTipo_logradouro(element.getText()); } if (element.getQualifiedName().equals("logradouro")) { setLogradouro(element.getText()); } if (element.getQualifiedName().equals("resultado")) { setResultado(Integer.parseInt(element.getText())); } if (element.getQualifiedName().equals("resultado_txt")) { setResultado_txt(element.getText()); } } } catch (Exception ex) { ex.printStackTrace(); } }