Changeset 2244 in josm
- Timestamp:
- 2009-10-04T12:39:37+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java
r2243 r2244 81 81 } 82 82 83 protected long getAttributeLong(Attributes attr, String name, long defaultValue) throws SAXException{ 84 String v = attr.getValue(name); 85 if (v == null) 86 return defaultValue; 87 Long l = 0l; 88 try { 89 l = Long.parseLong(v); 90 } catch(NumberFormatException e) { 91 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long. Got ''{1}''.", name, v)); 92 } 93 if (l < 0) { 94 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long (>=0). Got ''{1}''.", name, v)); 95 } 96 return l; 97 } 98 83 99 protected Double getMandatoryAttributeDouble(Attributes attr, String name) throws SAXException{ 84 100 String v = attr.getValue(name); … … 86 102 throwException(tr("Missing mandatory attribute ''{0}''.", name)); 87 103 } 88 double d = 0 ;104 double d = 0.0; 89 105 try { 90 106 d = Double.parseDouble(v); … … 92 108 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type double. Got ''{1}''.", name, v)); 93 109 } 94 if (d < 0) {95 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type double (>=0). Got ''{1}''.", name, v));96 }97 110 return d; 98 111 } … … 103 116 throwException(tr("Missing mandatory attribute ''{0}''.", name)); 104 117 } 118 return v; 119 } 120 121 protected String getAttributeString(Attributes attr, String name, String defaultValue) { 122 String v = attr.getValue(name); 123 if (v == null) 124 return defaultValue; 105 125 return v; 106 126 } … … 123 143 long changesetId = getMandatoryAttributeLong(atts,"changeset"); 124 144 boolean visible= getMandatoryAttributeBoolean(atts, "visible"); 125 long uid = get MandatoryAttributeLong(atts, "uid");126 String user = get MandatoryAttributeString(atts, "user");145 long uid = getAttributeLong(atts, "uid",-1); 146 String user = getAttributeString(atts, "user", tr("<anonymous>")); 127 147 String v = getMandatoryAttributeString(atts, "timestamp"); 128 148 Date timestamp = DateUtils.fromString(v);
Note:
See TracChangeset
for help on using the changeset viewer.