@SuppressWarnings("unchecked")
    static Object readObjectFrom(Input input, Schema<?> schema, Object owner,
            IdStrategy strategy, final int number) throws IOException
    {
        final boolean graph = input instanceof GraphInput;
        Object ret = null;
        switch (number)
        {
            case ID_EMPTY_MAP:
                if (graph)
                {
                    // update the actual reference.
                    ((GraphInput) input).updateLast(Collections.EMPTY_MAP, owner);
                }

                if (0 != input.readUInt32())
                    throw new ProtostuffException("Corrupt input.");

                ret = Collections.EMPTY_MAP;
                break;

            case ID_SINGLETON_MAP:
            {
                final Object map = iSingletonMap.newInstance();
                if (graph)
                {
                    // update the actual reference.
                    ((GraphInput) input).updateLast(map, owner);
                }

                if (0 != input.readUInt32())
                    throw new ProtostuffException("Corrupt input.");

                return fillSingletonMapFrom(input, schema, owner, strategy, graph,
                        map);
            }

            case ID_UNMODIFIABLE_MAP:
                ret = readUnmodifiableMapFrom(input, schema, owner, strategy,
                        graph, iUnmodifiableMap.newInstance(), false);
                break;

            case ID_UNMODIFIABLE_SORTED_MAP:
                ret = readUnmodifiableMapFrom(input, schema, owner, strategy,
                        graph, iUnmodifiableSortedMap.newInstance(), true);
                break;

            case ID_SYNCHRONIZED_MAP:
                ret = readSynchronizedMapFrom(input, schema, owner, strategy,
                        graph, iSynchronizedMap.newInstance(), false);
                break;

            case ID_SYNCHRONIZED_SORTED_MAP:
                ret = readSynchronizedMapFrom(input, schema, owner, strategy,
                        graph, iSynchronizedSortedMap.newInstance(), true);
                break;

            case ID_CHECKED_MAP:
                ret = readCheckedMapFrom(input, schema, owner, strategy, graph,
                        iCheckedMap.newInstance(), false);
                break;

            case ID_CHECKED_SORTED_MAP:
                ret = readCheckedMapFrom(input, schema, owner, strategy, graph,
                        iCheckedSortedMap.newInstance(), true);
                break;

            case ID_ENUM_MAP:
            {
                final Map<?, Object> em = strategy.resolveEnumFrom(input)
                        .newEnumMap();

                if (input instanceof GraphInput)
                {
                    // update the actual reference.
                    ((GraphInput) input).updateLast(em, owner);
                }

                strategy.MAP_SCHEMA.mergeFrom(input, (Map<Object, Object>) em);

                return em;
            }
            case ID_MAP:
            {
                final Map<Object, Object> map = strategy.resolveMapFrom(input)
                        .newMessage();

                if (input instanceof GraphInput)
                {
                    // update the actual reference.
                    ((GraphInput) input).updateLast(map, owner);
                }

                strategy.MAP_SCHEMA.mergeFrom(input, map);

                return map;
            }

            default:
                throw new ProtostuffException("Corrupt input.");
        }

        if (0 != input.readFieldNumber(schema))
            throw new ProtostuffException("Corrupt input.");

        return ret;
    }
Used when the type is an interface (Map/SortedMap).

@author David Yu
@created Apr 24, 2012
protostuff-runtime/src/main/java/io/protostuff/runtime/PolymorphicMapSchema.java