List of usage examples for org.jdom2 Attribute getIntValue
public int getIntValue() throws DataConversionException
int
form, and if no conversion can occur, throws a DataConversionException
From source file:org.jpos.q2.qbean.QThreadPoolExecutor.java
License:Open Source License
/** * Handle specific config elements/*from w w w . j a v a2 s . c o m*/ * * type := "fixed" | "scheduled" | "cached" corePoolSize := integer * (required for "fixed" and "scheduled" kinds, optional for "cached" kind) * */ @Override protected void initService() throws Exception { Element rootElt = this.getPersist(); Attribute execSrvTypeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TYPE, true, "(thread pool executor type among {fixed|cached|scheduled|single})"); execSrvType = execSrvTypeAttr.getValue().trim(); if ("fixed".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else if ("cached".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, false, "(number of threads in the pool)"); if (null != corePoolSizeAttr) { initialCorePoolSize = corePoolSizeAttr.getIntValue(); } } else if ("scheduled".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else { throw new ConfigurationException( "Invalid thread pool executor type '%s' (valid types={fixed|cached|scheduled} )"); } Attribute terminationTimerAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER, false, "(termination timer in seconds)"); if (null != terminationTimerAttr) { terminationTimer = terminationTimerAttr.getIntValue(); } }
From source file:strategies.StockPurchase.java
void LoadFromXml(Element purchaseElement) { try {/*from ww w .j av a 2 s . c o m*/ Attribute attribute = purchaseElement.getAttribute("priceForOne"); priceForOne = attribute.getDoubleValue(); attribute = purchaseElement.getAttribute("position"); position = attribute.getIntValue(); attribute = purchaseElement.getAttribute("portions"); portions = attribute.getIntValue(); attribute = purchaseElement.getAttribute("date"); date = LocalDate.parse(attribute.getValue()); } catch (DataConversionException ex) { logger.severe("Error in loading from XML: Failed to convert values in purchases. " + ex.getMessage()); } }
From source file:tradingapp.Settings.java
public static void ReadSettings() { try {//from w w w . ja va 2 s.co m File inputFile = new File(FilePaths.settingsPathFile); SAXBuilder saxBuilder = new SAXBuilder(); Document document = saxBuilder.build(inputFile); Element rootElement = document.getRootElement(); Attribute attribute; // connection Element connectionElement = rootElement.getChild("connection"); attribute = connectionElement.getAttribute("port"); port = attribute.getIntValue(); attribute = connectionElement.getAttribute("clientId"); clientId = attribute.getIntValue(); // money Element moneyElement = rootElement.getChild("money"); attribute = moneyElement.getAttribute("investCash"); investCash = attribute.getDoubleValue(); attribute = moneyElement.getAttribute("leverage"); leverage = attribute.getDoubleValue(); // mail Element mailElement = rootElement.getChild("mail"); mailAddressTradeLog = mailElement.getAttribute("addressTradeLog").getValue(); mailAddressCheck = mailElement.getAttribute("addressCheck").getValue(); mailAddressError = mailElement.getAttribute("addressError").getValue(); mailFrom = mailElement.getAttribute("from").getValue(); mailPassword = mailElement.getAttribute("password").getValue(); logger.fine("Updated Settings"); logger.fine("Loaded Connection - port: " + port + ", clientId: " + clientId); logger.fine("Loaded money - investCash: " + investCash + ", leverage: " + leverage); logger.fine("Loaded mail - mailAddressTradeLog: " + mailAddressTradeLog + ", mailAddressCheck: " + mailAddressCheck + ", mailAddressError: " + mailAddressError + ", mailFrom: " + mailFrom + ", mailPassword: " + mailPassword); } catch (JDOMException e) { logger.severe("Error in loading from XML: JDOMException.\r\n" + e); } catch (IOException ioe) { logger.severe("Error in loading from XML: IOException.\r\n" + ioe); } }