Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/trapezium/vrml/grammar/NodeBodyRule.java


1   /*
2    * @(#)NodeBodyRule.java
3    *
4    * Copyright (c) 1998 by Trapezium Development LLC.  All Rights Reserved.
5    *
6    * The information in this file is the property of Trapezium Development LLC
7    * and may be used only in accordance with the terms of the license granted
8    * by Trapezium.
9    *
10   */
11  package com.trapezium.vrml.grammar;
12  
13  import com.trapezium.parse.TokenEnumerator;
14  import com.trapezium.vrml.node.Node;
15  import com.trapezium.vrml.Scene;
16  
17  /**
18   *  Creates the scene graph component representing the body of a node.
19   *  
20   *  Grammar handled by "Build" method:
21   *  <PRE>
22   *  nodeBody ::=
23   *         nodeBodyElement |
24   *         nodeBodyElement nodeBody |
25   *         empty ;
26   *  </PRE>    
27   *  @author          Johannes N. Johannsen
28   *  @version         1.12, 2 April 1998, make class public
29   *  @version         1.1, 18 Dec 1997
30   *
31   *  @since           1.0
32   */
33  public class NodeBodyRule {
34      PROTORule protoRule;
35      ROUTERule routeRule = new ROUTERule();
36      FieldFactory fieldFactory;
37      
38      public NodeBodyRule( NodeRule nodeRule ) {
39          fieldFactory = new FieldFactory( nodeRule );
40          protoRule = nodeRule.getPROTORule();
41      }
42  
43    /** Build onto a Node by adding on individual NodeGuts */
44    public void Build( int tokenOffset, TokenEnumerator v, Scene scene, Node parent ) {
45      GrammarRule.Enter( "NodeBodyRule.Build" );
46      if ( v.sameAs( tokenOffset, "PROTO" )) {
47        protoRule.Build( tokenOffset, v, scene, parent );
48      } else if ( v.sameAs( tokenOffset, "ROUTE" )) {
49        routeRule.Build( tokenOffset, v, scene, parent );
50      } else {
51          parent.addChild( fieldFactory.CreateInstance( tokenOffset, v, scene, parent ));
52      }
53      GrammarRule.Exit( "NodeBodyRule.Build" );
54    }
55  }