Changeset 7704 in josm for trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java
- Timestamp:
- 2014-11-04T02:33:20+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java
r7700 r7704 8 8 import java.nio.charset.StandardCharsets; 9 9 import java.text.MessageFormat; 10 import java.util.Date; 10 11 import java.util.LinkedList; 11 12 import java.util.List; … … 16 17 import org.openstreetmap.josm.data.coor.LatLon; 17 18 import org.openstreetmap.josm.data.osm.Changeset; 19 import org.openstreetmap.josm.data.osm.ChangesetDiscussionComment; 18 20 import org.openstreetmap.josm.data.osm.User; 19 21 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 70 72 private Changeset current = null; 71 73 74 /** The current comment */ 75 private ChangesetDiscussionComment comment = null; 76 77 /** The current comment text */ 78 private StringBuilder text = null; 79 72 80 protected void parseChangesetAttributes(Changeset cs, Attributes atts) throws XmlParsingException { 73 81 // -- id … … 78 86 current.setId(parseNumericAttribute(value, 1)); 79 87 80 // -- user 81 String user = atts.getValue("user"); 82 String uid = atts.getValue("uid"); 83 current.setUser(createUser(uid, user)); 88 // -- user / uid 89 current.setUser(createUser(atts)); 84 90 85 91 // -- created_at … … 155 161 } 156 162 163 private void parseCommentAttributes(Attributes atts) throws XmlParsingException { 164 // -- date 165 String value = atts.getValue("date"); 166 Date date = null; 167 if (value != null) { 168 date = DateUtils.fromString(value); 169 } 170 171 comment = new ChangesetDiscussionComment(date, createUser(atts)); 172 } 173 157 174 private int parseNumericAttribute(String value, int minAllowed) throws XmlParsingException { 158 175 int att = 0; … … 193 210 current.put(key, value); 194 211 break; 212 case "discussion": 213 break; 214 case "comment": 215 parseCommentAttributes(atts); 216 break; 217 case "text": 218 text = new StringBuilder(); 219 break; 195 220 default: 196 221 throwException(tr("Undefined element ''{0}'' found in input stream. Aborting.", qName)); 222 } 223 } 224 225 @Override 226 public void characters(char[] ch, int start, int length) throws SAXException { 227 if (text != null) { 228 text.append(ch, start, length); 197 229 } 198 230 } … … 202 234 if ("changeset".equals(qName)) { 203 235 changesets.add(current); 204 } 205 } 206 207 protected User createUser(String uid, String name) throws XmlParsingException { 236 current = null; 237 } else if ("comment".equals(qName)) { 238 current.addDiscussionComment(comment); 239 comment = null; 240 } else if ("text".equals(qName)) { 241 comment.setText(text.toString()); 242 text = null; 243 } 244 } 245 246 protected User createUser(Attributes atts) throws XmlParsingException { 247 String name = atts.getValue("user"); 248 String uid = atts.getValue("uid"); 208 249 if (uid == null) { 209 250 if (name == null)
Note:
See TracChangeset
for help on using the changeset viewer.