KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > kilim > description > KILIM


1 /**
2  * Copyright (C) 2002 Kelua SA
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package org.objectweb.kilim.description;
20
21 import java.util.Iterator JavaDoc;
22 import java.util.LinkedList JavaDoc;
23
24 /**
25  * @author horn
26  * Abstract class introduced for grouping common kiilim constants.
27  * @see Port
28  */

29 public abstract class KILIM {
30
31     /** integer value identifying a port */
32    public static final int PORT = 1;
33     /** integer value identifying a property */
34    public static final int PROPERTY = 2;
35
36     /** integer value identifying a getter */
37    public static final int GETTER = 3;
38     /** integer value identifying a setter */
39    public static final int SETTER = 4;
40     /** integer value identifying a method */
41    public static final int METHOD = 5;
42     /** integer value identifying a constructor */
43    public static final int CONSTRUCTOR = 6;
44
45     /** integer value identifying a reference */
46    public static final int REFERENCE = 7;
47     /** integer value identifying a class provider */
48    public static final int CLASS = 8;
49     /** integer value identifying a array provider */
50    public static final int ARRAY = 9;
51  
52     /** integer value identifying an event source */
53    public static final int EVENT_SOURCE = 10;
54
55     /** integer value identifying a null element */
56    public static final int NULL_ELEMENT = 11;
57     /** integer value identifying a provider */
58    public static final int PROVIDER = 12;
59     /** integer value identifying a transformer */
60    public static final int TRANSFORMER = 13;
61
62     /** return value for empty list */
63     public static final LinkedList JavaDoc EMPTY_LIST = new LinkedList JavaDoc();
64     /** return value for empty iterator */
65     public static final Iterator JavaDoc EMPTY_ITERATOR = EMPTY_LIST.listIterator();
66     
67     /** private status */
68     public static final int PRIVATE = 1;
69     /** protected status */
70     public static final int PROTECTED = 2;
71     /** public status */
72     public static final int PUBLIC = 3;
73     /** undefined status */
74     public static final int UNDEFINED_STATUS = 0;
75     
76     /** a primitive type */
77     public static final int BOOLEAN = 1;
78     /** a primitive type */
79     public static final int CHAR = 2;
80     /** a primitive type */
81     public static final int BYTE = 3;
82     /** a primitive type */
83     public static final int SHORT = 4;
84     /** a primitive type */
85     public static final int INT = 5;
86     /** a primitive type */
87     public static final int LONG = 6;
88     /** a primitive type */
89     public static final int FLOAT = 7;
90     /** a primitive type */
91     public static final int DOUBLE = 8;
92     /** a primitive type */
93     public static final int STRING = 9;
94     /** a primitive type */
95     public static final int OBJECT = 10;
96     /** undefined status */
97     public static final int UNDEFINED_TYPE = 0;
98
99     /** name of class wrappers for primitive types */
100     public static final String JavaDoc[] CLASS_NAME = { "", "java.lang.Boolean", "java.lang.Character", "java.lang.Byte", "java.lang.Short",
101                                                                             "java.lang.Integer", "java.lang.Long", "java.lang.Float", "java.lang.Double", "java.lang.String", "java.lang.Object" };
102         
103     private static int uniqueIndex = 0;
104         
105     /**
106      * generates a unique index. This method is used to generate unique names in Kilim (for unnamed inlined elements for examples):
107      * unique indexes are added as suffixes to predefined names.
108      * @return int
109      */

110     public static int getUniqueIndex() {
111         return uniqueIndex++;
112     }
113     
114    /**
115     * returns the Class class corresponding to a type. If it is a primitive type name, convert it to corresponding wrapper class.
116     * @param name : the name of the class.
117     * @return Class
118     * @throws ClassNotFoundException :
119     */

120    public static Class JavaDoc getClassFromName(String JavaDoc name) throws ClassNotFoundException JavaDoc {
121       if (name.equals("boolean")) {
122          return boolean.class;
123       } else if (name.equals("byte")) {
124          return byte.class;
125       } else if (name.equals("short")) {
126          return short.class;
127       } else if (name.equals("int")) {
128          return int.class;
129       } else if (name.equals("long")) {
130          return long.class;
131       } else if (name.equals("float")) {
132          return float.class;
133       } else if (name.equals("double")) {
134          return double.class;
135       } else if (name.equals("char")) {
136          return char.class;
137       } else {
138          return Class.forName(name);
139       }
140    }
141 }
Popular Tags