View Javadoc

1   /*
2    * Created on 26 oct. 2003
3    *
4    * To change this generated comment go to 
5    * Window>Preferences>Java>Code Generation>Code Template
6    */
7   package salto.tool.jdo.data;
8   
9   import salto.tool.jdo.util.CreatorUtil;
10  import salto.tool.sql.data.TableColInfo;
11  
12  /***
13   * @author Loiez
14   */
15  public class JdoColInfo extends TableColInfo {
16  	/***
17  	 * classe java de l'attribut
18  	 */
19  	private String javaAttClass;
20  	/***
21  	 * classes java possible pour l'attribut
22  	 */
23  	private String[] javaPossTyp;
24  	/***
25  	 * Nom de la constante java
26  	 */
27  	private String javaAttCteName;
28  	/***
29  	 * nom de l'attribut java (d�duit du nom de la colonne)
30  	 */
31  	private String javaAttName;
32  	public JdoColInfo() {}
33  	
34  	public JdoColInfo(TableColInfo colInfo) {
35  		autoIncrement = colInfo.isAutoIncrement();
36  		tableCat = colInfo.getTableCat();
37  		tableShem = colInfo.getTableShem();
38  		tableName = colInfo.getTableName();
39  		colName = colInfo.getColName();
40  		colTyp = colInfo.getColTyp();
41  		typName = colInfo.getTypName();
42  		colSize = colInfo.getColSize();
43  		decDigit = colInfo.getDecDigit();
44  		numPrecRadix = colInfo.getNumPrecRadix();
45  		colNullable = colInfo.getColNullable();
46  		colRemarks = colInfo.getColRemarks();
47  		colDefaultVal = colInfo.getColDefaultVal();
48  		colCharOctetLength = colInfo.getColCharOctetLength();
49  		colPosition = colInfo.getColPosition();
50  		colIsNullable = colInfo.getColIsNullable();
51  	}
52  	/***
53  	 * @return Returns the javaAttName.
54  	 */
55  	public String getJavaAttName() {
56  		if (javaAttName == null) 
57  			javaAttName = CreatorUtil.getDoNameCreator().createJavaAttName(colName);
58  		return javaAttName;
59  	}
60  
61  
62  	/***
63  	 * retourne le nom de la constante java 
64  	 * @return Returns the javaAttCteName.
65  	 */
66  	public String getJavaAttCteName() {
67  		if (javaAttCteName == null) 
68  			javaAttCteName = CreatorUtil.getDoNameCreator().createJavaCteName(getJavaAttName());
69  		
70  		return javaAttCteName;
71  	}
72  
73  	/***
74  	 * @return Returns the javaPossTyp.
75  	 */
76  	public String[] getJavaPossTyp() {
77  		if (javaPossTyp == null)
78  			javaPossTyp = CreatorUtil.getJdbcConvert().getJavaPossTyp(this);
79  		return javaPossTyp;
80  	}
81  
82  	/***
83  	 * @return Returns the javaTypName.
84  	 */
85  	public String getJavaAttClass() {
86  		if (javaAttClass == null) 
87  			javaAttClass = CreatorUtil.getJdbcConvert().convert(this);
88  		return javaAttClass;
89  	}
90  	
91  	public boolean isPrimitif() {
92  		if(getJavaAttClass().equals("byte")) return true;
93  		if(getJavaAttClass().equals("boolean")) return true;
94  		if(getJavaAttClass().equals("short")) return true;
95  		if(getJavaAttClass().equals("int")) return true;
96  		if(getJavaAttClass().equals("long")) return true;
97  		if(getJavaAttClass().equals("float")) return true;
98  		if(getJavaAttClass().equals("double")) return true;
99  		return false;
100 	}
101 	public String getNonPrimitifClass() {
102 		if(getJavaAttClass().equals("byte")) return "Byte";
103 		if(getJavaAttClass().equals("boolean")) return "Boolean";
104 		if(getJavaAttClass().equals("short")) return "Short";
105 		if(getJavaAttClass().equals("int")) return "Integer";
106 		if(getJavaAttClass().equals("long")) return "Long";
107 		if(getJavaAttClass().equals("float")) return "Float";
108 		if(getJavaAttClass().equals("double")) return "Double";
109 		return getJavaAttClass();
110 	}
111 	
112 	public String getterMethod() {
113 		return "get"+Character.toUpperCase(getJavaAttName().charAt(0))+getJavaAttName().substring(1);
114 	}
115 	public String setterMethod() {
116 		return "set"+Character.toUpperCase(getJavaAttName().charAt(0))+getJavaAttName().substring(1);
117 	}
118 }