org.kohsuke.rngom.digested
Class DSchemaBuilderImpl

java.lang.Object
  extended by org.kohsuke.rngom.digested.DSchemaBuilderImpl
All Implemented Interfaces:
SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>

public class DSchemaBuilderImpl
extends Object
implements SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>

Parses as Parseable into a DPattern.

Author:
Kohsuke Kawaguchi (kk@kohsuke.org)

Constructor Summary
DSchemaBuilderImpl()
           
 
Method Summary
 DPattern annotate(DPattern p, org.kohsuke.rngom.digested.Annotation anno)
          Called when annotation is found right inside a pattern such as,
 DPattern annotateAfter(DPattern p, org.kohsuke.rngom.digested.ElementWrapper e)
          Called when element annotation is found after a pattern.
 DPattern commentAfter(DPattern p, org.kohsuke.rngom.digested.CommentListImpl comments)
           
 DPattern expandPattern(DPattern p)
          Called after all the parsing is done.
 NameClassBuilder getNameClassBuilder()
          Returns the NameClassBuilder, which is used to build name classes for this SchemaBuilder.
 org.kohsuke.rngom.digested.Annotation makeAnnotations(org.kohsuke.rngom.digested.CommentListImpl comments, Context context)
          Creates Annotations object to parse annotations on patterns.
 DPattern makeAttribute(NameClass nc, DPattern p, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 DPattern makeChoice(List<DPattern> patterns, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 org.kohsuke.rngom.digested.CommentListImpl makeCommentList()
           
 DataPatternBuilder makeDataPatternBuilder(String datatypeLibrary, String type, LocatorImpl loc)
           
 DPattern makeElement(NameClass nc, DPattern p, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 ElementAnnotationBuilder makeElementAnnotationBuilder(String ns, String localName, String prefix, LocatorImpl loc, org.kohsuke.rngom.digested.CommentListImpl comments, Context context)
           
 DPattern makeEmpty(LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 DPattern makeErrorPattern()
           
 DPattern makeExternalRef(Parseable current, String uri, String ns, Scope<DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl> scope, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 Grammar makeGrammar(Scope parent)
           
 DPattern makeGroup(List<DPattern> patterns, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 DPattern makeInterleave(List<DPattern> patterns, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 DPattern makeList(DPattern p, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 LocatorImpl makeLocation(String systemId, int lineNumber, int columnNumber)
           
 DPattern makeMixed(DPattern p, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 DPattern makeNotAllowed(LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 DPattern makeOneOrMore(DPattern p, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 DPattern makeOptional(DPattern p, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 DPattern makeText(LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 DPattern makeValue(String datatypeLibrary, String type, String value, Context c, String ns, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 DPattern makeZeroOrMore(DPattern p, LocatorImpl loc, org.kohsuke.rngom.digested.Annotation anno)
           
 boolean usesComments()
          If this SchemaBuilderis interested in actually parsing comments, this method returns true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DSchemaBuilderImpl

public DSchemaBuilderImpl()
Method Detail

getNameClassBuilder

public NameClassBuilder getNameClassBuilder()
                                     throws BuildException
Description copied from interface: SchemaBuilder
Returns the NameClassBuilder, which is used to build name classes for this SchemaBuilder. The NameClasses that are built will then be fed into this SchemaBuilderto further build RELAX NG patterns.

Specified by:
getNameClassBuilder in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Returns:
always return a non-null valid object. This method can (and probably should) always return the same object.
Throws:
BuildException

makeChoice

public DPattern makeChoice(List<DPattern> patterns,
                           LocatorImpl loc,
                           org.kohsuke.rngom.digested.Annotation anno)
                    throws BuildException
Specified by:
makeChoice in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeInterleave

public DPattern makeInterleave(List<DPattern> patterns,
                               LocatorImpl loc,
                               org.kohsuke.rngom.digested.Annotation anno)
                        throws BuildException
Specified by:
makeInterleave in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeGroup

public DPattern makeGroup(List<DPattern> patterns,
                          LocatorImpl loc,
                          org.kohsuke.rngom.digested.Annotation anno)
                   throws BuildException
Specified by:
makeGroup in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeOneOrMore

public DPattern makeOneOrMore(DPattern p,
                              LocatorImpl loc,
                              org.kohsuke.rngom.digested.Annotation anno)
                       throws BuildException
Specified by:
makeOneOrMore in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeZeroOrMore

public DPattern makeZeroOrMore(DPattern p,
                               LocatorImpl loc,
                               org.kohsuke.rngom.digested.Annotation anno)
                        throws BuildException
Specified by:
makeZeroOrMore in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeOptional

public DPattern makeOptional(DPattern p,
                             LocatorImpl loc,
                             org.kohsuke.rngom.digested.Annotation anno)
                      throws BuildException
Specified by:
makeOptional in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeList

public DPattern makeList(DPattern p,
                         LocatorImpl loc,
                         org.kohsuke.rngom.digested.Annotation anno)
                  throws BuildException
Specified by:
makeList in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeMixed

public DPattern makeMixed(DPattern p,
                          LocatorImpl loc,
                          org.kohsuke.rngom.digested.Annotation anno)
                   throws BuildException
Specified by:
makeMixed in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeEmpty

public DPattern makeEmpty(LocatorImpl loc,
                          org.kohsuke.rngom.digested.Annotation anno)
Specified by:
makeEmpty in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>

makeNotAllowed

public DPattern makeNotAllowed(LocatorImpl loc,
                               org.kohsuke.rngom.digested.Annotation anno)
Specified by:
makeNotAllowed in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>

makeText

public DPattern makeText(LocatorImpl loc,
                         org.kohsuke.rngom.digested.Annotation anno)
Specified by:
makeText in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>

makeAttribute

public DPattern makeAttribute(NameClass nc,
                              DPattern p,
                              LocatorImpl loc,
                              org.kohsuke.rngom.digested.Annotation anno)
                       throws BuildException
Specified by:
makeAttribute in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeElement

public DPattern makeElement(NameClass nc,
                            DPattern p,
                            LocatorImpl loc,
                            org.kohsuke.rngom.digested.Annotation anno)
                     throws BuildException
Specified by:
makeElement in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeDataPatternBuilder

public DataPatternBuilder makeDataPatternBuilder(String datatypeLibrary,
                                                 String type,
                                                 LocatorImpl loc)
                                          throws BuildException
Specified by:
makeDataPatternBuilder in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeValue

public DPattern makeValue(String datatypeLibrary,
                          String type,
                          String value,
                          Context c,
                          String ns,
                          LocatorImpl loc,
                          org.kohsuke.rngom.digested.Annotation anno)
                   throws BuildException
Specified by:
makeValue in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeGrammar

public Grammar makeGrammar(Scope parent)
Specified by:
makeGrammar in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Parameters:
parent - The parent scope. null if there's no parent scope. For example, if the complete document looks like the following:

      <grammar>
        <start><element name="root"><empty/></element></start>
      </grammar>
      
Then when the outer-most Grammar is created, it will receive the null parent.

annotate

public DPattern annotate(DPattern p,
                         org.kohsuke.rngom.digested.Annotation anno)
                  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 interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

annotateAfter

public DPattern annotateAfter(DPattern p,
                              org.kohsuke.rngom.digested.ElementWrapper e)
                       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 interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

commentAfter

public DPattern commentAfter(DPattern p,
                             org.kohsuke.rngom.digested.CommentListImpl comments)
                      throws BuildException
Specified by:
commentAfter in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException

makeExternalRef

public DPattern makeExternalRef(Parseable current,
                                String uri,
                                String ns,
                                Scope<DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl> scope,
                                LocatorImpl loc,
                                org.kohsuke.rngom.digested.Annotation anno)
                         throws BuildException,
                                IllegalSchemaException
Specified by:
makeExternalRef in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.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. See SchemaBuilder.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 interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>

makeAnnotations

public org.kohsuke.rngom.digested.Annotation makeAnnotations(org.kohsuke.rngom.digested.CommentListImpl comments,
                                                             Context context)
Description copied from interface: SchemaBuilder
Creates Annotations object to parse annotations on patterns.

Specified by:
makeAnnotations in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Returns:
must be non-null.

makeElementAnnotationBuilder

public ElementAnnotationBuilder makeElementAnnotationBuilder(String ns,
                                                             String localName,
                                                             String prefix,
                                                             LocatorImpl loc,
                                                             org.kohsuke.rngom.digested.CommentListImpl comments,
                                                             Context context)
Specified by:
makeElementAnnotationBuilder in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>

makeCommentList

public org.kohsuke.rngom.digested.CommentListImpl makeCommentList()
Specified by:
makeCommentList in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>

makeErrorPattern

public DPattern makeErrorPattern()
Specified by:
makeErrorPattern in interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>

usesComments

public boolean usesComments()
Description copied from interface: SchemaBuilder
If this SchemaBuilderis 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 interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>

expandPattern

public DPattern expandPattern(DPattern p)
                       throws BuildException,
                              IllegalSchemaException
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 interface SchemaBuilder<NameClass,DPattern,org.kohsuke.rngom.digested.ElementWrapper,LocatorImpl,org.kohsuke.rngom.digested.Annotation,org.kohsuke.rngom.digested.CommentListImpl>
Throws:
BuildException
IllegalSchemaException


Copyright © 2011. All Rights Reserved.