@Test public void testSerializeDocumentReference() throws Exception { EntityReference reference = resolver.resolve("wiki:space.page", EntityType.DOCUMENT); Assert.assertEquals("wiki:space.page", serializer.serialize(reference)); reference = resolver.resolve("wiki:space.", EntityType.DOCUMENT); Assert.assertEquals("wiki:space.WebHome", serializer.serialize(reference)); reference = resolver.resolve("space.", EntityType.DOCUMENT); Assert.assertEquals("xwiki:space.WebHome", serializer.serialize(reference)); reference = resolver.resolve("page", EntityType.DOCUMENT); Assert.assertEquals("xwiki:XWiki.page", serializer.serialize(reference)); reference = resolver.resolve(".", EntityType.DOCUMENT); Assert.assertEquals("xwiki:XWiki.WebHome", serializer.serialize(reference)); reference = resolver.resolve(null, EntityType.DOCUMENT); Assert.assertEquals("xwiki:XWiki.WebHome", serializer.serialize(reference)); reference = resolver.resolve("", EntityType.DOCUMENT); Assert.assertEquals("xwiki:XWiki.WebHome", serializer.serialize(reference)); reference = resolver.resolve("wiki1.wiki2:wiki3:some.space.page", EntityType.DOCUMENT); Assert.assertEquals("wiki1.wiki2:wiki3:some\\.space.page", serializer.serialize(reference)); reference = resolver.resolve("some.space.page", EntityType.DOCUMENT); Assert.assertEquals("xwiki:some\\.space.page", serializer.serialize(reference)); reference = resolver.resolve("wiki:page", EntityType.DOCUMENT); Assert.assertEquals("xwiki:XWiki.wiki:page", serializer.serialize(reference)); Assert.assertNull(serializer.serialize(null)); reference = resolver.resolve("\\.:@\\.", EntityType.DOCUMENT); Assert.assertEquals("xwiki:XWiki.\\.:@\\.", serializer.serialize(reference)); }
public String serialize(EntityReference reference) { if (reference == null) { return null; } EntityReference currentReference = reference.getRoot(); StringBuilder representation = new StringBuilder(); while (currentReference != null && currentReference != reference.getChild()) { serializeEntityReference(currentReference, representation, currentReference == reference); currentReference = currentReference.getChild(); } return representation.toString(); }
DefaultStringEntityReferenceSerializer implements EntityReferenceSerializer<String> { public String serialize(EntityReference reference) { if (reference == null) { return null; } EntityReference currentReference = reference.getRoot(); StringBuilder representation = new StringBuilder(); while (currentReference != null && currentReference != reference.getChild()) { serializeEntityReference(currentReference, representation, currentReference == reference); currentReference = currentReference.getChild(); } return representation.toString(); } }
DefaultStringEntityReferenceSerializer implements EntityReferenceSerializer<String> { public String serialize(EntityReference reference) { if (reference == null) { return null; } EntityReference currentReference = reference.getRoot(); StringBuilder representation = new StringBuilder(); while (currentReference != null && currentReference != reference.getChild()) { serializeEntityReference(currentReference, representation, currentReference == reference); currentReference = currentReference.getChild(); } return representation.toString(); }  }
DefaultStringEntityReferenceSerializer implements EntityReferenceSerializer<String> { public String serialize(EntityReference reference) { if (reference == null) { return null; } EntityReference currentReference = reference.getRoot(); StringBuilder representation = new StringBuilder(); while (currentReference != null && currentReference != reference.getChild()) { serializeEntityReference(currentReference, representation, currentReference == reference); currentReference = currentReference.getChild(); } return representation.toString(); }  String serialize(EntityReference reference); }
DefaultStringEntityReferenceSerializer implements EntityReferenceSerializer<String> { public String serialize(EntityReference reference) { if (reference == null) { return null; } EntityReference currentReference = reference.getRoot(); StringBuilder representation = new StringBuilder(); while (currentReference != null && currentReference != reference.getChild()) { serializeEntityReference(currentReference, representation, currentReference == reference); currentReference = currentReference.getChild(); } return representation.toString(); }  String serialize(EntityReference reference);  }