1 package org.opensync.tools;
2
3 import java.io.FileNotFoundException;
4 import java.io.IOException;
5 import java.io.ObjectInputStream;
6 import java.io.ObjectOutputStream;
7 import java.io.Serializable;
8 import java.util.Vector;
9
10 import org.xml.sax.SAXException;
11
12 public class Element implements Serializable {
13 protected String keyWord,label,file,field,parentFile,keyParent,formatDateSql,separatorDateSql,formatTimeSql,separatorTimeSql ;
14 protected String primaryKey,type,length,refThemeNumber,sequenceNumber, dateDebPlanning, dateFinPlanning;
15 protected GroupFixedCriteria groupOfElement[];
16 protected ElementLink elementsLink[];
17 protected ElementAssociation elementAssociation;
18 protected boolean isFixedCriteria=false;
19 protected boolean isAssociatedTheme=false;
20 protected boolean isAssociatedParentTheme=false;
21 /***
22 * Constructor
23 */
24 public Element() {
25
26 }
27
28 public void initLabels(String lang) throws SAXException,FileNotFoundException,IOException {
29 label = DicoReader.getLabelDicoByKey(lang,keyWord);
30 for (int i=0;i<groupOfElement.length;i++)
31 groupOfElement[i].initLabels(lang);
32 }
33
34
35
36 public void setDateDebPlanning(String s)
37 {
38 this.dateDebPlanning = s;
39 }
40 public void setDateFinPlanning(String s)
41 {
42 this.dateFinPlanning = s;
43 }
44 public void setKeyWord(String s) {
45 this.keyWord = s;
46 }
47 public void setLabel(String s) {
48 this.label = s;
49 }
50 public void setFile(String s) {
51 this.file = s;
52 }
53 public void setField(String s) {
54 this.field = s;
55 }
56 public void setParentFile(String s) {
57 this.parentFile = s;
58 }
59 public void setKeyParent(String s) {
60 this.keyParent = s;
61 }
62 public void setFormatDateSql(String s) {
63 this.formatDateSql = s;
64 }
65 public void setSeparatorDateSql(String s) {
66 this.separatorDateSql = s;
67 }
68 public void setFormatTimeSql(String s) {
69 this.formatTimeSql = s;
70 }
71 public void setSeparatorTimeSql(String s) {
72 this.separatorTimeSql = s;
73 }
74 public void setPrimaryKey(String s) {
75 this.primaryKey = s;
76 }
77 public void setType(String s) {
78 this.type = s;
79 }
80 public void setLength(String s) {
81 if (s == null) this.length = "0";
82 else this.length = s;
83 }
84 public void setRefThemeNumber(String s) {
85 this.refThemeNumber = s;
86 }
87 public void setSequenceNumber(String s) {
88 if (s == null) this.sequenceNumber = "";
89 else this.sequenceNumber = s;
90 }
91 public void setIsFixedCriteria(boolean s) {
92 this.isFixedCriteria = s;
93 }
94 public void setIsAssociatedTheme(boolean s) {
95 this.isAssociatedTheme = s;
96 }
97 public void setIsAssociatedParentTheme(boolean s) {
98 this.isAssociatedTheme = s;
99 }
100
101
102 public String getDateDebPlanning()
103 {
104 return dateDebPlanning;
105 }
106 public String getDateFinPlanning()
107 {
108 return dateFinPlanning;
109 }
110 public String getKeyWord() {
111 return(keyWord);
112 }
113 public String getLabel() {
114 return(label);
115 }
116 public String getFile() {
117 return(file);
118 }
119 public String getField() {
120 return(field);
121 }
122 public String getParentFile() {
123 return(parentFile);
124 }
125 public String getKeyParent() {
126 return(keyParent);
127 }
128 public String getPrimaryKey() {
129 return(primaryKey);
130 }
131 public String getType() {
132 return(type);
133 }
134 public String getLength() {
135 return(length);
136 }
137 public String getRefThemeNumber() {
138 return(refThemeNumber);
139 }
140 public String getFormatDateSql() {
141 if (formatDateSql==null || formatDateSql.length()==0) return "";
142 return(formatDateSql);
143 }
144 public String getSeparatorDateSql() {
145 if (separatorDateSql==null || separatorDateSql.length()==0) return "";
146 return(separatorDateSql);
147 }
148 public String getFormatTimeSql() {
149 if (formatTimeSql==null || formatTimeSql.length()==0) return "";
150 return(formatTimeSql);
151 }
152 public String getSeparatorTimeSql() {
153 if (separatorTimeSql==null || separatorTimeSql.length()==0) return "";
154 return(separatorTimeSql);
155 }
156 public boolean getIsFixedCriteria() {
157 return(isFixedCriteria);
158 }
159 public boolean getIsAssociatedTheme() {
160 return(isAssociatedTheme);
161 }
162 public boolean getIsAssociatedParentTheme() {
163 return(isAssociatedParentTheme);
164 }
165 public String getSequenceNumber() {
166 return(sequenceNumber);
167 }
168 public boolean equalsByKeyWord(String k) {
169 if (this.keyWord.equals(k)) return true;
170 else return false;
171 }
172 public boolean equalsByField(String k) {
173 if (this.field.equals(k)) return true;
174 else return false;
175 }
176
177 public void setGroups(Vector f) {
178 groupOfElement = new GroupFixedCriteria[f.size()];
179 if (Utils.debug) System.out.println("groupOfElement : "+groupOfElement);
180 f.toArray(groupOfElement);
181 f.clear();
182 }
183 public GroupFixedCriteria[] getGroups() {
184 return groupOfElement;
185 }
186 public GroupFixedCriteria getGroupByIndex(int k) {
187 if( groupOfElement.length<0) return null;
188 else return groupOfElement[k];
189 }
190 public GroupFixedCriteria getGroupByKey(String k) {
191 for (int i=0;i<groupOfElement.length;i++)
192 if (groupOfElement[i].equals(k)) return groupOfElement[i];
193 return null;
194 }
195
196 public void setElementsLink(Vector f) {
197 elementsLink = new ElementLink[f.size()];
198 if (Utils.debug) System.out.println("elementsLink : "+elementsLink);
199 f.toArray(elementsLink);
200 f.clear();
201 }
202 public ElementLink[] getElementsLink() {
203 if( elementsLink==null || elementsLink.length<0) return null;
204 return elementsLink;
205 }
206
207
208 public void setElementAssociation(ElementAssociation asso) {
209 elementAssociation = asso;
210 if (Utils.debug) System.out.println("elementAssociation : "+elementAssociation);
211 }
212 public ElementAssociation getElementAssociation() {
213 if( elementAssociation==null) return null;
214 return elementAssociation;
215 }
216 private void writeObject(ObjectOutputStream oos) throws IOException {
217 oos.defaultWriteObject();
218 }
219 private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
220 ois.defaultReadObject();
221 }
222
223 }
224
225