List of usage examples for org.aspectj.apache.bcel.classfile JavaClass getMinor
public int getMinor()
From source file:br.jabuti.project.Project2XML.java
License:Open Source License
public boolean project2XML(JabutiProject prj, File xmlFile) { try {/* w w w .ja v a2s .co m*/ this.prj = prj; out = new OutputStreamWriter(new FileOutputStream(xmlFile), "UTF8"); } catch (Throwable t) { ToolConstants.reportException(t, ToolConstants.STDERR); return false; } StringBuilder xmlOut = new StringBuilder(); // Saving the high level element: JABUTI emit("<" + XML2Project.JABUTI + ">"); // Saving the PROJECT and its attributes indentLevel++; xmlOut.append("<" + XML2Project.PROJECT); xmlOut.append(" name=\"" + prj.getProjectFileName() + "\""); xmlOut.append(" type=\"research\""); xmlOut.append(" mobility=\"" + (prj.isMobility() ? "Y" : "N") + "\""); xmlOut.append("\">"); nl(); emit(xmlOut.toString()); // Saving the CLASSPATH and its attributes xmlOut.setLength(0); xmlOut.append("<" + XML2Project.CLASSPATH); // TODO: save each path of the classpath as a single element // Converting the classpath in a system independent way (more less) StringTokenizer st = new StringTokenizer(prj.getClasspath(), File.pathSeparator); StringBuffer sb = new StringBuffer(); while (st.hasMoreTokens()) { String s = st.nextToken(); if (File.pathSeparatorChar == ';') // If windows s = s.replace(':', '?'); // replacing driver letter d: by d? for instance. sb.append(s + " "); } xmlOut.append(" path=\"" + sb.toString().trim() + "\"/>"); nl(); emit(xmlOut.toString()); // Saving the JUNIT_SRC_DIR and its attributes xmlOut = new StringBuffer("<" + XML2Project.JUNIT_SRC_DIR); xmlOut.append(" dir=\"" + prj.getJunitSrcDir() + "\"/>"); nl(); emit(xmlOut.toString()); // Saving the JUNIT_BIN_DIR and its attributes xmlOut = new StringBuffer("<" + XML2Project.JUNIT_BIN_DIR); xmlOut.append(" dir=\"" + prj.getJunitBinDir() + "\"/>"); nl(); emit(xmlOut.toString()); // Saving the JUNIT_TEST_SET and its attributes xmlOut = new StringBuffer("<" + XML2Project.JUNIT_TEST_SET); xmlOut.append(" name=\"" + prj.getJunitTestSet() + "\"/>"); nl(); emit(xmlOut.toString()); // Saving the JABUTI_BIN and its attributes xmlOut = new StringBuffer("<" + XML2Project.JUNIT_JAR); xmlOut.append(" name=\"" + prj.getJUnitJar() + "\"/>"); nl(); emit(xmlOut.toString()); // Saving the AVOIDED_PACKAGES and its attributes nl(); emit("<" + XML2Project.AVOIDED_PACKAGES + ">"); // Saving the individual PACKAGE and its attributes indentLevel++; Iterator it = prj.getAvoid().iterator(); while (it.hasNext()) { xmlOut = new StringBuffer("<" + XML2Project.PACKAGE); xmlOut.append(" name=\"" + (String) it.next() + "\"/>"); nl(); emit(xmlOut.toString()); } indentLevel--; nl(); emit("</" + XML2Project.AVOIDED_PACKAGES + ">"); // Saving CLASS and INST_CLASS tags Program pg = prj.getProgram(); String[] cnames = pg.getCodeClasses(); for (int i = 0; i < cnames.length; i++) { ClassFile cf = prj.getClassFile(cnames[i]); xmlOut = new StringBuffer("<"); String tag = null; String size = "0000"; String check = "00000000"; if (cf != null) { // INST_CLASS tag tag = XML2Project.INST_CLASS; JavaClass theClass = cf.getJavaClass(); size = new Integer(theClass.getBytes().length).toString(); check = theClass.getMajor() + "-" + theClass.getMinor(); } else { // CLASS tag tag = XML2Project.CLASS; } // CLASS commom attributes xmlOut.append(tag + " "); xmlOut.append(" name=\"" + cnames[i] + "\""); xmlOut.append(" size=\"" + size + "\""); xmlOut.append(" checksum=\"" + check + "\">"); nl(); emit(xmlOut.toString()); indentLevel++; // EXTEND attributes RClassCode cc = (RClassCode) pg.get(cnames[i]); String superC = cc.getSuperClass(); int level = pg.levelOf(cnames[i]); xmlOut = new StringBuffer("<" + XML2Project.EXTEND); xmlOut.append(" name=\"" + superC + "\""); xmlOut.append(" level=\"" + new Integer(level).toString() + "\"/>"); nl(); emit(xmlOut.toString()); // IMPLEMENT String[] interfaces = cc.getInterfaces(); for (int k = 0; k < interfaces.length; k++) { xmlOut = new StringBuffer("<" + XML2Project.IMPLEMENT); xmlOut.append(" name=\"" + interfaces[k] + "\"/>"); nl(); emit(xmlOut.toString()); } if (cf != null) classFile2XML(prj, cf); // Closing the correct tag indentLevel--; nl(); emit("</" + tag + ">"); } // The TEST_SET element and its attributes testSet2XML(); indentLevel--; // Closing PROJECT nl(); emit("</" + XML2Project.PROJECT + ">"); indentLevel--; // Closing JABUTI nl(); emit("</" + XML2Project.JABUTI + ">"); try { out.flush(); } catch (IOException ioe) { ToolConstants.reportException(ioe, ToolConstants.STDERR); return false; } try { out.close(); } catch (IOException ioe) { ToolConstants.reportException(ioe, ToolConstants.STDERR); return false; } return true; }