Revision 35720
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/NumberComparator.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.utiles; |
|
42 |
|
|
43 |
import java.util.Comparator; |
|
44 |
|
|
45 |
|
|
46 |
/** |
|
47 |
* Comparador de numeros en orden habitual |
|
48 |
* |
|
49 |
* @author Fernando Gonz?lez Cort?s |
|
50 |
*/ |
|
51 |
public class NumberComparator implements Comparator { |
|
52 |
/** |
|
53 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
54 |
*/ |
|
55 |
public int compare(Object o1, Object o2) { |
|
56 |
double d1 = ((Number) o1).doubleValue(); |
|
57 |
double d2 = ((Number) o2).doubleValue(); |
|
58 |
|
|
59 |
return (int) (d1 - d2); |
|
60 |
} |
|
61 |
} |
|
0 | 62 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/SymbolSet.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.utiles; |
|
42 |
|
|
43 |
/** |
|
44 |
* Conjunto de s?mbolos |
|
45 |
* |
|
46 |
* @author Fernando Gonz?lez Cort?s |
|
47 |
*/ |
|
48 |
public interface SymbolSet { |
|
49 |
/** |
|
50 |
* Devuelve true si el caracter c est? en el conjunto |
|
51 |
* |
|
52 |
* @param c caracter |
|
53 |
* |
|
54 |
* @return true si est? en el conjunto y false en caso contrario |
|
55 |
*/ |
|
56 |
public boolean contains(char c); |
|
57 |
} |
|
0 | 58 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/NotExistInXMLEntity.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.utiles; |
|
42 |
|
|
43 |
|
|
44 |
public class NotExistInXMLEntity extends RuntimeException { |
|
45 |
|
|
46 |
public NotExistInXMLEntity(){ |
|
47 |
|
|
48 |
} |
|
49 |
|
|
50 |
} |
|
0 | 51 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/Queue.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 10-mar-2006 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
/* CVS MESSAGES: |
|
45 |
* |
|
46 |
* $Id$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.1 2006-03-14 19:23:07 azabala |
|
49 |
* *** empty log message *** |
|
50 |
* |
|
51 |
* |
|
52 |
*/ |
|
53 |
package com.iver.utiles; |
|
54 |
import java.util.Vector; |
|
55 |
|
|
56 |
/** |
|
57 |
* A simple FIFO queue class which causes the calling thread to wait if the |
|
58 |
* queue is empty and notifies threads that are waiting when it is not |
|
59 |
* empty. |
|
60 |
* |
|
61 |
* @author Anil V (akv@eng.sun.com) |
|
62 |
*/ |
|
63 |
public class Queue { |
|
64 |
private Vector vector = new Vector(); |
|
65 |
|
|
66 |
/** |
|
67 |
* Put the object into the queue. |
|
68 |
* |
|
69 |
* @param object |
|
70 |
* the object to be appended to the queue. |
|
71 |
*/ |
|
72 |
public synchronized void put(Object object) { |
|
73 |
vector.addElement(object); |
|
74 |
notify(); |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Pull the first object out of the queue. Wait if the queue is empty. |
|
79 |
*/ |
|
80 |
public synchronized Object pull() { |
|
81 |
while (isEmpty()) |
|
82 |
try { |
|
83 |
wait(); |
|
84 |
} catch (InterruptedException ex) { |
|
85 |
} |
|
86 |
return get(); |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Get the first object out of the queue. Return null if the queue is |
|
91 |
* empty. |
|
92 |
*/ |
|
93 |
public synchronized Object get() { |
|
94 |
Object object = peek(); |
|
95 |
if (object != null) |
|
96 |
vector.removeElementAt(0); |
|
97 |
return object; |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Peek to see if something is available. |
|
102 |
*/ |
|
103 |
public Object peek() { |
|
104 |
if (isEmpty()) |
|
105 |
return null; |
|
106 |
return vector.elementAt(0); |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* Is the queue empty? |
|
111 |
*/ |
|
112 |
public boolean isEmpty() { |
|
113 |
return vector.isEmpty(); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* How many elements are there in this queue? |
|
118 |
*/ |
|
119 |
public int size() { |
|
120 |
return vector.size(); |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
|
|
0 | 125 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/IPersistenceObject.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
|
|
43 |
package com.iver.utiles; |
|
44 |
|
|
45 |
/** |
|
46 |
* Add Object before call setXMLEntity. |
|
47 |
* |
|
48 |
* @author Vicente Caballero Navarro |
|
49 |
*/ |
|
50 |
public interface IPersistenceObject extends IPersistence { |
|
51 |
void setObject(Object obj); |
|
52 |
} |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/MathExtension.java | ||
---|---|---|
1 |
package com.iver.utiles; |
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
|
|
43 |
/** |
|
44 |
* Some more mathematical functions that 'java.lang.Math' doesn't have: |
|
45 |
* - Logarithm operations: log2, log2Integer, logX, logXInteger |
|
46 |
* |
|
47 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
|
48 |
*/ |
|
49 |
public final class MathExtension { |
|
50 |
|
|
51 |
/** |
|
52 |
* 2-base logarithm of a |
|
53 |
* @param a The value to do the calculations |
|
54 |
* @return Logarithm in 2 base of 'a' |
|
55 |
*/ |
|
56 |
public static double log2(double a) { |
|
57 |
return (Math.log(a) / Math.log(2)); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* 2-base logarithm of a, but the result doesn't have decimals (approximated to the integer number most near by below) |
|
62 |
* @param a The value to do the calculations |
|
63 |
* @return Logarithm in 2 base of 'a', as an integer |
|
64 |
*/ |
|
65 |
public static int log2Integer(double a) { |
|
66 |
return (int) Math.floor(log2(a)); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* X-base logarithm of a |
|
71 |
* @param a The value to do the calculations |
|
72 |
* @return Logarithm in X base of 'a' |
|
73 |
*/ |
|
74 |
public static double logX(double x_base, double a) { |
|
75 |
return (Math.log(a) / Math.log(x_base)); |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* X-base logarithm of a, but the result doesn't have decimals (approximated to the integer number most near by below) |
|
80 |
* @param a The value to do the calculations |
|
81 |
* @return Logarithm in X base of 'a', as an integer |
|
82 |
*/ |
|
83 |
public static int logXInteger(double x_base, double a) { |
|
84 |
return (int) Math.floor(logX(x_base, a)); |
|
85 |
} |
|
86 |
} |
|
0 | 87 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/extensionPoints/ExtensionPointsSingleton.java | ||
---|---|---|
1 |
package com.iver.utiles.extensionPoints; |
|
2 |
|
|
3 |
public class ExtensionPointsSingleton extends ExtensionPoints { |
|
4 |
|
|
5 |
private static final long serialVersionUID = -630976693542039111L; |
|
6 |
|
|
7 |
private static ExtensionPoints extensionPoints = new ExtensionPointsSingleton(); |
|
8 |
|
|
9 |
private ExtensionPointsSingleton() { |
|
10 |
super(); |
|
11 |
} |
|
12 |
|
|
13 |
public static ExtensionPoints getInstance() { |
|
14 |
return ExtensionPointsSingleton.extensionPoints; |
|
15 |
} |
|
16 |
} |
|
0 | 17 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/extensionPoints/IExtensionBuilder.java | ||
---|---|---|
1 |
package com.iver.utiles.extensionPoints; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
/** |
|
6 |
* Interface utilizado para indicar al registro de extensiones |
|
7 |
* que no se trata de una clase lo que hey registrado, si no |
|
8 |
* una instancia de un objeto a usar para crear la extension. |
|
9 |
* |
|
10 |
* |
|
11 |
* @author jjdelcerro |
|
12 |
* |
|
13 |
*/ |
|
14 |
public interface IExtensionBuilder { |
|
15 |
/** |
|
16 |
* Crea una instancia de la extension y la retorna. |
|
17 |
* <br> |
|
18 |
* @return |
|
19 |
*/ |
|
20 |
public Object create(); |
|
21 |
|
|
22 |
/** |
|
23 |
* Crea una instancia de la extension y la retorna. |
|
24 |
* <br> |
|
25 |
* En <i>args</i> recibira la lista de argumeentos a utilizar |
|
26 |
* para crear la extension. |
|
27 |
* <br> |
|
28 |
* @param args |
|
29 |
* @return |
|
30 |
*/ |
|
31 |
public Object create(Object [] args); |
|
32 |
|
|
33 |
public Object create(Map args); |
|
34 |
} |
|
0 | 35 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/extensionPoints/package.html | ||
---|---|---|
1 |
<html> |
|
2 |
<body> |
|
3 |
<p> |
|
4 |
Este paquete expone un mecanismo para registro de clases. |
|
5 |
</p> |
|
6 |
<p> |
|
7 |
Permite registrar clases o factorias de clases que luego pueden ser |
|
8 |
recuperadas para construir instancias. |
|
9 |
</p> |
|
10 |
<p> |
|
11 |
La finalidad de este registro es el manejo de puntos de extension a una |
|
12 |
aplicacion. Una aplicacion declara o registra con un nombre los puntos de |
|
13 |
extension que va a tener. Cada punto de extension puede tener registradas una |
|
14 |
o mas extensiones. Cuando se quiere a?adir una extension a la aplicacion, se |
|
15 |
registra la clase o factoria que gestiona esa extension para el punto de extension |
|
16 |
que se desee. |
|
17 |
</p> |
|
18 |
<p> |
|
19 |
Veamos esto con un ejemplo. |
|
20 |
</p> |
|
21 |
<p> |
|
22 |
Supongamos que queremos a?adir un punto de extension a la aplicacion gvSIG, que |
|
23 |
permita asignar un mecanismo de presentacion de la informacion asociada a la |
|
24 |
herramienta de "informacion" especializada segun el tipo de tema sobre el que se |
|
25 |
esta trabajando. |
|
26 |
</p> |
|
27 |
<p> |
|
28 |
Lo primero que tendriamos que hacer es darle un nombre al punto de extension. |
|
29 |
Lo llamaremos "InfoByPoint". Para esto, la aplicacion que valla a utilizar |
|
30 |
las extensiones que se registren en este punto deberia hacer lo siguiente: |
|
31 |
</p> |
|
32 |
<pre> |
|
33 |
ExtensionPoint infoByPoint = new ExtensionPoint("InfoByPoint","Registra las distintas extensiones que se pueden a?adir al 'InfoByPoint'"); |
|
34 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
35 |
|
|
36 |
extensionPoints.put(infoByPoint); |
|
37 |
</pre> |
|
38 |
<p> |
|
39 |
Con esto creamos un punto de extension de nombre "InfoByPoint", recogemos la |
|
40 |
instancia del registro de extensiones e insertamos el nuevo punto de extenstion |
|
41 |
en el.<br> |
|
42 |
Normalmente esta operacion, en el contexto de gvSIG, se realizaria en la |
|
43 |
inicializacion de la extension de andami en la que vallamos a a?adir |
|
44 |
la herramienta de informacion. |
|
45 |
</p> |
|
46 |
<p> |
|
47 |
Las extensiones a registrar en el "InfoByPoint" podrian consistir un un |
|
48 |
JPanel que gestione la presentacion a usar para el tema. |
|
49 |
</p> |
|
50 |
<p> |
|
51 |
Luego, desde la parte de la aplicacion que necesite a?adir nueva funcionalidad |
|
52 |
en este punto de extension, se deberia a?adir la extension. Por ejemplo |
|
53 |
en la extension de andami de WMS, se podria a?adir a "InfoByPoint" la posibilidad |
|
54 |
de usar una forma especial de presentacion. Podria hacerse: |
|
55 |
</p> |
|
56 |
<pre> |
|
57 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
58 |
extensionPoints.add("InfoByPoint","WMS",PanelQueGestionaLaExtension); |
|
59 |
</pre> |
|
60 |
<p> |
|
61 |
Donde "PanelQueGestionaLaExtension" sera el JPanel que gestiona la extension para |
|
62 |
"InfoByPoint" de WMS. |
|
63 |
</p> |
|
64 |
<p> |
|
65 |
Si quieran acceder a la extension de nombre "WMS" |
|
66 |
se haria: |
|
67 |
</p> |
|
68 |
<pre> |
|
69 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
70 |
ExtensionPoint infoByPoint = (ExtensionPoint)extensionPoints.get("InfoByPoint"); |
|
71 |
Object ext = infoByPoint.create("WMS"); |
|
72 |
</pre> |
|
73 |
<p> |
|
74 |
Y esto nos devolberia un objeto JPanel que gestiona la extension "WMS" |
|
75 |
para el "InfoByPoint". |
|
76 |
</p> |
|
77 |
<p> |
|
78 |
Si quisiesemos recorrer las distintas extensiones de ese punto podriamos |
|
79 |
hacerlo asi: |
|
80 |
</p> |
|
81 |
<pre> |
|
82 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
83 |
ExtensionPoint infoByPoint = (ExtensionPoint)extensionPoints.get("InfoByPoint"); |
|
84 |
Iterator infoByPoint =infoByPoint.keySet().iterator(); |
|
85 |
while( i.hasNext() ) { |
|
86 |
String nombre = (String)i.next(); |
|
87 |
... |
|
88 |
// Y para crear los JPanel asociados a la extension... |
|
89 |
Object panel = infoByPoint.create(nombre); |
|
90 |
... |
|
91 |
} |
|
92 |
</pre> |
|
93 |
<p> |
|
94 |
Ademas de registrar clases en un punto de extension, se pueden registrar |
|
95 |
instancias que implementen el interface de IExtensionBuilder. En este caso, |
|
96 |
cuando se invoque al metodo "create" del punto de extension, en lugar |
|
97 |
de crear una instancia, como no tiene la clase, este invocara al metodo |
|
98 |
create del objeto que ha sido registrado. |
|
99 |
</p> |
|
100 |
|
|
101 |
<p> |
|
102 |
Podemos encontrar un ejemplo de esto en la extension de JDBC para el |
|
103 |
catalogo. Como no existe una capa especifica para las capas JDBC, en lugar |
|
104 |
de registrar en el punto de extension una clase "capa JDBC", se registra |
|
105 |
una clase que implementa el interface IExtensionBuilder, que en su |
|
106 |
metodo create construye una capa vectorial y la inicializa de la forma |
|
107 |
apropiada para funcionar con la fuente de datos de JDBC. |
|
108 |
</p> |
|
109 |
<p> |
|
110 |
Hay que tener en cuenta que para un punto de extension dado, deberia ser |
|
111 |
trasparente que se registren en el clases o instancias que contruyen las clases. |
|
112 |
E incluso que es posible mezclar en un punto de extension los dos |
|
113 |
mecanismos, como es el caso del catalogo. |
|
114 |
</p> |
|
115 |
</body> |
|
116 |
</html> |
|
0 | 117 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/extensionPoints/ExtensionBuilder.java | ||
---|---|---|
1 |
package com.iver.utiles.extensionPoints; |
|
2 |
|
|
3 |
import java.lang.reflect.Constructor; |
|
4 |
import java.lang.reflect.InvocationTargetException; |
|
5 |
import java.util.Map; |
|
6 |
|
|
7 |
/** |
|
8 |
* Clase de utilidad usada para crear las extensiones. |
|
9 |
* |
|
10 |
* Esta clase presenta un par de metodos estaticos para |
|
11 |
* permitir crear un objeto a partir de una clase. |
|
12 |
* |
|
13 |
* @author jjdelcerro |
|
14 |
* |
|
15 |
*/ |
|
16 |
public abstract class ExtensionBuilder implements IExtensionBuilder { |
|
17 |
|
|
18 |
/** |
|
19 |
* Crea un objeto de la clase indicada. |
|
20 |
* |
|
21 |
* @param cls Clase de la que crear la instancia |
|
22 |
* @return |
|
23 |
* |
|
24 |
* @throws InstantiationException |
|
25 |
* @throws IllegalAccessException |
|
26 |
*/ |
|
27 |
public static Object create(Class cls) throws InstantiationException, IllegalAccessException { |
|
28 |
Object obj = null; |
|
29 |
|
|
30 |
if( cls == null ) { |
|
31 |
return null; |
|
32 |
} |
|
33 |
obj = cls.newInstance(); |
|
34 |
return obj; |
|
35 |
} |
|
36 |
|
|
37 |
/** |
|
38 |
* Crea un objeto de la clase indicada. |
|
39 |
* |
|
40 |
* Crea un objeto de la clase indicada pasandole al constructor |
|
41 |
* los argumentos indicados en <i>args</i>. |
|
42 |
* <br> |
|
43 |
* @param cls Clase de la que crear la instancia |
|
44 |
* @param args Argumentos que pasar al constructor. |
|
45 |
* @return |
|
46 |
* |
|
47 |
* @throws SecurityException |
|
48 |
* @throws NoSuchMethodException |
|
49 |
* @throws IllegalArgumentException |
|
50 |
* @throws InstantiationException |
|
51 |
* @throws IllegalAccessException |
|
52 |
* @throws InvocationTargetException |
|
53 |
*/ |
|
54 |
public static Object create(Class cls, Object [] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { |
|
55 |
Object obj = null; |
|
56 |
Constructor create = null; |
|
57 |
Class [] types = new Class[args.length]; |
|
58 |
|
|
59 |
if( cls == null ) { |
|
60 |
return null; |
|
61 |
} |
|
62 |
for( int n=0 ; n<args.length ; n++ ) { |
|
63 |
Object arg = args[n]; |
|
64 |
types[n] = arg.getClass(); |
|
65 |
} |
|
66 |
create = cls.getConstructor(types); |
|
67 |
obj = create.newInstance(args); |
|
68 |
return obj; |
|
69 |
} |
|
70 |
/** |
|
71 |
* Crea un objeto de la clase indicada. |
|
72 |
* |
|
73 |
* Crea un objeto de la clase indicada pasandole al constructor |
|
74 |
* un como argumento un Map.. |
|
75 |
* <br> |
|
76 |
* @param cls Clase de la que crear la instancia |
|
77 |
* @param args Map a pasar como argumento al constructor. |
|
78 |
* @return |
|
79 |
* |
|
80 |
* @throws SecurityException |
|
81 |
* @throws NoSuchMethodException |
|
82 |
* @throws IllegalArgumentException |
|
83 |
* @throws InstantiationException |
|
84 |
* @throws IllegalAccessException |
|
85 |
* @throws InvocationTargetException |
|
86 |
*/ |
|
87 |
public static Object create(Class cls, Map args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { |
|
88 |
Object obj = null; |
|
89 |
Constructor create = null; |
|
90 |
Class [] types = new Class[1]; |
|
91 |
Object [] argsx = new Object[1]; |
|
92 |
|
|
93 |
if( cls == null ) { |
|
94 |
return null; |
|
95 |
} |
|
96 |
types[0] = Map.class; |
|
97 |
argsx[0] = args; |
|
98 |
create = cls.getConstructor(types); |
|
99 |
obj = create.newInstance(argsx); |
|
100 |
return obj; |
|
101 |
} |
|
102 |
} |
|
0 | 103 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/extensionPoints/ExtensionPoint.java | ||
---|---|---|
1 |
package com.iver.utiles.extensionPoints; |
|
2 |
|
|
3 |
import java.lang.reflect.InvocationTargetException; |
|
4 |
import java.security.KeyException; |
|
5 |
import java.util.Hashtable; |
|
6 |
import java.util.Iterator; |
|
7 |
import java.util.LinkedHashMap; |
|
8 |
import java.util.Map; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* Esta clase permite registrar extensiones para un punto de extension. |
|
13 |
* <br> |
|
14 |
* <br> |
|
15 |
* La clase se comporta como un Map que mantiene el orden de insercion |
|
16 |
* de los elementos, para que puedan ser recorridos en ese orden. |
|
17 |
* <br> |
|
18 |
* Ademas de registrar las extensiones para un punto de extension, presenta |
|
19 |
* metodos para facilitar la creacion de la extension. |
|
20 |
* <br> |
|
21 |
* A la hora de registrar una extension, mediante el metodo <i>put</i>, |
|
22 |
* podremos suministrarle una clase o una instancia que implemente el |
|
23 |
* interface IExtensionBuilder. Si le suministramos una clase, cuando |
|
24 |
* queramos crear la extension mediante el metodo <i>create</i>, se creara |
|
25 |
* una instancia de la clase y se retornara. Si lo que se suministro fue |
|
26 |
* una instancia que implementa el interface IExtensionBuilder, se invocara |
|
27 |
* al metodo <i>create</i> de esta para crear la extension. |
|
28 |
* <br> |
|
29 |
* @author jjdelcerro |
|
30 |
* |
|
31 |
*/ |
|
32 |
public class ExtensionPoint extends LinkedHashMap { |
|
33 |
|
|
34 |
private static final long serialVersionUID = -5908427725588553371L; |
|
35 |
|
|
36 |
private String name; |
|
37 |
private String description; |
|
38 |
private Hashtable extensionDescriptions = new Hashtable(); |
|
39 |
private Hashtable aliases = new Hashtable(); |
|
40 |
|
|
41 |
/** |
|
42 |
* Construye un punto de extension. |
|
43 |
* <br> |
|
44 |
* @param extensionPointName Nombre del punto de extension. |
|
45 |
*/ |
|
46 |
public ExtensionPoint(String extensionPointName) { |
|
47 |
this.name = extensionPointName; |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* Construye un punto de extension. |
|
52 |
* <br> |
|
53 |
* @param extensionPointName Nombre del punto de extension |
|
54 |
* @param description Descripcion del punto de extension |
|
55 |
*/ |
|
56 |
public ExtensionPoint(String extensionPointName, String description) { |
|
57 |
this.name = extensionPointName; |
|
58 |
this.description = description; |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Retorna el nombre de punto de extension. |
|
63 |
* <br> |
|
64 |
* @return Nombre del punto de extension |
|
65 |
*/ |
|
66 |
public String getName() { |
|
67 |
return this.name; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Retorna la descripcion asociada al punto de extension. |
|
72 |
* <br> |
|
73 |
* @return descripcion del punto de extension |
|
74 |
*/ |
|
75 |
public String getDescription() { |
|
76 |
return this.description; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Asocia una descripcion al punto de extension. |
|
81 |
* <br> |
|
82 |
* |
|
83 |
* @param description |
|
84 |
*/ |
|
85 |
public void setDescripcion(String description) { |
|
86 |
this.description = description; |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Retorna la descripcion asociada a una extension. |
|
91 |
* <br> |
|
92 |
* @param key |
|
93 |
* <br> |
|
94 |
* @return descripcion del punto de extension |
|
95 |
*/ |
|
96 |
public String getExtensionDescription(String key) { |
|
97 |
return (String)this.extensionDescriptions.get(key); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Asocia una descripcion a una extension registrada. |
|
102 |
* <br> |
|
103 |
* |
|
104 |
* @param key Nombre de la extension |
|
105 |
* @param description |
|
106 |
*/ |
|
107 |
public void setExtensionDescription(String key,String description) { |
|
108 |
if (this.containsKey(key)) { |
|
109 |
this.extensionDescriptions.put(key,description); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* A?ade una extension con su descripcion asociada |
|
115 |
* |
|
116 |
* @param key clave de la extension |
|
117 |
* @param decription descripcion de la extension |
|
118 |
* @param value extension |
|
119 |
*/ |
|
120 |
|
|
121 |
public Object put(String key, String description,Object value) { |
|
122 |
this.extensionDescriptions.put(key,description); |
|
123 |
return super.put(key,value); |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* A?ade una extension antes de la indicada con beforeKey, |
|
128 |
* con su descripcion asociada |
|
129 |
* |
|
130 |
* @param key clave de la extension |
|
131 |
* @param decription descripcion de la extension |
|
132 |
* @param value extension |
|
133 |
*/ |
|
134 |
|
|
135 |
public Object insert(String beforeKey, String key, String description,Object value) { |
|
136 |
boolean mover = false; |
|
137 |
Map tmp = new LinkedHashMap(); |
|
138 |
|
|
139 |
for (Iterator i = this.entrySet().iterator(); i.hasNext(); ) { |
|
140 |
Map.Entry e = (Map.Entry)i.next(); |
|
141 |
if ( e.getKey().equals(beforeKey) ) { |
|
142 |
mover = true; |
|
143 |
} |
|
144 |
if( mover ) { |
|
145 |
tmp.put(e.getKey(), e.getValue()); |
|
146 |
} |
|
147 |
} |
|
148 |
for (Iterator i = tmp.keySet().iterator(); i.hasNext(); ) { |
|
149 |
String key1 = (String)i.next(); |
|
150 |
this.remove(key1); |
|
151 |
} |
|
152 |
if ( description!= null ) { |
|
153 |
this.extensionDescriptions.put(key,description); |
|
154 |
} |
|
155 |
Object returnValue = super.put(key,value); |
|
156 |
this.putAll(tmp); |
|
157 |
return returnValue; |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* Crea una extension. |
|
162 |
* <br> |
|
163 |
* Dado un nombre de extension asociada a este punto de extension, crea |
|
164 |
* el objeto registrado para manejar la extension. |
|
165 |
* <br> |
|
166 |
* Si el objeto registrado para esa extension implementa el interface |
|
167 |
* <i>IExtensionBuilder</i>, se invoca al metodo create para crear la instancia |
|
168 |
* de la extension. |
|
169 |
* <br> |
|
170 |
* Si no implementa este interface, debera ser una clase, y se creara una |
|
171 |
* instancia de esa clase. |
|
172 |
* <br> |
|
173 |
* @param name Nombre de la extension a crear. |
|
174 |
* @return La instancia creada de la extension. |
|
175 |
* |
|
176 |
* @throws InstantiationException |
|
177 |
* @throws IllegalAccessException |
|
178 |
*/ |
|
179 |
public Object create(String name) throws InstantiationException, IllegalAccessException { |
|
180 |
Object extension = this.get(name); |
|
181 |
if (extension == null) { |
|
182 |
extension = this.get(this.aliases.get(name)); |
|
183 |
} |
|
184 |
|
|
185 |
if( extension instanceof IExtensionBuilder ) { |
|
186 |
return ((IExtensionBuilder)extension).create(); |
|
187 |
} |
|
188 |
return ExtensionBuilder.create((Class) extension); |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Crea una extension. |
|
193 |
* <br> |
|
194 |
* Dado un nombre de extension asociada a este punto de extension, crea |
|
195 |
* el objeto registrado para manejar la extension. |
|
196 |
* <br> |
|
197 |
* A la hora de crear la instancia de la extension, le pasara los parametros |
|
198 |
* indicados en <i>args</i>. |
|
199 |
* <br> |
|
200 |
* Debido a que los argumentos se pasan como un array de objetos, no es posible |
|
201 |
* pasar al constructor de la extension parametros de tipos basicos como <i>int</i> |
|
202 |
* o <i>long</i>. Se deberan pasar como objetos y existir un constructor de la clase |
|
203 |
* que los pueda recibir de esta manera. |
|
204 |
* <br> |
|
205 |
* @param name Nombre de la extension a crear. |
|
206 |
* @param args Array de objetos a pasar como parametros en la construccion de la instancia de la extension. |
|
207 |
* @return La instancia creada de la extension. |
|
208 |
* |
|
209 |
* @throws SecurityException |
|
210 |
* @throws NoSuchMethodException |
|
211 |
* @throws IllegalArgumentException |
|
212 |
* @throws InstantiationException |
|
213 |
* @throws IllegalAccessException |
|
214 |
* @throws InvocationTargetException |
|
215 |
*/ |
|
216 |
public Object create(String name, Object [] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { |
|
217 |
Object extension = this.get(name); |
|
218 |
if (extension == null) { |
|
219 |
extension = this.get(this.aliases.get(name)); |
|
220 |
} |
|
221 |
|
|
222 |
if( extension instanceof IExtensionBuilder ) { |
|
223 |
return ((IExtensionBuilder)extension).create(args); |
|
224 |
} |
|
225 |
return ExtensionBuilder.create((Class) extension, args); |
|
226 |
} |
|
227 |
|
|
228 |
public Object create(String name, Map args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { |
|
229 |
Object extension = this.get(name); |
|
230 |
if (extension == null) { |
|
231 |
extension = this.get(this.aliases.get(name)); |
|
232 |
} |
|
233 |
|
|
234 |
if( extension instanceof IExtensionBuilder ) { |
|
235 |
return ((IExtensionBuilder)extension).create(args); |
|
236 |
} |
|
237 |
return ExtensionBuilder.create((Class) extension, args); |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* Crea un alias para una extension registrada. |
|
242 |
* <br> |
|
243 |
* @param item Nombre de la extension registrada. |
|
244 |
* @param alias alias a a?adir. |
|
245 |
* |
|
246 |
**/ |
|
247 |
public void addAlias(String item, String alias) throws KeyException{ |
|
248 |
if (!this.containsKey(item)) { |
|
249 |
throw new KeyException(item); |
|
250 |
} |
|
251 |
this.aliases.put(alias,item); |
|
252 |
} |
|
253 |
} |
|
0 | 254 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/extensionPoints/ExtensionPoints.java | ||
---|---|---|
1 |
package com.iver.utiles.extensionPoints; |
|
2 |
|
|
3 |
import java.util.TreeMap; |
|
4 |
|
|
5 |
/** |
|
6 |
* Clase para registro de puntos de extension. |
|
7 |
* <br> |
|
8 |
* <br> |
|
9 |
* |
|
10 |
* @author jjdelcerro |
|
11 |
*/ |
|
12 |
public class ExtensionPoints extends TreeMap { |
|
13 |
|
|
14 |
|
|
15 |
private static final long serialVersionUID = -798417910971607414L; |
|
16 |
|
|
17 |
/** |
|
18 |
* Evita que se a?adan elementos que no son puntos de extension. |
|
19 |
* <br> |
|
20 |
* <br> |
|
21 |
* Aunque la clase se comporta como un <i>Map</i>, no esta permitido |
|
22 |
* a?adir a esta objetos que no sean de la clase <i>ExtensionPoint</i>. |
|
23 |
* Si intentamos a?adir un elemento que no sea de esta clase, se disparara |
|
24 |
* una excepcion ClassCastException. |
|
25 |
* <br> |
|
26 |
* <br> |
|
27 |
* @see java.util.Map#put(java.lang.Object, java.lang.Object) |
|
28 |
*/ |
|
29 |
public Object put(Object key, Object value) throws ClassCastException { |
|
30 |
throw new ClassCastException(); |
|
31 |
} |
|
32 |
|
|
33 |
/** |
|
34 |
* A?ade un punto de extension al registro de puntos de extension. |
|
35 |
* <br> |
|
36 |
* <br> |
|
37 |
* Mediante este metodo puede a?adir un punto de extension al registro |
|
38 |
* de puntos de extension, llevandose detras todas las extensiones que |
|
39 |
* esten registradas en el. |
|
40 |
* <br> |
|
41 |
* <br> |
|
42 |
* En caso de que ya existiese un punto de extension con el nombre dado, |
|
43 |
* a?adira a este las extensiones del punto de extension suministrado. |
|
44 |
* <br> |
|
45 |
* <br> |
|
46 |
* @param value Punto de extension a registrar |
|
47 |
* @return |
|
48 |
* |
|
49 |
*/ |
|
50 |
public Object put(ExtensionPoint value) { |
|
51 |
return put(value.getName(),value); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* A?ade un punto de extension al registro de puntos de extension. |
|
56 |
* <br> |
|
57 |
* <br> |
|
58 |
* Mediante este metodo puede a?adir un punto de extension al registro |
|
59 |
* de puntos de extension, llevandose detras todas las extensiones que |
|
60 |
* esten registradas en el. |
|
61 |
* <br> |
|
62 |
* <br> |
|
63 |
* En caso de que ya existiese un punto de extension con el nombre dado, |
|
64 |
* a?adira a este las extensiones del punto de extension suministrado. |
|
65 |
* <br> |
|
66 |
* <br> |
|
67 |
* Cuando se a?ade un punto de extension, es imprescindible que <i>key</i> y |
|
68 |
* el nombre del punto de extension que se este a?adiendo coincidan. |
|
69 |
* <br> |
|
70 |
* <br> |
|
71 |
* @param key Nombre del punto de extension |
|
72 |
* @param value Punto de extension a registrar |
|
73 |
* @return |
|
74 |
* |
|
75 |
*/ |
|
76 |
public Object put(String key, ExtensionPoint value) { |
|
77 |
if ( !value.getName().equals(key) ) { |
|
78 |
throw new IllegalArgumentException (); |
|
79 |
} |
|
80 |
ExtensionPoint n = (ExtensionPoint)super.get(key); |
|
81 |
if( n == null ) { |
|
82 |
return super.put(key,value); |
|
83 |
} |
|
84 |
// Como estamos actualizando un punto de extension, a?adimos a este las |
|
85 |
// extensiones del que nos acaban de suministrar. |
|
86 |
n.putAll(value); |
|
87 |
return value; |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Registra una extension en un punto de extension. |
|
92 |
* <br> |
|
93 |
* <br> |
|
94 |
* Mediante este metodo puede registrar sobre un punto de extension |
|
95 |
* una extension. La extension esta identificada mediante un nombre |
|
96 |
* unico, y una clase que se usara para manejar la extension o una |
|
97 |
* clase que contruira el objeto que maneje la extension. |
|
98 |
* <br> |
|
99 |
* <br> |
|
100 |
* Si ya existe en el punto de extension indicado por <i>extensionPointName</i> |
|
101 |
* una extension con el nombre <i>name</i>, esta sera sustituida por la |
|
102 |
* nueva extension. |
|
103 |
* <br> |
|
104 |
* @param extensionPointName Nombre del punto de extension |
|
105 |
* @param name Nombre o identificador de la extension |
|
106 |
* @param data Clase que implementa la extension o que la construye. |
|
107 |
* |
|
108 |
* |
|
109 |
*/ |
|
110 |
public void add(String extensionPointName, String name, Object data) { |
|
111 |
ExtensionPoint extensionPoint = (ExtensionPoint)super.get(extensionPointName); |
|
112 |
if( extensionPoint == null ) { |
|
113 |
extensionPoint = new ExtensionPoint(extensionPointName); |
|
114 |
super.put(extensionPoint.getName(), extensionPoint); |
|
115 |
} |
|
116 |
|
|
117 |
extensionPoint.put(name, data); |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* Registra una extension en un punto de extension. |
|
122 |
* <br> |
|
123 |
* <br> |
|
124 |
* Mediante este metodo puede registrar sobre un punto de extension |
|
125 |
* una extension. La extension esta identificada mediante un nombre |
|
126 |
* unico, y una clase que se usara para manejar la extension o una |
|
127 |
* clase que contruira el objeto que maneje la extension. |
|
128 |
* <br> |
|
129 |
* <br> |
|
130 |
* Si ya existe en el punto de extension indicado por <i>extensionPointName</i> |
|
131 |
* una extension con el nombre <i>name</i>, esta sera sustituida por la |
|
132 |
* nueva extension. |
|
133 |
* <br> |
|
134 |
* @param extensionPointName Nombre del punto de extension |
|
135 |
* @param name Nombre o identificador de la extension |
|
136 |
* @param description descripcion de la extension. |
|
137 |
* @param data Clase que implementa la extension o que la construye. |
|
138 |
* |
|
139 |
* |
|
140 |
*/ |
|
141 |
public void add(String extensionPointName, String name, String description, Object data) { |
|
142 |
ExtensionPoint extensionPoint = (ExtensionPoint)super.get(extensionPointName); |
|
143 |
if( extensionPoint == null ) { |
|
144 |
extensionPoint = new ExtensionPoint(extensionPointName); |
|
145 |
super.put(extensionPoint.getName(), extensionPoint); |
|
146 |
} |
|
147 |
|
|
148 |
extensionPoint.put(name,description, data); |
|
149 |
} |
|
150 |
|
|
151 |
} |
|
0 | 152 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/DateTime.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package com.iver.utiles; |
|
43 |
import java.util.Calendar; |
|
44 |
import java.util.Date; |
|
45 |
import java.util.GregorianCalendar; |
|
46 |
import java.util.Locale; |
|
47 |
|
|
48 |
/** |
|
49 |
* This class contains static methods to manage Dates. It was principally |
|
50 |
* created because of some problems doing the "String do DateTime" |
|
51 |
* and the "DateTime to String" conversions. |
|
52 |
* |
|
53 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
54 |
*/ |
|
55 |
public class DateTime { |
|
56 |
|
|
57 |
/** |
|
58 |
* returns the current date |
|
59 |
* |
|
60 |
* |
|
61 |
* @return java.util.Date |
|
62 |
*/ |
|
63 |
public static Date getCurrentDate() { |
|
64 |
Calendar cal = new GregorianCalendar(); |
|
65 |
|
|
66 |
return cal.getTime(); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* It trnasforms one date in one String |
|
71 |
* |
|
72 |
* |
|
73 |
* @return A String |
|
74 |
* @param dtK Date |
|
75 |
* @param sFormat Date format. Example: "Y-m-d H:i:s.Z"; |
|
76 |
*/ |
|
77 |
public static String dateToString(Date dtK, String sFormat) { |
|
78 |
String sDate; |
|
79 |
int nYear; |
|
80 |
int nMonth; |
|
81 |
int nDay; |
|
82 |
int nHour; |
|
83 |
int nMinute; |
|
84 |
int nSecond; |
|
85 |
int nMS; |
|
86 |
Calendar clnK; |
|
87 |
String sf; |
|
88 |
int jc; |
|
89 |
clnK = Calendar.getInstance(Locale.US); |
|
90 |
clnK.setTime(dtK); |
|
91 |
nYear = clnK.get(Calendar.YEAR); |
|
92 |
nMonth = 1 + clnK.get(Calendar.MONTH); |
|
93 |
nDay = clnK.get(Calendar.DAY_OF_MONTH); |
|
94 |
nHour = clnK.get(Calendar.HOUR_OF_DAY); |
|
95 |
nMinute = clnK.get(Calendar.MINUTE); |
|
96 |
nSecond = clnK.get(Calendar.SECOND); |
|
97 |
nMS = clnK.get(Calendar.MILLISECOND); |
|
98 |
sDate = ""; |
|
99 |
for (jc = 0; jc < sFormat.length(); jc++) { |
|
100 |
switch (sFormat.charAt(jc)) { |
|
101 |
case 'Y': |
|
102 |
sDate += nYear; |
|
103 |
break; |
|
104 |
case 'm': |
|
105 |
sf = "" + nMonth; |
|
106 |
if (nMonth < 10) { |
|
107 |
sf = "0" + sf; |
|
108 |
} |
|
109 |
sDate += sf; |
|
110 |
break; |
|
111 |
case 'd': |
|
112 |
sf = "" + nDay; |
|
113 |
if (nDay < 10) { |
|
114 |
sf = "0" + sf; |
|
115 |
} |
|
116 |
sDate += sf; |
|
117 |
break; |
|
118 |
case 'H': |
|
119 |
sf = "" + nHour; |
|
120 |
if (nHour < 10) { |
|
121 |
sf = "0" + sf; |
|
122 |
} |
|
123 |
sDate += sf; |
|
124 |
break; |
|
125 |
case 'i': |
|
126 |
sf = "" + nMinute; |
|
127 |
if (nMinute < 10) { |
|
128 |
sf = "0" + sf; |
|
129 |
} |
|
130 |
sDate += sf; |
|
131 |
break; |
|
132 |
case 's': |
|
133 |
sf = "" + nSecond; |
|
134 |
if (nSecond < 10) { |
|
135 |
sf = "0" + sf; |
|
136 |
} |
|
137 |
sDate += sf; |
|
138 |
break; |
|
139 |
case 'Z': |
|
140 |
sf = "" + nMS; |
|
141 |
if (nMS < 10) { |
|
142 |
sf = "0" + sf; |
|
143 |
} |
|
144 |
sDate += sf; |
|
145 |
break; |
|
146 |
default: |
|
147 |
sDate += sFormat.substring(jc, jc + 1); |
|
148 |
} |
|
149 |
} |
|
150 |
return sDate; |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* It transfoms one String in one Date |
|
155 |
* |
|
156 |
* |
|
157 |
* @return Date |
|
158 |
* @param sDate String |
|
159 |
*/ |
|
160 |
public static Date stringToDate(String sDate) { |
|
161 |
Date dtRes; |
|
162 |
Calendar clnK; |
|
163 |
int nYear; |
|
164 |
int nMonth; |
|
165 |
int nDay; |
|
166 |
int nHour; |
|
167 |
int nMinute; |
|
168 |
int nSecond; |
|
169 |
int nMS; |
|
170 |
String sf; |
|
171 |
for (; sDate.length() < 23;) |
|
172 |
sDate += "0"; |
|
173 |
sf = sDate.substring(0, 4); |
|
174 |
nYear = Integer.parseInt(sf); |
|
175 |
sf = sDate.substring(5, 7); |
|
176 |
nMonth = Integer.parseInt(sf) - 1; |
|
177 |
sf = sDate.substring(8, 10); |
|
178 |
nDay = Integer.parseInt(sf); |
|
179 |
sf = sDate.substring(11, 13); |
|
180 |
nHour = Integer.parseInt(sf); |
|
181 |
sf = sDate.substring(14, 16); |
|
182 |
nMinute = Integer.parseInt(sf); |
|
183 |
sf = sDate.substring(17, 19); |
|
184 |
nSecond = Integer.parseInt(sf); |
|
185 |
sf = sDate.substring(20, 23); |
|
186 |
nMS = Integer.parseInt(sf); |
|
187 |
clnK = Calendar.getInstance(Locale.US); |
|
188 |
clnK.set(nYear, nMonth, nDay, nHour, nMinute, nSecond); |
|
189 |
clnK.set(Calendar.MILLISECOND, nMS); |
|
190 |
dtRes = new Date(); |
|
191 |
dtRes = clnK.getTime(); |
|
192 |
// sf=dateToString(dtRes,"Y-m-d H:i:s.Z"); |
|
193 |
return dtRes; |
|
194 |
} |
|
195 |
} |
|
0 | 196 |
tags/v1_11_0_Build_1306/libraries/libIverUtiles/src/com/iver/utiles/XMLEntity.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
Also available in: Unified diff