Package com.bazaarvoice.jolt.exception

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


        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

            for ( Object dotNotation : rhsList ) {
                writers.add( parseOutputDotNotation( dotNotation ) );
            }
        }
        else {
            throw new SpecException( "Invalid Shiftr spec RHS.  Should be map, string, or array of strings.  Spec in question : " + rhs );
        }

        shiftrWriters = Collections.unmodifiableList( writers );
    }
View Full Code Here

    }

    private static ShiftrWriter parseOutputDotNotation( Object rawObj ) {

        if ( ! ( rawObj instanceof String ) ) {
            throw new SpecException( "Invalid Shiftr spec, RHS should be a String or array of Strings.   Value in question : " + rawObj );
        }

        // Prepend "root" to each output path.
        // This is needed for the "identity" transform, eg if we are just supposed to put the input into the output
        //  what key do we put it under?
View Full Code Here

        try {
            cardinalityRelationship = CardinalityRelationship.valueOf( rhs.toString() );
        }
        catch( Exception e ) {
            throw new SpecException( "Invalid Cardinality type :" + rhs.toString(), e );
        }
    }
View Full Code Here

        specialChild = null;

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

        List<CardinalitySpec> children = createChildren( spec );

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

        for ( CardinalitySpec child : children ) {
            literals.put( child.pathElement.getRawKey(), child );

            if ( child.pathElement instanceof LiteralPathElement ) {
                literals.put( child.pathElement.getRawKey(), child );
            }
            // special is it is "@"
            else if ( child.pathElement instanceof AtPathElement ) {
                if ( child instanceof CardinalityLeafSpec ) {
                    specialChild = (CardinalityLeafSpec) child;
                } else {
                    throw new SpecException( "@ CardinalityTransform key, can not have children." );
                }
            } else {   // star
                computed.add( child );
            }
        }
View Full Code Here

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

        if ( pathElements.size() != 1 ){
            throw new SpecException( "CardinalityTransform 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

public class AtPathElement extends BasePathElement implements MatchablePathElement {
    public AtPathElement( String key ) {
        super(key);

        if ( ! "@".equals( key ) ) {
            throw new SpecException( "'References Input' key '@', can only be a single '@'.  Offending key : " + key );
        }
    }
View Full Code Here

    public HashPathElement( String key ) {
        super(key);

        if ( StringTools.isBlank( key ) ) {
            throw new SpecException( "HashPathElement cannot have empty String as input." );
        }

        if ( ! key.startsWith( "#" ) ) {
            throw new SpecException( "LHS # should start with a # : " + key );
        }

        if ( key.length() <= 1 ) {
            throw new SpecException( "HashPathElement input is too short : " + key );
        }


        if ( key.charAt( 1 ) == '(' ) {
            if ( key.charAt( key.length() -1 ) == ')' ) {
                keyValue = key.substring( 2, key.length() -1 );
            }
            else {
                throw new SpecException( "HashPathElement, mismatched parens : " + key );
            }
        }
        else {
            keyValue = key.substring( 1 );
        }
View Full Code Here

     * @return a TransposePathElement
     */
    public static TransposePathElement parse( String key ) {

        if ( key == null || key.length() < 2 ) {
            throw new SpecException( "'Transpose Input' key '@', can not be null or of length 1.  Offending key : " + key );
        }
        if ( '@' != key.charAt( 0 ) ) {
            throw new SpecException( "'Transpose Input' key must start with an '@'.  Offending key : " + key );
        }

        // Strip off the leading '@' as we don't need it anymore.
        String meat = key.substring( 1 );

        if ( meat.contains( "@" ) ) {
            throw new SpecException( "@ pathElement can not contain a nested @." );
        }
        if ( meat.contains( "*" ) || meat.contains( "[]" ) ) {
            throw new SpecException( "'Transpose Input' can not contain expansion wildcards (* and []).  Offending key : " + key );
        }

        // Check to see if the key is wrapped by parens
        if ( meat.startsWith( "(" ) ) {
            if ( meat.endsWith( ")" ) ) {
                meat = meat.substring( 1, meat.length() - 1 );
            }
            else {
                throw new SpecException( "@ path element that starts with '(' must have a matching ')'.  Offending key : " + key );
            }
        }

        return innerParse( key, meat );
    }
View Full Code Here

TOP

Related Classes of com.bazaarvoice.jolt.exception.SpecException

Copyright © 2018 www.massapicom. 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.