public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { // read the items from xml into a list List items = new ArrayList(); while (reader.hasMoreChildren()) { final Object item = readCompleteItem(reader, context, null); // TODO: arg, what should replace null? items.add(item); } // now convertAnother the list into an array // (this has to be done as a separate list as the array size is not // known until all items have been read) Object array = Array.newInstance(context.getRequiredType().getComponentType(), items.size()); int i = 0; for (Iterator iterator = items.iterator(); iterator.hasNext();) { Array.set(array, i++, iterator.next()); } return array; } }
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { // read the items from xml into a list List items = new ArrayList(); while (reader.hasMoreChildren()) { final Object item = readCompleteItem(reader, context, null); // TODO: arg, what should replace null? items.add(item); } // now convertAnother the list into an array // (this has to be done as a separate list as the array size is not // known until all items have been read) Object array = Array.newInstance(context.getRequiredType().getComponentType(), items.size()); int i = 0; for (Iterator iterator = items.iterator(); iterator.hasNext();) { Array.set(array, i++, iterator.next()); } return array; } }
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { // read the items from xml into a list List items = new ArrayList(); while (reader.hasMoreChildren()) { final Object item = readCompleteItem(reader, context, null); // TODO: arg, what should replace null? items.add(item); } // now convertAnother the list into an array // (this has to be done as a separate list as the array size is not // known until all items have been read) Object array = Array.newInstance(context.getRequiredType().getComponentType(), items.size()); int i = 0; for (Iterator iterator = items.iterator(); iterator.hasNext();) { Array.set(array, i++, iterator.next()); } return array; } }
@Override public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) { // read the items from xml into a list (the array size is not known until all items have been read) final List<Object> items = new ArrayList<>(); while (reader.hasMoreChildren()) { final Object item = readCompleteItem(reader, context, null); // TODO: arg, what should replace null? items.add(item); } // now convertAnother the list into an array final Object array = Array.newInstance(context.getRequiredType().getComponentType(), items.size()); int i = 0; for (final Object item : items) { Array.set(array, i++, item); } return array; } }
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { // read the items from xml into a list List items = new ArrayList(); while (reader.hasMoreChildren()) { final Object item = readCompleteItem(reader, context, null); // TODO: arg, what should replace null? items.add(item); } // now convertAnother the list into an array // (this has to be done as a separate list as the array size is not // known until all items have been read) Object array = Array.newInstance(context.getRequiredType().getComponentType(), items.size()); int i = 0; for (Iterator iterator = items.iterator(); iterator.hasNext();) { Array.set(array, i++, iterator.next()); } return array; } }