fferpcore.MessageDescriptionVisitorglobal inherited sharing 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
visitglobal 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
Return ValueThis 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; visitglobal 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
Return ValueThis 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; visitglobal 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
Return ValueThis service returns an Object object. |