Sha256: 657693721ff96be5b8f956ec050b9248ea7279b98a8ba4e0b8d6c414cc8eb3b1

Contents?: true

Size: 1.85 KB

Versions: 2

Compression:

Stored size: 1.85 KB

Contents

package org.embulk.filter.column;

import com.dena.analytics.jsonpathcompiler.expressions.path.ArrayIndexOperation;
import com.dena.analytics.jsonpathcompiler.expressions.path.ArrayPathToken;
import com.dena.analytics.jsonpathcompiler.expressions.path.FunctionPathToken;
import com.dena.analytics.jsonpathcompiler.expressions.path.PathToken;
import com.dena.analytics.jsonpathcompiler.expressions.path.PredicatePathToken;
import com.dena.analytics.jsonpathcompiler.expressions.path.ScanPathToken;
import org.embulk.config.ConfigException;

public class PathTokenUtil
{
    public static void assertSupportedPathToken(PathToken pathToken, String path)
    {
        if (pathToken instanceof ArrayPathToken) {
            ArrayIndexOperation arrayIndexOperation = ((ArrayPathToken) pathToken).getArrayIndexOperation();
            assertSupportedArrayPathToken(arrayIndexOperation, path);
        }
        else if (pathToken instanceof ScanPathToken) {
            throw new ConfigException(String.format("scan path token is not supported \"%s\"", path));
        }
        else if (pathToken instanceof FunctionPathToken) {
            throw new ConfigException(String.format("function path token is not supported \"%s\"", path));
        }
        else if (pathToken instanceof PredicatePathToken) {
            throw new ConfigException(String.format("predicate path token is not supported \"%s\"", path));
        }
    }

    public static void assertSupportedArrayPathToken(ArrayIndexOperation arrayIndexOperation, String path)
    {
        if (arrayIndexOperation == null) {
            throw new ConfigException(String.format("Array Slice Operation is not supported \"%s\"", path));
        }
        else if (!arrayIndexOperation.isSingleIndexOperation()) {
            throw new ConfigException(String.format("Multi Array Indexes is not supported \"%s\"", path));
        }
    }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
embulk-filter-column-0.6.0.pre2 src/main/java/org/embulk/filter/column/PathTokenUtil.java
embulk-filter-column-0.6.0.pre1 src/main/java/org/embulk/filter/column/PathTokenUtil.java