亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? catalog.java

?? 用JAVA實現的miniSQL
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
import java.io.*;
public class Catalog {
	public RandomAccessFile catalog;
	public RandomAccessFile indexlog;
	public String reason;
    public Catalog(){
    }
    long existFile(String file){
    	long address=0;
    	long current=0;
    	byte length=0;
    	byte[] name;
    	try{
    	    catalog = new RandomAccessFile(new File("catalog.log"),"rws");
    	    while(current<catalog.length()){
    		    catalog.seek(current);
    		    address = current;
    		    current=current+catalog.readInt();;
    		    length = catalog.readByte();
    		    if(length==0)
    			    continue;
    		    name = new byte[length*2];    		
    		    catalog.read(name);
    		    if(file.equals(new String(name,"UTF16"))){
                    catalog.close();
                    return address;
    		    }
    	    }
    	    catalog.close();
    	}catch(Exception e){ 
    		reason = new String("無此表");
    	    return -1; 
    	}
    	reason = new String("無此表");
    	return -1;
    }
    boolean getinformation(Interpreter cmd , String table){
    	long pos = existFile(table);
    	if(pos==-1){
    		reason = new String("無此表");
    	    return false; 
    	}
    	try{
    		catalog = new RandomAccessFile(new File("catalog.log"),"rws");
    		long current = pos+515;
    		catalog.seek(current);
    		cmd.attnumber = catalog.read();
    		cmd.attribute = new String[cmd.attnumber];
            cmd.atttype = new int[cmd.attnumber];
            cmd.attlength = new int[cmd.attnumber];
            cmd.unique = new boolean[cmd.attnumber];
            cmd.attindex = new String[cmd.attnumber];
    		current = pos+ 528;
    		catalog.seek(current);
    		byte[] name;
    		int length= 0;
    		int type = 0;
    		for(int i=0;i<cmd.attnumber;i++){
    			length = catalog.read()*2;
    			name = new byte[length];
    			catalog.read(name);
    			cmd.attribute[i]= new String(name, "UTF16");
    			catalog.seek(current+511);
    			type = catalog.read();
    			cmd.atttype[i]=type/4;
    			if((type%4)/2==0)
    				cmd.unique[i]=false;
    			else
    				cmd.unique[i]=true;
    			if(type/2==1)
    				cmd.primarykey = cmd.attribute[i];
    			cmd.attlength[i]=catalog.read()*2;
    			length = catalog.read()*2;
    			if(length!=0){
    				name = new byte[length];
    			    catalog.read(name);
    			    cmd.attindex[i]= new String(name, "UTF16");
    			}
    			current = current+1024;
    			catalog.seek(current);
    		}
    	}catch(Exception e){
    		return false;
    	}
    	return true;
    }
    boolean createTable(Interpreter command){
    	if(command.mean!=1)
    		return false;
    	try{	
    	    catalog = new RandomAccessFile(new File("catalog.log"),"rws");
            int lenght=528+command.attnumber*1024;
            int rlenght=command.attnumber+1;
            for(int i=0;i<command.attnumber;i++)
        	    rlenght=rlenght+command.attlength[i];
            long filelenght=catalog.length();
            boolean isprimary = false;
            catalog.seek(filelenght);
            catalog.writeInt(lenght);
            catalog.write(command.table.length());
            long current=catalog.getFilePointer()+510;
            catalog.writeChars(command.table);
            catalog.seek(current);
            catalog.write(command.attnumber);
            catalog.writeLong(0);
            if(rlenght < 9)
            	rlenght = 9;
            catalog.writeInt(rlenght);
            for(int i=0;i<command.attnumber;i++){
        	    catalog.write(command.attribute[i].length());
        	    current=catalog.getFilePointer()+510;
        	    catalog.writeChars(command.attribute[i]);
        	    catalog.seek(current);
        	    if(command.attribute[i].equalsIgnoreCase(command.primarykey))
        		    isprimary = true;
        	    else
        		    isprimary = false;
        	    catalog.write(toType(command.atttype[i],command.unique[i],isprimary));
        	    catalog.write(command.attlength[i]/2);
        	    catalog.write(0);
        	    current=catalog.getFilePointer()+510;
        	    catalog.seek(current);
            }
            catalog.setLength(current);
    	    catalog.close();
    	}catch(Exception e){ return false; }
    	return createIndex(command , command.table, command.primarykey, command.primarykey+"index");
    }
    boolean deleteTable(Interpreter cmd, long pos){
    	if(pos<0)
    		return false;
    	getinformation(cmd, cmd.table);
    	try{
            catalog = new RandomAccessFile(new File("catalog.log"),"rws");
    	    catalog.seek(pos+4);
    	    catalog.write(0);
    	    catalog.close();
    	}catch(Exception e){ return false; }
    	return true;
    }
    boolean createIndex(Interpreter cmd, String table,String attribute,String index){
    	long pos= existFile(table);
    	if(pos<0)
    		return false;
    	long current = pos + 528;
    	int length=0;
    	byte[] name;
    	int total=0;
    	try{
    		catalog = new RandomAccessFile(new File("catalog.log"),"rws");
    		catalog.seek(pos);
    		total=catalog.readInt();
    		while(current<pos+total){
    			catalog.seek(current);
    		    length = catalog.read();
    		    name = new byte[length*2];
    		    catalog.read(name);
    		    if(attribute.equalsIgnoreCase(new String(name,"UTF16")))
    			    break;
    			current = current + 1024;
    		}
    		if(current>pos+total){
    			catalog.close();
    			reason = new String("不存在此屬性");
    			return false;
    		}
    		catalog.seek(current+511);
    		length = catalog.read();
    		if((length%4)/2!=1){
    			catalog.close();
    			reason = new String("此屬性不是unique型的");
    			return false;
    		}
    		catalog.seek(current+513);
    		length = catalog.read();
    		if(length!=0){
    			catalog.close();
    			reason = new String("該屬性上的索引已存在");
    			return false;
    		}
    		catalog.seek(current+513);
    		catalog.write(index.length());
    		catalog.writeChars(index);
    		catalog.close();
    		indexlog = new RandomAccessFile(new File("indexlog.log"),"rws");
    		current = indexlog.length();
    		indexlog.seek(current);
    		indexlog.write(index.length());
    		indexlog.writeChars(index);
    		indexlog.seek(current+511);
    		indexlog.write(table.length());
    		indexlog.writeChars(table);
    		indexlog.seek(current+1022);
    		indexlog.write(attribute.length());
    		indexlog.writeChars(attribute);
    		indexlog.setLength(current+1533);
    		indexlog.close();
    	}catch(Exception e){ 
    		return false;
    	}
    	return getinformation(cmd, cmd.table);
    }
    void deleteIndexfromTable(String index){
    	long current = 0;
    	int length;
    	byte[] name;
    	try{
    	    indexlog = new RandomAccessFile(new File("indexlog.log"),"rws");
    	    while(current<indexlog.length()){
    	    	indexlog.seek(current);
    	    	length = indexlog.read();
    	    	if(length==0){
    	    		current = current+1533;
    	    		continue;
    	    	}
    	    	name = new byte[length*2];
    	    	indexlog.read(name);
    	    	if(index.equalsIgnoreCase(new String(name,"UTF16")))
    	    		break;
    	    	current = current+1533;
    	    }
    	    indexlog.seek(current);
    	    indexlog.write(0);
    	    indexlog.close();
    	}catch(Exception e){
    		System.out.println("Catalog error 1");
    		return;
    	}
    }
    boolean deleteIndex(String index){
    	long current = 0;
    	int length;
    	byte[] name;
    	String attribute;
    	String table;
    	try{
    	    indexlog = new RandomAccessFile(new File("indexlog.log"),"rws");
    	    while(current<indexlog.length()){
    	    	indexlog.seek(current);
    	    	length = indexlog.read();
    	    	if(length==0){
    	    		current = current+1533;
    	    		continue;
    	    	}
    	    	name = new byte[length*2];
    	    	indexlog.read(name);
    	    	if(index.equalsIgnoreCase(new String(name,"UTF16")))
    	    		break;
    	    	current = current+1533;
    	    }
    	    if(current>indexlog.length()){
    	    	reason = new String("無此索引");
    	    	indexlog.close();
    	    	return false;
    	    }
    	    indexlog.seek(current+511);
    	    length = indexlog.read();
    	    name = new byte[length*2];
    	    indexlog.read(name);
    	    table = new String(name, "UTF16");
    	    indexlog.seek(current+1022);
    	    length = indexlog.read();
    	    name = new byte[length*2];
    	    indexlog.read(name);
    	    attribute = new String(name, "UTF16");
    	    if(!deleteIndex(table,attribute,index)){
    	    	indexlog.close();
    	    	return false;
    	    }
    	    indexlog.seek(current);
    	    indexlog.write(0);
    	    indexlog.close();
    	}catch(Exception e){
    		return false;
    	}
    	return true;
    }
    boolean deleteIndex(String table,String attribute,String index){
    	long pos= existFile(table);
    	if(pos<0)
    		return false;
    	long current = pos + 528;
    	int length=0;
    	byte[] name;
    	int total=0;
    	try{
    		catalog = new RandomAccessFile(new File("catalog.log"),"rws");
    		catalog.seek(pos);
    		total=catalog.readInt();
    		while(current<pos+total){
    			catalog.seek(current);
    		    length = catalog.read();
    		    name = new byte[length*2];
    		    catalog.read(name);
    		    if(attribute.equalsIgnoreCase(new String(name,"UTF16")))
    			    break;
    			current = current + 1024;
    		}
    		if(current>pos+total){
    			catalog.close();

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区免费视频| 国产一区二区三区香蕉| www久久精品| 在线视频中文字幕一区二区| 国产成人免费av在线| 奇米777欧美一区二区| 亚洲福利电影网| 亚洲一区二区三区四区五区黄| 亚洲女同一区二区| 1区2区3区国产精品| 亚洲欧美日韩电影| 福利一区二区在线| 成人在线一区二区三区| 91婷婷韩国欧美一区二区| 成人高清视频免费观看| 波多野结衣亚洲| 欧美亚洲综合网| 欧美sm美女调教| 国产欧美日韩激情| 中文字幕日韩欧美一区二区三区| 麻豆精品新av中文字幕| 成人高清免费观看| 国产欧美va欧美不卡在线| 狠狠色综合色综合网络| 色婷婷综合久久久中文字幕| 欧美性受xxxx| 亚洲伦理在线免费看| 日本欧美大码aⅴ在线播放| 91成人免费在线| 欧美亚洲丝袜传媒另类| 亚洲视频免费在线观看| 欧美aa在线视频| 欧美一区二区美女| 欧美国产日韩亚洲一区| 亚洲自拍偷拍av| 欧美系列日韩一区| 一区二区三区91| 国产成人在线免费观看| 国产精品素人一区二区| 日本成人在线电影网| 欧美高清视频一二三区| 国产日韩欧美综合一区| 成人精品高清在线| 自拍偷自拍亚洲精品播放| 欧洲一区二区av| 日本午夜精品一区二区三区电影| 日韩视频中午一区| 亚洲免费观看在线观看| 日本精品一区二区三区高清| 亚洲一区二区影院| 日韩免费观看高清完整版| 亚洲欧美激情视频在线观看一区二区三区 | 青青青伊人色综合久久| 日韩欧美在线不卡| 国产成人精品免费网站| 一区二区三区免费在线观看| 欧美高清hd18日本| 国产精品系列在线播放| 欧美一区二区视频在线观看| 国产真实乱偷精品视频免| 中文乱码免费一区二区 | 国产麻豆成人精品| 亚洲欧美日韩人成在线播放| 欧美一区二区视频在线观看 | 国产一区二区三区黄视频 | 国产精品自在欧美一区| 亚洲视频一区二区在线| 欧美大片拔萝卜| 97精品久久久午夜一区二区三区 | 国产麻豆精品95视频| 18成人在线观看| 91精品国产色综合久久| 丁香亚洲综合激情啪啪综合| 亚洲二区视频在线| 亚洲国产高清不卡| 日韩一区二区在线观看视频播放| 大尺度一区二区| 蜜桃视频在线观看一区二区| 成人免费在线视频观看| 精品国产1区二区| 韩国v欧美v亚洲v日本v| 极品瑜伽女神91| 亚洲成人av在线电影| 日本久久精品电影| 福利视频网站一区二区三区| 麻豆专区一区二区三区四区五区| 亚洲人成伊人成综合网小说| 精品国产乱码久久久久久图片| 在线精品观看国产| 成人手机在线视频| 国模大尺度一区二区三区| 亚洲成人动漫精品| 一区二区三区日韩在线观看| 国产精品午夜在线观看| 2020国产精品| 欧美va在线播放| 在线综合+亚洲+欧美中文字幕| 日本成人在线看| 亚洲成av人片| 亚洲午夜久久久久| 亚洲精品午夜久久久| 国产精品欧美久久久久一区二区| 久久一夜天堂av一区二区三区| 欧美日韩日本视频| 狠狠色丁香久久婷婷综| 麻豆成人综合网| 精品一区二区三区在线观看 | 精品福利在线导航| 日韩女优制服丝袜电影| 欧美一区二区三区白人| 日韩欧美精品三级| 日韩视频不卡中文| 精品国产91乱码一区二区三区| 日韩欧美精品三级| 午夜亚洲福利老司机| 91麻豆精品国产无毒不卡在线观看| 色综合久久久久网| 91国偷自产一区二区三区成为亚洲经典 | 亚洲四区在线观看| 亚洲精品乱码久久久久久久久 | 在线免费观看一区| 在线日韩国产精品| 欧美日韩中字一区| 678五月天丁香亚洲综合网| 欧美一级片免费看| 精品女同一区二区| 欧美国产视频在线| 亚洲精品成人天堂一二三| 亚洲香肠在线观看| 蜜桃91丨九色丨蝌蚪91桃色| 国产在线视视频有精品| 99国产精品99久久久久久| 欧美日韩在线直播| 日韩欧美你懂的| 成人免费在线播放视频| 亚洲高清免费视频| 国产精品影视在线| 日本电影亚洲天堂一区| 欧美一级夜夜爽| 国产精品久久久久aaaa樱花| 精品久久一二三区| 国产精品国产自产拍高清av | 男男gaygay亚洲| 国产 欧美在线| 欧美日韩综合在线免费观看| 亚洲精品一区二区三区精华液| 国产精品国产自产拍高清av| 午夜a成v人精品| 成人一区二区在线观看| 欧美福利视频一区| 中文av一区特黄| 肉色丝袜一区二区| 亚洲小说春色综合另类电影| 久久电影网站中文字幕| 国产一区二区福利| 欧美丝袜第三区| 欧美激情一区二区三区在线| 亚洲一区二区成人在线观看| 国产一区二区免费看| 欧美日韩一区二区在线观看| 亚洲国产高清在线观看视频| 日韩中文字幕91| 99精品视频在线免费观看| 欧美一区二区播放| 亚洲国产中文字幕在线视频综合| 国产成人在线看| 日韩欧美电影一区| 午夜欧美大尺度福利影院在线看| 成人午夜短视频| 欧美精品一区二区在线播放| 亚洲成人免费影院| 91在线精品秘密一区二区| 久久久久99精品一区| 国产精品久久三区| 久久er精品视频| 欧美日韩激情一区二区三区| 欧美伦理影视网| 亚洲综合色丁香婷婷六月图片| 国产99久久久久久免费看农村| 日韩久久久精品| 偷拍一区二区三区四区| 在线一区二区三区| 成人免费视频在线观看| 成人激情小说乱人伦| 国产亚洲综合av| 一区二区久久久久| 不卡视频免费播放| 国产精品视频在线看| 国产传媒久久文化传媒| 久久久久久99精品| 国产一区二区中文字幕| 欧美mv日韩mv国产网站app| 日韩激情视频在线观看| 欧美日韩精品一区二区在线播放| 亚洲男人的天堂一区二区| 99国产精品久| 亚洲一区二区三区视频在线播放| 色婷婷综合激情| 亚洲国产成人av网| 欧美日韩精品一区二区在线播放|