/** * Invoked by JAXB for specifying the unique identifier. * * @see org.apache.sis.metadata.iso.ISOMetadata#setUUID(String) */ @SuppressWarnings("unused") private void setUUID(final String id) { getIdentifierMap().put(IdentifierSpace.UUID, id); } }
/** * Invoked by JAXB for specifying the unique identifier. * * @see org.apache.sis.metadata.iso.ISOMetadata#setUUID(String) */ private void setUUID(final String id) { getIdentifierMap().put(IdentifierSpace.UUID, id); } }
/** * Sets an unique identifier. * This method is invoked automatically by JAXB and should never be invoked explicitly. */ private void setUUID(final String id) { /* * IdentifierMapAdapter will take care of converting the String to UUID if possible, or * will store the value as a plain String if it can not be converted. In the later case, * a warning will be emitted (logged or processed by listeners). */ getIdentifierMap().put(IdentifierSpace.UUID, id); } }
/** * Sets an unique identifier. * This method is invoked automatically by JAXB and should never be invoked explicitely. */ private void setUUID(final String id) { /* * IdentifierMapAdapter will take care of converting the String to UUID if possible, or * will store the value as a plain String if it can not be converted. In the later case, * a warning will be emitted (logged or processed by listeners). */ getIdentifierMap().put(IdentifierSpace.UUID, id); } }
/** * Assigns the {@link #id} value (if non-null) to the given object. This method * is typically invoked at unmarshalling time in order to assign the ID of this * temporary wrapper to the "real" GeoAPI implementation instance. * * @param wrapped the GeoAPI implementation for which to assign the ID. */ public final void copyIdTo(final Object wrapped) { if (id != null && wrapped instanceof IdentifiedObject) { final IdentifierMap map = ((IdentifiedObject) wrapped).getIdentifierMap(); if (map != null) { // Should not be null, but let be safe. map.put(IdentifierSpace.ID, id); } } } }
/** * Assigns the {@link #id} value (if non-null) to the given object. This method * is typically invoked at unmarshalling time in order to assign the ID of this * temporary wrapper to the "real" GeoAPI implementation instance. * * @param wrapped the GeoAPI implementation for which to assign the ID. */ public final void copyIdTo(final Object wrapped) { if (id != null && wrapped instanceof IdentifiedObject) { final IdentifierMap map = ((IdentifiedObject) wrapped).getIdentifierMap(); if (map != null) { // Should not be null, but let be safe. map.put(IdentifierSpace.ID, id); } } } }
/** * Tests read operations on an {@link IdentifierMap} using specific API. */ @Test public void testGetSpecialized() { final List<Identifier> identifiers = new ArrayList<>(); final IdentifierMap map = new ModifiableIdentifierMap(identifiers); assertNull(map.put(ID, "myID")); assertNull(map.put(UUID, "a1eb6e53-93db-4942-84a6-d9e7fb9db2c7")); assertNull(map.put(HREF, "http://mylink")); assertMapEquals("{gml:id=“myID”," + " gco:uuid=“a1eb6e53-93db-4942-84a6-d9e7fb9db2c7”," + " xlink:href=“http://mylink”}", map); assertEquals("myID", map.get (ID)); assertEquals("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7", map.get (UUID)); assertEquals("http://mylink", map.get (HREF)); assertEquals("myID", map.getSpecialized(ID)); assertEquals(URI.create("http://mylink"), map.getSpecialized(HREF)); assertEquals(fromString("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7"), map.getSpecialized(UUID)); }
/** * Tests explicitly the special handling of {@code href} values. */ @Test public void testHRefSubstitution() { final List<Identifier> identifiers = new ArrayList<>(); final IdentifierMap map = new ModifiableIdentifierMap(identifiers); assertNull(map.put(HREF, "myHREF")); assertEquals("Shall contain the entry we added.", "myHREF", map.get(HREF)); // Check the XLink object final XLink link = map.getSpecialized(XLINK); assertEquals("Added href shall be stored as XLink attribute.", "myHREF", String.valueOf(link.getHRef())); assertEquals("Identifier list shall contain the XLink.", link.toString(), getSingleton(identifiers).getCode()); // Modidfy the XLink object directly link.setHRef(URI.create("myNewHREF")); assertEquals("Change in XLink shall be reflected in href.", "myNewHREF", map.get(HREF)); }
/** * Compares the marshalling and unmarshalling of a {@link DefaultExtent} with XML in the given file. */ private void roundtrip(final String filename, final Version version) throws JAXBException { final DefaultGeographicBoundingBox bbox = new DefaultGeographicBoundingBox(-99, -79, 14.9844, 31); bbox.getIdentifierMap().put(IdentifierSpace.ID, "bbox"); final DefaultTemporalExtent temporal = new DefaultTemporalExtent(); if (PENDING_FUTURE_SIS_VERSION) { // This block needs sis-temporal module. temporal.setBounds(date("2010-01-27 13:26:10"), date("2010-08-27 13:26:10")); } final DefaultExtent extent = new DefaultExtent(null, bbox, null, temporal); assertMarshalEqualsFile(filename, extent, version, "xmlns:*", "xsi:schemaLocation"); assertEquals(extent, unmarshalFile(DefaultExtent.class, filename)); }