KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javacore > parser > InfoUtil


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * InfoUtil.java
21  *
22  * Created on November 13, 2003, 2:08 PM
23  */

24
25 package org.netbeans.modules.javacore.parser;
26
27 import java.util.ArrayList JavaDoc;
28 import java.util.List JavaDoc;
29 import org.netbeans.jmi.javamodel.CallableFeature;
30 import org.netbeans.jmi.javamodel.Feature;
31 import org.netbeans.modules.javacore.jmiimpl.javamodel.ParameterImpl;
32
33 /**
34  *
35  * @author Tomas Hurka
36  */

37 class InfoUtil {
38
39     /** Creates a new instance of InfoUtil */
40     private InfoUtil() {
41     }
42
43     static TypeRef[] getTypeNames(CallableFeature call) {
44         Object JavaDoc[] pars=call.getParameters().toArray();
45         List JavaDoc types=new ArrayList JavaDoc(pars.length);
46
47         for (int i=0;i<pars.length;i++) {
48             ParameterImpl par=(ParameterImpl)pars[i];
49             
50             types.add(par.getTypeRef());
51         }
52         return (TypeRef[])types.toArray(new TypeRef[pars.length]);
53     }
54     
55     static TypeRef[] getTypeNames(ParameterInfo[] parameters) {
56         TypeRef[] typeNames = new TypeRef[parameters.length];
57         
58         for (int i = 0; i < parameters.length; i++) {
59             typeNames[i] = parameters[i].type;
60         }
61         return typeNames;
62     }
63
64     static String JavaDoc[] getElementNames(ElementInfo[] features) {
65         String JavaDoc memberNames[] = new String JavaDoc[features.length];
66
67         for (int i = 0; i < features.length; i++) {
68             memberNames[i] = features[i].name;
69         }
70         return memberNames;
71     }
72     
73     static String JavaDoc[] getElementNames(List JavaDoc featuresList) {
74         Object JavaDoc[] features=featuresList.toArray();
75         List JavaDoc names=new ArrayList JavaDoc();
76
77         for(int i=0;i<features.length;i++) {
78             Feature f=(Feature)features[i];
79             
80             names.add(f.getName());
81         }
82         return (String JavaDoc[])names.toArray(new String JavaDoc[names.size()]);
83     }
84 }
85
Popular Tags