Revision 611
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dynobject/impl/DefaultDynField.java | ||
---|---|---|
194 | 194 |
|
195 | 195 |
public DynField setSubtype(String subtype) { |
196 | 196 |
this.subtype = subtype; |
197 |
if( subtype!=null && this.dataType.getType() == DataTypes.DYNOBJECT ) { |
|
198 |
if( ToolsLocator.getDynObjectManager().get(subtype) == null ) { |
|
199 |
throw new IllegalArgumentException("DynClass '" + subtype + "' does not exist."); |
|
200 |
} |
|
201 |
}else if( subtype!=null && this.dataType.getType() == DataTypes.LIST && this.elementsType!=null && this.elementsType.getType() == DataTypes.DYNOBJECT ) { |
|
197 |
if (subtype != null && this.dataType.getType() == DataTypes.LIST |
|
198 |
&& this.elementsType != null |
|
199 |
&& this.elementsType.getType() == DataTypes.DYNOBJECT) { |
|
202 | 200 |
if( ToolsLocator.getDynObjectManager().get(subtype) == null ) { |
203 | 201 |
throw new IllegalArgumentException("DynClass '" + subtype + "' does not exist."); |
204 | 202 |
} |
205 | 203 |
this.elementsType.setSubtype(subtype); |
204 |
} else if (subtype != null |
|
205 |
&& this.dataType.getType() == DataTypes.DYNOBJECT) { |
|
206 |
if (ToolsLocator.getDynObjectManager().get(subtype) == null) { |
|
207 |
throw new IllegalArgumentException("DynClass '" + subtype |
|
208 |
+ "' does not exist."); |
|
209 |
} |
|
206 | 210 |
} |
207 | 211 |
return this; |
208 | 212 |
} |
... | ... | |
221 | 225 |
} |
222 | 226 |
|
223 | 227 |
public DynField setAvailableValues(DynObjectValueItem[] availableValues) { |
224 |
if( availableValues.length == 0 ) {
|
|
228 |
if (availableValues == null || availableValues.length == 0) {
|
|
225 | 229 |
this.availableValues = null; |
226 | 230 |
} else { |
227 | 231 |
this.availableValues = availableValues; |
... | ... | |
336 | 340 |
|
337 | 341 |
public DynField setElementsType(DynStruct type) |
338 | 342 |
throws DynFieldIsNotAContainerException { |
339 |
this.setElementsType(DataTypes.DYNOBJECT).getElementsType().setSubtype(type.getFullName()); |
|
343 |
// Getter allows null values |
|
344 |
if (type != null) { |
|
345 |
this.setElementsType(DataTypes.DYNOBJECT).getElementsType().setSubtype(type.getFullName()); |
|
346 |
} |
|
340 | 347 |
return this; |
341 | 348 |
} |
342 | 349 |
|
... | ... | |
568 | 575 |
|
569 | 576 |
public DynField setClassOfItems(Class theClass) |
570 | 577 |
throws DynFieldIsNotAContainerException { |
578 |
// Getter allows null values |
|
579 |
if (theClass == null) { |
|
580 |
return this; |
|
581 |
} |
|
571 | 582 |
if (! this.dataType.isContainer() ) { |
572 | 583 |
throw new DynFieldIsNotAContainerException(this.name); |
573 | 584 |
} |
Also available in: Unified diff