<commit_before>/**********************************************************\
|                                                          |
|                          hprose                          |
|                                                          |
| Official WebSite: http://www.hprose.com/                 |
|                   http://www.hprose.org/                 |
|                                                          |
\**********************************************************/
/**********************************************************\
 *                                                        *
 * TimeZoneUnserializer.java                              *
 *                                                        *
 * TimeZone unserializer class for Java.                  *
 *                                                        *
 * LastModified: Jun 27, 2015                             *
 * Author: <NAME> <<EMAIL>>                  *
 *                                                        *
\**********************************************************/

package hprose.io.unserialize;

import static hprose.io.HproseTags.TagEmpty;
import static hprose.io.HproseTags.TagNull;
import static hprose.io.HproseTags.TagRef;
import static hprose.io.HproseTags.TagString;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.nio.ByteBuffer;
import java.util.TimeZone;

final class TimeZoneUnserializer implements HproseUnserializer {

    public final static TimeZoneUnserializer instance = new TimeZoneUnserializer();

    final static Object readTimeZone(HproseReader reader, ByteBuffer buffer) throws IOException {
        TimeZone tz = TimeZone.getTimeZone(ValueReader.readString(buffer));
        reader.refer.set(tz);
        return tz;
    }

    final static Object readTimeZone(HproseReader reader, InputStream stream) throws IOException {
        TimeZone tz = TimeZone.getTimeZone(ValueReader.readString(stream));
        reader.refer.set(tz);
        return tz;
    }

    private static Object toTimeZone(Object obj) throws IOException {
        if (obj instanceof TimeZone) {
            return obj;
        }
        if (obj instanceof char[]) {
            return TimeZone.getTimeZone(new String((char[])obj));
        }
        return TimeZone.getTimeZone(obj.toString());
    }

    final static Object read(HproseReader reader, ByteBuffer buffer) throws IOException {
        int tag = buffer.get();
        switch (tag) {
            case TagNull:
            case TagEmpty: return null;
            case TagString: return readTimeZone(reader, buffer);
            case TagRef: return toTimeZone(reader.readRef(buffer));
            default: throw ValueReader.castError(reader.tagToString(tag), TimeZone.class);
        }
    }

    final static Object read(HproseReader reader, InputStream stream) throws IOException {
        int tag = stream.read();
        switch (tag) {
            case TagNull:
            case TagEmpty: return null;
            case TagString: return readTimeZone(reader, stream);
            case TagRef: return toTimeZone(reader.readRef(stream));
            default: throw ValueReader.castError(reader.tagToString(tag), TimeZone.class);
        }
    }

    public final Object read(HproseReader reader, ByteBuffer buffer, Class<?> cls, Type type) throws IOException {
        return read(reader, buffer);
    }

    public final Object read(HproseReader reader, InputStream stream, Class<?> cls, Type type) throws IOException {
        return read(reader, stream);
    }

}
<commit_msg>Improved TimeZoneUnserializer<commit_after>/**********************************************************\
|                                                          |
|                          hprose                          |
|                                                          |
| Official WebSite: http://www.hprose.com/                 |
|                   http://www.hprose.org/                 |
|                                                          |
\**********************************************************/
/**********************************************************\
 *                                                        *
 * TimeZoneUnserializer.java                              *
 *                                                        *
 * TimeZone unserializer class for Java.                  *
 *                                                        *
 * LastModified: Jun 27, 2015                             *
 * Author: <NAME> <<EMAIL>>                  *
 *                                                        *
\**********************************************************/

package hprose.io.unserialize;

import static hprose.io.HproseTags.TagEmpty;
import static hprose.io.HproseTags.TagNull;
import static hprose.io.HproseTags.TagRef;
import static hprose.io.HproseTags.TagString;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.nio.ByteBuffer;
import java.util.TimeZone;

final class TimeZoneUnserializer implements HproseUnserializer {

    public final static TimeZoneUnserializer instance = new TimeZoneUnserializer();

    final static TimeZone readTimeZone(HproseReader reader, ByteBuffer buffer) throws IOException {
        TimeZone tz = TimeZone.getTimeZone(ValueReader.readString(buffer));
        reader.refer.set(tz);
        return tz;
    }

    final static TimeZone readTimeZone(HproseReader reader, InputStream stream) throws IOException {
        TimeZone tz = TimeZone.getTimeZone(ValueReader.readString(stream));
        reader.refer.set(tz);
        return tz;
    }

    private static TimeZone toTimeZone(Object obj) throws IOException {
        if (obj instanceof TimeZone) {
            return (TimeZone)obj;
        }
        if (obj instanceof char[]) {
            return TimeZone.getTimeZone(new String((char[])obj));
        }
        return TimeZone.getTimeZone(obj.toString());
    }

    final static TimeZone read(HproseReader reader, ByteBuffer buffer) throws IOException {
        int tag = buffer.get();
        switch (tag) {
            case TagNull:
            case TagEmpty: return null;
            case TagString: return readTimeZone(reader, buffer);
            case TagRef: return toTimeZone(reader.readRef(buffer));
            default: throw ValueReader.castError(reader.tagToString(tag), TimeZone.class);
        }
    }

    final static TimeZone read(HproseReader reader, InputStream stream) throws IOException {
        int tag = stream.read();
        switch (tag) {
            case TagNull:
            case TagEmpty: return null;
            case TagString: return readTimeZone(reader, stream);
            case TagRef: return toTimeZone(reader.readRef(stream));
            default: throw ValueReader.castError(reader.tagToString(tag), TimeZone.class);
        }
    }

    public final Object read(HproseReader reader, ByteBuffer buffer, Class<?> cls, Type type) throws IOException {
        return read(reader, buffer);
    }

    public final Object read(HproseReader reader, InputStream stream, Class<?> cls, Type type) throws IOException {
        return read(reader, stream);
    }

}

{'fraction_non_alphanumeric': 0.1412833930046819, 'fraction_numerical': 0.0016524373450839988, 'mean_word_length': 1.8151162790697675, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4891504', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1651, 'n_words': 411}