Changeset 7889 in josm for trunk/src/org
- Timestamp:
- 2014-12-25T21:52:53+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetReader.java
r7847 r7889 10 10 import java.io.InputStreamReader; 11 11 import java.io.Reader; 12 import java. nio.charset.StandardCharsets;12 import java.util.ArrayDeque; 13 13 import java.util.ArrayList; 14 14 import java.util.Collection; 15 import java.util.Deque; 15 16 import java.util.HashMap; 16 17 import java.util.Iterator; … … 19 20 import java.util.Map; 20 21 import java.util.Set; 21 import java.util.Stack;22 22 23 23 import javax.swing.JOptionPane; … … 72 72 } 73 73 74 p ublicstaticList<TaggingPreset> readAll(Reader in, boolean validate) throws SAXException{74 private static XmlObjectParser buildParser() { 75 75 XmlObjectParser parser = new XmlObjectParser(); 76 76 parser.mapOnStart("item", TaggingPreset.class); … … 94 94 parser.mapBoth("chunk", Chunk.class); 95 95 parser.map("reference", Reference.class); 96 97 LinkedList<TaggingPreset> all = new LinkedList<>(); 96 return parser; 97 } 98 99 /** 100 * Reads all tagging presets from the input reader. 101 * @param in The input reader 102 * @param validate if {@code true}, XML validation will be performed 103 * @return collection of tagging presets 104 * @throws SAXException if any XML error occurs 105 */ 106 public static Collection<TaggingPreset> readAll(Reader in, boolean validate) throws SAXException { 107 XmlObjectParser parser = buildParser(); 108 109 Deque<TaggingPreset> all = new LinkedList<>(); 98 110 TaggingPresetMenu lastmenu = null; 99 111 TaggingPresetItems.Roles lastrole = null; … … 101 113 List<TaggingPresetItems.PresetListEntry> listEntries = new LinkedList<>(); 102 114 final Map<String, List<Object>> byId = new HashMap<>(); 103 final Stack<String> lastIds = newStack<>();115 final Deque<String> lastIds = new ArrayDeque<>(); 104 116 /** lastIdIterators contains non empty iterators of items to be handled before obtaining the next item from the XML parser */ 105 final Stack<Iterator<Object>> lastIdIterators = newStack<>();117 final Deque<Iterator<Object>> lastIdIterators = new ArrayDeque<>(); 106 118 107 119 if (validate) { … … 200 212 } else if (o instanceof TaggingPresetItems.CheckGroup) { 201 213 all.getLast().data.add((TaggingPresetItem) o); 214 // Make sure list of checks is empty to avoid adding checks several times 215 // when used in chunks (fix #10801) 216 ((TaggingPresetItems.CheckGroup) o).checks.clear(); 202 217 ((TaggingPresetItems.CheckGroup) o).checks.addAll(checks); 203 218 checks.clear(); … … 229 244 } 230 245 246 /** 247 * Reads all tagging presets from the given source. 248 * @param source a given filename, URL or internal resource 249 * @param validate if {@code true}, XML validation will be performed 250 * @return collection of tagging presets 251 * @throws SAXException if any XML error occurs 252 * @throws IOException if any I/O error occurs 253 */ 231 254 public static Collection<TaggingPreset> readAll(String source, boolean validate) throws SAXException, IOException { 232 255 Collection<TaggingPreset> tp; -
trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java
r7248 r7889 271 271 } 272 272 273 /** 274 * Starts parsing from the given input reader, without validation. 275 * @param in The input reader 276 * @return iterable collection of objects 277 * @throws SAXException if any XML or I/O error occurs 278 */ 273 279 public Iterable<Object> start(final Reader in) throws SAXException { 274 280 try { … … 279 285 } 280 286 287 /** 288 * Starts parsing from the given input reader, with XSD validation. 289 * @param in The input reader 290 * @param namespace default namespace 291 * @param schemaSource XSD schema 292 * @return iterable collection of objects 293 * @throws SAXException if any XML or I/O error occurs 294 */ 281 295 public Iterable<Object> startWithValidation(final Reader in, String namespace, String schemaSource) throws SAXException { 282 296 SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Note:
See TracChangeset
for help on using the changeset viewer.