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
Interface RwiVisitor

All Known Implementing Classes:
  RwiVisitorAdapter

public interface RwiVisitor

An implementation of a Visitor pattern from GoF "Design Patterns" book. It performs different actions upon different kinds of `RwiElement`s. Desired actions have to be written in corresponding methods (for example, actions for nodes in `visitNode`, actions for members in `visitMember` etc). They are called up from element's `accept` method which will run the right method dependning on the kind of this element.

Every method returns a result of its actions. It can be `null` if it is not required from this visitor to return any information.

For example, here is a visitor which outputs different things regarding to the type of an element called a visitor via `accept` method:

     public class NameVisitor implements RwiVisitor{
      public Object visitNode(RwiNode node){
         IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Visiting a node."); // specific  action for a node
         return null;
      }
      public Object visitMember(RwiMember member){
         IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Visiting a member.");   //specific  action for a member
         return null;
      }
      public Object visitPackage(RwiPackage rwiPackage){
         IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Visiting a package."); // specific  action for a package
         return null;
      }
      public Object visitDiagram(RwiDiagram diagram){
         IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Visiting a diagram."); // specific  action for a diagram
         return null;
      }
      public Object visitLink(RwiLink link){
         IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Visiting a link."); // specific  action for a link
         return null;
      }
     }

Now, this will make Together do different things for different `RwiElement`s without any calculation of a RwiProperty.SHAPE_TYPE property:

     NameVisitor nameVisitor = new NameVisitor();
     for (int i=0;i<myArrayOfRwiElements.length;i++){
        myArrayOfRwiElements[i].accept(nameVisitor);
     }

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

Method Summary
`Object` | `visitDiagram(RwiDiagram diagram)` Performs an action upon `RwiDiagram`.
`Object` | `visitLink(RwiLink link)` Performs an action upon `RwiLink`.
`Object` | `visitMember(RwiMember member)` Performs an action upon `RwiMember`.
`Object` | `visitNode(RwiNode node)` Performs an action upon `RwiNode`.
`Object` | `visitPackage(RwiPackage rwiPackage)` Performs an action upon `RwiPackage`.

Method Detail

### visitDiagram

    public Object visitDiagram(RwiDiagram diagram)

  Performs an action upon `RwiDiagram`.
  Parameters:
    diagram - the `RwiDiagram` which is the subject for the action
  Returns: a visitor-specific result

### visitLink

    public Object visitLink(RwiLink link)

  Performs an action upon `RwiLink`.
  Parameters:
    link - the `RwiLink` which is the subject for the action
  Returns: a visitor-specific result

### visitMember

    public Object visitMember(RwiMember member)

  Performs an action upon `RwiMember`.
  Parameters:
    member - the `RwiMember` which is the subject for the action
  Returns: a visitor-specific result

### visitNode

    public Object visitNode(RwiNode node)

  Performs an action upon `RwiNode`.
  Parameters:
    node - the `RwiNode` which is the subject for the action
  Returns: a visitor-specific result

### visitPackage

    public Object visitPackage(RwiPackage rwiPackage)

  Performs an action upon `RwiPackage`.
  Parameters:
    rwiPackage - the `RwiPackage` which is the subject for the action
  Returns: a visitor-specific result

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