@Test public void testResolveAndSerializeObjectReference() { EntityReference reference = resolver.resolve("wiki:space.page^Object", EntityType.OBJECT); Assert.assertEquals("wiki:space.page^Object", serializer.serialize(reference)); reference = resolver.resolve("", EntityType.OBJECT); Assert.assertEquals("xwiki:XWiki.WebHome^Object", serializer.serialize(reference)); reference = resolver.resolve("wiki:space.page.property", EntityType.OBJECT); Assert.assertEquals("xwiki:XWiki.WebHome^wiki:space.page.property", serializer.serialize(reference)); reference = resolver.resolve("wiki:space.page^Obje\\^ct", EntityType.OBJECT); Assert.assertEquals("wiki:space.page^Obje\\^ct", serializer.serialize(reference)); reference = resolver.resolve("wiki:spa^ce.page^Obje\\^ct", EntityType.OBJECT); Assert.assertEquals("wiki:spa^ce.page^Obje\\^ct", serializer.serialize(reference)); reference = resolver.resolve(":.\\^@", EntityType.OBJECT); 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);  }