/** * Returns the value to which the specified key is mapped, or {@code null} * if this map contains no mapping for the key. */ @Override public Integer get(final Object key) { if (key instanceof String) { final int i = accessor.indexOf((String) key, false); if (i >= 0) return i; } return null; }
/** * Returns {@code true} if this map contains a mapping for the specified key. * The default implementation is okay only if all metadata defined by the standard are included * in the map. Subclasses shall override this method if their map contain only a subset of all * possible metadata elements. */ @Override public boolean containsKey(final Object key) { return (key instanceof String) && accessor.indexOf((String) key, false) >= 0; }
/** * Returns {@code true} if this map contains a mapping for the specified key. * The default implementation is okay only if all metadata defined by the standard are included * in the map. Subclasses shall override this method if their map contain only a subset of all * possible metadata elements. */ @Override public boolean containsKey(final Object key) { return (key instanceof String) && accessor.indexOf((String) key, false) >= 0; }
/** * Returns the value to which the specified key is mapped, or {@code null} * if this map contains no mapping for the key. */ @Override public Integer get(final Object key) { if (key instanceof String) { final int i = accessor.indexOf((String) key, false); if (i >= 0) return i; } return null; }
/** * Returns the value to which the specified key is mapped, or {@code null} * if this map contains no mapping for the key. */ @Override public Class<?> get(final Object key) { if (key instanceof String) { return accessor.type(accessor.indexOf((String) key, false), valuePolicy); } return null; }
/** * Returns the information to which the specified key is mapped, * or {@code null} if this map contains no mapping for the key. */ @Override public ExtendedElementInformation get(final Object key) { if (key instanceof String) { return accessor.information(accessor.indexOf((String) key, false)); } return null; }
/** * Returns the value to which the specified key is mapped, or {@code null} * if this map contains no mapping for the key. */ @Override public Class<?> get(final Object key) { if (key instanceof String) { return accessor.type(accessor.indexOf((String) key, false), valuePolicy); } return null; }
/** * Returns the information to which the specified key is mapped, * or {@code null} if this map contains no mapping for the key. */ @Override public ExtendedElementInformation get(final Object key) { if (key instanceof String) { return accessor.information(accessor.indexOf((String) key, false)); } return null; }
/** * Returns the value to which the specified key is mapped, or {@code null} * if this map contains no mapping for the key. */ @Override public String get(final Object key) { if (key instanceof String) { return accessor.name(accessor.indexOf((String) key, false), valuePolicy); } return null; }
/** * Returns the value to which the specified key is mapped, or {@code null} * if this map contains no mapping for the key. */ @Override public String get(final Object key) { if (key instanceof String) { return accessor.name(accessor.indexOf((String) key, false), valuePolicy); } return null; }
/** * Puts every entries from the given map. This method is overloaded for performance reasons * since we are not interested in the return value of the {@link #put(String, Object)} method. * * @throws IllegalArgumentException if at least one key is not the name of a property in the metadata. * @throws ClassCastException if at least one value is not of the expected type. * @throws UnmodifiableMetadataException if at least one property is read-only. */ @Override public void putAll(final Map<? extends String, ?> map) { for (final Map.Entry<? extends String, ?> e : map.entrySet()) { accessor.set(accessor.indexOf(e.getKey(), true), metadata, e.getValue(), RETURN_NULL); } }
/** * Associates the specified value with the specified key in this map. * * @throws IllegalArgumentException if the given key is not the name of a property in the metadata. * @throws ClassCastException if the given value is not of the expected type. * @throws UnmodifiableMetadataException if the property for the given key is read-only. */ @Override public Object put(final String key, final Object value) { final Object old = accessor.set(accessor.indexOf(key, true), metadata, value, RETURN_PREVIOUS); return valuePolicy.isSkipped(old) ? null : old; }
/** * Associates the specified value with the specified key in this map. * * @throws IllegalArgumentException if the given key is not the name of a property in the metadata. * @throws ClassCastException if the given value is not of the expected type. * @throws UnmodifiableMetadataException if the property for the given key is read-only. */ @Override public Object put(final String key, final Object value) { final Object old = accessor.set(accessor.indexOf(key, true), metadata, value, RETURN_PREVIOUS); return valuePolicy.isSkipped(old) ? null : old; }
/** * Returns the value to which the specified key is mapped, or {@code null} * if this map contains no mapping for the key. */ @Override public Object get(final Object key) { if (key instanceof String) { final Object value = accessor.get(accessor.indexOf((String) key, false), metadata); if (!valuePolicy.isSkipped(value)) { return value; } } return null; }
/** * Invokes {@link SpecialCases#type(int, TypeValuePolicy)} * and ensures that the result is equals to the expected value. */ private void assertTypeEquals(final String name, final Class<?> expected) { assertEquals(name, expected, accessor.type(accessor.indexOf(name, true), TypeValuePolicy.ELEMENT_TYPE)); }
/** * Invokes {@link SpecialCases#set(int, Object, Object, int)} in {@code RETURN_PREVIOUS} mode with the given * {@code newValue}, and ensures that the return value is equals to the given {@code oldValue}. */ private void assertPreviousEquals(final String name, final Object oldValue, final Object newValue) { final Object value = accessor.set(accessor.indexOf(name, true), box, newValue, PropertyAccessor.RETURN_PREVIOUS); assertEquals(name, oldValue, value); }
/** * Invokes {@link SpecialCases#set(int, Object, Object, int)} in {@code APPEND} mode with the given * {@code newValue}, and ensures that the return value is equals to the given {@code changed}. */ private void assertAppendResultEquals(final String name, final Boolean changed, final Object newValue) { final Object value = accessor.set(accessor.indexOf(name, true), box, newValue, PropertyAccessor.APPEND); assertEquals(name, changed, value); }
/** * Invokes {@link SpecialCases#get(int, Object)} and ensures that the result is equals to the expected value. */ private void assertPropertyEquals(final String name, final Object expected) { assertEquals(name, expected, accessor.get(accessor.indexOf(name, true), box)); }
/** * Tests the {@link PropertyAccessor#information(int)} method. * This method delegates to some {@link PropertyInformationTest} methods. */ @Test @DependsOnMethod("testConstructor") public void testInformation() { final PropertyAccessor accessor = createPropertyAccessor(); PropertyInformationTest.validateTitle (accessor.information(accessor.indexOf("title", true))); PropertyInformationTest.validatePresentationForm(accessor.information(accessor.indexOf("presentationForm", true))); }
/** * Tests {@link SpecialCases#information(int)}. */ @Test public void testPropertyInformation() { final ExtendedElementInformation info = accessor.information(accessor.indexOf("westBoundLongitude", true)); final InternationalString domain = info.getDomainValue(); assertInstanceOf("Expected numerical information about range.", NumberRange.class, domain); final NumberRange<?> range = (NumberRange) domain; assertEquals(-180, range.getMinDouble(), STRICT); assertEquals(+180, range.getMaxDouble(), STRICT); } }