List of usage examples for org.jdom2 Document Document
public Document()
From source file:tinytablescoringengine.TinyTable.java
License:Open Source License
public static TableObject create(String obj) throws TinyTableScoringException { if (StringUtils.isEmpty(obj)) return null; try {//from w w w. jav a 2s . com StringReader sr = new StringReader(obj); XmlReader reader = new XmlReader(sr); Document doc = new Document(); doc = reader.getDocument(); return TableObject.create(doc); } catch (JDOMException | IOException ex) { throw new TinyTableScoringException(ex); } }
From source file:view.MobilePartnerView.java
public boolean createXML(String url, String user, String driver, String password) throws Exception { Element root = new Element("dbconf"); Document doc = new Document(); Element child1 = new Element("url"); // child1.addContent("jdbc:mysql://localhost:3306/mobile_partner"); child1.addContent(url);/*from w ww . ja v a 2 s. c o m*/ child1.setAttribute("name", "javax.persistence.jdbc.url"); Element child2 = new Element("user"); // child2.addContent("root"); child2.addContent(user); child2.setAttribute("name", "javax.persistence.jdbc.user"); Element child3 = new Element("driver"); //child3.addContent("com.mysql.jdbc.Driver"); child3.addContent(driver); child3.setAttribute("name", "javax.persistence.jdbc.driver"); Element child4 = new Element("password"); // child4.addContent("nbuser"); child4.addContent(password); child4.setAttribute("name", "javax.persistence.jdbc.password"); root.addContent(child1); root.addContent(child2); root.addContent(child3); root.addContent(child4); doc.setRootElement(root); XMLOutputter outter = new XMLOutputter(); outter.setFormat(Format.getPrettyFormat()); outter.output(doc, new FileWriter(new File(dir + "\\dbconf.xml"))); File xmlFile = new File(dir + "\\dbconf.xml"); if (xmlFile.exists()) { return true; } else { return false; } }
From source file:warningfix.treemap.JTreeMapWarningsFIX.java
License:Apache License
/** * Add a splitPane with a treeview on the left and the JTreeMap on the right *//*from ww w . j a v a 2 s.c o m*/ public void StrategiesQuantitiesofWarningsforClass() { File f = new File( "programs_analyzeds/" + program_analyzed + "/treemap/warnings/" + class_analyzed + "_warnings.xml"); if (f.exists()) { setXmlFile(f.getAbsolutePath()); } else { Document doc = new Document(); Element root = new Element("root"); Element label = new Element("label"); label.addContent("" + class_analyzed); root.addContent(label); try { Conexao.open(); String sql1 = "select beginline, quantidade_warning from quantity_tool_and_warnings_for_line A inner join arquivo B on (A.nameprogram=B.nomeprograma AND A.nameprogram='" + program_analyzed + "') AND (A.nameclass='" + class_analyzed + "' AND A.nameclass=B.nomearquivo) AND nomepacote='" + package_analyzed + "'"; Statement stmt7; stmt7 = Conexao.cn.createStatement(); ResultSet rs7 = stmt7.executeQuery(sql1); while (rs7.next()) { Element branch = new Element("branch"); Element leaf = new Element("leaf"); Element label3 = null, weight = null, value = null; label3 = new Element("label"); label3.addContent("" + rs7.getString(1)); leaf.addContent(label3); weight = new Element("weight"); weight.addContent("" + rs7.getString(2)); value = new Element("value"); value.addContent("" + rs7.getString(2)); leaf.addContent(weight); leaf.addContent(value); branch.addContent(leaf); root.addContent(branch); } rs7.close(); stmt7.close(); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } doc.setRootElement(root); XMLOutputter xout = new XMLOutputter(); OutputStream out; try { out = new FileOutputStream(f); xout.output(doc, out); out.close(); Conexao.cn.close(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } setXmlFile(f.getAbsolutePath()); } }
From source file:warningfix.treemap.JTreeMapWarningsFIX.java
License:Apache License
public void StrategiesQuantitiesofSuspectionRateforPackage() throws NumberFormatException, SQLException, ClassNotFoundException { File f = new File("programs_analyzeds/" + program_analyzed + "/treemap/suspection_rate/" + package_analyzed + "_suspection.xml"); if (f.exists()) { setXmlFile(f.getAbsolutePath()); } else {// ww w. java 2s .c o m Conexao.open(); Statement sentenca = Conexao.cn.createStatement(); String tamanho_matriz = ""; ResultSet rs3 = sentenca.executeQuery( " SELECT count(distinct A.nameclass) FROM quantity_warnings_for_tool_for_line_eliminar_linhas_repetidas A inner join arquivo B on A.nameprogram=B.nomeprograma AND B.nomepacote='" + package_analyzed + "' AND (A.nameclass=B.nomearquivo AND A.nameclass NOT LIKE '%.class' AND A.nameclass NOT LIKE '%jlint%' AND A.nameclass NOT LIKE '%.zip')"); while (rs3.next()) { for (int i = 1; i <= 1; i++) { tamanho_matriz += rs3.getObject(i).toString(); System.out.println("Tamanho da Matriz" + tamanho_matriz); } } rs3.close(); double[] mean = new double[5]; ResultSet rs4 = sentenca.executeQuery( " SELECT A.nameclass, sum(qnt_nv1), sum(qnt_nv2), sum(qnt_nv3), sum(qnt_nv4), sum(qnt_nv5) FROM quantity_warnings_for_tool_for_line_eliminar_linhas_repetidas A inner join arquivo B on A.nameprogram=B.nomeprograma AND B.nomepacote='" + package_analyzed + "' AND (A.nameclass=B.nomearquivo AND A.nameclass NOT LIKE '%.class' AND A.nameclass NOT LIKE '%jlint%' AND A.nameclass NOT LIKE '%.zip') group by A.nameclass"); double[][] matriz_ = new double[Integer.parseInt(tamanho_matriz)][5]; int j = 0; int soma_coluna_1 = 1; int soma_coluna_2 = 1; int soma_coluna_3 = 1; int soma_coluna_4 = 1; int soma_coluna_5 = 1; while (rs4.next()) { String part1 = "", part11[] = null; for (int i = 1; i <= 6; i++) { part1 += rs4.getObject(i) + "/"; if (i == 6) { if (matriz_[j][0] != 0) { soma_coluna_1 += 1; } if (matriz_[j][1] != 0) { soma_coluna_2 += 1; } if (matriz_[j][2] != 0) { soma_coluna_3 += 1; } if (matriz_[j][3] != 0) { soma_coluna_4 += 1; } if (matriz_[j][4] != 0) { soma_coluna_5 += 1; } j++; } } } rs4.close(); Document doc = new Document(); Element root = new Element("root"); Element label = new Element("label"); label.addContent("" + package_analyzed); root.addContent(label); String sql1 = "select A.nameclass, sum(qnt_nv1), sum(qnt_nv2), sum(qnt_nv3), sum(qnt_nv4), sum(qnt_nv5) from quantity_warnings_for_tool_for_line_eliminar_linhas_repetidas A inner join arquivo B on A.nameprogram=B.nomeprograma AND B.nomepacote='" + package_analyzed + "' AND (A.nameclass=B.nomearquivo AND A.nameclass NOT LIKE '%.class' AND A.nameclass NOT LIKE '%jlint%' AND A.nameclass NOT LIKE '%.zip') group by A.nameclass"; Statement stmt2; stmt2 = Conexao.cn.createStatement(); ResultSet rs = stmt2.executeQuery(sql1); double[] matriz_coeficientes = new double[Integer.parseInt(tamanho_matriz)]; int i = 0; while (rs.next()) { double coeficiente = Integer.parseInt(rs.getString(2)) / soma_coluna_5 * 5 + Integer.parseInt(rs.getString(3)) / soma_coluna_4 * 4 + Integer.parseInt(rs.getString(4)) / soma_coluna_3 * 3 + Integer.parseInt(rs.getString(5)) / soma_coluna_2 * 2 + Integer.parseInt(rs.getString(6)) / soma_coluna_1 * 1; matriz_coeficientes[i] = coeficiente; System.out.println(matriz_coeficientes[i]); i++; } rs.close(); stmt2.close(); // System.out.println(selecionar_maior_coeficiente(matriz_coeficientes)); int x = 0; Statement stmt; stmt = Conexao.cn.createStatement(); ResultSet rs2 = stmt.executeQuery(sql1); double maior = selecionar_maior_coeficiente(matriz_coeficientes); System.out.println(maior); double valor; while (rs2.next()) { Element branch = new Element("branch"); Element leaf = new Element("leaf"); Element label3 = null, weight = null, value = null; label3 = new Element("label"); label3.addContent("" + rs2.getString(1)); leaf.addContent(label3); valor = matriz_coeficientes[x] / maior; weight = new Element("weight"); weight.addContent("" + valor); value = new Element("value"); value.addContent("" + valor); leaf.addContent(weight); leaf.addContent(value); branch.addContent(leaf); root.addContent(branch); x++; } rs2.close(); stmt.close(); doc.setRootElement(root); XMLOutputter xout = new XMLOutputter(); OutputStream out; try { out = new FileOutputStream(f); xout.output(doc, out); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { Conexao.cn.close(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } setXmlFile(f.getAbsolutePath()); } }
From source file:warningfix.treemap.JTreeMapWarningsFIX.java
License:Apache License
public void StrategiesQuantitiesofSuspectionRateforProgram() throws NumberFormatException, SQLException, ClassNotFoundException { File f = new File("programs_analyzeds/" + program_analyzed + "/treemap/suspection_rate/" + program_analyzed + "_suspection.xml"); if (f.exists()) { setXmlFile(f.getAbsolutePath()); } else {/* ww w .j a v a 2s . c o m*/ Conexao.open(); Statement sentenca = Conexao.cn.createStatement(); String tamanho_matriz = ""; ResultSet rs3 = sentenca .executeQuery("select count(distinct nomepacote)from arquivo where nomeprograma='" + program_analyzed + "' AND nomepacote IS NOT NULL group by nomepacote"); while (rs3.next()) { for (int i = 1; i <= 1; i++) { tamanho_matriz += rs3.getObject(i); } } rs3.close(); ResultSet rs4 = sentenca.executeQuery( " SELECT B.nomepacote, sum(qnt_nv1), sum(qnt_nv2), sum(qnt_nv3), sum(qnt_nv4), sum(qnt_nv5) FROM quantity_warnings_for_tool_for_line_eliminar_linhas_repetidas A inner join arquivo B on (A.nameprogram='" + program_analyzed + "' AND A.nameprogram=B.nomeprograma) AND (nameclass NOT LIKE '%.class' AND nameclass NOT LIKE '%jlint%' AND nameclass NOT LIKE '%.zip') AND B.nomepacote IS NOT NULL group by B.nomepacote"); double[][] matriz_ = new double[Integer.parseInt(tamanho_matriz)][5]; int j = 0; int soma_coluna_1 = 1; int soma_coluna_2 = 1; int soma_coluna_3 = 1; int soma_coluna_4 = 1; int soma_coluna_5 = 1; while (rs4.next()) { String part1 = "", part11[] = null; for (int i = 1; i <= 6; i++) { part1 += rs4.getObject(i) + "/"; if (i == 6) { // System.out.println(j); if (matriz_[j][0] != 0) { soma_coluna_1 += 1; } if (matriz_[j][1] != 0) { soma_coluna_2 += 1; } if (matriz_[j][2] != 0) { soma_coluna_3 += 1; } if (matriz_[j][3] != 0) { soma_coluna_4 += 1; } if (matriz_[j][4] != 0) { soma_coluna_5 += 1; } j++; } } } rs4.close(); Document doc = new Document(); Element root = new Element("root"); Element label = new Element("label"); label.addContent("" + program_analyzed); root.addContent(label); String sql1 = "select B.nomepacote, sum(qnt_nv1), sum(qnt_nv2), sum(qnt_nv3), sum(qnt_nv4), sum(qnt_nv5) from quantity_warnings_for_tool_for_line_eliminar_linhas_repetidas A inner join arquivo B on (A.nameprogram='" + program_analyzed + "' AND A.nameprogram=B.nomeprograma) AND (nameclass NOT LIKE '%.class' AND nameclass NOT LIKE '%jlint%' AND nameclass NOT LIKE '%.zip') group by B.nomepacote"; Statement stmt2; stmt2 = Conexao.cn.createStatement(); ResultSet rs = stmt2.executeQuery(sql1); double[] matriz_coeficientes = new double[Integer.parseInt(tamanho_matriz)]; int i = 0; while (rs.next()) { double coeficiente = Integer.parseInt(rs.getString(2)) / soma_coluna_5 * 5 + Integer.parseInt(rs.getString(3)) / soma_coluna_4 * 4 + Integer.parseInt(rs.getString(4)) / soma_coluna_3 * 3 + Integer.parseInt(rs.getString(5)) / soma_coluna_2 * 2 + Integer.parseInt(rs.getString(6)) / soma_coluna_1 * 1; matriz_coeficientes[i] = coeficiente; i++; } rs.close(); stmt2.close(); int x = 0; Statement stmt; stmt = Conexao.cn.createStatement(); ResultSet rs2 = stmt.executeQuery(sql1); Double maior = selecionar_maior_coeficiente(matriz_coeficientes); Double valor; while (rs2.next()) { Element branch = new Element("branch"); Element leaf = new Element("leaf"); Element label3 = null, weight = null, value = null; label3 = new Element("label"); label3.addContent("" + rs2.getString(1)); leaf.addContent(label3); weight = new Element("weight"); valor = matriz_coeficientes[x] / maior; weight.addContent("" + valor); value = new Element("value"); value.addContent("" + valor); leaf.addContent(weight); leaf.addContent(value); branch.addContent(leaf); root.addContent(branch); x++; } rs2.close(); stmt.close(); doc.setRootElement(root); XMLOutputter xout = new XMLOutputter(); OutputStream out; try { out = new FileOutputStream(f); xout.output(doc, out); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { Conexao.cn.close(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } setXmlFile(f.getAbsolutePath()); } }
From source file:warningfix.treemap.JTreeMapWarningsFIX.java
License:Apache License
public void StrategiesQuantitiesofSuspectionRateforClass() throws NumberFormatException, SQLException, ClassNotFoundException { File f = new File("programs_analyzeds/" + program_analyzed + "/treemap/suspection_rate/" + class_analyzed + "_suspection.xml"); if (f.exists()) { setXmlFile(f.getAbsolutePath()); } else {/*from w w w . ja va 2 s.c om*/ Conexao.open(); Statement sentenca = Conexao.cn.createStatement(); String tamanho_matriz = ""; ResultSet rs0 = sentenca.executeQuery( " SELECT count(*) FROM quantity_warnings_for_tool_for_line_eliminar_linhas_repetidas where nameprogram='" + program_analyzed + "' AND ( nameclass='" + class_analyzed + "' AND nameclass NOT LIKE '%.class' AND nameclass NOT LIKE '%jlint%' AND nameclass NOT LIKE '%.zip')"); while (rs0.next()) { for (int i = 1; i <= 1; i++) { tamanho_matriz += rs0.getObject(i); } } rs0.close(); ResultSet rs1 = sentenca.executeQuery( " SELECT beginline, qnt_nv1, qnt_nv2, qnt_nv3, qnt_nv4, qnt_nv5 FROM quantity_warnings_for_tool_for_line_eliminar_linhas_repetidas where nameprogram='" + program_analyzed + "' AND (nameclass='" + class_analyzed + "' AND nameclass NOT LIKE '%.class' AND nameclass NOT LIKE '%jlint%' AND nameclass NOT LIKE '%.zip')"); double[][] matriz_ = new double[Integer.parseInt(tamanho_matriz)][5]; int j = 0; int soma_coluna_1 = 1; int soma_coluna_2 = 1; int soma_coluna_3 = 1; int soma_coluna_4 = 1; int soma_coluna_5 = 1; while (rs1.next()) { String part1 = "", part11[] = null; for (int i = 1; i <= 6; i++) { part1 += rs1.getObject(i) + "/"; if (i == 6) { if (matriz_[j][0] != 0) { soma_coluna_1 += 1; } if (matriz_[j][1] != 0) { soma_coluna_2 += 1; } if (matriz_[j][2] != 0) { soma_coluna_3 += 1; } if (matriz_[j][3] != 0) { soma_coluna_4 += 1; } if (matriz_[j][4] != 0) { soma_coluna_5 += 1; } j++; } } } rs1.close(); Document doc = new Document(); Element root = new Element("root"); Element label = new Element("label"); label.addContent("" + class_analyzed); root.addContent(label); String sql1 = " SELECT beginline, qnt_nv1, qnt_nv2, qnt_nv3, qnt_nv4, qnt_nv5 FROM quantity_warnings_for_tool_for_line_eliminar_linhas_repetidas where nameprogram='" + program_analyzed + "' AND (nameclass='" + class_analyzed + "' AND nameclass NOT LIKE '%.class' AND nameclass NOT LIKE '%jlint%' AND nameclass NOT LIKE '%.zip')"; Statement stmt2; stmt2 = Conexao.cn.createStatement(); ResultSet rs3 = stmt2.executeQuery(sql1); double[] matriz_coeficientes = new double[Integer.parseInt(tamanho_matriz)]; int i = 0; while (rs3.next()) { double coeficiente = Integer.parseInt(rs3.getString(2)) / soma_coluna_5 * 5 + Integer.parseInt(rs3.getString(3)) / soma_coluna_4 * 4 + +Integer.parseInt(rs3.getString(4)) / soma_coluna_3 * 3 + Integer.parseInt(rs3.getString(5)) / soma_coluna_2 * 2 + Integer.parseInt(rs3.getString(6)) / soma_coluna_1 * 1; matriz_coeficientes[i] = coeficiente; i++; } rs3.close(); stmt2.close(); // System.out.println(""); int x = 0; Statement stmt; stmt = Conexao.cn.createStatement(); ResultSet rs4 = stmt.executeQuery(sql1); double maior = selecionar_maior_coeficiente(matriz_coeficientes); double valor; while (rs4.next()) { Element branch = new Element("branch"); Element leaf = new Element("leaf"); Element label3 = null, weight = null, value = null; label3 = new Element("label"); label3.addContent("" + rs4.getString(1)); leaf.addContent(label3); weight = new Element("weight"); valor = matriz_coeficientes[x] / maior; weight.addContent("" + valor); // System.out.println(selecionar_maior_coeficiente(matriz_coeficientes)); value = new Element("value"); value.addContent("" + valor); leaf.addContent(weight); leaf.addContent(value); branch.addContent(leaf); root.addContent(branch); x++; } rs4.close(); stmt.close(); doc.setRootElement(root); XMLOutputter xout = new XMLOutputter(); OutputStream out; try { out = new FileOutputStream(f); xout.output(doc, out); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { Conexao.cn.close(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } setXmlFile(f.getAbsolutePath()); } }
From source file:warningfix.treemap.JTreeMapWarningsFIX.java
License:Apache License
public void StrategiesQuantitiesofToolsforClass() { File f = new File( "programs_analyzeds/" + program_analyzed + "/treemap/tools/" + class_analyzed + "_tools.xml"); if (f.exists()) { setXmlFile(f.getAbsolutePath()); } else {//from w w w .j a v a 2s . c om Document doc = new Document(); // DocType dt= new DocType("root SYSTEM \"TreeMap.dtd\""); // doc.setDocType(dt); Element root = new Element("root"); Element label = new Element("label"); label.addContent("" + class_analyzed); root.addContent(label); try { Conexao.open(); String sql1 = "select nameclass, nameprogram, beginline, quantidade_ferramentas from quantity_tool_and_warnings_for_line where nameprogram='" + program_analyzed + "' AND nameclass='" + class_analyzed + "'"; Statement stmt2; stmt2 = Conexao.cn.createStatement(); ResultSet rs4 = stmt2.executeQuery(sql1); while (rs4.next()) { Element branch = new Element("branch"); Element leaf = new Element("leaf"); Element label3 = null, weight = null, value = null; label3 = new Element("label"); label3.addContent("" + rs4.getString(3)); leaf.addContent(label3); weight = new Element("weight"); weight.addContent("" + rs4.getString(4)); value = new Element("value"); value.addContent("" + rs4.getString(4)); leaf.addContent(weight); leaf.addContent(value); branch.addContent(leaf); root.addContent(branch); } rs4.close(); stmt2.close(); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } doc.setRootElement(root); XMLOutputter xout = new XMLOutputter(); OutputStream out; try { out = new FileOutputStream(f); xout.output(doc, out); Conexao.cn.close(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } setXmlFile(f.getAbsolutePath()); } }
From source file:warningfix.treemap.JTreeMapWarningsFIX.java
License:Apache License
public void StrategiesQuantitiesofWarningsforPackage() { File f = new File("programs_analyzeds/" + program_analyzed + "/treemap/warnings/" + package_analyzed + "_warnings.xml"); if (f.exists()) { setXmlFile(f.getAbsolutePath()); } else {/* w w w. j ava2 s. c o m*/ Document doc = new Document(); Element root = new Element("root"); Element label = new Element("label"); label.addContent("" + package_analyzed); root.addContent(label); try { Conexao.open(); String sql1 = "select nameclass, count(*) from warning A inner join arquivo B on A.nameprogram=B.nomeprograma AND nomepacote='" + package_analyzed + "' AND (A.nameclass=B.nomearquivo AND nameclass NOT LIKE '%.class' AND nameclass NOT LIKE '%jlint%' AND nameclass NOT LIKE '%.zip') group by A.nameclass"; Statement stmt3; stmt3 = Conexao.cn.createStatement(); ResultSet rs3 = stmt3.executeQuery(sql1); while (rs3.next()) { Element branch = new Element("branch"); Element leaf = new Element("leaf"); Element label3 = null, weight = null, value = null; label3 = new Element("label"); // cria todos xmls das classes if (buffer == 1) { all_class_xml = new JTreeMapWarningsFIX(program_analyzed, package_analyzed, rs3.getString(1)); all_class_xml.StrategiesQuantitiesofWarningsforClass(); all_class_xml.StrategiesQuantitiesofSuspectionRateforClass(); all_class_xml.StrategiesQuantitiesofToolsforClass(); } label3.addContent("" + rs3.getString(1)); System.out.println(rs3.getString(1) + "\n"); leaf.addContent(label3); weight = new Element("weight"); weight.addContent("" + rs3.getString(2)); value = new Element("value"); value.addContent("" + rs3.getString(2)); leaf.addContent(weight); leaf.addContent(value); branch.addContent(leaf); root.addContent(branch); } rs3.close(); stmt3.close(); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } doc.setRootElement(root); XMLOutputter xout = new XMLOutputter(); OutputStream out; try { out = new FileOutputStream(f); xout.output(doc, out); out.close(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { Conexao.cn.close(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } setXmlFile(f.getAbsolutePath()); } }
From source file:warningfix.treemap.JTreeMapWarningsFIX.java
License:Apache License
public void StrategiesQuantitiesofWarningsforProgram() throws SQLException, ClassNotFoundException { File f = new File("programs_analyzeds/" + program_analyzed + "/treemap/warnings/" + program_analyzed + "_warnings.xml"); if (f.exists()) { setXmlFile(f.getAbsolutePath()); } else {/*from w w w . j a v a 2s . c o m*/ Conexao.open(); Document doc = new Document(); Element root = new Element("root"); Element label = new Element("label"); label.addContent("" + program_analyzed); root.addContent(label); String sql0 = "select distinct nomepacote from arquivo where nomeprograma='" + program_analyzed + "' AND nomepacote IS NOT NULL group by nomepacote"; Statement stmt0 = Conexao.cn.createStatement(); ResultSet rs0 = stmt0.executeQuery(sql0); // armazenar nome dos pacotes while (rs0.next()) { String namepacote = rs0.getString(1); String sql1 = "select sum(quant_warnings) from quantity_warnings_for_package where nomepacote='" + namepacote + "'"; Statement stmt2; stmt2 = Conexao.cn.createStatement(); ResultSet rs4 = stmt2.executeQuery(sql1); while (rs4.next()) { Element branch = new Element("branch"); Element leaf = new Element("leaf"); Element label3 = null, weight = null, value = null; label3 = new Element("label"); label3.addContent("" + namepacote); leaf.addContent(label3); weight = new Element("weight"); weight.addContent("" + rs4.getString(1)); value = new Element("value"); value.addContent("" + rs4.getString(1)); leaf.addContent(weight); leaf.addContent(value); branch.addContent(leaf); root.addContent(branch); } } doc.setRootElement(root); XMLOutputter xout = new XMLOutputter(); OutputStream out; try { out = new FileOutputStream(f); xout.output(doc, out); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { Conexao.cn.close(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } setXmlFile(f.getAbsolutePath()); } }
From source file:warningfix.treemap.JTreeMapWarningsFIX.java
License:Apache License
public void StrategiesQuantitiesofWarningsforProgram_Means() throws SQLException, ClassNotFoundException { File f = new File("programs_analyzeds/" + program_analyzed + "/treemap/warnings/" + program_analyzed + "_means_warnings.xml"); Conexao.open();//from w ww . ja v a 2 s . c o m if (f.exists()) { setXmlFile(f.getAbsolutePath()); } else { Document doc = new Document(); Element root = new Element("root"); Element label = new Element("label"); label.addContent("" + program_analyzed); root.addContent(label); String sql0 = "select distinct nomepacote from arquivo where nomeprograma='" + program_analyzed + "' AND nomepacote IS NOT NULL group by nomepacote"; Statement stmt4; stmt4 = Conexao.cn.createStatement(); ResultSet rs4 = stmt4.executeQuery(sql0); Statement stmt5; stmt5 = Conexao.cn.createStatement(); // armazenar nome dos pacotes while (rs4.next()) { String namepacote = rs4.getString(1); String sql1 = "select nomepacote, sum(quant_warnings)/count(*) from quantity_warnings_for_package where nomepacote='" + namepacote + "' group by nomepacote"; ResultSet rs5 = stmt5.executeQuery(sql1); // all_packages_xml = new JTreeMapWarningsFIX(program_analyzed, // namepacote, ""); // all_packages_xml // .StrategiesQuantitiesofWarningsforPackage_Means(); while (rs5.next()) { Element branch = new Element("branch"); Element leaf = new Element("leaf"); Element label3 = null, weight = null, value = null; label3 = new Element("label"); label3.addContent("" + namepacote); leaf.addContent(label3); weight = new Element("weight"); weight.addContent("" + rs5.getString(2)); value = new Element("value"); value.addContent("" + rs5.getString(2)); leaf.addContent(weight); leaf.addContent(value); branch.addContent(leaf); root.addContent(branch); } rs5.close(); } rs4.close(); stmt4.close(); stmt5.close(); doc.setRootElement(root); XMLOutputter xout = new XMLOutputter(); OutputStream out; try { out = new FileOutputStream(f); xout.output(doc, out); out.close(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { Conexao.cn.close(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } setXmlFile(f.getAbsolutePath()); } }