attribute.java

来自「一个用java编写的从底层开始设计的小型数据库管理系统」· Java 代码 · 共 39 行

JAVA
39
字号

package compiler;
import recordmanagement.*;
public class Attribute {
	public Table table;
	public byte attIndex;
	public Attribute(Table t, byte b){
		table = t;
		attIndex = b;
	}
	private static Attribute All = new Attribute(null, (byte)-1);
	//返回Singleton对象, *
	public static Attribute GetInstanceAll(){
		return Attribute.All;
	}
	//返回对象Table.*
	public static Attribute GetInstanceAllinTable(Table table){
		return new Attribute(table, (byte)-1);
	}
	public String toString(){
		if(table == null && attIndex == (byte)-1){
			return "*";
		}else if (table != null && attIndex == (byte)-1){
			return (table.getTableName() + ".*" );
		}else{
			return (table.getTableName() + "." + table.getSchema().getAttributeName(attIndex));
		}
		
	}
	public boolean equals(Object att){
		if (att instanceof Attribute){
			if ( ((Attribute)att).table == this.table  && ((Attribute)att).attIndex == this.attIndex){
				return true;
			}
		}
		return false;
	}
}

⌨️ 快捷键说明

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