Sha256: 4d625ced6bd0e7deb758680a7d8a136b6135f904109d6145b500c73c24adedb1

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

package org.embulk.parser.jsonpath.cast;

import org.embulk.spi.DataException;
import org.embulk.spi.time.Timestamp;
import org.msgpack.value.Value;

public class JsonCast
{
    private JsonCast() {}

    private static String buildErrorMessage(String as, Value value)
    {
        return String.format("cannot cast Json to %s: \"%s\"", as, value);
    }

    public static boolean asBoolean(Value value) throws DataException
    {
        throw new DataException(buildErrorMessage("boolean", value));
    }

    public static long asLong(Value value) throws DataException
    {
        throw new DataException(buildErrorMessage("long", value));
    }

    public static double asDouble(Value value) throws DataException
    {
        throw new DataException(buildErrorMessage("double", value));
    }

    public static String asString(Value value) throws DataException
    {
        return value.toString();
    }

    public static Timestamp asTimestamp(Value value) throws DataException
    {
        throw new DataException(buildErrorMessage("timestamp", value));
    }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
embulk-parser-jsonpath-0.3.1 src/main/java/org/embulk/parser/jsonpath/cast/JsonCast.java
embulk-parser-jsonpath-0.3.0 src/main/java/org/embulk/parser/jsonpath/cast/JsonCast.java
embulk-parser-jsonpath-0.2.0 src/main/java/org/embulk/parser/jsonpath/cast/JsonCast.java
embulk-parser-jsonpath-0.1.3 src/main/java/org/embulk/parser/jsonpath/cast/JsonCast.java
embulk-parser-jsonpath-0.1.2 src/main/java/org/embulk/parser/jsonpath/cast/JsonCast.java
embulk-parser-jsonpath-0.1.1 src/main/java/org/embulk/parser/jsonpath/cast/JsonCast.java
embulk-parser-jsonpath-0.1.0 src/main/java/org/embulk/parser/jsonpath/cast/JsonCast.java