protected Serializable convert(Collection<?> value) throws PropertyConversionException { Property typedProperty = getRoot().createProperty(null, getType().getField(), NONE); Collection<Object> col = new ArrayList<>(value.size()); for (Object v : value) { if (v == null) { col.add(null); } else { col.add(typedProperty.normalize(v)); } } return col.toArray((Object[]) Array.newInstance(typedProperty.newInstance().getClass(), col.size())); }
protected Field resolveSubField(ListType listType, String subName, boolean fallbackOnSubElement) { Type itemType = listType.getFieldType(); if (itemType.isComplexType() && subName != null) { ComplexType complexType = (ComplexType) itemType; Field subField = complexType.getField(subName); return subField; } if (fallbackOnSubElement) { return listType.getField(); } return null; }
break; field = listType.getField(); parts.add("*"); } else {
@Override public Property addEmpty() { Field lfield = getType().getField(); Property property = getRoot().createProperty(this, lfield, 0); children.add(property); return property; }
buildComplexFields(jg, lt.getField()); jg.writeStringField("type", "complex[]"); jg.writeEndObject();
@Override public Property addValue(int index, Object value) throws PropertyException { Field lfield = getType().getField(); Property property = getRoot().createProperty(this, lfield, IS_NEW); property.setValue(value); children.add(index, property); return property; }
updateList(state, name, listType.getField(), xpath, values);
@Override public Property addValue(Object value) throws PropertyException { Field lfield = getType().getField(); Property property = getRoot().createProperty(this, lfield, IS_NEW); property.setValue(value); children.add(property); return property; }
jg.writeStringField("type", "complex[]"); jg.writeObjectFieldStart("fields"); ComplexType cplXType = (ComplexType) lt.getField().getType(); for (Field subField : cplXType.getFields()) { writeField(jg, subField);
@Override @SuppressWarnings("unchecked") public void init(Serializable value) throws PropertyException { if (value == null) { // IGNORE null values - properties will be // considered PHANTOMS return; } List<Serializable> list; if (value.getClass().isArray()) { // accept also arrays list = (List<Serializable>) PrimitiveArrays.toList(value); } else { list = (List<Serializable>) value; } children.clear(); // do not use clear() method since it is marking the // list as dirty Field lfield = getType().getField(); for (Serializable obj : list) { Property property = getRoot().createProperty(this, lfield, 0); property.init(obj); children.add(property); } removePhantomFlag(); }
} else { Field listField = listType.getField(); List<T> childStates = getChildAsList(state, name);
Field itemField = ((ListType) field.getType()).getField(); if (xpathToken.matches("\\d+")) {
field = ((ListType) type).getField(); if (i == segments.length - 1) {
Field lfield = ltype.getField(); Type ftype = lfield.getType(); List<Object> list;
Field listField = listType.getField(); int index = 0; for (Object item : castedValue) {
Field lfield = getType().getField(); for (Object obj : col) { Property property = getRoot().createProperty(this, lfield, IS_NEW);
protected final void readList(Element element, ListType ltype, List list, boolean inlineBlobs) throws IOException { Field field = ltype.getField(); for (Object obj : list) { readProperty(element, Namespace.DEFAULT_NS, field, obj, inlineBlobs); } }
private void fillListProperty(Property property, JsonNode jn) throws IOException { ListType listType = (ListType) property.getType(); if (property instanceof ArrayProperty) { fillScalarProperty(property, jn); } else { JsonNode elNode; Iterator<JsonNode> it = jn.elements(); while (it.hasNext()) { elNode = it.next(); Property child = readProperty(property, listType.getField(), elNode); property.addValue(child.getValue()); } } }
protected void walkType(Type type, String path, String addPrefix) { if (type.isSimpleType()) { walkSimpleType(type, path, addPrefix); } else if (type.isListType()) { String listPath = path + "/*"; Type ftype = ((ListType) type).getField().getType(); if (ftype.isComplexType()) { // complex list walkComplexType((ComplexType) ftype, listPath, addPrefix); } else { // array walkSimpleType(ftype, listPath, addPrefix); } } else { // complex type ComplexType ctype = (ComplexType) type; walkComplexType(ctype, path, addPrefix); } }