/*
* To change this template, choose Tools
Templates
* and open the template in the editor.
*/
package com.nag.form
import com.bind.Expences
import java.io.BufferedWriter
import java.io.File
import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.io.IOException
import java.io.OutputStreamWriter
import java.util.logging.Level
import java.util.logging.Logger
/**
*
* @author nageswararao.m
*/
public class Marshaller {
public void doMarshalling(Expences sb){
try {
javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(sb.getClass().getPackage().getName())
javax.xml.bind.Marshaller marshaller = jaxbCtx.createMarshaller()
marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, "UTF-8") //NOI18N
marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE)
try {
File f=new File("exp.xml")
if(!f.isFile()){
try {
f.createNewFile()
System.out.println("file "+f.getAbsolutePath())
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)))
bw.write("<?xml version="1.0" encoding="UTF-8" standalone="yes"?>" + 'n' + "<expences/>")
bw.flush()
} catch (IOException ex) {
Logger.getLogger(Marshaller.class.getName()).log(Level.SEVERE, null, ex)
}
}
marshaller.marshal(sb, new FileOutputStream(f))
} catch (FileNotFoundException ex) {
Logger.getLogger(Marshaller.class.getName()).log(Level.SEVERE, null, ex)
}
} catch (javax.xml.bind.JAXBException ex) {
// XXXTODO Handle exception
java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, null, ex) //NOI18N
}
}
public void doMarshalling(com.bind.getmoney.PaidMoney sb){
try {
javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(sb.getClass().getPackage().getName())
javax.xml.bind.Marshaller marshaller = jaxbCtx.createMarshaller()
marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, "UTF-8") //NOI18N
marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE)
try {
File f=new File("income.xml")
if(!f.isFile()){
try {
f.createNewFile()
System.out.println("file "+f.getAbsolutePath())
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)))
bw.write("<?xml version="1.0" encoding="UTF-8" standalone="yes"?>" + 'n' + "<PaidMoney/>")
bw.flush()
} catch (IOException ex) {
Logger.getLogger(Marshaller.class.getName()).log(Level.SEVERE, null, ex)
}
}
marshaller.marshal(sb, new FileOutputStream(f))
} catch (FileNotFoundException ex) {
Logger.getLogger(Marshaller.class.getName()).log(Level.SEVERE, null, ex)
}
} catch (javax.xml.bind.JAXBException ex) {
// XXXTODO Handle exception
java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, null, ex) //NOI18N
}
}
}