Package com.bazaarvoice.jolt.common.pathelement

Examples of com.bazaarvoice.jolt.common.pathelement.PathElement


        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


        ShiftrWriter path = new ShiftrWriter( "ugc.photos-&1-bob[&2]" );

        AssertJUnit.assertEquals( 3, path.size() );
        // 0
            PathElement pe = path.get( 0 );
            AssertJUnit.assertTrue( "First pathElement should be a literal one.", pe instanceof LiteralPathElement );
        }

        { // 1
            PathElement pe = path.get( 1 );
            AssertJUnit.assertTrue( "Second pathElement should be a literal one.", pe instanceof AmpPathElement );

            AmpPathElement refElement = (AmpPathElement) pe;

            AssertJUnit.assertEquals( 3, refElement.getTokens().size() );

            {
                AssertJUnit.assertTrue( refElement.getTokens().get(0) instanceof String );
                AssertJUnit.assertEquals( "photos-", (String) refElement.getTokens().get(0) );
            }
            {
                AssertJUnit.assertTrue( refElement.getTokens().get(1) instanceof AmpReference );
                AmpReference ref = (AmpReference) refElement.getTokens().get(1);
                AssertJUnit.assertEquals( "&(1,0)", ref.getCanonicalForm() );
                AssertJUnit.assertEquals( 1, ref.getPathIndex() );
                AssertJUnit.assertEquals( 0, ref.getKeyGroup() );
            }
            {
                AssertJUnit.assertTrue( refElement.getTokens().get(2) instanceof String );
                AssertJUnit.assertEquals( "-bob", (String) refElement.getTokens().get(2) );
            }
        }

        { // 2
            PathElement pe = path.get( 2 );
            AssertJUnit.assertTrue( "Third pathElement should be a literal one.", pe instanceof ArrayPathElement );

            ArrayPathElement arrayElement = (ArrayPathElement) pe;
            AssertJUnit.assertEquals( "[&(2,0)]", arrayElement.getCanonicalForm() );
        }
View Full Code Here

        }

        @Override
        public int compare( CardinalitySpec a, CardinalitySpec b ) {

            PathElement ape = a.pathElement;
            PathElement bpe = b.pathElement;

            int aa = orderMap.get( ape.getClass() );
            int bb = orderMap.get( bpe.getClass() );

            int elementsEqual = aa < bb ? -1 : aa == bb ? 0 : 1;

            if ( elementsEqual != 0 ) {
                return elementsEqual;
            }

            // At this point we have two PathElements of the same type.
            String acf = ape.getCanonicalForm();
            String bcf = bpe.getCanonicalForm();

            int alen = acf.length();
            int blen = bcf.length();

            // Sort them by length, with the longest (most specific) being first
View Full Code Here

        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

        }

        @Override
        public int compare( CardinalitySpec a, CardinalitySpec b ) {

            PathElement ape = a.pathElement;
            PathElement bpe = b.pathElement;

            int aa = orderMap.get( ape.getClass() );
            int bb = orderMap.get( bpe.getClass() );

            int elementsEqual = aa < bb ? -1 : aa == bb ? 0 : 1;

            if ( elementsEqual != 0 ) {
                return elementsEqual;
            }

            // At this point we have two PathElements of the same type.
            String acf = ape.getCanonicalForm();
            String bcf = bpe.getCanonicalForm();

            int alen = acf.length();
            int blen = bcf.length();

            // Sort them by length, with the longest (most specific) being first
View Full Code Here

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

            String[] subkeys = canonicalKey.split( "\\." );

            List<PathElement> subElements = parsesubkeys ); // at this point each sub key should be a valid key, so just recall parse

            for ( int index = 0; index < subElements.size() - 1; index++ ) {
                PathElement v = subElements.get( index );
                if ( v instanceof ArrayPathElement ) {
                    throw new SpecException( "Array [..] must be the last thing in the key, was:" + key );
                }
            }
View Full Code Here

        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

        }

        @Override
        public int compare( ShiftrSpec a, ShiftrSpec b ) {

            PathElement ape = a.pathElement;
            PathElement bpe = b.pathElement;

            int aa = orderMap.get( ape.getClass() );
            int bb = orderMap.get( bpe.getClass() );

            int elementsEqual =  aa < bb ? -1 : aa == bb ? 0 : 1;

            if ( elementsEqual != 0 ) {
                return elementsEqual;
            }

            // At this point we have two PathElements of the same type.
            String acf = ape.getCanonicalForm();
            String bcf = bpe.getCanonicalForm();

            int alen = acf.length();
            int blen = bcf.length();

            // Sort them by length, with the longest (most specific) being first
View Full Code Here

        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

TOP

Related Classes of com.bazaarvoice.jolt.common.pathelement.PathElement

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.