KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > component > asmgen > Utils


1 /*
2  * ################################################################
3  *
4  * ProActive: The Java(TM) library for Parallel, Distributed,
5  * Concurrent computing with Security and Mobility
6  *
7  * Copyright (C) 1997-2004 INRIA/University of Nice-Sophia Antipolis
8  * Contact: proactive-support@inria.fr
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23  * USA
24  *
25  * Initial developer(s): The ProActive Team
26  * http://www.inria.fr/oasis/ProActive/contacts.html
27  * Contributor(s):
28  *
29  * ################################################################
30  */

31 package org.objectweb.proactive.core.component.asmgen;
32
33
34 import org.apache.log4j.Logger;
35
36
37 /**
38  * Utility class for bytecode generation operations.
39  *
40  * @author Matthieu Morel
41  *
42  */

43 public class Utils {
44     protected static Logger logger = Logger.getLogger(Utils.class.getName());
45     public static final String JavaDoc GENERATED_DEFAULT_PREFIX = "Generated_";
46     public static final String JavaDoc REPRESENTATIVE_DEFAULT_SUFFIX = "_representative";
47     public static final String JavaDoc COMPOSITE_REPRESENTATIVE_SUFFIX = "_composite";
48     public static final String JavaDoc STUB_DEFAULT_PACKAGE = null;
49
50     public static String JavaDoc convertClassNameToRepresentativeClassName(String JavaDoc classname) {
51         if (classname.length() == 0) {
52             return classname;
53         }
54
55         int n = classname.lastIndexOf('.');
56         if (n == -1) {
57             // no package
58
return STUB_DEFAULT_PACKAGE + GENERATED_DEFAULT_PREFIX + classname;
59         } else {
60             return STUB_DEFAULT_PACKAGE + classname.substring(0, n + 1) + GENERATED_DEFAULT_PREFIX +
61                    classname.substring(n + 1);
62         }
63     }
64
65     public static String JavaDoc getMetaObjectClassName(String JavaDoc functionalInterfaceName, String JavaDoc javaInterfaceName) {
66         // just a way to have an identifier (possibly not unique ? ... but readable)
67
return (GENERATED_DEFAULT_PREFIX + javaInterfaceName.replace('.', '_') + "_" +
68                functionalInterfaceName.replace('.', '/').replace('-', '_'));
69     }
70
71     public static String JavaDoc getMetaObjectComponentRepresentativeClassName(String JavaDoc functionalInterfaceName,
72                                                                                 String JavaDoc javaInterfaceName) {
73         // just a way to have an identifier (possibly not unique ... but readable)
74
return (getMetaObjectClassName(functionalInterfaceName, javaInterfaceName) + REPRESENTATIVE_DEFAULT_SUFFIX);
75     }
76
77
78 }
Popular Tags