public Object readObject()

in src/main/java/com/alibaba/com/caucho/hessian/io/HessianInput.java [1107:1214]


    public Object readObject(List<Class<?>> expectedTypes)
            throws IOException {
        int tag = read();

        switch (tag) {
            case 'N':
                return null;

            case 'T':
                return Boolean.valueOf(true);

            case 'F':
                return Boolean.valueOf(false);

            case 'I':
                return Integer.valueOf(parseInt());

            case 'L':
                return Long.valueOf(parseLong());

            case 'D':
                return Double.valueOf(parseDouble());

            case 'd':
                return new Date(parseLong());

            case 'x':
            case 'X': {
                _isLastChunk = tag == 'X';
                _chunkLength = (read() << 8) + read();

                return parseXML();
            }

            case 's':
            case 'S': {
                _isLastChunk = tag == 'S';
                _chunkLength = (read() << 8) + read();

                int data;
                _sbuf.setLength(0);

                while ((data = parseChar()) >= 0)
                    _sbuf.append((char) data);

                return _sbuf.toString();
            }

            case 'b':
            case 'B': {
                _isLastChunk = tag == 'B';
                _chunkLength = (read() << 8) + read();

                int data;
                ByteArrayOutputStream bos = new ByteArrayOutputStream();

                while ((data = parseByte()) >= 0)
                    bos.write(data);

                return bos.toByteArray();
            }

            case 'V': {
                String type = readType();
                int length = readLength();

                Deserializer reader;
                reader = _serializerFactory.getObjectDeserializer(type);

                boolean valueType = expectedTypes != null && expectedTypes.size() == 1;

                if (List.class != reader.getType() && List.class.isAssignableFrom(reader.getType()))
                    return reader.readList(this, length, valueType ? expectedTypes.get(0) : null);
                Class clazz = type.equals(HashSet.class.getName()) ? Set.class : List.class;
                reader = _serializerFactory.getDeserializer(clazz);

                Object v = reader.readList(this, length, valueType ? expectedTypes.get(0) : null);

                return v;
            }

            case 'M': {
                String type = readType();

                boolean keyValuePair = expectedTypes != null && expectedTypes.size() == 2;

                return _serializerFactory.readMap(this, type
                        , keyValuePair ? expectedTypes.get(0) : null
                        , keyValuePair ? expectedTypes.get(1) : null);
            }

            case 'R': {
                int ref = parseInt();

                return _refs.get(ref);
            }

            case 'r': {
                String type = readType();
                String url = readString();

                return resolveRemote(type, url);
            }

            default:
                throw error("unknown code for readObject at " + codeName(tag));
        }
    }