KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* $Id: ContainedImpl.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.UnicastRemoteObject JavaDoc;
5
6 import SOFA.SOFAnode.Made.TIR.AbsoluteName;
7 import SOFA.SOFAnode.Made.TIR.Contained;
8 import SOFA.SOFAnode.Made.TIR.Container;
9 import SOFA.SOFAnode.Made.TIR.Identification;
10 import SOFA.SOFAnode.Made.TIR.Repository;
11 import SOFA.SOFAnode.Made.TIR.TIRExceptCreate;
12 import SOFA.SOFAnode.Made.TIR.TIRExceptLock;
13
14 public abstract class ContainedImpl extends UnicastRemoteObject JavaDoc implements Contained, TIRImplObject, SContained {
15   protected Identification id;
16   protected Container parent;
17   protected Repository rep;
18   
19   public ContainedImpl(Identification ident, Container in, Repository inrep) throws RemoteException JavaDoc {
20     id = ident;
21     parent = in;
22     rep = inrep;
23   }
24
25   public ContainedImpl() throws RemoteException JavaDoc {
26     id = null;
27     parent = null;
28     rep = null;
29   }
30
31   public Identification get_identification() throws RemoteException JavaDoc {
32     return id;
33   }
34
35   public Container get_defined_in() throws RemoteException JavaDoc {
36     return parent;
37   }
38   
39   public Container get_containing_repository() throws RemoteException JavaDoc {
40     return rep;
41   }
42
43   public AbsoluteName get_absolute_name() throws RemoteException JavaDoc {
44     AbsoluteNameImpl absName;
45 /* if (rep == parent) { // object is contained in repository
46       absName = new AbsoluteNameImpl("::"+id.name());
47     } else { */

48       absName = new AbsoluteNameImpl(((SContained)parent).get_absolute_name().name()+"::"+id.name());
49  /* } */
50     return (AbsoluteName) absName;
51   }
52
53   public void tag(String JavaDoc t) throws RemoteException JavaDoc, TIRExceptCreate, TIRExceptLock {
54     String JavaDoc ebt = id.branchTag();
55     if (t.compareTo(ebt)==0)
56       throw new TIRExceptCreate("This tag exists");
57     String JavaDoc[] et = id.tag();
58     int i,j;
59     for (i=0;i<et.length;i++) {
60       if (t.compareTo(et[i])==0)
61        throw new TIRExceptCreate("This tag exists");
62     }
63     Contained[] sibl = parent.lookup_name(id);
64     for (j=0;j<sibl.length;j++) {
65       Identification idl = sibl[j].get_identification();
66       
67       ebt = idl.branchTag();
68       if (t.compareTo(ebt)==0)
69         throw new TIRExceptCreate("This tag exists");
70       et = idl.tag();
71       for (i=0;i<et.length;i++) {
72         if (t.compareTo(et[i])==0)
73           throw new TIRExceptCreate("This tag exists");
74       }
75     }
76     ((SIdentification) id).tag(t);
77   }
78
79 }
80
Popular Tags