All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hprose.io.unserialize.HashMapUnserializer Maven / Gradle / Ivy

/**********************************************************\
|                                                          |
|                          hprose                          |
|                                                          |
| Official WebSite: http://www.hprose.com/                 |
|                   http://www.hprose.org/                 |
|                                                          |
\**********************************************************/
/**********************************************************\
 *                                                        *
 * HashMapUnserializer.java                               *
 *                                                        *
 * HashMap unserializer class for Java.                   *
 *                                                        *
 * LastModified: Aug 4, 2016                              *
 * Author: Ma Bingyao                   *
 *                                                        *
\**********************************************************/

package hprose.io.unserialize;

import static hprose.io.HproseTags.TagList;
import static hprose.io.HproseTags.TagMap;
import static hprose.io.HproseTags.TagObject;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.HashMap;

public final class HashMapUnserializer extends BaseUnserializer {

    public final static HashMapUnserializer instance = new HashMapUnserializer();

    @Override
    public HashMap unserialize(Reader reader, int tag, Type type) throws IOException {
        switch (tag) {
            case TagList: return ReferenceReader.readListAsHashMap(reader, type);
            case TagMap: return ReferenceReader.readHashMap(reader, type);
            case TagObject:  return ReferenceReader.readObjectAsHashMap(reader, type);
        }
        return super.unserialize(reader, tag, type);
    }

    public HashMap read(Reader reader) throws IOException {
        return super.read(reader, HashMap.class);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy