Class SchemaBuilderImpl
- java.lang.Object
-
- com.sun.tools.txw2.builder.relaxng.SchemaBuilderImpl
-
- All Implemented Interfaces:
SchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
public final class SchemaBuilderImpl extends Object implements SchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
Builds a model from a RELAX NG grammar.- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description SchemaBuilderImpl(JCodeModel codeModel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Leaf
annotate(Leaf leaf, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Called when annotation is found right inside a pattern such as,Leaf
annotateAfter(Leaf leaf, ParsedElementAnnotation parsedElementAnnotation)
Called when element annotation is found after a pattern.Leaf
commentAfter(Leaf leaf, CommentListImpl commentList)
Leaf
expandPattern(Leaf leaf)
Called after all the parsing is done.NameClassBuilder
getNameClassBuilder()
Returns theNameClassBuilder
, which is used to build name classes for thisSchemaBuilder
.com.sun.tools.txw2.builder.relaxng.AnnotationsImpl
makeAnnotations(CommentListImpl commentList, Context context)
CreatesAnnotations
object to parse annotations on patterns.Leaf
makeAttribute(NameClass nameClass, Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Leaf
makeChoice(List<Leaf> leaves, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
CommentListImpl
makeCommentList()
DataPatternBuilder
makeDataPatternBuilder(String datatypeLibrary, String type, LocatorImpl locator)
Leaf
makeElement(NameClass nameClass, Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
ElementAnnotationBuilder<Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
makeElementAnnotationBuilder(String ns, String localName, String prefix, LocatorImpl locator, CommentListImpl commentList, Context context)
Leaf
makeEmpty(LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Leaf
makeErrorPattern()
Leaf
makeExternalRef(Parseable current, String uri, String ns, Scope<Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl> scope, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Grammar<Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
makeGrammar(Scope<Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl> scope)
Leaf
makeGroup(List<Leaf> leaves, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Leaf
makeInterleave(List<Leaf> leaves, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Leaf
makeList(Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
LocatorImpl
makeLocation(String systemId, int lineNumber, int columnNumber)
Leaf
makeMixed(Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Leaf
makeNotAllowed(LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Leaf
makeOneOrMore(Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Leaf
makeOptional(Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Leaf
makeText(LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Leaf
makeValue(String datatypeLibrary, String type, String value, Context c, String ns, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
Leaf
makeZeroOrMore(Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
boolean
usesComments()
If thisSchemaBuilder
is interested in actually parsing comments, this method returns true.
-
-
-
Constructor Detail
-
SchemaBuilderImpl
public SchemaBuilderImpl(JCodeModel codeModel)
-
-
Method Detail
-
expandPattern
public Leaf expandPattern(Leaf leaf) throws BuildException
Description copied from interface:SchemaBuilder
Called after all the parsing is done.This hook typically allows as
SchemaBuilder
to expand notAllowed (if it's following the simplification as in the spec.)- Specified by:
expandPattern
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
getNameClassBuilder
public NameClassBuilder getNameClassBuilder() throws BuildException
Description copied from interface:SchemaBuilder
Returns theNameClassBuilder
, which is used to build name classes for thisSchemaBuilder
. TheNameClass
es that are built will then be fed into thisSchemaBuilder
to further build RELAX NG patterns.- Specified by:
getNameClassBuilder
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Returns:
- always return a non-null valid object. This method can (and probably should) always return the same object.
- Throws:
BuildException
-
makeChoice
public Leaf makeChoice(List<Leaf> leaves, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeChoice
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeInterleave
public Leaf makeInterleave(List<Leaf> leaves, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeInterleave
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeGroup
public Leaf makeGroup(List<Leaf> leaves, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeGroup
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeOneOrMore
public Leaf makeOneOrMore(Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeOneOrMore
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeZeroOrMore
public Leaf makeZeroOrMore(Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeZeroOrMore
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeOptional
public Leaf makeOptional(Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeOptional
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeList
public Leaf makeList(Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeList
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeMixed
public Leaf makeMixed(Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeMixed
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeEmpty
public Leaf makeEmpty(LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
- Specified by:
makeEmpty
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
-
makeNotAllowed
public Leaf makeNotAllowed(LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
- Specified by:
makeNotAllowed
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
-
makeText
public Leaf makeText(LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations)
- Specified by:
makeText
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
-
makeAttribute
public Leaf makeAttribute(NameClass nameClass, Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeAttribute
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeElement
public Leaf makeElement(NameClass nameClass, Leaf leaf, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeElement
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeDataPatternBuilder
public DataPatternBuilder makeDataPatternBuilder(String datatypeLibrary, String type, LocatorImpl locator) throws BuildException
- Specified by:
makeDataPatternBuilder
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeValue
public Leaf makeValue(String datatypeLibrary, String type, String value, Context c, String ns, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
- Specified by:
makeValue
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeGrammar
public Grammar<Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl> makeGrammar(Scope<Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl> scope)
- Specified by:
makeGrammar
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Parameters:
scope
- The parent scope. null if there's no parent scope. For example, if the complete document looks like the following:
Then when the outer-most<grammar> <start><element name="root"><empty/></element></start> </grammar>
Grammar
is created, it will receive thenull
parent.
-
annotate
public Leaf annotate(Leaf leaf, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException
Description copied from interface:SchemaBuilder
Called when annotation is found right inside a pattern such as,<element name="foo"> <!-- this becomes 'P' --> <foreign:annotation /> <!-- this becomes 'A' --> ... </element>
- Specified by:
annotate
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
annotateAfter
public Leaf annotateAfter(Leaf leaf, ParsedElementAnnotation parsedElementAnnotation) throws BuildException
Description copied from interface:SchemaBuilder
Called when element annotation is found after a pattern. such as,<element name="foo"> <empty /> <!-- this becomes 'P' --> <foreign:annotation /> <!-- this becomes 'E' --> </element>
- Specified by:
annotateAfter
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
makeErrorPattern
public Leaf makeErrorPattern()
- Specified by:
makeErrorPattern
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
-
usesComments
public boolean usesComments()
Description copied from interface:SchemaBuilder
If thisSchemaBuilder
is interested in actually parsing comments, this method returns true.Returning false allows the schema parser to speed up the processing by skiping comment-related handlings.
- Specified by:
usesComments
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
-
makeExternalRef
public Leaf makeExternalRef(Parseable current, String uri, String ns, Scope<Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl> scope, LocatorImpl locator, com.sun.tools.txw2.builder.relaxng.AnnotationsImpl annotations) throws BuildException, IllegalSchemaException
- Specified by:
makeExternalRef
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Parameters:
current
- Current grammar that we are parsing. This is what contains externalRef.scope
- The parent scope. null if there's no parent scope. SeeSchemaBuilder.makeGrammar(Scope)
for more details about when this parameter can be null.- Throws:
BuildException
IllegalSchemaException
-
makeLocation
public LocatorImpl makeLocation(String systemId, int lineNumber, int columnNumber)
- Specified by:
makeLocation
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
-
makeAnnotations
public com.sun.tools.txw2.builder.relaxng.AnnotationsImpl makeAnnotations(CommentListImpl commentList, Context context)
Description copied from interface:SchemaBuilder
CreatesAnnotations
object to parse annotations on patterns.- Specified by:
makeAnnotations
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Returns:
- must be non-null.
-
makeElementAnnotationBuilder
public ElementAnnotationBuilder<Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl> makeElementAnnotationBuilder(String ns, String localName, String prefix, LocatorImpl locator, CommentListImpl commentList, Context context)
- Specified by:
makeElementAnnotationBuilder
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
-
makeCommentList
public CommentListImpl makeCommentList()
- Specified by:
makeCommentList
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
-
commentAfter
public Leaf commentAfter(Leaf leaf, CommentListImpl commentList) throws BuildException
- Specified by:
commentAfter
in interfaceSchemaBuilder<NameClass,Leaf,ParsedElementAnnotation,LocatorImpl,com.sun.tools.txw2.builder.relaxng.AnnotationsImpl,CommentListImpl>
- Throws:
BuildException
-
-