/**
*
*/
/**
* @author Uisleandro Costa dos Santos
*/
public class MyColumn {
private String dataType = null;
private Integer dataSize = null;
private Boolean autoIncrement = false;
private String mask = null;
/*
* @param dataType String representing the dataType of this column
* @param dataSize Integer representing the dataSize in bytes of this column
* */
public MyColumn(String dataType, Integer dataSize){
this.dataType = dataType;
this.dataSize = dataSize;
if(dataType.toLowerCase().equals("int")){
this.dataSize = 4;
}
else if(dataType.toLowerCase().equals("date")){
this.dataSize = 10;
}
/*else if(dataSize == null){
this.dataSize = 0;
}*/
}
public MyColumn(String mask){
if(mask == null){
System.out.println("Erro: MyColumn: mask is null");
return;
}
this.mask = mask;
this.dataType = "mask";
this.dataSize = mask.length();
}
/**
* @param size the size of the Data Field
* @param mask the mask
*/
public MyColumn(Integer size, String mask){
if(mask == null){
System.out.println("Erro: MyColumn: mask is null");
return;
}
this.mask = mask;
this.dataType = "mask";
this.dataSize = size;
}
/**
* @return String
*/
public String getMask() {
return this.mask;
}
/**
* @return String
*/
public String getType() {
return dataType;
}
/**
* @return Integer this.dataSize
*/
public Integer getSize() {
return dataSize;
}
/**
* @return The Column Name that is pointed by Instance of one class inherited of MyColumn, this method is not implemented properly in MyColumn Class, but in MyFKColumn.
*/
public String getRefColumn(){
return null;
}
/**
* @return The Table Name that is pointed by Instance of one class inherited of MyColumn, this method is not implemented properly in MyColumn Class, but in MyFKColumn.
*/
public String getRefTable(){
return null;
}
/**
* @return Boolean that indicates that this column is a ForeignKey, Default value = false;
*/
public Boolean isForeignKey(){
return false;
}
/**
* @return Boolean that indicates that this column is an Auto Increment Column;
*/
public Boolean isAutoIncrement(){
return this.autoIncrement;
}
/**
* @param autoIncrement, used to ignore this column in the insertions
*/
public void setAutoIncrement(Boolean autoIncrement){
this.autoIncrement = autoIncrement;
}
/**
* @param args
*/
public static void main(String[] args) {
MyColumn teste;
teste = new MyColumn("+(55) ?? ???? - ????"); //telefone = 20
System.out.println(teste.getSize());
teste = new MyColumn("????? - ???"); //CEP = 11
System.out.println(teste.getSize());
teste = new MyColumn("???.???.???-??"); //CPF = 14
System.out.println(teste.getSize());
}
}