/** * Closes this element. This method verifies that there is no unprocessed value (dates, * numbers, booleans or strings), but ignores inner elements as required by ISO 19162. * * This method add the keywords of ignored elements in the {@code ignoredElements} map as below: * <ul> * <li><b>Keys</b>: keyword of ignored elements. Note that a key may be null.</li> * <li><b>Values</b>: keywords of all elements containing an element identified by the above-cited key. * This list is used for helping the users to locate the ignored elements.</li> * </ul> * * @param ignoredElements the collection where to declare ignored elements. * @throws ParseException if the list still contains some unprocessed values. */ final void close(final Map<String, List<String>> ignoredElements) throws ParseException { if (list != null) { for (final Object value : list) { if (value instanceof Element) { CollectionsExt.addToMultiValuesMap(ignoredElements, ((Element) value).keyword, keyword); } else { throw new UnparsableObjectException(locale, Errors.Keys.UnexpectedValueInElement_2, new Object[] {keyword, value}, offset + keyword.length()); } } } }
/** * Closes this element. This method verifies that there is no unprocessed value (dates, * numbers, booleans or strings), but ignores inner elements as required by ISO 19162. * * This method add the keywords of ignored elements in the {@code ignoredElements} map as below: * <ul> * <li><b>Keys</b>: keyword of ignored elements. Note that a key may be null.</li> * <li><b>Values</b>: keywords of all elements containing an element identified by the above-cited key. * This list is used for helping the users to locate the ignored elements.</li> * </ul> * * @param ignoredElements the collection where to declare ignored elements. * @throws ParseException if the list still contains some unprocessed values. */ final void close(final Map<String, List<String>> ignoredElements) throws ParseException { if (list != null) { for (final Object value : list) { if (value instanceof Element) { CollectionsExt.addToMultiValuesMap(ignoredElements, ((Element) value).keyword, keyword); } else { throw new UnparsableObjectException(locale, Errors.Keys.UnexpectedValueInElement_2, new Object[] {keyword, value}, offset + keyword.length()); } } } }
if (variable.isCoordinateSystemAxis()) { for (final Dimension dimension : variable.dimensions) { CollectionsExt.addToMultiValuesMap(dimToAxes, dimension, variable);
if (variable.isCoordinateSystemAxis()) { for (final Dimension dimension : variable.dimensions) { CollectionsExt.addToMultiValuesMap(dimToAxes, dimension, variable);
CollectionsExt.addToMultiValuesMap(aliases, key, key); name = ((ScopedName) name).tail(); final String alias = name.toString(); final List<String> fullNames = CollectionsExt.addToMultiValuesMap(aliases, alias, key); if (fullNames.size() > 1) { CollectionsExt.addToMultiValuesMap(aliases, alias, alias);
CollectionsExt.addToMultiValuesMap(aliases, key, key); name = ((ScopedName) name).tail(); final String alias = name.toString(); final List<String> fullNames = CollectionsExt.addToMultiValuesMap(aliases, alias, key); if (fullNames.size() > 1) { CollectionsExt.addToMultiValuesMap(aliases, alias, alias);
if (variable.isCoverage()) { final List<String> dimensions = Arrays.asList(variable.getGridDimensionNames()); CollectionsExt.addToMultiValuesMap(contents, dimensions, variable);
if (variable.isCoverage(2)) { final List<String> dimensions = Arrays.asList(variable.getGridDimensionNames()); CollectionsExt.addToMultiValuesMap(contents, dimensions, variable);
/** * Tests {@link CollectionsExt#addToMultiValuesMap(Map, Object, Object)}, then * opportunistically tests {@link CollectionsExt#removeFromMultiValuesMap(Map, Object, Object)}, */ @Test public void testAddAndRemoveToMultiValuesMap() { final Map<String, List<Integer>> map = new LinkedHashMap<>(); final Integer A1 = 2; final Integer A2 = 4; final Integer B1 = 3; final Integer B2 = 6; final Integer B3 = 9; assertArrayEquals(new Integer[] {A1}, CollectionsExt.addToMultiValuesMap(map, "A", A1).toArray()); assertArrayEquals(new Integer[] {B1}, CollectionsExt.addToMultiValuesMap(map, "B", B1).toArray()); assertArrayEquals(new Integer[] {B1, B2}, CollectionsExt.addToMultiValuesMap(map, "B", B2).toArray()); assertArrayEquals(new Integer[] {A1, A2}, CollectionsExt.addToMultiValuesMap(map, "A", A2).toArray()); assertArrayEquals(new Integer[] {B1, B2, B3}, CollectionsExt.addToMultiValuesMap(map, "B", B3).toArray()); assertArrayEquals(new String[] {"A", "B"}, map.keySet().toArray()); assertArrayEquals(new Integer[] {A1, A2}, map.get("A").toArray()); assertArrayEquals(new Integer[] {B1, B2, B3}, map.get("B").toArray()); assertNull( CollectionsExt.removeFromMultiValuesMap(map, "C", A2)); assertArrayEquals(new Integer[] {A1}, CollectionsExt.removeFromMultiValuesMap(map, "A", A2).toArray()); assertArrayEquals(new Integer[] {B1, B3}, CollectionsExt.removeFromMultiValuesMap(map, "B", B2).toArray()); assertArrayEquals(new Integer[] {}, CollectionsExt.removeFromMultiValuesMap(map, "A", A1).toArray()); assertArrayEquals(new String[] {"B"}, map.keySet().toArray()); assertArrayEquals(new Integer[] {B1, B3}, map.get("B").toArray()); }
importedKeys.add(relation); for (final String column : relation.getForeignerKeys()) { CollectionsExt.addToMultiValuesMap(foreignerKeys, column, relation);