List of usage examples for org.dom4j Element attributeValue
String attributeValue(QName qName);
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 ww w . jav a 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:bixo.examples.webmining.AnalyzeHtml.java
License:Apache License
private String getAttributeFromNode(Node node, String attribute) { String attributeValue = null; if (node.getNodeType() == Node.ELEMENT_NODE) { Element e = (Element) node; attributeValue = e.attributeValue(attribute); }//from ww w . j av a 2 s . com return (attributeValue == null ? "" : attributeValue); }
From source file:ca.upei.roblib.fedora.servletfilter.DrupalAuthModule.java
License:Apache License
protected Map<String, String> parseConnectionElement(Element connection) { Map<String, String> toReturn = new HashMap<String, String>(); toReturn.put("server", connection.attributeValue("server")); toReturn.put("database", connection.attributeValue("dbname")); toReturn.put("user", connection.attributeValue("user")); toReturn.put("pass", connection.attributeValue("password")); toReturn.put("port", connection.attributeValue("port")); toReturn.put("jdbcDriverClass", connection.attributeValue("jdbcDriverClass")); toReturn.put("jdbcURLProtocol", connection.attributeValue("jdbcURLProtocol")); Element sqlElement = connection.element("sql"); toReturn.put("sql", sqlElement.getTextTrim()); return toReturn; }
From source file:cc.warlock.core.client.logging.LoggingConfiguration.java
License:Open Source License
public void parseElement(Element element) { if (element.getName().equals("logging")) { enableLogging = Boolean.parseBoolean(element.attributeValue("enabled")); logFormat = element.attributeValue("format"); Element dir = element.element("dir"); if (dir != null) { logDirectory = new File(dir.getTextTrim()); }//from w w w. ja v a 2 s. c o m } }
From source file:cc.warlock.core.client.settings.internal.ClientConfigurationProvider.java
License:Open Source License
protected WarlockFont elementToFont(Element element) { if (element == null) return WarlockFont.DEFAULT_FONT; if (element.attributeValue("family").equals("default")) return WarlockFont.DEFAULT_FONT; WarlockFont font = new WarlockFont(); font.setFamilyName(element.attributeValue("family")); font.setSize(Integer.parseInt(element.attributeValue("size"))); return font;// w ww .j a va 2 s. c o m }
From source file:cc.warlock.core.client.settings.internal.ClientSettings.java
License:Open Source License
@Override public boolean supportsElement(Element element) { if (element.getName().equals("client-settings") && client.getClientId() != null) { String clientId = element.attributeValue("client-id"); if (clientId.equals(client.getClientId())) { return true; }/* www. j a va 2 s . co m*/ } return false; }
From source file:cc.warlock.core.client.settings.internal.HighlightConfigurationProvider.java
License:Open Source License
protected IWarlockStyle createStyle(Element sElement) { WarlockStyle style = new WarlockStyle(); style.setBackgroundColor(colorValue(sElement, "background")); style.setForegroundColor(colorValue(sElement, "foreground")); if (sElement.attributeValue("name") != null) { style.setName(stringValue(sElement, "name")); }//from www. j a v a2 s .c om for (Element typeElement : (List<Element>) sElement.elements()) { String text = typeElement.getTextTrim(); style.addStyleType(IWarlockStyle.StyleType.valueOf(text)); } style.setFullLine(booleanValue(sElement, "full-line")); //System.out.println("Setting style sound to " + sElement.attributeValue("sound")); style.setSound(sElement.attributeValue("sound")); return style; }
From source file:cc.warlock.core.client.settings.internal.PatternConfigurationProvider.java
License:Open Source License
protected void fillSetting(IPatternSetting setting, Element element) { String pattern = stringValue(element, "pattern"); boolean literal = booleanValue(element, "literal"); boolean caseSensitive = booleanValue(element, "caseSensitive"); boolean fullWordMatch = true; if (element.attributeValue("fullWordMatch") == null) { fullWordMatch = true;/* www.ja v a 2 s.c o m*/ } else { fullWordMatch = booleanValue(element, "fullWordMatch"); } setting.setLiteral(literal); setting.setCaseSensitive(caseSensitive); setting.setFullWordMatch(fullWordMatch); setting.setText(pattern); }
From source file:cc.warlock.core.client.settings.internal.VariableConfigurationProvider.java
License:Open Source License
@Override protected void parseChild(Element child) { if (child.getName().equals("variable")) { String name = child.attributeValue("id"); String value = child.getStringValue(); Variable variable = new Variable(this, name, value); variables.put(name, variable);/*from ww w . ja v a 2 s.c o m*/ } }
From source file:cc.warlock.core.client.settings.internal.WindowSettingsConfigurationProvider.java
License:Open Source License
@Override protected void parseChild(Element child) { if (child.getName().equals("window")) { WindowSettings settings = (WindowSettings) getWindowSettings(child.attributeValue("id")); boolean add = false; if (settings == null) { settings = new WindowSettings(this); add = true;/*from w w w.ja v a 2 s . c o m*/ } settings.setBackgroundColor(colorValue(child, "background")); settings.setForegroundColor(colorValue(child, "foreground")); settings.setFont(elementToFont(child.element("font"))); settings.setColumnFont(elementToFont(child.element("columnFont"))); settings.setId(child.attributeValue("id")); if (add) { windowSettings.add(settings); } } }