public void toFile(String file) { try { PrintStream ps = new PrintStream(new FileOutputStream(file), true); ps.print(sw.toString()); } catch (Exception e) { System.err.println(e.toString()); } }
public void sendQuery(String Select, String Where) { // Driver="com.mysql.jdbc.Driver" try { jc = JAXBContext.newInstance("org.vamdc.xsams"); m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); rs = con.createStatement().executeQuery("select " + Select + " from vald " + Where); ResultSetMetaData rsmd = rs.getMetaData(); colCount = rsmd.getColumnCount(); } catch (Exception e) { System.out.println(e.toString()); } }
public void build() { rt = null; root = new XSAMSData(); procs = new ProcessesType(); rad = new Radiative(); atoms = new Atoms(); sources = new Sources(); procs.setRadiative(rad); states = new StatesType(); states.setAtoms(atoms); root.setStates(states); root.setProcesses(procs); try { int nr = 0; while (rs.next()) { rt = new RadiativeTransitionType(); rtp = new RadiativeTransitionProbabilityType(); rt.getProbabilities().add(rtp); atom = new AtomType(); ist = new IsotopeType(); atom.getIsotopes().add(ist); is = new IonStateType(); ist.getIonStates().add(is); aslow = new AtomicStateType(); asup = new AtomicStateType(); aslow.setStateID("Initial_" + nr); asup.setStateID("Final_" + nr); andtlow = new AtomicNumericalDataType(); andtup = new AtomicNumericalDataType(); aslow.setAtomicNumericalData(andtlow); asup.setAtomicNumericalData(andtup); is.getAtomicStates().add(aslow); is.getAtomicStates().add(asup); aqnlow = new AtomicQuantumNumbersType(); aqnup = new AtomicQuantumNumbersType(); aslow.setAtomicQuantumNumbers(aqnlow); asup.setAtomicQuantumNumbers(aqnup); aclow = new AtomicCompositionType(); acup = new AtomicCompositionType(); aslow.setAtomicComposition(aclow); asup.setAtomicComposition(acup); acmlow = new AtomicComponentType(); acmup = new AtomicComponentType(); conflow = new ConfigurationType(); acmlow.setConfiguration(conflow); confup = new ConfigurationType(); acmup.setConfiguration(confup); aclow.getComponents().add(acmlow); acup.getComponents().add(acmup); termlow = new TermType(); termup = new TermType(); acmlow.setTerm(termlow); acmup.setTerm(termup); wavelength = ((Double) (rs.getObject("wavelength"))).doubleValue(); code = rs.getObject("code").toString(); loggf = ((Double) (rs.getObject("loggf"))).doubleValue(); E_low = ((Double) (rs.getObject("E_low"))).doubleValue(); E_up = ((Double) (rs.getObject("E_up"))).doubleValue(); J_low = ((Double) (rs.getObject("J_low"))).doubleValue(); J_up = ((Double) (rs.getObject("J_up"))).doubleValue(); g_low = ((Double) (rs.getObject("g_low"))).doubleValue(); g_up = ((Double) (rs.getObject("g_up"))).doubleValue(); Connection_low = rs.getObject("Connection_low").toString(); Connection_up = rs.getObject("Connection_up").toString(); Conf_low = rs.getObject("Conf_low").toString(); Conf_up = rs.getObject("Conf_up").toString(); Term_low = rs.getObject("Term_low").toString(); Term_up = rs.getObject("Term_up").toString(); Ref = rs.getObject("Ref").toString(); Comments = rs.getObject("Ref").toString(); setWavelength(wavelength); setElement(code); setProbability(loggf); setElow(E_low); setEup(E_up); setglow(g_low); setgup(g_up); setQNlow(J_low); setQNup(J_up); // setConnlow(Connection_low); // setConnup(Connection_up); setConflow(Conf_low); setConfup(Conf_up); setComments(Comments); atoms.getAtoms().add(atom); rad.getRadiativeTransitions().add(rt); nr++; } data2xml(); con.close(); rs.close(); } catch (Exception e) { System.out.println(e.toString()); } }