📄 xmlrepository.java
字号:
{ ChartRow row = new ChartRow(new Integer(r)); row.setRepository(this); row.setParent(chart); NodeList tabList = item.getChildNodes(); for (int t = 0; t < tabList.getLength(); t++) { item = tabList.item(t); nodeName = item.getNodeName(); if (nodeName.equalsIgnoreCase("tab")) //$NON-NLS-1$ { ChartTab tab = new ChartTab(new Integer(t)); tab.setRepository(this); tab.setParent(row); tab.setLabel(((Node)item).getAttributes().getNamedItem("label").getNodeValue()); NodeList indicatorList = item.getChildNodes(); for (int i = 0; i < indicatorList.getLength(); i++) { item = indicatorList.item(i); nodeName = item.getNodeName(); if (nodeName.equalsIgnoreCase("indicator")) //$NON-NLS-1$ { ChartIndicator indicator = new ChartIndicator(new Integer(i)); indicator.setRepository(this); indicator.setParent(tab); indicator.setPluginId(((Node)item).getAttributes().getNamedItem("pluginId").getNodeValue()); NodeList parametersList = item.getChildNodes(); for (int p = 0; p < parametersList.getLength(); p++) { item = parametersList.item(p); nodeName = item.getNodeName(); if (nodeName.equalsIgnoreCase("param")) //$NON-NLS-1$ { String key = ((Node)item).getAttributes().getNamedItem("key").getNodeValue(); String value = ((Node)item).getAttributes().getNamedItem("value").getNodeValue(); indicator.getParameters().put(key, value); } } tab.getIndicators().add(indicator); } else if (nodeName.equalsIgnoreCase("object")) //$NON-NLS-1$ { ChartObject object = new ChartObject(new Integer(i)); object.setRepository(this); object.setParent(tab); object.setPluginId(((Node)item).getAttributes().getNamedItem("pluginId").getNodeValue()); NodeList parametersList = item.getChildNodes(); for (int p = 0; p < parametersList.getLength(); p++) { item = parametersList.item(p); nodeName = item.getNodeName(); if (nodeName.equalsIgnoreCase("param")) //$NON-NLS-1$ { String key = ((Node)item).getAttributes().getNamedItem("key").getNodeValue(); String value = ((Node)item).getAttributes().getNamedItem("value").getNodeValue(); object.getParameters().put(key, value); } } tab.getObjects().add(object); } } row.getTabs().add(tab); } } chart.getRows().add(row); } } chart.clearChanged(); return chart; } private SecurityGroup loadSecurityGroup(NodeList node) { SecurityGroup group = new SecurityGroup(new Integer(Integer.parseInt(((Node)node).getAttributes().getNamedItem("id").getNodeValue()))); 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$ group.setCode(value.getNodeValue()); else if (nodeName.equals("description")) //$NON-NLS-1$ group.setDescription(value.getNodeValue()); else if (nodeName.equals("currency")) //$NON-NLS-1$ group.setCurrency(Currency.getInstance(value.getNodeValue())); } if (nodeName.equals("security")) //$NON-NLS-1$ { Security obj = loadSecurity(item.getChildNodes()); obj.setGroup(group); obj.setRepository(this); obj.clearChanged(); securitiesMap.put(obj.getId(), obj); allSecurities().add(obj); group.getSecurities().add(obj); } else if (nodeName.equals("group")) //$NON-NLS-1$ { SecurityGroup obj = loadSecurityGroup(item.getChildNodes()); obj.setGroup(group); obj.setRepository(this); obj.clearChanged(); group.getGroups().add(obj); allSecurityGroups().add(obj); } } group.clearChanged(); return group; } private Security loadSecurity(NodeList node) { Security security = new Security(new Integer(Integer.parseInt(((Node)node).getAttributes().getNamedItem("id").getNodeValue()))); 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()); } if (nodeName.equals("dataCollector")) //$NON-NLS-1$ { security.setEnableDataCollector(new Boolean(((Node)item).getAttributes().getNamedItem("enable").getNodeValue()).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(":"); security.setBeginTime(Integer.parseInt(s[0]) * 60 + Integer.parseInt(s[1])); } else if (nodeName.equals("end")) //$NON-NLS-1$ { String[] s = value.getNodeValue().split(":"); 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 (n
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -