Foundations Apex API Developer Reference

fferpcore.MessageDescriptionVisitor

global abstract class MessageDescriptionVisitor

A fferpcore.MessageDescriptionVisitor structure. This class is an implementation of the visitor design pattern. As a result, the implementation of these methods depends solely on the needs of the child class.

Methods

visit

global abstract Object visit(fferpcore.MessageDescription.ScalarNode scalarNode, Object args)

This method is used when our fferpcore.MessageDescriptionVisitor is interacting with a ScalarNode. This method is part of the visitor design pattern and, as a result, the implementation of such varies depending on the usage. This abstract method must be overridden by all classes extending fferpcore.MessageDescriptionVisitor

Input Parameters

Name Type Description
scalarNode fferpcore.MessageDescription.ScalarNode The node we want to interact with.
args Object An object storing data used by the visitor.

Return Value

This service returns an Object object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

/**
 * Only counts the leaf nodes.
 */
public class CounterVisitor extends fferpcore.MessageDescriptionVisitor
{
    public Integer count = 0;

    public override Object visit(fferpcore.MessageDescription.ScalarNode node, Object args)
    {
        count++;
    }

    public override Object visit(fferpcore.MessageDescription.MapNode mapNode, Object args)
    {
        for(fferpcore.MessageDescription.NamedNode namedNode : mapNode.getChildren())
        {
            namedNode.getNode().accept(this, null);
        }
    }
} 

fferpcore.MessageDescription.ScalarNode node = getNode(); //get a node from somewhere
CounterVisitor visitor = new CounterVisitor();
visitor.visit(node, null);
Integer numLeaves = visitor.count;

visit

global abstract Object visit(fferpcore.MessageDescription.MapNode mapNode, Object args)

This method is used when our fferpcore.MessageDescriptionVisitor is interacting with a MapNode. This method is part of the visitor design pattern and, as a result, the implementation of such varies depending on the usage. This abstract method must be overridden by all classes extending MessageDescriptionVisitor.

Input Parameters

Name Type Description
mapNode fferpcore.MessageDescription.MapNode The node we want to interact with.
args Object An object storing data used by the visitor.

Return Value

This service returns an Object object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

/**
 * Only counts the leaf nodes.
 */
public class CounterVisitor extends fferpcore.MessageDescriptionVisitor
{
    public Integer count = 0;

    public override Object visit(fferpcore.MessageDescription.ScalarNode node, Object args)
    {
        count++;
    }

    public override Object visit(fferpcore.MessageDescription.MapNode mapNode, Object args)
    {
        for(fferpcore.MessageDescription.NamedNode namedNode : mapNode.getChildren())
        {
            namedNode.getNode().accept(this, null);
        }
    }
} 

fferpcore.MessageDescription.MapNode node = getNode(); //get a node from somewhere
CounterVisitor visitor = new CounterVisitor();
visitor.visit(node, null);
Integer numLeaves = visitor.count;

visit

global virtual Object visit(fferpcore.MessageDescription.ListNode listNode, Object args)

This method is used when our fferpcore.MessageDescriptionVisitor is interacting with a ListNode. This method is part of the visitor design pattern and, as a result, the implementation of such varies depending on the usage. This abstract method must be overridden by all classes extending MessageDescriptionVisitor.

Input Parameters

Name Type Description
listNode fferpcore.MessageDescription.ListNode The node we want to interact with.
args Object An object storing data used by the visitor.

Return Value

This service returns an Object object.

© Copyright 2009–2020 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.