Examples of SpecException


Examples of com.bazaarvoice.jolt.exception.SpecException

            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

Examples of com.bazaarvoice.jolt.exception.SpecException

    }

    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

Examples of com.bazaarvoice.jolt.exception.SpecException

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

Examples of com.bazaarvoice.jolt.exception.SpecException

        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

Examples of com.bazaarvoice.jolt.exception.SpecException

    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

Examples of com.bazaarvoice.jolt.exception.SpecException

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

Examples of com.bazaarvoice.jolt.exception.SpecException

    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

Examples of com.bazaarvoice.jolt.exception.SpecException

     * @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

Examples of com.bazaarvoice.jolt.exception.SpecException

                    try {
                        upLevel = Integer.valueOf( sb.toString() );
                    }
                    catch ( NumberFormatException nfe ) {
                        // I don't know how this exception would get thrown, as all the chars were checked by isDigit, but oh well
                        throw new SpecException( "@ path element with non/mixed numeric key is not valid, key=" + originalKey );
                    }

                    return new TransposePathElement( originalKey, upLevel, meat.substring( index + 1 ) );
                }
                else if ( Character.isDigit( c ) ) {
                    sb.append( c );
                }
                else {
                    throw new SpecException( "@ path element with non/mixed numeric key is not valid, key=" + originalKey );
                }
            }

            // if we got out of the for loop, then the whole thing was a number.
            return new TransposePathElement( originalKey, Integer.valueOf( sb.toString() ), null );
View Full Code Here

Examples of com.bazaarvoice.jolt.exception.SpecException

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

        if ( key.charAt( 0 ) != '[' || key.charAt( key.length() - 1 ) != ']') {
            throw new SpecException( "Invalid ArrayPathElement key:" + key );
        }

        ArrayPathType apt;
        PathReference r = null;
        String aI = "";

        if ( key.length() == 2 ) {
            apt = ArrayPathType.AUTO_EXPAND;
            canonicalForm = "[]";
        }
        else {
            String meat = key.substring( 1, key.length() - 1 )// trim the [ ]

            if ( AmpReference.TOKEN.equals( meat.charAt( 0 ) ) ) {
                r = new AmpReference( meat );
                apt = ArrayPathType.REFERENCE;

                canonicalForm = "[" + r.getCanonicalForm() + "]";
            }
            else if ( HashReference.TOKEN.equals( meat.charAt( 0 ) ) ) {
                r = new HashReference( meat );
                apt = ArrayPathType.HASH;

                canonicalForm = "[" + r.getCanonicalForm() + "]";
            }
            else {
                try {
                    Integer.parseInt( meat );
                    apt = ArrayPathType.EXPLICIT_INDEX;

                    canonicalForm = "[" + meat + "]";
                    aI = meat;
                }
                catch ( NumberFormatException nfe ){
                    throw new SpecException( "Unable to parse explicit array index of:" + meat + " from key:" + key );
                }
            }
        }

        arrayPathType = apt;
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.