- Timestamp:
- 2011-12-27T18:25:55+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r4724 r4726 306 306 * All data sources of this DataSet. 307 307 */ 308 public Collection<DataSource> dataSources = new LinkedList<DataSource>();308 public final Collection<DataSource> dataSources = new LinkedList<DataSource>(); 309 309 310 310 /** -
trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java
r4520 r4726 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.io.IOException; 6 7 import java.io.Reader; 7 import java.io.IOException;8 8 import java.lang.reflect.Field; 9 9 import java.lang.reflect.Method; … … 15 15 import java.util.Stack; 16 16 17 import javax.xml.parsers.ParserConfigurationException; 17 18 import javax.xml.parsers.SAXParser; 18 19 import javax.xml.parsers.SAXParserFactory; … … 23 24 24 25 import org.openstreetmap.josm.io.MirroredInputStream; 25 26 26 import org.xml.sax.Attributes; 27 27 import org.xml.sax.ContentHandler; … … 89 89 90 90 public static final String lang = LanguageInfo.getLanguageCodeXML(); 91 public static class Uniform<T> implements Iterable<T>{92 private Iterator<Object> iterator;93 /**94 * @param klass This has to be specified since generics are erased from95 * class files so the JVM cannot deduce T itself.96 */97 public Uniform(Reader input, String tagname, Class<T> klass) {98 XmlObjectParser parser = new XmlObjectParser();99 parser.map(tagname, klass);100 parser.start(input);101 iterator = parser.iterator();102 }103 public Iterator<T> iterator() {104 return new Iterator<T>(){105 public boolean hasNext() {return iterator.hasNext();}106 @SuppressWarnings("unchecked") public T next() {return (T)iterator.next();}107 public void remove() {iterator.remove();}108 };109 }110 }111 91 112 92 private static class AddNamespaceFilter extends XMLFilterImpl { … … 204 184 { 205 185 String locfieldName = "locale_" + 206 fieldName.substring(lang.length());186 fieldName.substring(lang.length()); 207 187 try { 208 188 f = c.getClass().getField(locfieldName); … … 285 265 } 286 266 287 private Iterable<Object> start(final Reader in, final ContentHandler contentHandler) {267 private Iterable<Object> start(final Reader in, final ContentHandler contentHandler) throws SAXException, IOException { 288 268 try { 289 269 SAXParserFactory parserFactory = SAXParserFactory.newInstance(); … … 293 273 reader.setContentHandler(contentHandler); 294 274 reader.parse(new InputSource(in)); 295 } catch (Exception e) { 275 queueIterator = queue.iterator(); 276 return this; 277 } catch (ParserConfigurationException e) { 278 // This should never happen ;-) 296 279 throw new RuntimeException(e); 297 280 } 298 queueIterator = queue.iterator(); 299 return this; 300 } 301 302 public Iterable<Object> start(final Reader in) { 303 return start(in, parser); 281 } 282 283 public Iterable<Object> start(final Reader in) throws SAXException { 284 try { 285 return start(in, parser); 286 } catch (IOException e) { 287 throw new SAXException(e); 288 } 304 289 } 305 290
Note:
See TracChangeset
for help on using the changeset viewer.