Examples of LiteralPathElement


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

    public Object transform( Object input ) {

        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 );
View Full Code Here

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

        } else if (numOfStars == 2) {
            return Arrays.<PathElement>asList(new StarDoublePathElement(key));
        } else if (numOfStars > 2) {
            return Arrays.<PathElement>asList(new StarRegexPathElement(key));
        } else {
            return Arrays.<PathElement>asList(new LiteralPathElement(key));
        }
    }
View Full Code Here

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

    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 );
        {
View Full Code Here

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

        // 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() );
View Full Code Here

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

     * @return true if this this spec "handles" the inputkey such that no sibling specs need to see it
     */
    @Override
    public boolean apply( String inputKey, Object input, WalkedPath walkedPath, Map<String,Object> output ){

        LiteralPathElement thisLevel = pathElement.match( inputKey, walkedPath );
        if ( thisLevel == null ) {
            return false;
        }

        Object data;
        boolean realChild = false// by default don't block further Shiftr matches

        if ( this.pathElement instanceof DollarPathElement ||
             this.pathElement instanceof HashPathElement ) {

            // The data is already encoded in the thisLevel object created by the pathElement.match called above
            data = thisLevel.getCanonicalForm();
        }
        else if ( this.pathElement instanceof AtPathElement ) {

            // The data is our parent's data
            data = input;
View Full Code Here

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

     * @return true if this this spec "handles" the inputkey such that no sibling specs need to see it
     */
    @Override
    public boolean apply( String inputKey, Object input, WalkedPath walkedPath, Object parentContainer ) {

        LiteralPathElement thisLevel = getMatch( inputKey, walkedPath );
        if ( thisLevel == null ) {
            return false;
        }
        performCardinalityAdjustment( inputKey, input, walkedPath, (Map) parentContainer, thisLevel );
        return true;
View Full Code Here

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

     *
     * @return null if no work was done, otherwise returns the re-parented data
     */
    public Object applyToParentContainer ( String inputKey, Object input, WalkedPath walkedPath, Object parentContainer ) {

        LiteralPathElement thisLevel = getMatch( inputKey, walkedPath );
        if ( thisLevel == null ) {
            return null;
        }
        return performCardinalityAdjustment( inputKey, input, walkedPath, (Map) parentContainer, thisLevel );
    }
View Full Code Here

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

     *
     * @return true if this this spec "handles" the inputkey such that no sibling specs need to see it
     */
    @Override
    public boolean apply( String inputKey, Object input, WalkedPath walkedPath, Object parentContainer ) {
        LiteralPathElement thisLevel = pathElement.match( inputKey, walkedPath );
        if ( thisLevel == null ) {
            return false;
        }

        walkedPath.add( input, thisLevel );
View Full Code Here

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

            else {
                return Arrays.<PathElement>asList( new StarRegexPathElement( key ) );
            }
        }
        else {
            return Arrays.<PathElement>asList( new LiteralPathElement( key ) );
        }
    }
View Full Code Here

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

    public Object transform( Object input ) {

        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 );
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.