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

Quick Search    Search Deep

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


1   /*
2    * @(#)InterfaceDeclarationRule.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.Scene;
15  import com.trapezium.vrml.node.Node;
16  import com.trapezium.vrml.fields.Field;
17  
18  /**
19   *  Creates an interface field scene graph component.
20   *  
21   *  The "interfaceDeclaration" handles exposedField, field, eventIn,
22   *  and eventOut interface declarations.  field, eventIn, and eventOut
23   *  declarations are handled by the RestrictedInterfaceDeclarationRule.
24   *
25   *  Grammar handled by "Build" method:
26   *  <PRE>
27   *  interfaceDeclaration:
28   *
29   *    restrictedInterfaceDeclaration
30   *    exposedField fieldType fieldId fieldValue
31   *  </PRE>    
32   *  @author          Johannes N. Johannsen
33   *  @version         1.12, 18 Mar 1998, added Table 7 base profile warning
34   *  @version         1.1, 18 Dec 1997
35   *
36   *  @since           1.0
37   */
38  class InterfaceDeclarationRule {
39      RestrictedInterfaceDeclarationRule restrictedInterfaceDeclarationRule;
40      FieldFactory fieldFactory;
41      
42      InterfaceDeclarationRule( NodeRule nodeRule ) {
43          fieldFactory = new FieldFactory( nodeRule );
44          restrictedInterfaceDeclarationRule = new RestrictedInterfaceDeclarationRule( nodeRule );
45      }
46      
47      /** Create an interface  declaration and add it to the scene graph
48       *
49       *  @param tokenOffset   first token of the interface declaration
50       *  @param v    token enumerator containing file text
51       *  @param scene   scene that contains the interface
52       *  @param parent  immediate parent of the interface declaration.
53       */
54    void Build( int tokenOffset, TokenEnumerator v, Scene scene, Node parent ) {
55      GrammarRule.Enter( "InterfaceDeclarationRule.Build" );
56  
57      if ( v.sameAs( tokenOffset, "exposedField" )) {
58          Field f = fieldFactory.CreateDeclaration( VRML97.exposedField, v, scene, parent );
59          if ( f != null ) {
60            parent.addChild( f );
61            parent.addInterface( f );
62            if ( parent.getInterfaceCount( f.getInterfaceType() ) == ( Table7.InterfaceLimit + 1 )) {
63                f.setError( "Nonconformance, base profile " + VRML97.getInterfaceTypeStr( f.getInterfaceType() ) + " limit of " + Table7.InterfaceLimit + " exceeded here" );
64            }
65          }
66      } else {
67        restrictedInterfaceDeclarationRule.Build( tokenOffset, v, scene, parent );
68      }
69      GrammarRule.Exit( "InterfaceDeclarationRule.Build" );
70    }
71  }