📄 dbs.java
字号:
LinkedList link2=new LinkedList();
for(int i=0;i<selectRadio1.length;i++)
{
if(selectRadio1[i].isSelected())
{
link1.add(new Integer(i));
}
}
for(int i=0;i<selectRadio2.length;i++)
{
if(selectRadio2[i].isSelected())
{
link2.add(new Integer(i));
}
}
for(int i=0;i<hang.size();i++)
{
LinkedList l=new LinkedList((LinkedList)hang.get(i));
LinkedList ll=new LinkedList();
for(int j=0;j<link1.size();j++)
{
Integer dex=(Integer)link1.get(j);
int d=dex.intValue();
ll.add(l.get(d));
}
for(int j=0;j<link2.size();j++)
{
Integer dex=(Integer)link2.get(j);
int d=dex.intValue();
ll.add(l.get(d+inlian));
}
boolean boo=contain(daishu,ll);
if(!boo)
{
daishu.add(ll);
}
}
}
tableList(daishu);
}
void tiaojian()///////////////////////////tiaojian窗口
{
xuanzeFrame=new JFrame("选择");
xuanzeFrame.setVisible(true);
xuanzeFrame.setBounds(200,200,200,200);
Container x=xuanzeFrame.getContentPane();
JLabel xl=new JLabel("请输入条件:");
and=new JButton("And");
and.addActionListener(this);
or=new JButton("or");
or.addActionListener(this);
xuan=new JButton("完成");
xuan.addActionListener(this);
JPanel xp1=new JPanel();
xp1.setLayout(new GridLayout(2,1));
JPanel xp2=new JPanel();
xp2.setLayout(new GridLayout(2,1));
JPanel xp3=new JPanel();
JPanel xp4=new JPanel();
JPanel xp5=new JPanel();
JPanel xp=new JPanel();
LinkedList l1=new LinkedList((LinkedList)hang.get(0));
if(hang2.isEmpty())
{
xiang1=new String[l1.size()];
}
else
{
xiang1=new String[inlian];
}
for(int i=0;i<xiang1.length;i++)
{
CreatBox c=new CreatBox((CreatBox)l1.get(i));
xiang1[i]=""+c.name;
}
xiangmu=new JComboBox(xiang1);
xiangmu.setVisible(false);
xp2.add(xiangmu);
if(!hang2.isEmpty())
{
LinkedList l2=new LinkedList((LinkedList)hang2.get(0));
xiang2=new String[l2.size()];
for(int i=0;i<l2.size();i++)
{
CreatBox c=new CreatBox((CreatBox)l2.get(i));
xiang2[i]=""+c.name;
}
xiangmu2=new JComboBox(xiang2);
xiangmu2.setVisible(false);
xp2.add(xiangmu2);
r2=new JRadioButton(filename[1]);
r2.addActionListener(this);
}
r1=new JRadioButton(filename[0]);
r1.addActionListener(this);
xg=new ButtonGroup();
xg.add(r1);xp1.add(r1);
if(!hang2.isEmpty())
{
xg.add(r2);
xp1.add(r2);
}
if(hang2.isEmpty())
{
r1.setSelected(true);
xiangmu.setVisible(true);
}
String fuhao[]={">","<","=","!="};
xc=new JComboBox(fuhao);
xc.setMaximumRowCount(3);
xp3.add(xc);
xf=new JTextField(10);
xp4.add(xf);
xp5.add(and);xp5.add(or);xp5.add(xuan);
xp.setLayout(new GridLayout(1,4));
xp.add(xp1);xp.add(xp2);xp.add(xp3);xp.add(xp4);
x.add(xp,BorderLayout.CENTER);
x.add(xp5,BorderLayout.SOUTH);
x.add(xl,BorderLayout.NORTH);
xuanzeFrame.pack();
}
boolean fuhaoMethod(String combo,String text)
{
if(xc.getSelectedItem().equals("<"))
{
int r=combo.compareTo(text);
if(r<0)
{
return true;
}
}
else if(xc.getSelectedItem().equals(">"))
{
int r=combo.compareTo(text);
if(r>0)
{
return true;
}
}
else if(xc.getSelectedItem().equals("="))
{
int r=combo.compareTo(text);
if(r==0)
{
return true;
}
}
else if(xc.getSelectedItem().equals("!="))
{
if(!combo.equals(text))
{
return true;
}
}
return false;
}
void andMethod()
{
daishu1.clear();
if(inlian==0)
{
int loc=-1;
String x=""+xiangmu.getSelectedItem();
LinkedList l=new LinkedList((LinkedList)daishu.get(0));
for(int i=0;i<l.size();i++)
{
CreatBox b=new CreatBox((CreatBox)l.get(i));
if(b.name.equals(x))
{
loc=i;
break;
}
}
daishu1.add(daishu.get(0));
for(int i=1;i<daishu.size();i++)
{
boolean yaoqiu=false;
LinkedList ll=new LinkedList((LinkedList)daishu.get(i));
CreatBox b=new CreatBox((CreatBox)ll.get(loc));
yaoqiu=fuhaoMethod(b.name,xf.getText());
if(yaoqiu)
{
daishu1.add(ll);
}
}
//tableList(daishu1);
daishu.clear();
for(int i=0;i<daishu1.size();i++)
{
daishu.add(daishu1.get(i));
}
}
else
{
int loc=-1;
if(r1.isSelected())
{
String x=""+xiangmu.getSelectedItem();
LinkedList l=new LinkedList((LinkedList)daishu.get(0));
for(int i=0;i<l.size();i++)
{
CreatBox b=new CreatBox((CreatBox)l.get(i));
if(b.name.equals(x))
{
loc=i;
break;
}
}
}
else if(r2.isSelected())
{
String x=""+xiangmu2.getSelectedItem();
LinkedList l=new LinkedList((LinkedList)daishu.get(0));
for(int i=inlian;i<l.size();i++)
{
CreatBox b=new CreatBox((CreatBox)l.get(i));
if(b.name.equals(x))
{
loc=i;
break;
}
}
}
daishu1.add(daishu.get(0));
for(int i=1;i<daishu.size();i++)
{
boolean yaoqiu=false;
LinkedList ll=new LinkedList((LinkedList)daishu.get(i));
CreatBox b=new CreatBox((CreatBox)ll.get(loc));
yaoqiu=fuhaoMethod(b.name,xf.getText());
if(yaoqiu)
{
daishu1.add(ll);
}
}
//tableList(daishu1);
daishu.clear();
for(int i=0;i<daishu1.size();i++)
{
daishu.add(daishu1.get(i));
}
}
}
void orMethod()
{
//daishu1.clear();
if(inlian==0)
{
int loc=-1;
String x=""+xiangmu.getSelectedItem();
LinkedList l=new LinkedList((LinkedList)hang.get(0));
for(int i=0;i<l.size();i++)
{
CreatBox b=new CreatBox((CreatBox)l.get(i));
if(b.name.equals(x))
{
loc=i;
break;
}
}
LinkedList lin=(LinkedList)hang.get(0);
boolean bool=contain(daishu2,lin);
if(!bool)
{
daishu1.add(hang.get(0));
}
for(int i=1;i<hang.size();i++)
{
boolean yaoqiu=false;
LinkedList ll=new LinkedList((LinkedList)hang.get(i));
CreatBox b=new CreatBox((CreatBox)ll.get(loc));
yaoqiu=fuhaoMethod(b.name,xf.getText());
if(yaoqiu)
{
boolean boo=contain(daishu2,ll);
if(!boo)
{
daishu1.add(ll);
}
}
}
daishu2.clear();
for(int i=0;i<daishu1.size();i++)
{
daishu2.add(daishu1.get(i));
}
daishu.clear();
for(int i=0;i<daishu2.size();i++)
{
daishu.add(daishu2.get(i));
}
//tableList(daishu);
}
else
{
int loc=-1;
if(r1.isSelected())
{
String x=""+xiangmu.getSelectedItem();
LinkedList l=new LinkedList((LinkedList)hang.get(0));
for(int i=0;i<l.size();i++)
{
CreatBox b=new CreatBox((CreatBox)l.get(i));
if(b.name.equals(x))
{
loc=i;
break;
}
}
}
else if(r2.isSelected())
{
String x=""+xiangmu.getSelectedItem();
LinkedList l=new LinkedList((LinkedList)hang.get(0));
for(int i=inlian;i<l.size();i++)
{
CreatBox b=new CreatBox((CreatBox)l.get(i));
if(b.name.equals(x))
{
loc=i;
break;
}
}
}
LinkedList lin=(LinkedList)hang.get(0);
boolean bool=contain(daishu2,lin);
if(!bool)
{
daishu1.add(hang.get(0));
}
for(int i=1;i<hang.size();i++)
{
boolean yaoqiu=false;
LinkedList ll=new LinkedList((LinkedList)hang.get(i));
CreatBox b=new CreatBox((CreatBox)ll.get(loc));
yaoqiu=fuhaoMethod(b.name,xf.getText());
if(yaoqiu)
{
boolean boo=contain(daishu2,ll);
if(!boo)
{
daishu1.add(ll);
}
}
}
daishu2.clear();
for(int i=0;i<daishu1.size();i++)
{
daishu2.add(daishu1.get(i));
}
daishu.clear();
for(int i=0;i<daishu2.size();i++)
{
daishu.add(daishu2.get(i));
}
}
}
boolean contain(LinkedList link1,LinkedList link2)
{
for(int i=0;i<link1.size();i++)
{
LinkedList l=new LinkedList((LinkedList)link1.get(i));
int flag=0;
for(int j=0;j<l.size();j++)
{
CreatBox b1=new CreatBox((CreatBox)l.get(j));
CreatBox b2=new CreatBox((CreatBox)link2.get(j));
if(b1.name.equals(b2.name))
{
flag++;
if(flag==l.size())
{
return true;
}
}
}
}
return false;
}
void Open(String name)////////////打开文件
{
hang.clear();
box.clear();
suoyin.clear();
try
{
File file=new File("g:\\fuyu",name);
//filename[0]=""+file.getName();
FileInputStream fi=new FileInputStream(file);
ObjectInputStream oi=new ObjectInputStream(fi);
LinkedList newhang=((LinkedList)oi.readObject());
fi.close();
oi.close();
for(int i=0;i<newhang.size()-3;i++)
{
object o=new object();
LinkedList l=new LinkedList((LinkedList)newhang.get(i));
for(int j=0;j<l.size();j++)
{
CreatBox c=new CreatBox();
c.name=(String)l.get(j);
c.type=(String)((LinkedList)newhang.get(newhang.size()-3)).get(j);
c.leg=(String)((LinkedList)newhang.get(newhang.size()-2)).get(j);
c.NULL=(String)((LinkedList)newhang.get(newhang.size()-1)).get(j);
o.ob.add(c);
}
hang.add(o.ob);
}jianlisuoyin();
tableList(hang);
}
catch(Exception e1)
{
System.out.print("error");
}
}
void Open2(String name)////////////打开文件
{
hang2.clear();
box.clear();
suoyin2.clear();
try
{
File file=new File("g:\\fuyu",name);
//filename[0]=""+file.getName();
FileInputStream fi=new FileInputStream(file);
ObjectInputStream oi=new ObjectInputStream(fi);
LinkedList newhang=((LinkedList)oi.readObject());
fi.close();
oi.close();
for(int i=0;i<newhang.size()-3;i++)
{
object o=new object();
LinkedList l=new LinkedList((LinkedList)newhang.get(i));
for(int j=0;j<l.size();j++)
{
CreatBox c=new CreatBox();
c.name=(String)l.get(j);
c.type=(String)((LinkedList)newhang.get(newhang.size()-3)).get(j);
c.leg=(String)((LinkedList)newhang.get(newhang.size()-2)).get(j);
c.NULL=(String)((LinkedList)newhang.get(newhang.size()-1)).get(j);
o.ob.add(c);
}
hang2.add(o.ob);
}jianlisuoyin();
tableList(hang2);
inlian=((LinkedList)hang.get(0)).size();
}
catch(Exception e1)
{
System.out.print("error");
}
}
boolean fuhaoMethodquel(String combo,String text,char fu)
{
if(fu=='<')
{
int r=combo.compareTo(text);
if(r<0)
{
return true;
}
}
else if(fu=='>')
{
int r=combo.compareTo(text);
if(r>0)
{
return true;
}
}
else if(fu=='=')
{
int r=combo.compareTo(text);
if(r==0)
{
return true;
}
}
return false;
}
void andquel(String fname,String shuxing,String tiaojian,char fu)
{
daishu1.clear();
if(inlian==0)
{
int loc=-1;
String x=""+shuxing;
LinkedList l=new LinkedList((LinkedList)daishu.get(0));
for(int i=0;i<l.size();i++)
{
CreatBox b=new CreatBox((CreatBox)l.get(i));
if(b.name.equals(x))
{
loc=i;
break;
}
}
daishu1.add(daishu.get(0));
for(int i=1;i<daishu.size();i++)
{
boolean yaoqiu=false;
LinkedList ll=new LinkedList((LinkedList)daishu.get(i));
CreatBox b=new CreatBox((CreatBox)ll.get(loc));
yaoqiu=fuhaoMethodquel(b.name,tiaojian,fu);
if(yaoqiu)
{
daishu1.add(ll);
}
}
daishu.clear();
for(int i=0;i<daishu1.size();i++)
{
daishu.add(daishu1.get(i));
}
}
else
{
int loc=-1;
if(fname.equals(filename[0]))
{
String x=""+shuxing;
LinkedList l=new LinkedList((LinkedList)daishu.get(0));
for(int i=0;i<l.size();i++)
{
CreatBox b=new CreatBox((CreatBox)l.get(i));
if(b.name.equals(x))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -