Menu

[r16]: / trunk / src / MyColumn.java  Maximize  Restore  History

Download this file

156 lines (111 with data), 3.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/**
*
*/
/**
* @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());
}
}