@Test public void testSerializeAttachmentReference() throws Exception { EntityReference reference = resolver.resolve("wiki:space.page@filename", EntityType.ATTACHMENT); Assert.assertEquals("wiki:space.page@filename", serializer.serialize(reference)); reference = resolver.resolve("", EntityType.ATTACHMENT); Assert.assertEquals("xwiki:XWiki.WebHome@filename", serializer.serialize(reference)); reference = resolver.resolve("wiki:space.page@my.png", EntityType.ATTACHMENT); Assert.assertEquals("wiki:space.page@my.png", serializer.serialize(reference)); reference = resolver.resolve("some:file.name", EntityType.ATTACHMENT); Assert.assertEquals("xwiki:XWiki.WebHome@some:file.name", serializer.serialize(reference)); reference = resolver.resolve(":.\\@", EntityType.ATTACHMENT); Assert.assertEquals("xwiki:XWiki.WebHome@:.\\@", 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);  }