field.java
来自「J2EE eclipse 下开发数据库一个插件」· Java 代码 · 共 218 行
JAVA
218 行
package com.tanghan.db;
import java.io.Serializable;
import com.tanghan.db.util.*;
public class Field implements Serializable{
//字段名称
private String fieldName = "";
//字段在java.sql.Types中的类型
private int fieldType = 0;
//字段类型
private String fieldTypeName = "";
//字段长度
private int fieldLength = 0;
//
private int precision = 0;
//
private int scale = 0;
//表名称
private String tableName = "";
//是否为空
private boolean nullable = false;
//是否为关键字
private boolean primaryKey = false;
//是否为外键
private boolean foreignKey = false;
//该表字段相对应得java类型
private String javaFieldType = "String";
public Field(String tableName ,String fieldName,int fieldType, String fieldTypeName, int fieldLength,
int precision, int scale,boolean nullable) {
this.tableName = tableName;
this.fieldName = fieldName;
this.fieldType = fieldType;
this.fieldTypeName = fieldTypeName;
this.fieldLength = fieldLength;
this.precision = precision;
this.scale = scale;
this.nullable = nullable;
javaFieldType = JavaFieldTypes.getJavaType(this);
}
/**
* Gets the fieldName
* @return Returns a String
*/
public String getFieldName() {
return fieldName;
}
/**
* Sets the fieldName
* @param fieldName The fieldName to set
*/
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
/**
* Gets the fieldType
* @return Returns a String
*/
public int getFieldType() {
return fieldType;
}
/**
* Sets the fieldType
* @param fieldType The fieldType to set
*/
public void setFieldType(int fieldType) {
this.fieldType = fieldType;
javaFieldType = JavaFieldTypes.getJavaType(this);
}
/**
* Gets the fieldLength
* @return Returns a int
*/
public int getFieldLength() {
return fieldLength;
}
/**
* Sets the fieldLength
* @param fieldLength The fieldLength to set
*/
public void setFieldLength(int fieldLength) {
this.fieldLength = fieldLength;
}
/**
* Gets the precision
* @return Returns a int
*/
public int getPrecision() {
return precision;
}
/**
* Sets the precision
* @param precision The precision to set
*/
public void setPrecision(int precision) {
this.precision = precision;
}
/**
* Gets the scale
* @return Returns a int
*/
public int getScale() {
return scale;
}
/**
* Sets the scale
* @param scale The scale to set
*/
public void setScale(int scale) {
this.scale = scale;
}
/**
* Gets the tableName
* @return Returns a String
*/
public String getTableName() {
return tableName;
}
/**
* Sets the tableName
* @param tableName The tableName to set
*/
public void setTableName(String tableName) {
this.tableName = tableName;
}
/**
* Gets the nullable
* @return Returns a boolean
*/
public boolean isNullable() {
return nullable;
}
/**
* Sets the nullable
* @param nullable The nullable to set
*/
public void setNullable(boolean nullable) {
this.nullable = nullable;
}
/**
* Gets the fieldTypeName
* @return Returns a String
*/
public String getFieldTypeName() {
return fieldTypeName;
}
/**
* Sets the fieldTypeName
* @param fieldTypeName The fieldTypeName to set
*/
public void setFieldTypeName(String fieldTypeName) {
this.fieldTypeName = fieldTypeName;
}
/**
* Gets the javaFieldType
* @return Returns a String
*/
public String getJavaFieldType() {
return javaFieldType;
}
/**
* Sets the javaFieldType
* @param javaFieldType The javaFieldType to set
*/
public void setJavaFieldType(String javaFieldType) {
this.javaFieldType = javaFieldType;
}
/**
* @return
*/
public boolean isForeignKey() {
return foreignKey;
}
/**
* @return
*/
public boolean isPrimaryKey() {
return primaryKey;
}
/**
* @param b
*/
public void setForeignKey(boolean b) {
foreignKey = b;
}
/**
* @param b
*/
public void setPrimaryKey(boolean b) {
primaryKey = b;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?