@Override public PrimitiveType getPrimitiveType() { if (primitiveType == null) { primitiveType = ((SimpleType) getSuperType()).getPrimitiveType(); } return primitiveType; }
public static Class<?> getClass(Type type) { if (type.isSimpleType() && !((SimpleType) type).isPrimitive()) { return getClass(((SimpleType) type).getPrimitiveType()); } return types2Class.get(type); }
private void fillScalarProperty(Property property, JsonNode jn) throws IOException { if ((property instanceof ArrayProperty) && jn.isArray()) { List<Object> values = new ArrayList<>(); Iterator<JsonNode> it = jn.elements(); JsonNode item; Type fieldType = ((ListType) property.getType()).getFieldType(); while (it.hasNext()) { item = it.next(); values.add(getScalarPropertyValue(property, item, fieldType)); } property.setValue(castArrayPropertyValue(((SimpleType) fieldType).getPrimitiveType(), values)); } else { property.setValue(getScalarPropertyValue(property, jn, property.getType())); } }
Type type = prop.getType(); if (type instanceof SimpleType) { type = ((SimpleType) type).getPrimitiveType();
protected void writeListProperty(JsonGenerator jg, Property prop) throws IOException { jg.writeStartArray(); if (prop instanceof ArrayProperty) { Object[] ar = (Object[]) prop.getValue(); if (ar == null) { jg.writeEndArray(); return; } Type itemType = ((ListType) prop.getType()).getFieldType(); ObjectResolver resolver = itemType.getObjectResolver(); String path = prop.getXPath(); for (Object o : ar) { if (!fetchProperty(jg, resolver, o, path)) { writeScalarPropertyValue(jg, ((SimpleType) itemType).getPrimitiveType(), o); } } } else { ListProperty listp = (ListProperty) prop; for (Property p : listp.getChildren()) { writeProperty(jg, p); } } jg.writeEndArray(); }
protected void writeScalarProperty(JsonGenerator jg, Property prop) throws IOException { Type type = prop.getType(); Object value = prop.getValue(); if (!fetchProperty(jg, prop.getType().getObjectResolver(), value, prop.getXPath())) { writeScalarPropertyValue(jg, ((SimpleType) type).getPrimitiveType(), value); } }
if (fieldType instanceof SimpleType) { SimpleType stype = (SimpleType) fieldType; fieldType = stype.getPrimitiveType(); if (type instanceof SimpleType) { SimpleType stype = (SimpleType) type; type = stype.getPrimitiveType();
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getField().getType(); if (!type.isSimpleType()) { throw new OperationException("Only scalar types can be set using update operation"); } if (value == null) { p.setValue(null); } else if (value.getClass() == String.class) { p.setValue(((SimpleType) type).getPrimitiveType().decode((String) value)); } else { p.setValue(value); } if (save) { doc = session.saveDocument(doc); } return doc; }
return readStringList(value, type.getPrimitiveType());
value = getPropertyValue(((SimpleType) type).getPrimitiveType(), jn);
p.setValue(((SimpleType) type).getPrimitiveType().decode(value));