用Java从XML文件中获取业务图表 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-23
dItem(elemItem, "url"); strDataURL = strDataURL.replace(''_'',''&''); LoadDataDoc(strDataURL); strChartConfigURL = GetChildItem(elemItem, "config"); LoadConfigDoc(strChartConfigURL); strDummy = GetChildItem(elemItem, "series"); LoadSeries(strDummy); strDummy = GetChildItem(elemItem, "categories"); LoadCategories(strDummy); nXSize = new Integer(strX).intValue(); if (nXSize==0) { strDummy = GetChildItem(elemItem, "XSize"); nXSize = new Integer(strDummy).intValue(); } nYSize = new Integer(strY).intValue(); if (nYSize==0) { strDummy = GetChildItem(elemItem, "YSize"); nYSize = new Integer(strDummy).intValue(); } DoChart(); response.setContentType("image/jpeg"); OutputStream out = response.getOutputStream(); ChartUtilities.writeChartAsJPEG(out, chart, nXSize, nYSize); out.close(); } catch(Exception e) { e.printStackTrace(); } } private String GetChildItem(Element elemItem, String strElemName) { NodeList nL; String strReturn; nL = elemItem.getElementsByTagName(strElemName); if(nL.getLength()>0) { Node ndeItem = nL.item(0); strReturn = ndeItem. getFirstChild().getNodeValue(); } else { strReturn = "null"; } return strReturn ; } private void LoadDataDoc(String strDocURL) { try{ URLConnection urlDataConn = new URL(strDataURL).openConnection(); urlDataConn.connect(); InputStream inData = urlDataConn.getInputStream(); xmlData = dfactory.newDocumentBuilder().parse(inData); } catch (Exception e){ } } private void LoadConfigDoc(String strConfigURL) { try{ URLConnection urlDataConn = new URL(strConfigURL).openConnection(); urlDataConn.connect(); InputStream inData = urlDataConn.getInputStream(); xmlConfig = dfactory.newDocumentBuilder().parse(inData); } catch (Exception e){ } } private void LoadSeries(String strSeries) { int nCurrentLoc = 0; int nLoc = 1; String chToFind = ","; String strCurrent; strDataXPaths.clear(); nDataXPathCount = 0; while(nLoc>0) { nLoc = strSeries.indexOf(chToFind,nCurrentLoc); if(nLoc>0) { strCurrent = strSeries.substring(nCurrentLoc,nLoc); strSeries = strSeries.substring(nLoc+1,strSeries.length()); } else { strCurrent = strSeries; } strDataXPaths.add(strCurrent); nDataXPathCount++; } } private void LoadCategories(String strCategories) { int nCurrentLoc = 0; int nLoc = 1; nCategoryXPathCount = 0; String chToFind = ","; String strCurrent; strCategoryXPaths.clear(); while(nLoc>0) { nLoc = strCategories.indexOf(chToFind,nCurrentLoc); if(nLoc>0) { strCurrent = strCategories.substring(nCurrentLoc,nLoc); strCategories = strCategories.substring(nLoc+1,strCategories.length()); } else { strCurrent = strCategories; } strCategoryXPaths.add(strCurrent); nCategoryXPathCount++; } } private void LoadSeriesTitles(String strSeriesTitles) { int nCurrentLoc = 0; int nLoc = 1; String chToFind = ","; String strCurrent; strSTitles.clear(); while(nLoc>0) { nLoc = strSeriesTitles.indexOf(chToFind,nCurrentLoc); if(nLoc>0) { strCu |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于用Java从XML文件中获取业务图表 - 编程入门网的所有评论