use of com.enonic.xp.util.Link in project xp by enonic.
the class ScriptValueTranslator method handleValue.
private void handleValue(final PropertySet parent, final String name, final Object value) {
if (value instanceof Instant) {
parent.addInstant(name, (Instant) value);
} else if (value instanceof GeoPoint) {
parent.addGeoPoint(name, (GeoPoint) value);
} else if (value instanceof Double) {
parent.addDouble(name, (Double) value);
} else if (value instanceof Float) {
parent.addDouble(name, ((Float) value).doubleValue());
} else if (value instanceof Integer) {
parent.addLong(name, ((Integer) value).longValue());
} else if (value instanceof Byte) {
parent.addLong(name, ((Byte) value).longValue());
} else if (value instanceof Long) {
parent.addLong(name, ((Long) value));
} else if (value instanceof Number) {
parent.addDouble(name, ((Number) value).doubleValue());
} else if (value instanceof Boolean) {
parent.addBoolean(name, (Boolean) value);
} else if (value instanceof LocalDateTime) {
parent.addLocalDateTime(name, (LocalDateTime) value);
} else if (value instanceof LocalDate) {
parent.addLocalDate(name, (LocalDate) value);
} else if (value instanceof LocalTime) {
parent.addLocalTime(name, (LocalTime) value);
} else if (value instanceof Date) {
parent.addInstant(name, ((Date) value).toInstant());
} else if (value instanceof Reference) {
parent.addReference(name, (Reference) value);
} else if (value instanceof BinaryReference) {
parent.addBinaryReference(name, (BinaryReference) value);
} else if (value instanceof Link) {
parent.addLink(name, (Link) value);
} else if (value instanceof BinaryAttachment) {
final BinaryAttachment binaryAttachment = (BinaryAttachment) value;
parent.addBinaryReference(name, binaryAttachment.getReference());
if (includeBinaryAttachments) {
this.binaryAttachmentsBuilder.add(new BinaryAttachment(binaryAttachment.getReference(), binaryAttachment.getByteSource()));
}
} else {
parent.addString(name, value.toString());
}
}
use of com.enonic.xp.util.Link in project xp by enonic.
the class PropertyTreeTest method setLink.
@Test
public void setLink() {
PropertyTree tree = new PropertyTree();
Link link1 = Link.from("enonic.com");
tree.setLink("enonic", link1);
assertEquals(1, tree.getTotalSize());
assertEquals(link1, tree.getLink("enonic"));
Link link2 = Link.from("wiki.enonic.com");
tree.setLink(PropertyPath.from("wiki"), link2);
assertEquals(2, tree.getTotalSize());
assertEquals(link2, tree.getLink(PropertyPath.from("wiki")));
Link link3 = Link.from("youtrack.enonic.net");
tree.setLink("youtrack", 0, link3);
assertEquals(3, tree.getTotalSize());
assertEquals(link3, tree.getLink("youtrack", 0));
assertEquals("youtrack.enonic.net", tree.getLinks("youtrack").iterator().next().toString());
}
Aggregations