Examples of WalkedPath


Examples of com.bazaarvoice.jolt.common.WalkedPath

        Map<String,Object> output = new HashMap<String,Object>();

        // Create a root LiteralPathElement so that # is useful at the root level
        LiteralPathElement rootLpe = new LiteralPathElement( ROOT_KEY );
        WalkedPath walkedPath = new WalkedPath();
        walkedPath.add( input, rootLpe );

        rootSpec.apply( ROOT_KEY, input, walkedPath, output );

        return output.get( ROOT_KEY );
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.common.WalkedPath

    public void calculateOutputTest_refsOnly() {

        MatchablePathElement pe1 = (MatchablePathElement) ShiftrSpec.parseSingleKeyLHS( "tuna-*-marlin-*" );
        MatchablePathElement pe2 = (MatchablePathElement) ShiftrSpec.parseSingleKeyLHS( "rating-*" );

        LiteralPathElement lpe = pe1.match( "tuna-marlin", new WalkedPath() );
        AssertJUnit.assertNull( lpe );

        lpe = pe1.match( "tuna-A-marlin-AAA", new WalkedPath() );
        AssertJUnit.assertEquals"tuna-A-marlin-AAA", lpe.getRawKey() );
        AssertJUnit.assertEquals"tuna-A-marlin-AAA", lpe.getSubKeyRef( 0 ) );
        AssertJUnit.assertEquals( 3, lpe.getSubKeyCount() );
        AssertJUnit.assertEquals( "A" , lpe.getSubKeyRef( 1 ) );
        AssertJUnit.assertEquals( "AAA" , lpe.getSubKeyRef( 2 ) );

        LiteralPathElement lpe2 = pe2.match( "rating-BBB", new WalkedPath( null, lpe ) );
        AssertJUnit.assertEquals"rating-BBB", lpe2.getRawKey() );
        AssertJUnit.assertEquals"rating-BBB", lpe2.getSubKeyRef( 0 ) );
        AssertJUnit.assertEquals( 2, lpe2.getSubKeyCount() );
        AssertJUnit.assertEquals( "BBB" , lpe2.getSubKeyRef( 1 ) );

        ShiftrWriter outputPath = new ShiftrWriter( "&(1,2).&.value" );
        WalkedPath twoSteps = new WalkedPath( null, lpe );
        twoSteps.add( null, lpe2 );
        {
            EvaluatablePathElement outputElement = (EvaluatablePathElement) outputPath.get( 0 );
            String evaledLeafOutput = outputElement.evaluate( twoSteps );
            AssertJUnit.assertEquals( "AAA", evaledLeafOutput );
        }
View Full Code Here

Examples of com.bazaarvoice.jolt.common.WalkedPath

        // simulate Shiftr LHS specs
        MatchablePathElement pe1 = (MatchablePathElement) ShiftrSpec.parseSingleKeyLHS( "tuna-*-marlin-*" );
        MatchablePathElement pe2 = (MatchablePathElement) ShiftrSpec.parseSingleKeyLHS( "rating-*" );

        // match them against some data to get LiteralPathElements with captured values
        LiteralPathElement lpe = pe1.match( "tuna-2-marlin-3", new WalkedPath() );
        AssertJUnit.assertEquals( "2" , lpe.getSubKeyRef( 1 ) );
        AssertJUnit.assertEquals( "3" , lpe.getSubKeyRef( 2 ) );

        LiteralPathElement lpe2 = pe2.match( "rating-BBB", new WalkedPath( null, lpe ) );
        AssertJUnit.assertEquals( 2, lpe2.getSubKeyCount() );
        AssertJUnit.assertEquals( "BBB" , lpe2.getSubKeyRef( 1 ) );

        // Build an write path path
        ShiftrWriter shiftrWriter = new ShiftrWriter( "tuna[&(1,1)].marlin[&(1,2)].&(0,1)" );

        AssertJUnit.assertEquals( 5, shiftrWriter.size() );
        AssertJUnit.assertEquals( "tuna.[&(1,1)].marlin.[&(1,2)].&(0,1)", shiftrWriter.getCanonicalForm() );

        // Evaluate the write path against the LiteralPath elements we build above ( like Shiftr does )
        WalkedPath twoSteps = new WalkedPath( null, lpe );
        twoSteps.add( null, lpe2 );
        List<String> stringPath = shiftrWriter.evaluate( twoSteps );

        AssertJUnit.assertEquals( "tuna",   stringPath.get( 0 ) );
        AssertJUnit.assertEquals( "2",      stringPath.get( 1 ) );
        AssertJUnit.assertEquals( "marlin", stringPath.get( 2 ) );
View Full Code Here

Examples of com.bazaarvoice.jolt.common.WalkedPath

     * the transform
     */
    @Override
    public Object transform( Object input ) {

        rootSpec.apply( ROOT_KEY, input, new WalkedPath(), null );

        return input;
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.common.WalkedPath

        Map<String,Object> output = new HashMap<String,Object>();

        // Create a root LiteralPathElement so that # is useful at the root level
        LiteralPathElement rootLpe = new LiteralPathElement( ROOT_KEY );
        WalkedPath walkedPath = new WalkedPath();
        walkedPath.add( rootLpe );

        rootSpec.apply( ROOT_KEY, input, walkedPath, output );

        return output.get( ROOT_KEY );
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.common.WalkedPath

     * the transform
     */
    @Override
    public Object transform( Object input ) {

        rootSpec.apply( ROOT_KEY, input, new WalkedPath(), null );

        return input;
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.common.WalkedPath

        Map<String,Object> output = new HashMap<String,Object>();

        // Create a root LiteralPathElement so that # is useful at the root level
        LiteralPathElement rootLpe = new LiteralPathElement( ROOT_KEY );
        WalkedPath walkedPath = new WalkedPath();
        walkedPath.add( rootLpe );

        rootSpec.apply( ROOT_KEY, input, walkedPath, output );

        return output.get( ROOT_KEY );
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.common.WalkedPath

     * the transform
     */
    @Override
    public Object transform( Object input ) {

        rootSpec.apply( ROOT_KEY, input, new WalkedPath(), null );

        return input;
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.common.WalkedPath

        Map<String,Object> output = new HashMap<String,Object>();

        // Create a root LiteralPathElement so that # is useful at the root level
        LiteralPathElement rootLpe = new LiteralPathElement( ROOT_KEY );
        WalkedPath walkedPath = new WalkedPath();
        walkedPath.add( rootLpe );

        rootSpec.apply( ROOT_KEY, input, walkedPath, output );

        return output.get( ROOT_KEY );
    }
View Full Code Here

Examples of com.bazaarvoice.jolt.common.WalkedPath

        Map<String,Object> output = new HashMap<String,Object>();

        // Create a root LiteralPathElement so that # is useful at the root level
        LiteralPathElement rootLpe = new LiteralPathElement( ROOT_KEY );
        WalkedPath walkedPath = new WalkedPath();
        walkedPath.add( rootLpe );

        rootSpec.apply( ROOT_KEY, input, walkedPath, output );

        return output.get( ROOT_KEY );
    }
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.