java - Saving database attributes via sql-lite -
in program,i provided users facility of designing own database. have sucessfully achived have tables , values saved in class objects.
now want save in sql lite/create output xml file of database.
public class table { private arraylist<column> columns; private string name; private static int count=0; public table() { columns = new arraylist<column>(); name=new string(); this.name="table"+count; count++; } public void addcolumn(column column) { for(column c: columns) { if(c.getname().equals(column.getname())){return;} } columns.add(column); } public void savetofile() throws ioexception { filewriter fw = new filewriter("c:/users/ashad/desktop/text.txt", true); bufferedwriter bw = new bufferedwriter(fw); bw.write("\r\n"); bw.write(this.name); bw.write("\r\n"); for(column c: columns) { bw.write("\r\n"); bw.write(c.getname()+" "); bw.write(c.getdatatype()+" "); if(c.getpk()== true) { bw.write("true"+" "); } else { bw.write("false"+" "); } if(c.getnn()== true) { bw.write("true"+" "); } else {bw.write("false"+" "); } } bw.close(); } public boolean deletecolumn(string name) { (column c : columns) { if (c.getname().equals(name)) {return columns.remove(c);} } return false; } public void viewcolumns() { system.out.append(name+" "); for(column c: columns) { system.out.append("\n"); system.out.append(c.getname()+" "); system.out.append( c.getdatatype()+" "); if(c.getpk()== true) { system.out.print(true); } else system.out.print(false); } } public string getname() { return name; } } public class column { private string name; private string datatype; private boolean pk; private boolean nn; public column() { string name=new string(); string datatype=new string(); boolean pk=false; boolean nn=false; } public string getname(){return name;} public string getdatatype(){return datatype;} public boolean getpk(){return pk;} public boolean getnn(){return nn;} public void setname(string n){name=n;} public void setdatatype(object object){datatype=(string) object;} public void setpk(boolean p){pk=p;} public void setnn(boolean n){nn=n;} }
Comments
Post a Comment