Revision 9360

View differences:

branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrDefault.java
45 45
import java.util.Hashtable;
46 46
import java.util.Iterator;
47 47
import java.util.List;
48
import java.util.Map;
48 49
import java.util.Set;
49 50

  
50 51
import javax.swing.ImageIcon;
......
124 125
		properties.put(key, val);
125 126
	}
126 127

  
128
	public Map getExtendedProperties() {
129
		return properties;
130
	}
127 131
	/**
128 132
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setActive(boolean)
129 133
	 */
......
292 296
		// persist Properties hashTable
293 297

  
294 298
		Set keyset = properties.keySet();
295
		xml.putProperty("numProperties", keyset.size());
299
		
296 300

  
301
		int numProperties = 0;
297 302
		Iterator keyitr = keyset.iterator();
298 303
	    while (keyitr.hasNext()) {
299 304
	      String propName = (String)keyitr.next();
......
314 319
	          }
315 320
	          xmlPropObj.putProperty("layerPropertyName", propName);
316 321
	          xml.addChild(xmlPropObj);
322
	          numProperties++;
323
	      } else if (obj instanceof String) {
324
	          XMLEntity xmlPropObj = new XMLEntity();
325
        	  xmlPropObj.putProperty("className", String.class.getName());
326
        	  xmlPropObj.putProperty("value",(String)obj);
327
	          xmlPropObj.putProperty("layerPropertyName", propName);
328
	          xml.addChild(xmlPropObj);
329
	          numProperties++;
317 330
	      }
318 331
	    }
332
	    xml.putProperty("numProperties", numProperties);
319 333

  
320 334
		return xml;
321 335
	}
......
368 382

  
369 383
		if (xml.contains("numProperties")) {
370 384
			int numProps = xml.getIntProperty("numProperties");
371

  
385
			Object obj= null;
386
			IPersistance objPersist;
372 387
            for (int iProp=0; iProp<numProps; iProp++) {
373
        	    XMLEntity xmlProp = xml.getChild(iProp);
388
        	    XMLEntity xmlProp = xml.getChild(0);
374 389
        	    try {
375 390
        	    	String className = xmlProp.getStringProperty("className");
376
        	        Class classProp = Class.forName(className);
377
	                Object obj = classProp.newInstance();
378
	                IPersistance objPersist = (IPersistance)obj;
379
	                objPersist.setXMLEntity(xmlProp);
391
        	    	if (className.equals(String.class.getName())) {
392
        	    		obj = xmlProp.getStringProperty("value");
393
        	    	} else {
394
	        	        Class classProp = Class.forName(className);
395
		                obj = classProp.newInstance();
396
	    	            objPersist = (IPersistance)obj;
397
	        	        objPersist.setXMLEntity(xmlProp);
398
	                }
380 399
	                String propName = xmlProp.getStringProperty("layerPropertyName");
381 400
	                properties.put(propName, obj);
382 401
        		} catch (Exception e) {
383 402
        			continue;
384 403
        		}
385
       		// remove Properties children to avoid breaking layers' XML reading logic
386
        	for (iProp=0; iProp<numProps; iProp++)
387
                xml.removeChild(numProps-1-iProp);
404
        		// remove Properties children to avoid breaking layers' XML reading logic
405
        		xml.removeChild(0);
388 406
            }
389 407
		}
390 408
	}

Also available in: Unified diff