@Override public JdomRepresentation add(Resource resource, boolean eager) { if (resource == null) { return this; } Object id = resource.getId(); String idString = id == null ? getEmptyValue() : id.toString(); Content idAsString = new Element(resource.getPrefix()).setText(idString); Content content; if (eager) { Representation representation = resource.getRepresentation(); if (representation instanceof JdomRepresentation) { content = ((JdomRepresentation) resource.getRepresentation()).checkRootDocument().detach(); } else { content = idAsString; } } else { content = idAsString; } this.checkRootDocument().addContent(content); return this; }
/** * Create a basic representation * * @param resource Resource * @return */ public static Representation construct(Resource resource) { CoupleList<String, Object> serialization = resource.serialize(); return JdomRepresentation.construct(resource.getPrefix(), serialization); }
/** * This is the simplest way to create a Representation * * @param resource */ public JdomRepresentation(Resource resource) { this(resource.getPrefix(), resource.serialize()); }