KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Made > TIR > Impl > WorkRepositoryImpl


1 /* $Id: WorkRepositoryImpl.java,v 1.2 2004/05/20 14:23:52 bures Exp $ */
2 package SOFA.SOFAnode.Made.TIR.Impl;
3 import java.rmi.RemoteException JavaDoc;
4 import java.rmi.server.ServerNotActiveException JavaDoc;
5 import java.rmi.server.UnicastRemoteObject JavaDoc;
6
7 import SOFA.SOFAnode.Made.TIR.ConstantDef;
8 import SOFA.SOFAnode.Made.TIR.Contained;
9 import SOFA.SOFAnode.Made.TIR.Container;
10 import SOFA.SOFAnode.Made.TIR.DefinitionKind;
11 import SOFA.SOFAnode.Made.TIR.EnumDef;
12 import SOFA.SOFAnode.Made.TIR.EnumMember;
13 import SOFA.SOFAnode.Made.TIR.ExprBinOperationDef;
14 import SOFA.SOFAnode.Made.TIR.ExprBoolean;
15 import SOFA.SOFAnode.Made.TIR.ExprChar;
16 import SOFA.SOFAnode.Made.TIR.ExprConstant;
17 import SOFA.SOFAnode.Made.TIR.ExprDefault;
18 import SOFA.SOFAnode.Made.TIR.ExprDouble;
19 import SOFA.SOFAnode.Made.TIR.ExprEnum;
20 import SOFA.SOFAnode.Made.TIR.ExprFixed;
21 import SOFA.SOFAnode.Made.TIR.ExprFloat;
22 import SOFA.SOFAnode.Made.TIR.ExprLong;
23 import SOFA.SOFAnode.Made.TIR.ExprLongDouble;
24 import SOFA.SOFAnode.Made.TIR.ExprLongLong;
25 import SOFA.SOFAnode.Made.TIR.ExprOctet;
26 import SOFA.SOFAnode.Made.TIR.ExprOperDef;
27 import SOFA.SOFAnode.Made.TIR.ExprProperty;
28 import SOFA.SOFAnode.Made.TIR.ExprShort;
29 import SOFA.SOFAnode.Made.TIR.ExprString;
30 import SOFA.SOFAnode.Made.TIR.ExprUnOperationDef;
31 import SOFA.SOFAnode.Made.TIR.ExprUnsigLong;
32 import SOFA.SOFAnode.Made.TIR.ExprUnsigLongLong;
33 import SOFA.SOFAnode.Made.TIR.ExprUnsigShort;
34 import SOFA.SOFAnode.Made.TIR.ExprWchar;
35 import SOFA.SOFAnode.Made.TIR.ExprWstring;
36 import SOFA.SOFAnode.Made.TIR.Identification;
37 import SOFA.SOFAnode.Made.TIR.ManageProfiles;
38 import SOFA.SOFAnode.Made.TIR.ManageRepository;
39 import SOFA.SOFAnode.Made.TIR.PrimitiveDef;
40 import SOFA.SOFAnode.Made.TIR.ProfileDef;
41 import SOFA.SOFAnode.Made.TIR.Repository;
42 import SOFA.SOFAnode.Made.TIR.StateKind;
43 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit;
44 import SOFA.SOFAnode.Made.TIR.TIRExceptCreate;
45 import SOFA.SOFAnode.Made.TIR.TIRExceptLock;
46 import SOFA.SOFAnode.Made.TIR.TIRExceptSave;
47 import SOFA.SOFAnode.Made.TIR.TIRObject;
48 import SOFA.SOFAnode.Made.TIR.ValueGen;
49 import SOFA.SOFAnode.Made.TIR.WorkRepository;
50
51 public class WorkRepositoryImpl extends ContainerImpl implements WorkRepository, Repository {
52   
53   Lock lock;
54   RepositoryImpl normalRep;
55   DefinitionKindImpl defKindImpl;
56   StateKindImpl stKindImpl;
57   //boolean hasCont;
58
PrimitiveDef[] primitives;
59
60   ProfileDef actProfile;
61   ManageProfilesImpl mProfiles;
62
63   boolean commited;
64   boolean aborted;
65
66   long workId; // id for create locking (id of "transaction")
67
String JavaDoc workIdString;
68   boolean lockForMe; // if normal rep. is locked for create for me
69

70   LiIdItem firstId; // for nextversions id
71
LiIdItem lastId;
72   int numOfIds;
73
74   public WorkRepositoryImpl(RepositoryImpl nR, ProfileDef prof) throws RemoteException JavaDoc, TIRExceptCreate, TIRExceptLock {
75     normalRep = nR;
76     normalRep.lockProfiles.lock();
77     lock = nR.lock;
78     mProfiles = new ManageProfilesImpl(normalRep.mProfiles, this);
79     if (prof == null) {
80       actProfile = null;
81     } else {
82       ProfileDef a = mProfiles.lookup(prof.name());
83       if (a==null) { // no profile if looked up ? it never should be
84
normalRep.lockProfiles.unlock();
85         throw new TIRExceptCreate("Bad profile");
86       }
87       if (((SProfileDef)a).isLocked()) { // test, if profile is locked
88
normalRep.lockProfiles.unlock();
89         throw new TIRExceptCreate("Profile is locked");
90       }
91      
92       if (!((SProfileDef)a).lock()) { // lock profile
93
normalRep.lockProfiles.unlock();
94         throw new TIRExceptLock("Profile can not lock.");
95       }
96       
97       actProfile = a;
98     }
99     normalRep.lockProfiles.unlock();
100     workId = nR.getUniqueNumber();
101     try {
102       workIdString = UnicastRemoteObject.getClientHost();
103     } catch (ServerNotActiveException JavaDoc e) {
104       workIdString = "unknown";
105     }
106     workIdString = workIdString + " : " + workId;
107     defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_WorkRepository);
108     stKindImpl = new StateKindImpl(StateKind.sk_work);
109     //hasCont = false;
110
primitives = new PrimitiveDef [17];
111     for(int i=0;i<17;i++) {
112       primitives[i] = new PrimitiveDefImpl(i,StateKind.sk_work);
113     }
114     commited = false;
115     aborted = false;
116     firstId = lastId = null;
117     numOfIds = 0;
118   }
119
120   public Contained lookup(Identification id) throws RemoteException JavaDoc, TIRExceptLock {
121     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
122       fromNormRep();
123     }
124       Contained ret = null;
125       LiItem akt = firstChild;
126       for(int i=0;i<numOfItems;i++) {
127         if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(id.name())==0) {
128           ret = (Contained) akt.obj;
129      break;
130         } else {
131           akt = akt.next;
132         }
133       }
134       return ret;
135   }
136
137   public Contained lookup(String JavaDoc name, String JavaDoc version) throws RemoteException JavaDoc, TIRExceptLock {
138     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
139       fromNormRep();
140     }
141       Contained ret = null;
142       LiItem akt = firstChild;
143       for(int i=0;i<numOfItems;i++) {
144         if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(name)==0) {
145           ret = (Contained) akt.obj;
146      break;
147         } else {
148           akt = akt.next;
149         }
150       }
151       return ret;
152   }
153
154   public Contained[] contents(DefinitionKind type) throws RemoteException JavaDoc, TIRExceptLock {
155     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
156       fromNormRep();
157     }
158     return super.contents(type);
159   }
160
161   public Contained[] lookup_name(Identification id) throws RemoteException JavaDoc, TIRExceptLock {
162     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
163       fromNormRep();
164     }
165     return super.lookup_name(id);
166   }
167
168   public Contained[] lookup_name(String JavaDoc name) throws RemoteException JavaDoc, TIRExceptLock {
169     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
170       fromNormRep();
171     }
172     return super.lookup_name(name);
173   }
174
175   public Contained lookup_tag(String JavaDoc name, String JavaDoc tag) throws RemoteException JavaDoc, TIRExceptLock {
176     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
177       fromNormRep();
178     }
179     return super.lookup_tag(name, tag);
180   }
181
182   public Contained[] lookup_branchtag(String JavaDoc name, String JavaDoc brtag) throws RemoteException JavaDoc, TIRExceptLock {
183     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
184       fromNormRep();
185     }
186     return super.lookup_branchtag(name, brtag);
187   }
188
189   public Contained lookup_lastinbranch(String JavaDoc name, String JavaDoc brtag) throws RemoteException JavaDoc, TIRExceptLock {
190     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
191       fromNormRep();
192     }
193     return super.lookup_lastinbranch(name, brtag);
194   }
195
196   public Contained lookup_lastfromversion(String JavaDoc name, String JavaDoc version) throws RemoteException JavaDoc, TIRExceptLock {
197     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
198       fromNormRep();
199     }
200     return super.lookup_lastfromversion(name, version);
201   }
202
203   public Contained[] scontents(DefinitionKind type) throws RemoteException JavaDoc, TIRExceptLock {
204     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
205       fromNormRep();
206     }
207     return super.scontents(type);
208   }
209
210   public Contained slookup(Identification id) throws RemoteException JavaDoc, TIRExceptLock {
211     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
212       fromNormRep();
213     }
214       Contained ret = null;
215       LiItem akt = firstChild;
216       for(int i=0;i<numOfItems;i++) {
217         if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(id.name())==0) {
218           ret = (Contained) akt.obj;
219      break;
220         } else {
221           akt = akt.next;
222         }
223       }
224       return ret;
225   }
226
227   public Contained slookup(String JavaDoc name, String JavaDoc version) throws RemoteException JavaDoc, TIRExceptLock {
228     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
229       fromNormRep();
230     }
231       Contained ret = null;
232       LiItem akt = firstChild;
233       for(int i=0;i<numOfItems;i++) {
234         if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(name)==0) {
235           ret = (Contained) akt.obj;
236      break;
237         } else {
238           akt = akt.next;
239         }
240       }
241       return ret;
242   }
243
244   public Contained[] slookup_name(Identification id) throws RemoteException JavaDoc, TIRExceptLock {
245     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
246       fromNormRep();
247     }
248       Contained[] ret = null;
249       LiItem akt = firstChild;
250       for(int i=0;i<numOfItems;i++) {
251         if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(id.name())==0) {
252       ret = new Contained [1];
253           ret[0] = (Contained) akt.obj;
254      break;
255         } else {
256           akt = akt.next;
257         }
258       }
259       return ret;
260   }
261
262   public Contained[] slookup_name(String JavaDoc name) throws RemoteException JavaDoc, TIRExceptLock {
263     if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
264       fromNormRep();
265     }
266       Contained[] ret = null;
267       LiItem akt = firstChild;
268       for(int i=0;i<numOfItems;i++) {
269         if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(name)==0) {
270       ret = new Contained [1];
271           ret[0] = (Contained) akt.obj;
272      break;
273         } else {
274           akt = akt.next;
275         }
276       }
277       return ret;
278   }
279
280   public DefinitionKind get_spec_def_kind(int kind) throws RemoteException JavaDoc {
281     return new DefinitionKindImpl(kind);
282   }
283   
284   static public TIRObject newWorkFromNormal(TIRObject norm, Repository r, Container in, long workId) throws RemoteException JavaDoc {
285     TIRObject ret=null;
286     int val = norm.get_def_kind().value();
287     switch (val) {
288       case DefinitionKind.dk_CDLRepository:
289         ret = new CDLRepositoryImpl((CDLRepositoryImpl) norm, r, workId);
290         break;
291       case DefinitionKind.dk_Module:
292         ret = new ModuleDefImpl((ModuleDefImpl) norm,in,r,workId);
293     break;
294       case DefinitionKind.dk_Provider:
295         ret = new ProviderDefImpl((ProviderDefImpl)norm,in,r,workId);
296     break;
297       case DefinitionKind.dk_Struct:
298         ret = new StructDefImpl((StructDefImpl)norm,in,r,workId);
299     break;
300       case DefinitionKind.dk_Exception:
301         ret = new ExceptionDefImpl((ExceptionDefImpl)norm,in,r,workId);
302     break;
303       case DefinitionKind.dk_Enum:
304         ret = new EnumDefImpl((EnumDefImpl)norm,in,r, workId);
305     break;
306       case DefinitionKind.dk_Union:
307         ret = new UnionDefImpl((UnionDefImpl)norm,in,r,workId);
308     break;
309       case DefinitionKind.dk_Constant:
310         ret = new ConstantDefImpl((ConstantDefImpl)norm,in,r, workId);
311     break;
312       case DefinitionKind.dk_Typedef:
313         ret = new TypedefDefImpl((TypedefDefImpl)norm,in,r,workId);
314     break;
315       case DefinitionKind.dk_Interface:
316         ret = new InterfaceDefImpl((InterfaceDefImpl)norm,in,r,workId);
317     break;
318       case DefinitionKind.dk_Frame:
319         ret = new FrameDefImpl((FrameDefImpl)norm,in,r, workId);
320     break;
321       case DefinitionKind.dk_AModule:
322         ret = new AModuleDefImpl((AModuleDefImpl)norm,in,r,workId);
323     break;
324       case DefinitionKind.dk_Architecture:
325         ret = new ArchitectureDefImpl((ArchitectureDefImpl)norm,in,r, workId);
326     break;
327       case DefinitionKind.dk_Attribute:
328         ret = new AttributeDefImpl((AttributeDefImpl)norm,in,r,workId);
329     break;
330       case DefinitionKind.dk_Operation:
331         ret = new OperationDefImpl((OperationDefImpl)norm,in,r,workId);
332     break;
333       case DefinitionKind.dk_Inst:
334         ret = new InstDefImpl((InstDefImpl)norm,in,r,workId);
335     break;
336       case DefinitionKind.dk_Property:
337         ret = new PropertyDefImpl((PropertyDefImpl)norm,in,r,workId);
338     break;
339       case DefinitionKind.dk_Provides:
340         ret = new ProvideDefImpl((ProvideDefImpl)norm,in,r,workId);
341     break;
342       case DefinitionKind.dk_Requires:
343         ret = new RequireDefImpl((RequireDefImpl)norm,in,r,workId);
344     break;
345       case DefinitionKind.dk_StructMember:
346         ret = new StructMemberImpl((StructMemberImpl)norm,in,r);
347     break;
348       case DefinitionKind.dk_UnionMember:
349         ret = new UnionMemberImpl((UnionMemberImpl)norm,in,r);
350     break;
351       case DefinitionKind.dk_Bind:
352         ret = new BindDefImpl((BindDefImpl)norm,in,r);
353     break;
354       case DefinitionKind.dk_EnumMember:
355         ret = new EnumMemberImpl((EnumMemberImpl)norm);
356     break;
357     }
358     return ret;
359   }
360
361   private void fromNormRep() throws RemoteException JavaDoc, TIRExceptLock {
362     if (normalRep.lock.isLocked())
363       throw new TIRExceptLock("Repository is locked");
364     int i;
365     LiItem akt;
366     // if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) {
367
akt = normalRep.firstChild;
368       for(i=0;i<normalRep.numOfItems;i++) {
369         addListItem(newWorkFromNormal(akt.obj,this,this, workId));
370     akt = akt.next;
371       }
372       hasCont = true;
373     // }
374
}
375
376   /* from interface TIRObject */
377   public DefinitionKind get_def_kind() throws RemoteException JavaDoc {
378     return (DefinitionKind) defKindImpl;
379   }
380
381   /* from interface TIRObject */
382   public StateKind get_state() throws RemoteException JavaDoc {
383     return (StateKind) stKindImpl;
384   }
385
386   public void canCommit() {;}
387   public void doCommit(Container in, Repository rep) {;}
388   public void doAbort(long workId) {;}
389   public ManageRepository getManage() throws RemoteException JavaDoc { return null; }
390   public WorkRepository[] getActiveWork() throws RemoteException JavaDoc { return null; }
391
392   synchronized public boolean commit() throws RemoteException JavaDoc, TIRExceptCommit {
393     if (commited || aborted)
394       return false;
395     lock.lock();
396     LiItem akt;
397     int i,j;
398
399     akt = firstChild;
400     for (i=0;i<numOfItems;i++) {
401       if (((TIRImplObject)akt.obj).isNew()) {
402         LiItem nak = normalRep.firstChild;
403         for (j=0;j<normalRep.numOfItems;j++) {
404           if (((SIdentification) ((Contained)nak.obj).get_identification()).is_short_name_equal(((Contained)akt.obj).get_identification())) {
405             if (akt.obj.get_def_kind().value()!=nak.obj.get_def_kind().value())
406               throw new TIRExceptCommit("Object with name \""+((SContained)nak.obj).get_absolute_name().name()+"\"exists.");
407             if (((SIdentification) ((Contained)nak.obj).get_identification()).is_short_equal(((Contained)akt.obj).get_identification()))
408               throw new TIRExceptCommit("Object with identification \""+((Contained)nak.obj).get_identification()+"\"in container \"::\" exists.");
409           }
410           nak = nak.next;
411         }
412       }
413       ((TIRImplObject)akt.obj).canCommit();
414       akt = akt.next;
415     }
416     mProfiles.canCommit();
417     
418     akt = firstChild;
419     boolean nn = false;
420     for(i=0;i<numOfItems;i++) {
421       if (((TIRImplObject)akt.obj).isNew())
422         nn = true;
423       ((TIRImplObject)akt.obj).doCommit(normalRep,normalRep);
424       if (nn) {
425         normalRep.addListItem(akt.obj);
426       }
427       akt = akt.next;
428       nn = false;
429     }
430     try {
431       normalRep.postLoad(normalRep);
432     } catch (TIRExceptStorage e) {
433       throw new TIRExceptCommit("Some unexcepted error. Repository is in unstable state posibly.\n"+
434                                  e.getMessage());
435     }
436     mProfiles.doCommit(normalRep, normalRep);
437     
438     if (lockForMe) {
439       normalRep.lockFor = -1L;
440       normalRep.lockCreate.unlock();
441       lockForMe = false;
442     }
443
444     LiIdItem aktId = firstId;
445     for(i=0;i<numOfIds;i++) {
446       ((SIdentification)aktId.obj).setNextVersion();
447       ((SIdentification)aktId.obj).unlock();
448       aktId = aktId.next;
449     }
450     normalRep.removeWork(workId);
451     commited = true;
452     try {
453       normalRep.commitSave();
454     } catch (TIRExceptSave e) {
455       lock.unlock();
456       throw new TIRExceptCommit("Unsuccessful saving of repository.\n"+e.getMessage());
457     }
458     lock.unlock();
459     return true;
460   }
461   
462   synchronized public boolean abort() throws RemoteException JavaDoc {
463     if (commited || aborted)
464       return false;
465     int i;
466     lock.lock();
467     LiItem akt = firstChild;
468     for(i=0;i<numOfItems;i++) {
469       // !!! repaired after add CDLRepository
470
// if (((TIRImplObject)akt.obj).isNew())
471
((TIRImplObject)akt.obj).doAbort(workId);
472       akt = akt.next;
473     }
474     mProfiles.doAbort(workId);
475
476     if (lockForMe) {
477       normalRep.lockFor = -1L;
478       normalRep.lockCreate.unlock();
479       lockForMe = false;
480     }
481     
482     LiIdItem aktId = firstId;
483     for(i=0;i<numOfIds;i++) {
484       ((SIdentification)aktId.obj).unlock();
485       aktId = aktId.next;
486     }
487     normalRep.removeWork(workId);
488     aborted = true;
489     lock.unlock();
490     return true;
491   }
492
493   /* from interface Repository */
494   public Identification create_identification(String JavaDoc lang, String JavaDoc name, String JavaDoc version) throws RemoteException JavaDoc, TIRExceptCreate {
495     if (name==null || version==null || lang ==null)
496       return null;
497     if (name.length()<3)
498       throw new TIRExceptCreate("Bad name for identification.");
499     if (name.charAt(0)!=':' && name.charAt(0)!=':')
500       throw new TIRExceptCreate("You must give absolute name.");
501     if (lang.compareTo("cdl")!=0) // !!! change this
502
throw new TIRExceptCreate("Bad language specification.");
503     return (Identification) new IdentificationImpl(new String JavaDoc(lang), new String JavaDoc(name), new String JavaDoc(version));
504   }
505
506   /* from interface Repository */
507   public Identification create_nextversion(Identification id) throws RemoteException JavaDoc, TIRExceptCreate {
508     //test same IP
509
String JavaDoc ver = id.version();
510     StringBuffer JavaDoc ip = new StringBuffer JavaDoc();
511     int i = 0;
512     while ((i<ver.length()) && (ver.charAt(i)!='!')) {
513       ip.append(ver.charAt(i));
514       i++;
515     }
516   
517     // update version number
518
if (normalRep.sofaNodeName.compareTo(ip.toString())!=0)
519       throw new TIRExceptCreate("You must create branch first.");
520     if (((SIdentification)id).hasNextVersion())
521       throw new TIRExceptCreate("Next version from this exists.");
522     if (((SIdentification)id).isLocked())
523       throw new TIRExceptCreate("Identification is locked for next version.");
524     ((SIdentification)id).lock(workId);
525     int last = ver.lastIndexOf('!');
526     if (last != -1) {
527       long a = 0;
528       int j = last;
529       last++;
530       while ((last < ver.length())&&(Character.isDigit(ver.charAt(last)))) {
531         a *= 10;
532         a += (int) (ver.charAt(last)-'0');
533     last++;
534       }
535       a++;
536       
537       String JavaDoc rver = new String JavaDoc(ver.substring(0,j+1) + Long.toString(a));
538       Identification newId = new IdentificationImpl(((SIdentification) id).language(), id.absolute_name().name(), rver);
539
540       LiIdItem item = new LiIdItem(id);
541       if (firstId == null) {
542         firstId = lastId = item;
543       } else {
544         LiIdItem akt = firstId;
545         while (akt.next != null) akt = akt.next;
546         akt.next = item;
547         item.prev = akt;
548         lastId = item;
549       }
550       numOfIds++;
551       
552       return newId;
553     } else {
554       ((SIdentification)id).unlock();
555       throw new TIRExceptCreate("Version parse error.");
556     }
557   }
558
559   public Identification create_initialversion(String JavaDoc lang, String JavaDoc name) throws RemoteException JavaDoc, TIRExceptCreate {
560     if (name==null || lang == null)
561       return null;
562     if (name.length()<3)
563       throw new TIRExceptCreate("Bad name for identification.");
564     if (name.charAt(0)!=':' && name.charAt(0)!=':')
565       throw new TIRExceptCreate("You must give absolute name.");
566     if (lang.compareTo("cdl")!=0) // !!! change this
567
throw new TIRExceptCreate("Bad language specification.");
568     return new IdentificationImpl(new String JavaDoc(lang), new String JavaDoc(name), normalRep.sofaNodeName+"!0");
569   }
570
571   public Identification create_branch(Identification from, String JavaDoc branchTag) throws RemoteException JavaDoc, TIRExceptCreate {
572     if (branchTag==null || branchTag.length()==0)
573       throw new TIRExceptCreate("You must give branchTag.");
574     String JavaDoc ver = from.version();
575     String JavaDoc rver = normalRep.sofaNodeName+"!"+ver+"!"+((SIdentification)from).nextNumBranch()+"!1";
576     ((SIdentification)from).incNextNumBranch();
577     return new IdentificationImpl(((SIdentification) from).language(), from.absolute_name().name(), rver, branchTag);
578   }
579
580   public PrimitiveDef get_primitive(int kind) throws RemoteException JavaDoc, TIRExceptCreate {
581     if (kind>=0 && kind<=17)
582       return primitives[kind];
583     else
584       return null;
585   }
586
587 /*
588   public ModuleDef create_module(Identification id) throws RemoteException, TIRExceptCreate, TIRExceptLock {
589     if (id!=null) {
590       if (id.absolute_name().size()!=1)
591         throw new TIRExceptCreate("Wrong identification for this object.");
592       if (!getCreateLock())
593         throw new TIRExceptLock("This part of repository is locked for creating.");
594       if (!hasCont) {
595         fromNormRep();
596       }
597       id = new IdentificationImpl (id.absolute_name().name(),"");
598       Contained[] a = lookup_name(id);
599       if (a.length != 0) {
600         if (a[0].get_def_kind().value() != DefinitionKind.dk_Module)
601       throw new TIRExceptCreate("Name \""+id.name()+"\" exists in repository.");
602     boolean found = false;
603     for (int i=0;i<a.length;i++) {
604       if (((SIdentification) a[i].get_identification()).is_short_equal(id)) {
605         found = true;
606         break;
607       }
608     }
609     if (found)
610       throw new TIRExceptCreate("Object with same identification exists in repository.");
611       }
612       // creating new object
613       ModuleDef ret = new ModuleDefImpl(id, this, this, StateKind.sk_work, workId);
614       addListItem(ret); // adding object to list
615       return ret; // return object
616     } else
617       return null;
618   }
619   
620   public ConstantDef create_constant(Identification id, CDLType type, ExprOperDef value) throws RemoteException, TIRExceptCreate, TIRExceptLock {
621     if (id==null || type==null || value==null)
622       return null;
623     else {
624       if (type.get_state().value()==StateKind.sk_work &&
625           value.get_state().value()==StateKind.sk_work) {
626         if (id.absolute_name().size()!=1)
627           throw new TIRExceptCreate("Wrong identification for this object.");
628         if (!getCreateLock())
629           throw new TIRExceptLock("This part of repository is locked for creating.");
630         if (!hasCont)
631           fromNormRep();
632         id = new IdentificationImpl(id);
633         Contained[] a = lookup_name(id.name());
634         if (a.length != 0) {
635           if (a[0].get_def_kind().value() != DefinitionKind.dk_Constant)
636         throw new TIRExceptCreate("Name \""+id.name()+"\" exists in repository.");
637       boolean found = false;
638       for (int i=0;i<a.length;i++) {
639         if (((SIdentification) a[i].get_identification()).is_short_equal(id)) {
640           found = true;
641           break;
642         }
643       }
644       if (found)
645         throw new TIRExceptCreate("Object with same identification exists in repository.");
646         }
647         // creating new object
648         ConstantDef ret = new ConstantDefImpl(id, this, this,type, value, workId);
649         addListItem(ret); // adding object to list
650         return ret; // return object
651       } else {
652         throw new TIRExceptCreate("Given objects aren't work.");
653       }
654     }
655   }
656   
657   public StructDef create_struct(Identification id) throws RemoteException, TIRExceptCreate, TIRExceptLock {
658     if (id!=null) {
659       if (id.absolute_name().size()!=1)
660         throw new TIRExceptCreate("Wrong identification for this object.");
661       if (!getCreateLock())
662         throw new TIRExceptLock("This part of repository is locked for creating.");
663       if (!hasCont)
664         fromNormRep();
665       id = new IdentificationImpl(id);
666       Contained[] a = lookup_name(id.name());
667       if (a.length != 0) {
668         if (a[0].get_def_kind().value() != DefinitionKind.dk_Struct)
669       throw new TIRExceptCreate("Name \""+id.name()+"\" exists in repository.");
670     boolean found = false;
671     for (int i=0;i<a.length;i++) {
672       if (((SIdentification) a[i].get_identification()).is_short_equal(id)) {
673         found = true;
674         break;
675       }
676     }
677     if (found)
678       throw new TIRExceptCreate("Object with same identification exists in repository.");
679       }
680       // creating new object
681       StructDef ret = new StructDefImpl(id, this, this,workId);
682       addListItem(ret); // adding object to list
683       return ret; // return object
684     } else
685       return null;
686   }
687     
688   public UnionDef create_union(Identification id, CDLType switch_type) throws RemoteException, TIRExceptCreate, TIRExceptLock {
689     if (id==null || switch_type==null)
690       return null;
691     else {
692       if (switch_type.get_state().value()==StateKind.sk_work ) {
693         if (id.absolute_name().size()!=1)
694           throw new TIRExceptCreate("Wrong identification for this object.");
695         if (!getCreateLock())
696           throw new TIRExceptLock("This part of repository is locked for creating.");
697         if (!hasCont)
698           fromNormRep();
699         id = new IdentificationImpl(id);
700         Contained[] a = lookup_name(id.name());
701         if (a.length != 0) {
702           if (a[0].get_def_kind().value() != DefinitionKind.dk_Union)
703         throw new TIRExceptCreate("Name \""+id.name()+"\" exists in repository.");
704       boolean found = false;
705       for (int i=0;i<a.length;i++) {
706         if (((SIdentification) a[i].get_identification()).is_short_equal(id)) {
707           found = true;
708           break;
709         }
710       }
711       if (found)
712         throw new TIRExceptCreate("Object with same identification exists in repository.");
713         }
714         // creating new object
715         UnionDef ret = new UnionDefImpl(id, this, this, switch_type,workId);
716         addListItem(ret); // adding object to list
717         return ret; // return object
718       } else {
719         throw new TIRExceptCreate("Given object isn't work.");
720       }
721     }
722   }
723     
724   public EnumDef create_enum(Identification id) throws RemoteException, TIRExceptCreate, TIRExceptLock {
725     if (id!=null) {
726       if (id.absolute_name().size()!=1)
727         throw new TIRExceptCreate("Wrong identification for this object.");
728       if (!getCreateLock())
729         throw new TIRExceptLock("This part of repository is locked for creating.");
730       if (!hasCont)
731         fromNormRep();
732       id = new IdentificationImpl(id);
733       Contained[] a = lookup_name(id.name());
734       if (a.length != 0) {
735         if (a[0].get_def_kind().value() != DefinitionKind.dk_Enum)
736       throw new TIRExceptCreate("Name \""+id.name()+"\" exists in repository.");
737     boolean found = false;
738     for (int i=0;i<a.length;i++) {
739       if (((SIdentification) a[i].get_identification()).is_short_equal(id)) {
740         found = true;
741         break;
742       }
743     }
744     if (found)
745       throw new TIRExceptCreate("Object with same identification exists in repository.");
746       }
747       // creating new object
748       EnumDef ret = new EnumDefImpl(id, this, this, workId);
749       addListItem(ret); // adding object to list
750       return ret; // return object
751     } else
752       return null;
753   }
754   
755   public TypedefDef create_typedef(Identification id, CDLType orig_type) throws RemoteException, TIRExceptCreate, TIRExceptLock {
756     if (id==null || orig_type==null)
757       return null;
758     else {
759       if (orig_type.get_state().value()==StateKind.sk_work ) {
760         if (id.absolute_name().size()!=1)
761           throw new TIRExceptCreate("Wrong identification for this object.");
762         if (!getCreateLock())
763           throw new TIRExceptLock("This part of repository is locked for creating.");
764         if (!hasCont)
765           fromNormRep();
766         id = new IdentificationImpl(id);
767         Contained[] a = lookup_name(id.name());
768         if (a.length != 0) {
769           if (a[0].get_def_kind().value() != DefinitionKind.dk_Typedef)
770         throw new TIRExceptCreate("Name \""+id.name()+"\" exists in repository.");
771       boolean foun