mulgara - semantic store

skip navigation

SHOW SITE NAV
fixed
fluid
straight

Built-in Visitor Pattern

JRDF nodes are implemented with a visitor pattern to provide an object oriented approach to node-type specific behaviour. Nodes implement the TypedNodeVisitable interface and classes that use the pattern implement the TypedNodeVisitor interface.

 

TypedNodeVisitable

Nodes implement the accept(TypedNodeVisitor visitor) method to call visitor.visitXXX(this), where XXX represents the node type. For example, visitBlankNode(this) is called by a BlankNode.

 

TypedNodeVisitor

TypedNodeVisitors implement three methods:

  1. visitBlankNode(BlankNode blankNode)
  2. visitLiteral(Literal literal)
  3. visitURIReference(URIReference uriReference)

When a TypedNodeVisitor calls accept(this) on a TypedNodeVisitable(Node), the TypedNodeVisitable calls the appropriate visitXXX() method, where XXX represents the Node type. The method names contain the node type to provide clarity for classes implementing the TypeNodeVisitor interface.

Valid XHTML 1.0 TransitionalValid CSS 3.0!