Examples of SpecException


Examples of com.bazaarvoice.jolt.exception.SpecException

        if ( operationNameObj == null ) {
            return null;
        }
        else if ( operationNameObj instanceof String) {
            if ( StringTools.isBlank((String) operationNameObj) ) {
                throw new SpecException( "JOLT Chainr '" + ChainrEntry.OPERATION_KEY + "' should not be blank" + getErrorMessageIndexSuffix() );
            }
            return (String) operationNameObj;
        }
        else {
            throw new SpecException( "JOLT Chainr needs a '" + ChainrEntry.OPERATION_KEY + "' of type String" + getErrorMessageIndexSuffix() );
        }
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.exception.SpecException

        try {
            Class opClass = Class.forName( operationClassName );

            if ( Chainr.class.isAssignableFrom( opClass ) ) {
                throw new SpecException( "Attempt to nest Chainr inside itself" + getErrorMessageIndexSuffix() );
            }

            if ( ! JoltTransform.class.isAssignableFrom( opClass ) )
            {
                throw new SpecException( "JOLT Chainr class:" + operationClassName + " does not implement the JoltTransform interface" + getErrorMessageIndexSuffix() );
            }

            @SuppressWarnings( "unchecked" ) // We know it is some type of Transform due to the check above
            Class<? extends JoltTransform> transformClass = (Class<? extends JoltTransform>) opClass;

            return transformClass;

        } catch ( ClassNotFoundException e ) {
            throw new SpecException( "JOLT Chainr could not find transform class:" + operationClassName + getErrorMessageIndexSuffix(), e );
        }
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.exception.SpecException

     */
    @Inject
    public Shiftr( Object spec ) {

        if ( spec == null ){
            throw new SpecException( "Shiftr expected a spec of Map type, got 'null'." );
        }
        if ( ! ( spec instanceof Map ) ) {
            throw new SpecException( "Shiftr expected a spec of Map type, got " + spec.getClass().getSimpleName() );
        }

        rootSpec = new ShiftrCompositeSpec( ROOT_KEY, (Map<String, Object>) spec );
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.exception.SpecException

    private final RemovrCompositeSpec rootSpec;

    @Inject
    public Removr( Object spec ) {
        if ( spec == null ){
            throw new SpecException( "Removr expected a spec of Map type, got 'null'." );
        }
        if ( ! ( spec instanceof Map ) ) {
            throw new SpecException( "Removr expected a spec of Map type, got " + spec.getClass().getSimpleName() );
        }
        rootSpec = new RemovrCompositeSpec( ROOT_KEY, (Map<String, Object>) spec );
        this.spec = (Map<String, Object>) spec;
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.exception.SpecException

    public ShiftrSpec(String rawJsonKey) {

        PathElement pe = parseSingleKeyLHS( rawJsonKey );

        if ( ! ( pe instanceof MatchablePathElement ) ) {
            throw new SpecException( "Spec LHS key=" + rawJsonKey + " is not a valid LHS key." );
        }

        this.pathElement = (MatchablePathElement) pe;
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.exception.SpecException

    public RemovrSpec(String rawJsonKey) {
        List<PathElement> pathElements = parse(rawJsonKey);

        if (pathElements.size() != 1) {
            throw new SpecException("Removr invalid LHS:" + rawJsonKey + " can not contain '.'");
        }

        PathElement pe = pathElements.get(0);
        if (!(pe instanceof MatchablePathElement)) {
            throw new SpecException("Spec LHS key=" + rawJsonKey + " is not a valid LHS key.");
        }

        this.pathElement = (MatchablePathElement) pe;
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.exception.SpecException

        }
        else if ( key.startsWith("@") || key.contains( "@(" ) ) {
            return TransposePathElement.parse( key );
        }
        else if ( key.contains( "@" ) ) {
            throw new SpecException( "Invalid key:" + key  + " can not have an @ other than at the front." );
        }
        else if ( key.contains("$") ) {
            return new DollarPathElement( key );
        }
        else if ( key.contains("[") ) {

            if ( StringTools.countMatches(key, "[") != 1 || StringTools.countMatches(key, "]") != 1 ) {
                throw new SpecException( "Invalid key:" + key + " has too many [] references.");
            }

            return new ArrayPathElement( key );
        }
        else if ( key.contains( "&" ) ) {

            if ( key.contains("*") )
            {
                throw new SpecException("Can't mix * with & ) ");
            }
            return new AmpPathElement( key );
        }
        else if ( "*".equals( key ) ) {
            return new StarAllPathElement( key );
View Full Code Here

Examples of com.bazaarvoice.jolt.exception.SpecException

        if ( c == '(' ) {
            isParensAt = true;
            atParensCount++;
        }
        else if ( c == '.' ) {
            throw new SpecException( "Unable to parse dotNotation, invalid TransposePathElement : " + dotNotationRef );
        }

        sb.append( c );

        while( iter.hasNext() ) {
            c = iter.next();
            sb.append( c );

            // Parsing "@(a.b.[&2])"
            if ( isParensAt ) {
                if ( c == '(' ) {
                    throw new SpecException( "Unable to parse dotNotation, too many open parens '(' : " + dotNotationRef );
                }
                else if ( c == ')' ) {
                    atParensCount--;
                }

                if ( atParensCount == 0 ) {
                    return sb.toString();
                }
                else if ( atParensCount < 0 ) {
                    throw new SpecException( "Unable to parse dotNotation, specifically the '@()' part : " + dotNotationRef );
                }
            }
            // Parsing "@abc.def
            else if ( c == '.' ) {
                return sb.toString();
            }
        }

        // if we got to the end of the String and we have mismatched parenthesis throw an exception.
        if ( isParensAt && atParensCount != 0 ) {
            throw new SpecException( "Invalid @() pathElement from : " + dotNotationRef );
        }
        // Parsing "@abc"
        return sb.toString();
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.exception.SpecException

        ArrayList<PathElement> paths = new ArrayList<PathElement>();

        for( String key: keys ) {
            PathElement path = parseSingleKeyLHS( key );
            if ( path instanceof AtPathElement ) {
                throw new SpecException( "'.@.' is not valid on the RHS: " + refDotNotation );
            }
            paths.add( path );
        }

        return paths;
View Full Code Here

Examples of com.bazaarvoice.jolt.exception.SpecException

        Map<String, ShiftrSpec> literals = new LinkedHashMap<String, ShiftrSpec>();
        ArrayList<ShiftrSpec> computed = new ArrayList<ShiftrSpec>();

        // self check
        if ( pathElement instanceof AtPathElement ) {
            throw new SpecException( "@ Shiftr key, can not have children." );
        }
        if ( pathElement instanceof DollarPathElement ) {
            throw new SpecException( "$ Shiftr key, can not have children." );
        }

        List<ShiftrSpec> children = createChildren( spec );

        if ( children.isEmpty() ) {
            throw new SpecException( "Shift ShiftrSpec format error : ShiftrSpec line with empty {} as value is not valid." );
        }

        for ( ShiftrSpec child : children ) {
            if ( child.pathElement instanceof LiteralPathElement ) {
                literals.put( child.pathElement.getRawKey(), child );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.