Revision 37325 branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/type/impl/DefaultGeometryType.java
DefaultGeometryType.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.fmap.geom.type.impl; |
29 | 29 |
|
30 |
import java.lang.reflect.Constructor; |
|
30 | 31 |
import java.util.ArrayList; |
31 | 32 |
import java.util.List; |
32 | 33 |
|
... | ... | |
89 | 90 |
*/ |
90 | 91 |
private int[] superSubTypes = null; |
91 | 92 |
|
93 |
private Constructor constructor; |
|
94 |
private final Object[] parameters = { this }; |
|
95 |
|
|
92 | 96 |
/** |
93 | 97 |
* This constructor is used by the {@link GeometryManager} when it |
94 | 98 |
* register a new GeometryType. It has not be used from other |
... | ... | |
123 | 127 |
this.subType = subType; |
124 | 128 |
this.superTypes = superTypes; |
125 | 129 |
this.superSubTypes = superSubTypes; |
130 |
|
|
131 |
Class[] parameterTypes = { GeometryType.class }; |
|
132 |
try { |
|
133 |
constructor = geometryClass.getConstructor(parameterTypes); |
|
134 |
} catch (NoSuchMethodException e) { |
|
135 |
throw new RuntimeException( |
|
136 |
"Error constructor of the geometry class " + geomClass |
|
137 |
+ " with one parameter of type GeometryType not found", e); |
|
138 |
} |
|
126 | 139 |
} |
127 | 140 |
|
128 | 141 |
/** |
... | ... | |
156 | 169 |
*/ |
157 | 170 |
public Geometry create() throws CreateGeometryException{ |
158 | 171 |
try { |
159 |
Class[] parameterTypes = {GeometryType.class}; |
|
160 |
Object[] parameters = {this}; |
|
161 |
return (Geometry)geometryClass.getConstructor(parameterTypes).newInstance(parameters); |
|
172 |
return (Geometry) constructor.newInstance(parameters); |
|
162 | 173 |
} catch (Exception e) { |
163 | 174 |
throw new CreateGeometryException(type, subType, e); |
164 | 175 |
} |
Also available in: Unified diff