Package com.sun.msv.generator
Class Generator
- java.lang.Object
-
- com.sun.msv.generator.Generator
-
- All Implemented Interfaces:
ExpressionVisitorVoid
public class Generator extends java.lang.Object implements ExpressionVisitorVoid
generates an XML DOM instance that conforms to the given schema.
-
-
Field Summary
Fields Modifier and Type Field Description private AttributeExp[]attributeDeclsall AttributeExps in the grammar.private intdepthcurrent nest level (depth of elements).private org.w3c.dom.DocumentdomDocprivate ElementExp[]elementDeclsall ElementExps in the grammar.private booleanerrorGeneratedthis flag is set to true once an error is generated.private java.util.SetidrefsText nodes of IDREFs that should be "patched" by IDs.private java.util.SetidsID tokens that are usedprivate org.w3c.dom.Nodenodecurrent generated nodeprivate GeneratorOptionoptsgeneration parametersprivate ExpressionPoolpool
-
Constructor Summary
Constructors Modifier Constructor Description protectedGenerator(Expression exp, org.w3c.dom.Document emptyDoc, GeneratorOption opts)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancutBack()returns true if generator should cut back.static voidgenerate(Expression exp, org.w3c.dom.Document emptyDoc)generates instance by using default settings.static voidgenerate(Expression exp, org.w3c.dom.Document emptyDoc, GeneratorOption opts)generates instance by custom settings.protected StringPairgenerateTypo(StringPair pair)generates 'typo'.private java.util.VectorgetChildren(BinaryExp exp)enumerates children of BinaryExp into a vector.protected ContextProviderImplgetContext()private StringPairgetName(NameClass nc)generaets a name that satisfies given NameClassprivate voidnoteError(java.lang.String error)annotate DOM by adding a comment that an error is generated.voidonAnyString()voidonAttribute(AttributeExp exp)voidonChoice(ChoiceExp cp)voidonConcur(ConcurExp exp)voidonData(DataExp exp)voidonElement(ElementExp exp)voidonEpsilon()voidonInterleave(InterleaveExp ip)voidonList(ListExp exp)voidonMixed(MixedExp exp)voidonNullSet()voidonOneOrMore(OneOrMoreExp exp)voidonOther(OtherExp exp)voidonRef(ReferenceExp exp)voidonSequence(SequenceExp exp)voidonValue(ValueExp exp)voidonZeroOrMore(OneOrMoreExp exp)
-
-
-
Field Detail
-
opts
private final GeneratorOption opts
generation parameters
-
pool
private final ExpressionPool pool
-
domDoc
private final org.w3c.dom.Document domDoc
-
node
private org.w3c.dom.Node node
current generated node
-
depth
private int depth
current nest level (depth of elements).
-
errorGenerated
private boolean errorGenerated
this flag is set to true once an error is generated.
-
ids
private final java.util.Set ids
ID tokens that are used
-
idrefs
private final java.util.Set idrefs
Text nodes of IDREFs that should be "patched" by IDs.
-
elementDecls
private final ElementExp[] elementDecls
all ElementExps in the grammar.
-
attributeDecls
private final AttributeExp[] attributeDecls
all AttributeExps in the grammar.
-
-
Constructor Detail
-
Generator
protected Generator(Expression exp, org.w3c.dom.Document emptyDoc, GeneratorOption opts)
-
-
Method Detail
-
cutBack
protected boolean cutBack()
returns true if generator should cut back.
-
generate
public static void generate(Expression exp, org.w3c.dom.Document emptyDoc)
generates instance by using default settings.
-
generate
public static void generate(Expression exp, org.w3c.dom.Document emptyDoc, GeneratorOption opts)
generates instance by custom settings.
-
noteError
private void noteError(java.lang.String error)
annotate DOM by adding a comment that an error is generated.
-
onEpsilon
public void onEpsilon()
- Specified by:
onEpsilonin interfaceExpressionVisitorVoid
-
onNullSet
public void onNullSet()
- Specified by:
onNullSetin interfaceExpressionVisitorVoid
-
onSequence
public void onSequence(SequenceExp exp)
- Specified by:
onSequencein interfaceExpressionVisitorVoid
-
onInterleave
public void onInterleave(InterleaveExp ip)
- Specified by:
onInterleavein interfaceExpressionVisitorVoid
-
onChoice
public void onChoice(ChoiceExp cp)
- Specified by:
onChoicein interfaceExpressionVisitorVoid
-
onMixed
public void onMixed(MixedExp exp)
- Specified by:
onMixedin interfaceExpressionVisitorVoid
-
onList
public void onList(ListExp exp)
- Specified by:
onListin interfaceExpressionVisitorVoid
-
onRef
public void onRef(ReferenceExp exp)
- Specified by:
onRefin interfaceExpressionVisitorVoid
-
onOther
public void onOther(OtherExp exp)
- Specified by:
onOtherin interfaceExpressionVisitorVoid
-
onAttribute
public void onAttribute(AttributeExp exp)
- Specified by:
onAttributein interfaceExpressionVisitorVoid
-
onElement
public void onElement(ElementExp exp)
- Specified by:
onElementin interfaceExpressionVisitorVoid
-
onAnyString
public void onAnyString()
- Specified by:
onAnyStringin interfaceExpressionVisitorVoid
-
onOneOrMore
public void onOneOrMore(OneOrMoreExp exp)
- Specified by:
onOneOrMorein interfaceExpressionVisitorVoid
-
onZeroOrMore
public void onZeroOrMore(OneOrMoreExp exp)
-
onValue
public void onValue(ValueExp exp)
- Specified by:
onValuein interfaceExpressionVisitorVoid
-
onData
public void onData(DataExp exp)
- Specified by:
onDatain interfaceExpressionVisitorVoid
-
onConcur
public void onConcur(ConcurExp exp)
- Specified by:
onConcurin interfaceExpressionVisitorVoid
-
getContext
protected ContextProviderImpl getContext()
-
getName
private StringPair getName(NameClass nc)
generaets a name that satisfies given NameClass
-
getChildren
private java.util.Vector getChildren(BinaryExp exp)
enumerates children of BinaryExp into a vector.
-
generateTypo
protected StringPair generateTypo(StringPair pair)
generates 'typo'.
-
-