String id = Context.getObjectID(context, object); if (id == null) { id = object.getIdentifierMap().getSpecialized(IdentifierSpace.ID); if (id != null) { final StringBuilder buffer = new StringBuilder();
String id = Context.getObjectID(context, object); if (id == null) { id = object.getIdentifierMap().getSpecialized(IdentifierSpace.ID); if (id != null) { final StringBuilder buffer = new StringBuilder();
XLink link = map.getSpecialized(IdentifierSpace.XLINK); UUID uuid = map.getSpecialized(IdentifierSpace.UUID); if (uuid != null || link != null) {
XLink link = map.getSpecialized(IdentifierSpace.XLINK); UUID uuid = map.getSpecialized(IdentifierSpace.UUID); if (uuid != null || link != null) {
/** * Verifies if the given metadata contains the expected {@code xlink:href} attribute value. * * @param isNilExpected {@code true} if the identification info is expected to be a {@link NilObject} instance. * @param metadata the metadata to verify. */ private static void verify(final boolean isNilExpected, final DefaultMetadata metadata) { final Identification identification = getSingleton(metadata.getIdentificationInfo()); assertEquals("NilObject", isNilExpected, identification instanceof NilObject); assertInstanceOf("Identification", IdentifiedObject.class, identification); final XLink xlink = ((IdentifiedObject) identification).getIdentifierMap().getSpecialized(IdentifierSpace.XLINK); assertEquals("xlink:href", "http://test.net", xlink.getHRef().toString()); }
/** * 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 write operations on an {@link IdentifierMap} using specific API. */ @Test public void testPutSpecialized() { final List<Identifier> identifiers = new ArrayList<>(); final IdentifierMap map = new ModifiableIdentifierMap(identifiers); final String myID = "myID"; final java.util.UUID myUUID = fromString("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7"); final URI myURI = URI.create("http://mylink"); assertNull(map.putSpecialized(ID, myID)); assertNull(map.putSpecialized(UUID, myUUID)); assertNull(map.putSpecialized(HREF, myURI)); assertMapEquals("{gml:id=“myID”," + " gco:uuid=“a1eb6e53-93db-4942-84a6-d9e7fb9db2c7”," + " xlink:href=“http://mylink”}", map); assertSame(myID, map.getSpecialized(ID)); assertSame(myUUID, map.getSpecialized(UUID)); assertSame(myURI, map.getSpecialized(HREF)); assertEquals("myID", map.get(ID)); assertEquals("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7", map.get(UUID)); assertEquals("http://mylink", map.get(HREF)); }
/** * 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)); }