use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.
the class JsonFieldWriter method createValueNode.
private JsonNode createValueNode(Field jsonField) {
FieldType type = jsonField.getFieldType();
Object value = jsonField.getValue();
JsonNode valueNode = null;
if (FieldType.STRING.equals(type)) {
if (value != null) {
valueNode = rootNode.textNode(String.valueOf(value));
} else {
valueNode = rootNode.nullNode();
}
} else if (FieldType.CHAR.equals(type)) {
valueNode = rootNode.textNode(Character.toString((char) value));
} else if (FieldType.BOOLEAN.equals(type)) {
valueNode = rootNode.booleanNode((Boolean) value);
} else if (FieldType.INTEGER.equals(type)) {
valueNode = rootNode.numberNode((Integer) value);
} else if (FieldType.DOUBLE.equals(type) || FieldType.FLOAT.equals(type)) {
valueNode = rootNode.numberNode(new BigDecimal(String.valueOf(value)));
} else if (FieldType.SHORT.equals(type)) {
valueNode = rootNode.numberNode(Short.valueOf(String.valueOf(value)));
} else if (FieldType.LONG.equals(type)) {
valueNode = rootNode.numberNode(Long.valueOf(String.valueOf(value)));
} else if (FieldType.BYTE.equals(type)) {
valueNode = rootNode.numberNode(Byte.valueOf(String.valueOf(value)));
} else {
valueNode = rootNode.nullNode();
}
if (LOG.isDebugEnabled()) {
String valueClass = value == null ? "null" : value.getClass().getName();
LOG.debug("Converted JsonField value to ValueNode. Type: " + type + ", value: " + value + "(" + valueClass + "), node class: " + valueNode.getClass().getName() + ", node: " + valueNode);
}
return valueNode;
}
use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.
the class BaseDefaultAtlasContextTest method populateSourceField.
protected Field populateSourceField(Mapping mapping, FieldType type, Object value, int index) {
Field field = populateSourceField(mapping, type, value);
field.setIndex(index);
return field;
}
use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.
the class BaseDefaultAtlasContextTest method populateSourceField.
protected Field populateSourceField(Mapping mapping, String docId, FieldType type, Object value) {
Field field = populateSourceField(mapping, type, value);
field.setDocId(docId);
return field;
}
use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.
the class BaseDefaultAtlasContextTest method populateSourceField.
protected Field populateSourceField(Mapping mapping, String docId, FieldType type, Object value, int index) {
Field field = populateSourceField(mapping, type, value);
field.setDocId(docId);
field.setIndex(index);
return field;
}
use of io.atlasmap.v2.FieldType in project atlasmap by atlasmap.
the class BaseDefaultAtlasContextTest method prepareTargetField.
protected Field prepareTargetField(Mapping mapping, FieldType type, String path, int index) {
Field field = prepareTargetField(mapping, path);
field.setFieldType(type);
field.setPath(path);
field.setIndex(index);
return field;
}
Aggregations