public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { // read the items from xml into a list List items = new ArrayList(); while (reader.hasMoreChildren()) { reader.moveDown(); Object item = readItem(reader, context, null); // TODO: arg, what should replace null? items.add(item); reader.moveUp(); } // 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()) { reader.moveDown(); Object item = readItem(reader, context, null); // TODO: arg, what should replace null? items.add(item); reader.moveUp(); } // 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()) { reader.moveDown(); Object item = readItem(reader, context, null); // TODO: arg, what should replace null? items.add(item); reader.moveUp(); } // 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()) { reader.moveDown(); Object item = readItem(reader, context, null); // TODO: arg, what should replace null? items.add(item); reader.moveUp(); } // 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; } }