KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > samples > solitaire > naming > SolitaireNamingAC


1 /*
2   JAC-Core version 0.5.1
3
4   Renaud Pawlak, pawlak@cnam.fr, CEDRIC Laboratory, Paris, France.
5   Lionel Seinturier, Lionel.Seinturier@lip6.fr, LIP6, Paris, France.
6
7   JAC-Core is free software. You can redistribute it and/or modify it
8   under the terms of the GNU Library General Public License as
9   published by the Free Software Foundation.
10   
11   JAC-Core is distributed in the hope that it will be useful, but
12   WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15   This work uses the Javassist system - Copyright (c) 1999-2000
16   Shigeru Chiba, University of Tsukuba, Japan. All Rights Reserved. */

17
18
19 package org.objectweb.jac.samples.solitaire.naming;
20 import org.objectweb.jac.aspects.naming.*;
21 import org.objectweb.jac.lib.java.util.*;
22
23 import org.objectweb.jac.core.*;
24
25 /**
26  *
27  * @version 0.5.1
28  * @author <a HREF="http://cedric.cnam.fr/~pawlak/index-english.html">Renaud Pawlak</a>
29  * @author <a HREF="http://www-src.lip6.fr/homepages/Lionel.Seinturier/index-eng.html">Lionel Seinturier</a>
30  */

31
32 /**
33  * Handles the naming aspect within the JAC system.
34  *
35  * <p>This aspect component automatically registers all the created
36  * JAC object into the sole instance of <code>NameRepository</code>.
37  *
38  * @see NameRepository */

39
40 public class SolitaireNamingAC extends NamingAC {
41    int count = 0;
42    /**
43     * Generate default JAC object names.
44     *
45     * <p>The programmer should overload this method to generically
46     * generate a name for the given JAC object. By default, the
47     * generated name is the name of the class concatenated with the
48     * index of the JAC object in the array of all the current
49     * instances of its class.
50     *
51     * <p>This method is used by this aspect component to name the JAC
52     * objects.
53     *
54     * @param object the object to give a name for
55     * @return the proposed name
56     *
57     * @see whenNewInstance(Wrappee) */

58
59    public String JavaDoc generateName ( Object JavaDoc object ) {
60       if (object instanceof Vector) {
61          if (method().equals("createChildren")) {
62             return super.generateName(object);
63          } else {
64             System.out.println("dans GenerateName " + count + " : " + method());
65             return "mainVector" + count++;
66          }
67       } else {
68          return super.generateName(object);
69       }
70    }
71 }
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Popular Tags