List of usage examples for java.util Currency getInstance
public static Currency getInstance(Locale locale)
Currency
instance for the country of the given locale. From source file:net.sourceforge.eclipsetrader.core.internal.XMLRepository.java
private Security loadSecurity(NodeList node) { Security security = new Security( new Integer(Integer.parseInt(((Node) node).getAttributes().getNamedItem("id").getNodeValue()))); //$NON-NLS-1$ for (int i = 0; i < node.getLength(); i++) { Node item = node.item(i); String nodeName = item.getNodeName(); Node value = item.getFirstChild(); if (value != null) { if (nodeName.equals("code")) //$NON-NLS-1$ security.setCode(value.getNodeValue()); else if (nodeName.equals("description")) //$NON-NLS-1$ security.setDescription(value.getNodeValue()); else if (nodeName.equals("currency")) //$NON-NLS-1$ security.setCurrency(Currency.getInstance(value.getNodeValue())); else if (nodeName.equals("comment")) //$NON-NLS-1$ security.setComment(value.getNodeValue()); }// ww w .j a v a 2 s.c om if (nodeName.equals("dataCollector")) //$NON-NLS-1$ { security.setEnableDataCollector( new Boolean(((Node) item).getAttributes().getNamedItem("enable").getNodeValue()) //$NON-NLS-1$ .booleanValue()); NodeList nodeList = item.getChildNodes(); for (int q = 0; q < nodeList.getLength(); q++) { item = nodeList.item(q); nodeName = item.getNodeName(); value = item.getFirstChild(); if (nodeName.equals("begin")) //$NON-NLS-1$ { String[] s = value.getNodeValue().split(":"); //$NON-NLS-1$ security.setBeginTime(Integer.parseInt(s[0]) * 60 + Integer.parseInt(s[1])); } else if (nodeName.equals("end")) //$NON-NLS-1$ { String[] s = value.getNodeValue().split(":"); //$NON-NLS-1$ security.setEndTime(Integer.parseInt(s[0]) * 60 + Integer.parseInt(s[1])); } else if (nodeName.equals("weekdays")) //$NON-NLS-1$ security.setWeekDays(Integer.parseInt(value.getNodeValue())); else if (nodeName.equals("keepdays")) //$NON-NLS-1$ security.setKeepDays(Integer.parseInt(value.getNodeValue())); } } else if (nodeName.equalsIgnoreCase("feeds")) //$NON-NLS-1$ { NodeList nodeList = item.getChildNodes(); for (int q = 0; q < nodeList.getLength(); q++) { item = nodeList.item(q); nodeName = item.getNodeName(); value = item.getFirstChild(); if (nodeName.equals("quote")) //$NON-NLS-1$ { FeedSource feed = new FeedSource(); feed.setId(item.getAttributes().getNamedItem("id").getNodeValue()); //$NON-NLS-1$ Node attribute = item.getAttributes().getNamedItem("exchange"); //$NON-NLS-1$ if (attribute != null) feed.setExchange(attribute.getNodeValue()); if (value != null) feed.setSymbol(value.getNodeValue()); security.setQuoteFeed(feed); } else if (nodeName.equals("level2")) //$NON-NLS-1$ { FeedSource feed = new FeedSource(); feed.setId(item.getAttributes().getNamedItem("id").getNodeValue()); //$NON-NLS-1$ Node attribute = item.getAttributes().getNamedItem("exchange"); //$NON-NLS-1$ if (attribute != null) feed.setExchange(attribute.getNodeValue()); if (value != null) feed.setSymbol(value.getNodeValue()); security.setLevel2Feed(feed); } else if (nodeName.equals("history")) //$NON-NLS-1$ { FeedSource feed = new FeedSource(); feed.setId(item.getAttributes().getNamedItem("id").getNodeValue()); //$NON-NLS-1$ Node attribute = item.getAttributes().getNamedItem("exchange"); //$NON-NLS-1$ if (attribute != null) feed.setExchange(attribute.getNodeValue()); if (value != null) feed.setSymbol(value.getNodeValue()); security.setHistoryFeed(feed); } } } else if (nodeName.equalsIgnoreCase("tradeSource")) //$NON-NLS-1$ { TradeSource source = new TradeSource(); source.setTradingProviderId(item.getAttributes().getNamedItem("id").getNodeValue()); //$NON-NLS-1$ Node attribute = item.getAttributes().getNamedItem("exchange"); //$NON-NLS-1$ if (attribute != null) source.setExchange(attribute.getNodeValue()); NodeList quoteList = item.getChildNodes(); for (int q = 0; q < quoteList.getLength(); q++) { item = quoteList.item(q); nodeName = item.getNodeName(); value = item.getFirstChild(); if (value != null) { if (nodeName.equalsIgnoreCase("symbol")) //$NON-NLS-1$ source.setSymbol(value.getNodeValue()); else if (nodeName.equalsIgnoreCase("account")) //$NON-NLS-1$ source.setAccountId(new Integer(value.getNodeValue())); else if (nodeName.equalsIgnoreCase("quantity")) //$NON-NLS-1$ source.setQuantity(Integer.parseInt(value.getNodeValue())); } } security.setTradeSource(source); } else if (nodeName.equalsIgnoreCase("quote")) //$NON-NLS-1$ { Quote quote = new Quote(); NodeList quoteList = item.getChildNodes(); for (int q = 0; q < quoteList.getLength(); q++) { item = quoteList.item(q); nodeName = item.getNodeName(); value = item.getFirstChild(); if (value != null) { if (nodeName.equalsIgnoreCase("date")) //$NON-NLS-1$ { try { quote.setDate(dateTimeFormat.parse(value.getNodeValue())); } catch (Exception e) { log.warn(e.toString()); } } else if (nodeName.equalsIgnoreCase("last")) //$NON-NLS-1$ quote.setLast(Double.parseDouble(value.getNodeValue())); else if (nodeName.equalsIgnoreCase("bid")) //$NON-NLS-1$ quote.setBid(Double.parseDouble(value.getNodeValue())); else if (nodeName.equalsIgnoreCase("ask")) //$NON-NLS-1$ quote.setAsk(Double.parseDouble(value.getNodeValue())); else if (nodeName.equalsIgnoreCase("bidSize")) //$NON-NLS-1$ quote.setBidSize(Integer.parseInt(value.getNodeValue())); else if (nodeName.equalsIgnoreCase("askSize")) //$NON-NLS-1$ quote.setAskSize(Integer.parseInt(value.getNodeValue())); else if (nodeName.equalsIgnoreCase("volume")) //$NON-NLS-1$ quote.setVolume(Integer.parseInt(value.getNodeValue())); } } security.setQuote(quote); } else if (nodeName.equalsIgnoreCase("data")) //$NON-NLS-1$ { NodeList dataList = item.getChildNodes(); for (int q = 0; q < dataList.getLength(); q++) { item = dataList.item(q); nodeName = item.getNodeName(); value = item.getFirstChild(); if (value != null) { if (nodeName.equalsIgnoreCase("open")) //$NON-NLS-1$ security.setOpen(new Double(Double.parseDouble(value.getNodeValue()))); else if (nodeName.equalsIgnoreCase("high")) //$NON-NLS-1$ security.setHigh(new Double(Double.parseDouble(value.getNodeValue()))); else if (nodeName.equalsIgnoreCase("low")) //$NON-NLS-1$ security.setLow(new Double(Double.parseDouble(value.getNodeValue()))); else if (nodeName.equalsIgnoreCase("close")) //$NON-NLS-1$ security.setClose(new Double(Double.parseDouble(value.getNodeValue()))); } } } else if (nodeName.equalsIgnoreCase("split")) //$NON-NLS-1$ { NamedNodeMap attributes = item.getAttributes(); Split split = new Split(); try { split.setDate(dateTimeFormat.parse(attributes.getNamedItem("date").getNodeValue())); //$NON-NLS-1$ split.setFromQuantity(Integer.parseInt(attributes.getNamedItem("fromQuantity").getNodeValue())); //$NON-NLS-1$ split.setToQuantity(Integer.parseInt(attributes.getNamedItem("toQuantity").getNodeValue())); //$NON-NLS-1$ security.getSplits().add(split); } catch (Exception e) { log.error(e.toString()); } } else if (nodeName.equalsIgnoreCase("dividend")) //$NON-NLS-1$ { NamedNodeMap attributes = item.getAttributes(); Dividend dividend = new Dividend(); try { dividend.setDate(dateTimeFormat.parse(attributes.getNamedItem("date").getNodeValue())); //$NON-NLS-1$ dividend.setValue( new Double(Double.parseDouble(attributes.getNamedItem("value").getNodeValue())) //$NON-NLS-1$ .doubleValue()); security.getDividends().add(dividend); } catch (Exception e) { log.error(e.toString()); } } } security.clearChanged(); security.getQuoteMonitor().clearChanged(); security.getLevel2Monitor().clearChanged(); securitiesMap.put(security.getId(), security); return security; }
From source file:com.concursive.connect.web.modules.wiki.utils.WikiToHTMLUtils.java
public static String toHtml(CustomFormField field, Wiki wiki, String contextPath) { // Return output based on type switch (field.getType()) { case CustomFormField.TEXTAREA: String textAreaValue = StringUtils.replace(field.getValue(), "^", CRLF); return StringUtils.toHtml(textAreaValue); case CustomFormField.SELECT: return StringUtils.toHtml(field.getValue()); case CustomFormField.CHECKBOX: if ("true".equals(field.getValue())) { return "Yes"; } else {/*ww w .j a v a 2s . co m*/ return "No"; } case CustomFormField.CALENDAR: String calendarValue = field.getValue(); if (StringUtils.hasText(calendarValue)) { try { String convertedDate = DateUtils.getUserToServerDateTimeString(null, DateFormat.SHORT, DateFormat.LONG, field.getValue()); Timestamp timestamp = DatabaseUtils.parseTimestamp(convertedDate); Locale locale = Locale.getDefault(); int dateFormat = DateFormat.SHORT; SimpleDateFormat dateFormatter = (SimpleDateFormat) SimpleDateFormat.getDateInstance(dateFormat, locale); calendarValue = dateFormatter.format(timestamp); } catch (Exception e) { LOG.error("toHtml calendar", e); } } return StringUtils.toHtml(calendarValue); case CustomFormField.PERCENT: return StringUtils.toHtml(field.getValue()) + "%"; case CustomFormField.INTEGER: // Determine the value to display in the field String integerValue = StringUtils.toHtmlValue(field.getValue()); if (StringUtils.hasText(integerValue)) { try { NumberFormat formatter = NumberFormat.getInstance(); integerValue = formatter.format(StringUtils.getIntegerNumber(field.getValue())); } catch (Exception e) { LOG.warn("Could not integer format: " + field.getValue()); } } return integerValue; case CustomFormField.FLOAT: // Determine the value to display in the field String decimalValue = StringUtils.toHtmlValue(field.getValue()); if (StringUtils.hasText(decimalValue)) { try { NumberFormat formatter = NumberFormat.getInstance(); decimalValue = formatter.format(StringUtils.getDoubleNumber(field.getValue())); } catch (Exception e) { LOG.warn("Could not decimal format: " + field.getValue()); } } return decimalValue; case CustomFormField.CURRENCY: // Use a currency for formatting String currencyCode = field.getValueCurrency(); if (currencyCode == null) { currencyCode = field.getCurrency(); } if (!StringUtils.hasText(currencyCode)) { currencyCode = "USD"; } try { NumberFormat formatter = NumberFormat.getCurrencyInstance(); if (currencyCode != null) { Currency currency = Currency.getInstance(currencyCode); formatter.setCurrency(currency); } return (StringUtils.toHtml(formatter.format(StringUtils.getDoubleNumber(field.getValue())))); } catch (Exception e) { LOG.error("toHtml currency", e); } return StringUtils.toHtml(field.getValue()); case CustomFormField.EMAIL: return StringUtils.toHtml(field.getValue()); case CustomFormField.PHONE: PhoneNumberBean phone = new PhoneNumberBean(); phone.setNumber(field.getValue()); PhoneNumberUtils.format(phone, Locale.getDefault()); return StringUtils.toHtml(phone.toString()); case CustomFormField.URL: String value = StringUtils.toHtmlValue(field.getValue()); if (StringUtils.hasText(value)) { if (!value.contains("://")) { value = "http://" + value; } if (value.contains("://")) { return ("<a href=\"" + StringUtils.toHtml(value) + "\">" + StringUtils.toHtml(value) + "</a>"); } } return StringUtils.toHtml(value); case CustomFormField.IMAGE: String image = StringUtils.toHtmlValue(field.getValue()); if (StringUtils.hasText(image)) { Project project = ProjectUtils.loadProject(wiki.getProjectId()); return ("<img src=\"" + contextPath + "/show/" + project.getUniqueId() + "/wiki-image/" + image + "\"/>"); } return StringUtils.toHtml(image); default: return StringUtils.toHtml(field.getValue()); } }
From source file:org.mobicents.servlet.restcomm.interpreter.VoiceInterpreter.java
private void createInitialCallRecord(CallResponse<CallInfo> message) { final CallDetailRecordsDao records = storage.getCallDetailRecordsDao(); final CallResponse<CallInfo> response = message; callInfo = response.get();// w ww. j a v a2s .com callState = callInfo.state(); if (callInfo.direction().equals("inbound")) { callRecord = records.getCallDetailRecord(callInfo.sid()); if (callRecord == null) { // Create a call detail record for the call. final CallDetailRecord.Builder builder = CallDetailRecord.builder(); builder.setSid(callInfo.sid()); builder.setInstanceId(RestcommConfiguration.getInstance().getMain().getInstanceId()); builder.setDateCreated(callInfo.dateCreated()); builder.setAccountSid(accountId); builder.setTo(callInfo.to()); if (callInfo.fromName() != null) { builder.setCallerName(callInfo.fromName()); } else { builder.setCallerName("Unknown"); } if (callInfo.from() != null) { builder.setFrom(callInfo.from()); } else { builder.setFrom("Unknown"); } builder.setForwardedFrom(callInfo.forwardedFrom()); builder.setPhoneNumberSid(phoneId); builder.setStatus(callState.toString()); final DateTime now = DateTime.now(); builder.setStartTime(now); builder.setDirection(callInfo.direction()); builder.setApiVersion(version); builder.setPrice(new BigDecimal("0.00")); builder.setMuted(false); builder.setOnHold(false); // TODO implement currency property to be read from Configuration builder.setPriceUnit(Currency.getInstance("USD")); final StringBuilder buffer = new StringBuilder(); buffer.append("/").append(version).append("/Accounts/"); buffer.append(accountId.toString()).append("/Calls/"); buffer.append(callInfo.sid().toString()); final URI uri = URI.create(buffer.toString()); builder.setUri(uri); builder.setCallPath(call.path().toString()); callRecord = builder.build(); records.addCallDetailRecord(callRecord); // // if (liveCallModification) { // logger.info("There is no CallRecord for this call but this is a LiveCallModificatin request. Will acquire call media group"); // fsm.transition(message, acquiringCallMediaGroup); // return; // } } // Update the application. callback(); } }
From source file:net.sourceforge.eclipsetrader.core.internal.XMLRepository.java
private Watchlist loadWatchlist(NodeList node) { int itemIndex = 1; Watchlist watchlist = new Watchlist( new Integer(Integer.parseInt(((Node) node).getAttributes().getNamedItem("id").getNodeValue()))); //$NON-NLS-1$ for (int i = 0; i < node.getLength(); i++) { Node item = node.item(i); String nodeName = item.getNodeName(); Node value = item.getFirstChild(); if (value != null) { if (nodeName.equalsIgnoreCase("title")) //$NON-NLS-1$ watchlist.setDescription(value.getNodeValue()); else if (nodeName.equalsIgnoreCase("style")) //$NON-NLS-1$ watchlist.setStyle(Integer.parseInt(value.getNodeValue())); else if (nodeName.equalsIgnoreCase("feed")) //$NON-NLS-1$ watchlist.setDefaultFeed(value.getNodeValue()); else if (nodeName.equals("currency")) //$NON-NLS-1$ watchlist.setCurrency(Currency.getInstance(value.getNodeValue())); }/*w ww. jav a 2s. co m*/ if (nodeName.equalsIgnoreCase("columns")) //$NON-NLS-1$ { List list = new ArrayList(); NodeList columnList = item.getChildNodes(); for (int c = 0; c < columnList.getLength(); c++) { item = columnList.item(c); nodeName = item.getNodeName(); if (nodeName.equalsIgnoreCase("column")) //$NON-NLS-1$ { WatchlistColumn column = new WatchlistColumn(); if (item.getAttributes().getNamedItem("id") != null) //$NON-NLS-1$ column.setId(item.getAttributes().getNamedItem("id").getNodeValue()); //$NON-NLS-1$ else if (item.getAttributes().getNamedItem("class") != null) //$NON-NLS-1$ { String id = item.getAttributes().getNamedItem("class").getNodeValue(); //$NON-NLS-1$ id = id.substring(id.lastIndexOf('.') + 1); column.setId("watchlist." + id.substring(0, 1).toLowerCase() + id.substring(1)); //$NON-NLS-1$ } list.add(column); } } watchlist.setColumns(list); } else if (nodeName.equalsIgnoreCase("items")) //$NON-NLS-1$ { List list = new ArrayList(); NodeList itemList = item.getChildNodes(); for (int c = 0; c < itemList.getLength(); c++) { item = itemList.item(c); nodeName = item.getNodeName(); if (nodeName.equalsIgnoreCase("security")) //$NON-NLS-1$ { String id = ((Node) item).getAttributes().getNamedItem("id").getNodeValue(); //$NON-NLS-1$ Security security = (Security) load(Security.class, new Integer(id)); if (security == null) { log.warn("Cannot load security (id=" + id + ")"); //$NON-NLS-1$ //$NON-NLS-2$ continue; } WatchlistItem watchlistItem = new WatchlistItem(new Integer(itemIndex++)); watchlistItem.setParent(watchlist); watchlistItem.setSecurity(security); int alertIndex = 1; NodeList quoteList = item.getChildNodes(); for (int q = 0; q < quoteList.getLength(); q++) { item = quoteList.item(q); nodeName = item.getNodeName(); value = item.getFirstChild(); if (value != null) { if (nodeName.equalsIgnoreCase("position")) //$NON-NLS-1$ watchlistItem.setPosition(Integer.parseInt(value.getNodeValue())); else if (nodeName.equalsIgnoreCase("paid")) //$NON-NLS-1$ watchlistItem.setPaidPrice(Double.parseDouble(value.getNodeValue())); } if (nodeName.equalsIgnoreCase("alert")) //$NON-NLS-1$ { Alert alert = new Alert(new Integer(alertIndex++)); alert.setPluginId(item.getAttributes().getNamedItem("pluginId").getNodeValue()); //$NON-NLS-1$ if (item.getAttributes().getNamedItem("lastSeen") != null) //$NON-NLS-1$ { try { alert.setLastSeen(dateTimeFormat.parse( item.getAttributes().getNamedItem("lastSeen").getNodeValue())); //$NON-NLS-1$ } catch (Exception e) { log.warn(e.toString()); } } if (item.getAttributes().getNamedItem("popup") != null) //$NON-NLS-1$ alert.setPopup( new Boolean(item.getAttributes().getNamedItem("popup").getNodeValue()) //$NON-NLS-1$ .booleanValue()); if (item.getAttributes().getNamedItem("hilight") != null) //$NON-NLS-1$ alert.setHilight( new Boolean(item.getAttributes().getNamedItem("hilight").getNodeValue()) //$NON-NLS-1$ .booleanValue()); NodeList paramList = item.getChildNodes(); for (int p = 0; p < paramList.getLength(); p++) { item = paramList.item(p); nodeName = item.getNodeName(); value = item.getFirstChild(); if (value != null) { if (nodeName.equalsIgnoreCase("param")) //$NON-NLS-1$ { String key = ((Node) item).getAttributes().getNamedItem("key") //$NON-NLS-1$ .getNodeValue(); alert.getParameters().put(key, value.getNodeValue()); } } } watchlistItem.getAlerts().add(alert); } } list.add(watchlistItem); } } watchlist.setItems(list); } } watchlist.clearChanged(); return watchlist; }
From source file:org.restcomm.connect.interpreter.VoiceInterpreter.java
private void createInitialCallRecord(CallResponse<CallInfo> message) { final CallDetailRecordsDao records = storage.getCallDetailRecordsDao(); final CallResponse<CallInfo> response = message; callInfo = response.get();/*from w w w. j a v a2 s . c o m*/ callState = callInfo.state(); if (callInfo.direction().equals("inbound")) { callRecord = records.getCallDetailRecord(callInfo.sid()); if (callRecord == null) { // Create a call detail record for the call. final CallDetailRecord.Builder builder = CallDetailRecord.builder(); builder.setSid(callInfo.sid()); builder.setInstanceId(RestcommConfiguration.getInstance().getMain().getInstanceId()); builder.setDateCreated(callInfo.dateCreated()); builder.setAccountSid(accountId); builder.setTo(callInfo.to()); if (callInfo.fromName() != null) { builder.setCallerName(callInfo.fromName()); } else { builder.setCallerName("Unknown"); } if (callInfo.from() != null) { builder.setFrom(callInfo.from()); } else { builder.setFrom("Unknown"); } builder.setForwardedFrom(callInfo.forwardedFrom()); builder.setPhoneNumberSid(phoneId); builder.setStatus(callState.toString()); final DateTime now = DateTime.now(); builder.setStartTime(now); builder.setDirection(callInfo.direction()); builder.setApiVersion(version); builder.setPrice(new BigDecimal("0.00")); builder.setMuted(false); builder.setOnHold(false); // TODO implement currency property to be read from Configuration builder.setPriceUnit(Currency.getInstance("USD")); final StringBuilder buffer = new StringBuilder(); buffer.append("/").append(version).append("/Accounts/"); buffer.append(accountId.toString()).append("/Calls/"); buffer.append(callInfo.sid().toString()); final URI uri = URI.create(buffer.toString()); builder.setUri(uri); builder.setCallPath(call.path().toString()); callRecord = builder.build(); records.addCallDetailRecord(callRecord); } // Update the application. callback(); } }
From source file:net.sourceforge.eclipsetrader.core.internal.XMLRepository.java
private Account loadAccount(NodeList node, AccountGroup group) { Integer id = new Integer(Integer.parseInt(((Node) node).getAttributes().getNamedItem("id").getNodeValue())); //$NON-NLS-1$ String pluginId = ""; //$NON-NLS-1$ if (((Node) node).getAttributes().getNamedItem("pluginId") != null) //$NON-NLS-1$ pluginId = ((Node) node).getAttributes().getNamedItem("pluginId").getNodeValue(); //$NON-NLS-1$ if (pluginId.equals("")) //$NON-NLS-1$ pluginId = "net.sourceforge.eclipsetrader.accounts.simple"; //$NON-NLS-1$ PersistentPreferenceStore preferenceStore = new PersistentPreferenceStore(); List transactions = new ArrayList(); for (int i = 0; i < node.getLength(); i++) { Node item = node.item(i); String nodeName = item.getNodeName(); Node value = item.getFirstChild(); if (nodeName.equals("transaction")) //$NON-NLS-1$ {//from w w w .j av a2 s .com Transaction transaction = new Transaction( new Integer(Integer.parseInt(item.getAttributes().getNamedItem("id").getNodeValue()))); //$NON-NLS-1$ NodeList childs = item.getChildNodes(); for (int ii = 0; ii < childs.getLength(); ii++) { item = childs.item(ii); nodeName = item.getNodeName(); value = item.getFirstChild(); if (value != null) { if (nodeName.equals("date")) //$NON-NLS-1$ { try { transaction.setDate(dateTimeFormat.parse(value.getNodeValue())); } catch (Exception e) { log.error(e.toString(), e); break; } } else if (nodeName.equals("security")) //$NON-NLS-1$ { transaction.setSecurity((Security) load(Security.class, new Integer(Integer.parseInt(value.getNodeValue())))); if (transaction.getSecurity() == null) log.warn("Cannot load security (id=" + value.getNodeValue() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } else if (nodeName.equals("price")) //$NON-NLS-1$ transaction.setPrice(Double.parseDouble(value.getNodeValue())); else if (nodeName.equals("quantity")) //$NON-NLS-1$ transaction.setQuantity(Integer.parseInt(value.getNodeValue())); else if (nodeName.equals("expenses")) //$NON-NLS-1$ transaction.setExpenses(Double.parseDouble(value.getNodeValue())); } if (nodeName.equalsIgnoreCase("param") == true) //$NON-NLS-1$ { NamedNodeMap map = item.getAttributes(); transaction.getParams().put(map.getNamedItem("key").getNodeValue(), //$NON-NLS-1$ map.getNamedItem("value").getNodeValue()); //$NON-NLS-1$ } } if (transaction.getSecurity() != null) transactions.add(transaction); } else if (value != null) { if (nodeName.equals("description")) //$NON-NLS-1$ ; else if (nodeName.equals("currency")) //$NON-NLS-1$ ; else if (nodeName.equals("initialBalance")) //$NON-NLS-1$ ; else preferenceStore.setValue(nodeName, value.getNodeValue()); } } Collections.sort(transactions, new Comparator() { public int compare(Object arg0, Object arg1) { return ((Transaction) arg0).getDate().compareTo(((Transaction) arg1).getDate()); } }); Account account = CorePlugin.createAccount(pluginId, preferenceStore, transactions); account.setId(id); account.setPluginId(pluginId); account.setGroup(group); for (int i = 0; i < node.getLength(); i++) { Node item = node.item(i); String nodeName = item.getNodeName(); Node value = item.getFirstChild(); if (value != null) { if (nodeName.equals("description")) //$NON-NLS-1$ account.setDescription(value.getNodeValue()); else if (nodeName.equals("currency")) //$NON-NLS-1$ account.setCurrency(Currency.getInstance(value.getNodeValue())); else if (nodeName.equals("initialBalance")) //$NON-NLS-1$ account.setInitialBalance(Double.parseDouble(value.getNodeValue())); } } account.clearChanged(); accountMap.put(account.getId(), account); allAccounts().add(account); return account; }
From source file:org.oscm.serviceprovisioningservice.bean.ServiceProvisioningServiceBean.java
SupportedCurrency getSupportedCurrency(VOPriceModel priceModel, Product product) throws CurrencyException { // load the currency information SupportedCurrency currency = null;// w ww. j a v a2s.com if (priceModel.getCurrencyISOCode() != null) { currency = new SupportedCurrency(); currency.setCurrency(Currency.getInstance(priceModel.getCurrencyISOCode())); currency = (SupportedCurrency) dm.find(currency); } if (priceModel.isChargeable()) { if (currency == null) { // currency is not supported by the system, so throw an // exception CurrencyException uc = new CurrencyException("Creation of price model failed.", new Object[] { priceModel.getCurrencyISOCode() }); logger.logWarn(Log4jLogger.SYSTEM_LOG, uc, LogMessageIdentifier.WARN_PRODUCT_CREATION_FAILED_CURRENCY_NOT_SUPPORTED, Long.toString(product.getKey()), priceModel.getCurrencyISOCode(), Long.toString(dm.getCurrentUser().getKey())); throw uc; } } return currency; }
From source file:de.schildbach.pte.AbstractEfaProvider.java
private Currency parseCurrency(final String currencyStr) { if (currencyStr.equals("US$")) return Currency.getInstance("USD"); if (currencyStr.equals("Dirham")) return Currency.getInstance("AED"); return Currency.getInstance(currencyStr); }