Revision 28465 branches/v2_0_0_prep/libraries/libIverUtiles/src/com/iver/utiles/PostProcessSupport.java
PostProcessSupport.java | ||
---|---|---|
2 | 2 |
* Created on 24-ago-2005 |
3 | 3 |
* |
4 | 4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
7 |
*
|
|
7 |
* |
|
8 | 8 |
* This program is free software; you can redistribute it and/or |
9 | 9 |
* modify it under the terms of the GNU General Public License |
10 | 10 |
* as published by the Free Software Foundation; either version 2 |
11 | 11 |
* of the License, or (at your option) any later version. |
12 |
*
|
|
12 |
* |
|
13 | 13 |
* This program is distributed in the hope that it will be useful, |
14 | 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | 16 |
* GNU General Public License for more details. |
17 |
*
|
|
17 |
* |
|
18 | 18 |
* You should have received a copy of the GNU General Public License |
19 | 19 |
* along with this program; if not, write to the Free Software |
20 | 20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 |
*
|
|
21 |
* |
|
22 | 22 |
* For more information, contact: |
23 | 23 |
* |
24 | 24 |
* Generalitat Valenciana |
... | ... | |
30 | 30 |
* +34 963862235 |
31 | 31 |
* gvsig@gva.es |
32 | 32 |
* www.gvsig.gva.es |
33 |
*
|
|
33 |
* |
|
34 | 34 |
* or |
35 |
*
|
|
35 |
* |
|
36 | 36 |
* IVER T.I. S.A |
37 | 37 |
* Salamanca 50 |
38 | 38 |
* 46005 Valencia |
39 | 39 |
* Spain |
40 |
*
|
|
40 |
* |
|
41 | 41 |
* +34 963163400 |
42 | 42 |
* dac@iver.es |
43 | 43 |
*/ |
... | ... | |
58 | 58 |
public class PostProcessSupport |
59 | 59 |
{ |
60 | 60 |
private static ArrayList callList = new ArrayList(); |
61 |
private static class Call
|
|
61 |
private static class Call |
|
62 | 62 |
{ |
63 | 63 |
private Object obj; |
64 | 64 |
private Method method; |
... | ... | |
77 | 77 |
// TODO Auto-generated catch block |
78 | 78 |
e.printStackTrace(); |
79 | 79 |
} catch (NoSuchMethodException e) { |
80 |
// Resulta que con getMethod no pilla bien el superinterface VectorialLegend,
|
|
80 |
// Resulta que con getMethod no pilla bien el superinterface VectorialLegend, |
|
81 | 81 |
// as? que lo hacemos manual |
82 | 82 |
Method[] list = obj.getClass().getMethods(); |
83 | 83 |
for (int i=0; i< list.length; i++) |
... | ... | |
87 | 87 |
{ |
88 | 88 |
boolean encontrado = true; |
89 | 89 |
Class[] params = list[i].getParameterTypes(); |
90 |
// En cada par?metro del m?todo, miramos si
|
|
90 |
// En cada par?metro del m?todo, miramos si |
|
91 | 91 |
// el par?metro correspondiente implementa la interfaz |
92 | 92 |
// adecuada. |
93 | 93 |
for (int j=0; j < params.length; j++) // for de los par?metros del m?todo. |
... | ... | |
95 | 95 |
// Miramos primero si es de la clase que buscamos, y si no lo es, pasamos |
96 | 96 |
// a revisar sus interfaces. |
97 | 97 |
boolean bParamOK = false; |
98 |
if (params[j].getName().compareTo(parameters[j].getClass().getName()) == 0) |
|
98 |
// if (params[j].getName().compareTo(parameters[j].getClass().getName()) == 0) |
|
99 |
if ( params[j].isInstance(parameters[j]) ) |
|
99 | 100 |
{ |
100 | 101 |
bParamOK = true; |
101 | 102 |
continue; |
102 | 103 |
} |
103 | 104 |
// Interfaces que implementa el par?metro j-?simo que le pasamos. |
104 | 105 |
Class[] theInterfaces = parameters[j].getClass().getInterfaces(); |
105 |
|
|
106 |
|
|
106 | 107 |
for (int k=0; k< theInterfaces.length; k++) |
107 | 108 |
{ |
108 | 109 |
// Si alguno de estos interfaces cuadra con lo que |
109 | 110 |
// espera el m?todo, podemos comprobar el siguiente par?metro. |
110 |
// Si al salir del for externo, encontrado sigue siendo true,
|
|
111 |
// Si al salir del for externo, encontrado sigue siendo true, |
|
111 | 112 |
// hemos encontrado el m?todo que busc?bamos. |
112 | 113 |
if (theInterfaces[k].getName().compareTo(params[j].getName()) == 0) |
113 | 114 |
{ |
... | ... | |
124 | 125 |
if (encontrado) |
125 | 126 |
{ |
126 | 127 |
method = list[i]; |
127 |
return;
|
|
128 |
return; |
|
128 | 129 |
} |
129 | 130 |
} |
130 | 131 |
} |
131 | 132 |
e.printStackTrace(); |
132 | 133 |
} |
133 | 134 |
} |
134 |
|
|
135 |
|
|
135 | 136 |
public Object executeMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException |
136 | 137 |
{ |
137 | 138 |
return method.invoke(obj,parameters); |
... | ... | |
139 | 140 |
} |
140 | 141 |
public static void addToPostProcess(Object obj, String strMethod, Object[] parameters, int priority) |
141 | 142 |
{ |
142 |
Call newCall = new Call(obj, strMethod, parameters, priority);
|
|
143 |
Call newCall = new Call(obj, strMethod, parameters, priority); |
|
143 | 144 |
callList.add(newCall); |
144 | 145 |
} |
145 | 146 |
public static void addToPostProcess(Object obj, String strMethod, Object parameter, int priority) |
... | ... | |
149 | 150 |
Call newCall = new Call(obj, strMethod, parameters, priority); |
150 | 151 |
callList.add(newCall); |
151 | 152 |
} |
152 |
|
|
153 |
|
|
153 | 154 |
private static void orderByPriority() |
154 | 155 |
{ |
155 | 156 |
// TODO |
... | ... | |
159 | 160 |
// TODO: Primero deber?amos ordenar por prioridad |
160 | 161 |
// por ahora no lo hago. |
161 | 162 |
orderByPriority(); |
162 |
|
|
163 |
|
|
163 | 164 |
for (int i=0; i < callList.size(); i++) |
164 | 165 |
{ |
165 | 166 |
Call call = (Call) callList.get(i); |
Also available in: Unified diff