⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbs.java

📁 用java编写的dbms
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
						loc=i;
						break;
					}
				}
			}
			else if(fname.equals(filename[1]))
			{
				String x=""+shuxing;
				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=fuhaoMethodquel(b.name,tiaojian,fu);
		    	System.out.println("sdfffffffffffffffffff"+b.name);
		    	System.out.println("sdfffffffffffffffffff"+tiaojian);
		    	System.out.println("sdfffffffffffffffffff"+fu);
		    	if(yaoqiu)
		    	{
		    		daishu1.add(ll);
		    	}
		    }
		    daishu.clear();
		    for(int i=0;i<daishu1.size();i++)
		    {
		    	daishu.add(daishu1.get(i));
		    }	
			
		}
	}
	void connectquel(LinkedList biao1,String shuxing1,LinkedList biao2,String shuxing2)
	{
		int m=-1,n=-1;
		LinkedList l1=new LinkedList((LinkedList)hang.get(0));
		LinkedList l2=new LinkedList((LinkedList)hang2.get(0));
		CreatBox o1=new CreatBox();
		CreatBox o2=new CreatBox();
		for(int i=0;i<l1.size();i++)
		{
			CreatBox c=new CreatBox((CreatBox)l1.get(i));
			if(c.name.equals(shuxing1))
			{
				o1=c;
				m=i;break;
			}
		}
		for(int i=0;i<l2.size();i++)
		{
			CreatBox c=new CreatBox((CreatBox)l2.get(i));
			if(c.name.equals(shuxing2))
			 {
				o2=c;
				n=i;break;
			}
		}
		daishu.clear();
		for(int i=0;i<l2.size();i++)
		{
			l1.add(l2.get(i));
		}
		daishu.add(l1);
		for(int i=1;i<biao1.size();i++)
		{
				
			for(int j=1;j<biao2.size();j++)
			{	
				LinkedList link1=new LinkedList((LinkedList)biao1.get(i));
				CreatBox c1=new CreatBox((CreatBox)link1.get(m));
				LinkedList link2=new LinkedList((LinkedList)biao2.get(j));
				CreatBox c2=new CreatBox((CreatBox)link2.get(n));
				if(c1.name.equals(c2.name))
				{
					for(int k=0;k<link2.size();k++)
					{
						link1.add(link2.get(k));
							
					}
					daishu.add(link1);
				}
			}
		}
			hang.clear();
			for(int i=0;i<daishu.size();i++)
			{
				hang.add(daishu.get(i));
			}
			tableList(hang);
		
	}
	void selectquel(String[] biao,String[] shuxing)
	{
		daishu2.clear();
		daishu.clear();
		if(inlian==0)
		{
			LinkedList link1=new LinkedList();
			LinkedList link=new LinkedList((LinkedList)hang.get(0));
			for(int i=0;i<biao.length;i++)
			{
				for(int j=0;j<link.size();j++)
				{
					CreatBox o=new CreatBox((CreatBox)link.get(j));
					System.out.println("sddddddddsssssss="+shuxing[i]);
					System.out.println("sddddddddsssssss="+o.name);
					if(shuxing[i].equals(o.name))
					{
						
	                   link1.add(new Integer(j));
					}
				}
				
			}
			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));	
				}
				boolean boo=contain(daishu,ll);
				if(!boo)
				{
					daishu.add(ll);
				}
			}
		}
		else
		{
			LinkedList link1=new LinkedList();
			LinkedList link=new LinkedList((LinkedList)hang.get(0));
			for (int k=0;k<biao.length;k++)
			{
				if(biao[k].equals(filename[0]))
				{
					for(int j=0;j<inlian;j++)
					{
						CreatBox o=new CreatBox((CreatBox)link.get(j));
						if(shuxing[k].equals(o.name))
						{
	                   		link1.add(new Integer(j));
	                   		
						}
					}	
				}
				else if(biao[k].equals(filename[1]))
				{
					for(int j=inlian;j<link.size();j++)
					{
						CreatBox o=new CreatBox((CreatBox)link.get(j));
						if(shuxing[k].equals(o.name))
						{
	                   		link1.add(new Integer(j));
	                   		continue;
						}
					}	
				}
				
			}
			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));	
				}
				boolean boo=contain(daishu,ll);
				if(!boo)
				{
					daishu.add(ll);
				}
			}
			tableList(daishu);
			
			System.out.print("yyyyyyyyyyyyyyyyyyyyyyyyyy");
		}
	}
	void quel()
	{
		daishu.clear();
		hang.clear();
		 String quelString=quelArea.getText();
		 StringTokenizer fenxi=new StringTokenizer(quelString);
		 String[] fenxiyuyan=new String[fenxi.countTokens()];
		 int i=0;
		
		 
		 while(fenxi.hasMoreTokens())
		 {
		 	String str=fenxi.nextToken();
		 	fenxiyuyan[i]=str;
		 	i++;	
		 }
		 daishu.clear();
		 for(int j=0;j<fenxiyuyan.length;j++)
		 {
		 	
		 	if(fenxiyuyan[j].equals("of"))
		 	{
		 		if(hang.isEmpty())
		 		{
		 			Open(fenxiyuyan[j+3]);
		 			filename[0]=""+fenxiyuyan[j+1];
		 		}
		 		else
		 		{
		 			Open2(fenxiyuyan[j+3]);
		 			filename[1]=""+fenxiyuyan[j+1];
		 		} 	
		 	}
		 	else if(fenxiyuyan[j].equals("where"))
		 	{
		 		daishu.clear();
		 		
		 		for(int y=0;y<hang.size();y++)
		 		{
		 			daishu.add(hang.get(y));
		 		}
		 				
		 		for(int count=j+1;count<fenxiyuyan.length;count++)
		 		{
		 			String left="",right="",lefta="",righta="",leftb="",rightb="",leftt="",rightt="",leftc="",rightc="";
		 			int countpoint=0;int findlianjie=0;
		 			char a[]=fenxiyuyan[count].toCharArray();
		 			for(int dex=0;dex<a.length;dex++)
		 			{
		 				if(a[dex]=='.')
		 				{
		 					countpoint++;
		 					findlianjie=count;
		 					System.out.print("countpoint="+countpoint);
		 					System.out.print("findlianjie="+findlianjie);
		 				}
		 			}
		 			if(countpoint==2)
		 			{
		 				for(int dex=0;dex<a.length;dex++)
		 				{
		 					if(a[dex]=='=')
		 					{
		 						
		 						left=""+fenxiyuyan[count].substring(0,dex);
		 						char a1[]=left.toCharArray();
		 						for(int in=0;in<a1.length;in++)
		 						{
		 							if(a1[in]=='.')
		 							{
		 								lefta=""+left.substring(0,in);
		 								righta=""+left.substring(in+1,a1.length);
		 								
		 								System.out.print("lefta="+lefta);
		 								System.out.println("righta="+righta);
		 								
		 							}
		 							
		 						}
		 						right=""+fenxiyuyan[count].substring(dex+1,a.length);
		 						char a2[]=right.toCharArray();
		 						for(int in=0;in<a2.length;in++)
		 						{
		 							if(a2[in]=='.')
		 							{
		 								leftb=""+right.substring(0,in);
		 								rightb=""+right.substring(in+1,a2.length);
		 								System.out.print("leftb="+leftb);
		 								System.out.println("rightb="+rightb);
		 								
		 							}
		 							
		 						}
		 						
		 						    System.out.print("sdfjisdf="+fenxiyuyan[j+1]);
		 							System.out.print("left="+left);
		 							System.out.println("right"+right);
		 					}	
		 				}
		 				if(lefta.equals(filename[0]))
		 				{
		 					connectquel(hang,righta,hang2,rightb);
		 				}
		 				else if(lefta.equals(filename[1]))
		 				{
		 					connectquel(hang2,rightb,hang,righta);
		 				}countpoint=0;
		 			}
		 			else if(countpoint==1)
		 			{
		 				System.out.print("sdddddddddddddddddddd");
		 				char fuhao='k';
		 				for(int dex=0;dex<a.length;dex++)
		 				{
		 					
		 					if(a[dex]=='='||a[dex]=='>'||a[dex]=='<')
		 					{
		 						fuhao=a[dex];
		 						leftt=""+fenxiyuyan[count].substring(0,dex);
		 						char a1[]=leftt.toCharArray();	System.out.print("leftt="+leftt);
		 						for(int in=0;in<a1.length;in++)
		 						{
		 							if(a1[in]=='.')
		 							{		
		 								
		 								leftc=""+leftt.substring(0,in);
		 								rightc=""+leftt.substring(in+1,a1.length);
		 								System.out.println("sdffffffffffffffffffffff");
		 								System.out.print("leftc="+leftc);
		 								System.out.println("rightc="+rightc);
		 								
		 							}
		 							
		 						}
		 						rightt=""+fenxiyuyan[count].substring(dex+1,fenxiyuyan[count].length());
		 						System.out.println("rightt"+rightt);countpoint=0;
		 					}	
		 				}
		 			
		 				andquel(leftc,rightc,rightt,fuhao);
		 				//tableList(daishu);
		 				hang.clear();
		 				for(int r=0;r<daishu.size();r++)
		 				{
		 					hang.add(daishu.get(r));
		 				}	
		 				
		 					
		 			}
		 		}
		 	
		 	}
		}
		for(int j=0;j<fenxiyuyan.length;j++)
		{
		 	
		 	if(fenxiyuyan[j].equals("retrieve"))
		 	{
		 		int countwhere=-1;
		 		for(int ser=j;ser<fenxiyuyan.length;ser++)
		 		{
		 			if(fenxiyuyan[ser].equals("where"))
		 			{
		 				countwhere=ser;
		 				break;
		 			}
		 			countwhere=fenxiyuyan.length;
		 		}
		 		String[] left=new String[countwhere-j-1];
		 		String[] right=new String[countwhere-j-1];
		 		int con=0,co=0;
				
		 		for(int ser=j+1;ser<countwhere;ser++)
		 		{
		 			String str=""+fenxiyuyan[ser];
		 			char c[]=str.toCharArray();
		 			
		 			for(int count=0;count<c.length;count++)
		 			{
		 				if(c[count]=='.')
		 				{
		 					co=count;
		 					break;
		 				}
		 			}
		 			left[con]=""+str.substring(0,co);
		 			right[con]=""+str.substring(co+1,str.length());
		 			System.out.println();
		 			System.out.print("left="+left[con]);
		 			System.out.println("right="+right[con]);
		 			System.out.print("fffffffffffffffff");con++;
		 		}
		 		selectquel(left,right); 
		 		tableList(daishu);
		 		hang.clear();
		 		for(int r=0;r<daishu.size();r++)
		 		{
		 			hang.add(daishu.get(r));
		 		}
		 		break;			
		 	}	
		 			
		}
			
	}
		 
		 
	
	

	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==itemNew)////////////新建文件
		{
			box.clear();
			hang.clear();
			daishu.clear();
			creatFrame.setVisible(true);
		}
		else if(e.getSource()==itemOpen)
		{
			daishu.clear();
			hang.clear();
			hang2.clear();
			fileOpen();
		}
		else if(e.getSource()==itemOpen2)
		{
			hang2.clear();
			fileOpen2();
		}
		else if(e.getSource()==itemSave)///////////保存文件
		{
			if(daishu.isEmpty())
			{
				fileSave(hang);
			}
			else if(!daishu.isEmpty())
			{
				fileSave(daishu);
			}
			
		}
		else if(e.getSource()==itemAppend)
		{
			inputdata();
		}
		else if(e.getSource()==itemsappend)
		{
			creatFramea.setVisible(true);
		}
		else if(e.getSource()==itemModify)
		{
			modifyf();
			modifyFrame.setVisible(true);
			modifyFrame.validate();	
		}
		else if(e.getSource()==itemshuxing)
		{
			shuxing();
		}
		else if(e.getSource()==s_b)
		{
			LinkedList l=(LinkedList)hang.get(0);
			for(int i=0;i<l.size();i++)
			{
				CreatBox oo=(CreatBox)l.get(i);
				oo.name=s_name[i].getText();
				oo.type=(String)s_type[i].getSelectedItem();
				oo.leg=s_width[i].getText();
				oo.NULL=s_NULL[i].getText();
			}
			shuxingFrame.setVisible(false);
			
			
		}
		else if(e.getSource()==m_b)
		{	
			for(int i=1;i<hang.size();i++)
			{
				LinkedList l=new LinkedList();
				l=(LinkedList)hang.get(i);
				for(int j=0;j<l.size();j++)
				{
					CreatBox oo=(CreatBox)l.get(j);
					
					oo.name=m_f[(i-1)*l.size()+j].getText();
					
				}
			}
			modifyFrame.setVisible(false);
			jianlisuoyin();
		}
		else if(e.getSource()==next)
		{
				creatBox();
		}
		else if(e.getSource()==NULL)
		{
				NULL.setText("1");
		}
		else if(e.getSource()==complete)
		{
			if(name.getText().equals(""))
			{
				inputdata();		
			}
			else 
			{
				creatBox();
				inputdata();
			}
			hang.add(box);
			creatFrame.setVisible(false);
			
		}
		else if(e.getSource()==nexta)
		{
			for(int i=0;i<hang.size();i++)
			{
				if(i==0)
				{
					CreatBox oo=new CreatBox();
					oo.name=namea.getText();
					oo.leg=widtha.getText();
					oo.NULL=NULLa.getText();
					oo.type=type.getSelectedItem().toString();
					object o=new object();
					o.ob=(LinkedList)hang.get(i);
					o.ob.add(oo);	
				}
				else 
				{
					CreatBox oo=new CreatBox();
					oo.name="";
					oo.leg=widtha.getText();
					oo.NULL=NULLa.getText();
					oo.type=type.getSelectedItem().toString();
					object o=new object();
					o.ob=(LinkedList)hang.get(i);
					o.ob.add(oo);
				}
				namea.setText("");
				widtha.setText("");
				NULLa.setText("");
					
						
			}
		}
		else if(e.getSource()==NULLa)
		{
				NULL.setText("1");
		}
		else if(e.getSource()==completea)
		{
				creatFramea.setVisible(false);
		}
		else if(e.getSource()==b1)//数据输入窗口的/下一个/按钮
		{	
			newbox();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -