Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.togethersoft.openapi.rwi
Class RwiVisitorAdapter

public class RwiVisitorAdapter
implements RwiVisitor

`RwiVisitorAdapter` class extends `RwiVisitor` functionality by providing two additional methods `visitContainer` and `visitElement`.

These methods are used to perform the same actions for all kinds of containers or elements. For example, the `visitContainer` method performs the same action for any container (which can be node, diagram or package), while `visitNode` method perfoms a special action for a node, which can be different from the action required for a diagram or a package:

     public class CoolVisitor extends RwiVisitorAdapter{
      public Object visitNode(RwiNode node){
         IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "An action for RwiNode."); // specific  action for a node
         return visitContainer(node);  //the same action for all kinds of containers
      }
      public Object visitPackage(RwiPackage rwiPackage){
         IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "An action for RwiPackage.");  // specific  action for a package
         return null; // for example, let's suppose for packages we do not need any additional actions;
      }
      public Object visitContainer(RwiContainer container){
         IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "An action for all RwiContainers.");
         return visitElement(container);  //the same action for all kinds of elements
      }
      public Object visitElement(RwiElement element){
         IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "An action for all RwiElements.");
         return null;
      }
      //since visitor methods for diagrams, members and links are not overridden, they will call visitContainer method (see below)
     }

In this class methods do nothing, here are the bodies of methods:

     public Object visitNode(RwiNode node){ return visitContainer(node); }
     public Object visitMember(RwiMember member){ return visitElement(member); }
     public Object visitContainer(RwiContainer container){ return visitElement(container); }
     public Object visitPackage(RwiPackage rwiPackage){ return visitContainer(rwiPackage); }
     public Object visitDiagram(RwiDiagram diagram){ return visitContainer(diagram); }
     public Object visitLink(RwiLink link){ return visitElement(link); }
     public Object visitElement(RwiElement element){ return null; }

See an example of a more sophisticated visitor in the script tutorial in the togetherx\script\sample directory under your installation.

Author:
  TogetherSoft
See Also: RwiElement.accept(com.togethersoft.openapi.rwi.RwiVisitor), RwiVisitor

Method Summary
`Object` | `visitContainer(RwiContainer container)`
`Object` | `visitDiagram(RwiDiagram diagram)`
`Object` | `visitElement(RwiElement element)`
`Object` | `visitLink(RwiLink link)`
`Object` | `visitMember(RwiMember member)`
`Object` | `visitNode(RwiNode node)`
`Object` | `visitPackage(RwiPackage rwiPackage)`

Method Detail

### visitContainer

    public Object visitContainer(RwiContainer container)

  Parameters:
    container - the `RwiContainer` which is the subject for the actions defined in this method
  Returns: `null`

### visitDiagram

    public Object visitDiagram(RwiDiagram diagram)

  Parameters:
    diagram - the `RwiDiagram` which is the subject for the actions defined in this method
  Returns: `null`

### visitElement

    public Object visitElement(RwiElement element)

  Parameters:
    element - the `RwiElement` which is the subject for the actions defined in this method
  Returns: `null`

### visitLink

    public Object visitLink(RwiLink link)

  Parameters:
    link - the `RwiLink` which is the subject for the actions defined in this method
  Returns: `null`

### visitMember

    public Object visitMember(RwiMember member)

  Parameters:
    member - the `RwiMember` which is the subject for the actions defined in this method
  Returns: `null`

### visitNode

    public Object visitNode(RwiNode node)

  Parameters:
    node - the `RwiNode` the subject for the actions
  Returns: `null`

### visitPackage

    public Object visitPackage(RwiPackage rwiPackage)

  Parameters:
    rwiPackage - the `RwiPackage` which is the subject for the actions defined in this method
  Returns: `null`

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD