com.thoughtworks.xstream.core.util.HierarchicalStreams Java Examples

The following examples show how to use com.thoughtworks.xstream.core.util.HierarchicalStreams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NamedArrayConverter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
    final List list = new ArrayList();
    while (reader.hasMoreChildren()) {
        reader.moveDown();
        final Object item;
        final String className = HierarchicalStreams.readClassAttribute(reader, mapper);
        final Class itemType = className == null ? arrayType.getComponentType() : mapper.realClass(className);
        if (Mapper.Null.class.equals(itemType)) {
            item = null;
        } else {
            item = context.convertAnother(null, itemType);
        }
        list.add(item);
        reader.moveUp();
    }
    final Object array = Array.newInstance(arrayType.getComponentType(), list.size());
    for (int i = 0; i < list.size(); ++i) {
        Array.set(array, i, list.get(i));
    }
    return array;
}
 
Example #2
Source File: NamedMapConverter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected Object readItem(Class type, HierarchicalStreamReader reader,
    UnmarshallingContext context, Object current) {
    String className = HierarchicalStreams.readClassAttribute(reader, mapper());
    Class itemType = className == null ? type : mapper().realClass(className);
    if (Mapper.Null.class.equals(itemType)) {
        return null;
    } else {
        return context.convertAnother(current, itemType);
    }
}
 
Example #3
Source File: NamedCollectionConverter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected Object readBareItem(final HierarchicalStreamReader reader, final UnmarshallingContext context,
        final Object current) {
    final String className = HierarchicalStreams.readClassAttribute(reader, mapper());
    final Class itemType = className == null ? type : mapper().realClass(className);
    if (Mapper.Null.class.equals(itemType)) {
        return null;
    } else {
        return context.convertAnother(current, itemType);
    }
}
 
Example #4
Source File: TreeUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public Object start(DataHolder dataHolder) {
    this.dataHolder = dataHolder;
    Class type = HierarchicalStreams.readClassType(reader, mapper);
    Object result = convertAnother(null, type);
    Iterator validations = validationList.iterator();
    while (validations.hasNext()) {
        Runnable runnable = (Runnable)validations.next();
        runnable.run();
    }
    return result;
}
 
Example #5
Source File: DelegateArrayConverter.java    From jease with GNU General Public License v3.0 4 votes vote down vote up
protected Object readItem(HierarchicalStreamReader reader,
		UnmarshallingContext context, Object current) {
	Class<?> type = HierarchicalStreams.readClassType(reader, mapper());
	return context.convertAnother(current, type, delegateConverter);
}
 
Example #6
Source File: AbstractCollectionConverter.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Read a bare item of the collection from the reader.
 *
 * @param reader the source reader
 * @param context the unmarshalling context
 * @param current the target collection (if already available)
 * @return the read item
 * @since 1.4.11
 */
protected Object readBareItem(final HierarchicalStreamReader reader, final UnmarshallingContext context,
        final Object current) {
    Class type = HierarchicalStreams.readClassType(reader, mapper());
    return context.convertAnother(current, type);
}