com.sun.xml.bind
Class GrammarImpl

java.lang.Object
  extended by com.sun.xml.bind.GrammarImpl
All Implemented Interfaces:
com.sun.msv.grammar.Grammar, java.io.Serializable

public class GrammarImpl
extends java.lang.Object
implements com.sun.msv.grammar.Grammar, java.io.Serializable

Implementation of the Grammar interface with "plugs" that allows a grammar to be connected to other grammars when assembled through the context path.

These classes will be freeze-dried to "bgm.ser", so they must be serializable.

This class also implements a trick to allow a large grammar to be serialized without causing a stack overflow error. This is done by modifying the ElementExp.contentModel field to Expression.nullSet in the serialized form. The correct references will be restored after the grammar is deserialized.

Since:
1.0
See Also:
Serialized Form

Nested Class Summary
static class GrammarImpl.Plug
          Inter-grammar connection that needs be bound.
 
Constructor Summary
GrammarImpl(com.sun.msv.grammar.ExpressionPool pool)
           
 
Method Summary
 void connect(com.sun.msv.grammar.Grammar[] others)
          Connect this grammar to other grammars.
 com.sun.msv.grammar.trex.ElementPattern createElement(com.sun.msv.grammar.NameClass nc, com.sun.msv.grammar.Expression contentModel)
          Creates a new ElementExp declaration inside this grammar.
 com.sun.msv.grammar.ExpressionPool getPool()
           
 com.sun.msv.grammar.Expression getTopLevel()
           
 void setPlugs(GrammarImpl.Plug[] plugs)
           
 void setTopLevel(com.sun.msv.grammar.Expression topLevel)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrammarImpl

public GrammarImpl(com.sun.msv.grammar.ExpressionPool pool)
Method Detail

setPlugs

public void setPlugs(GrammarImpl.Plug[] plugs)

setTopLevel

public void setTopLevel(com.sun.msv.grammar.Expression topLevel)

getTopLevel

public com.sun.msv.grammar.Expression getTopLevel()
Specified by:
getTopLevel in interface com.sun.msv.grammar.Grammar

getPool

public com.sun.msv.grammar.ExpressionPool getPool()
Specified by:
getPool in interface com.sun.msv.grammar.Grammar

connect

public void connect(com.sun.msv.grammar.Grammar[] others)
Connect this grammar to other grammars.


createElement

public com.sun.msv.grammar.trex.ElementPattern createElement(com.sun.msv.grammar.NameClass nc,
                                                             com.sun.msv.grammar.Expression contentModel)
Creates a new ElementExp declaration inside this grammar.

While the other ordinary ElementExps can be also used, this ElementExp allows the grammar to be serialized without too much recursion.