KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > ref > api > Referencable


1 /*====================================================================
2
3 ObjectWeb Util Ref Package.
4 Copyright (C) 2004 INRIA & USTL - LIFL - GOAL
5 Contact: architecture@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 --------------------------------------------------------------------
26 $Id: Referencable.java,v 1.1 2004/02/13 17:46:08 rouvoy Exp $
27 ====================================================================*/

28
29 package org.objectweb.util.ref.api;
30
31 import org.objectweb.util.misc.api.Identifiable;
32
33
34 /**
35  * Base interface for Java objects that could be referenced by
36  * other Referencable objects.
37  *
38  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
39  * @version 0.1
40  */

41 public interface Referencable
42          extends Identifiable
43 {
44     /**
45      * Obtains the reference counter,
46      * i.e. the number of Referencable objects that reference it.
47      *
48      * @return The number of references.
49      */

50     public int
51     getReferencedByCounter();
52
53     /**
54      * Obtains all its added Referencable objects.
55      *
56      * @return All added Referencable objects.
57      */

58     public Referencable[]
59     getReferencedBy();
60
61     /**
62      * Adds a reference.
63      *
64      * @param ref The Referencable object to add.
65      *
66      * @postcondition getReferencedByCounter() == old.getReferencedByCounter() + 1
67      */

68     public void
69     addReferencedBy(Referencable ref);
70
71     /**
72      * Removes a reference.
73      *
74      * @param ref The Referencable object to remove.
75      *
76      * @postcondition if ref was previously added then
77      * getReferencedByCounter() == old.getReferencedByCounter() - 1
78      */

79     public void
80     removeReferencedBy(Referencable ref);
81 }
82
Popular Tags