org.kohsuke.rngom.parse.host
Class SchemaBuilderHost

java.lang.Object
  extended by org.kohsuke.rngom.parse.host.Base
      extended by org.kohsuke.rngom.parse.host.SchemaBuilderHost
All Implemented Interfaces:
SchemaBuilder
Direct Known Subclasses:
CheckingSchemaBuilder

public class SchemaBuilderHost
extends Base
implements SchemaBuilder

Author:
Kohsuke Kawaguchi (kk@kohsuke.org)

Constructor Summary
SchemaBuilderHost(SchemaBuilder lhs, SchemaBuilder rhs)
           
 
Method Summary
 ParsedPattern annotate(ParsedPattern _p, Annotations _anno)
          Called when annotation is found right inside a pattern such as,
 ParsedPattern annotateAfter(ParsedPattern _p, ParsedElementAnnotation _e)
          Called when element annotation is found after a pattern.
 ParsedPattern commentAfter(ParsedPattern _p, CommentList _comments)
           
 ParsedPattern expandPattern(ParsedPattern _p)
          Called after all the parsing is done.
 NameClassBuilder getNameClassBuilder()
          Returns the NameClassBuilder, which is used to build name classes for this SchemaBuilder.
 Annotations makeAnnotations(CommentList _comments, Context context)
          Creates Annotations object to parse annotations on patterns.
 ParsedPattern makeAttribute(ParsedNameClass _nc, ParsedPattern _p, Location _loc, Annotations _anno)
           
 ParsedPattern makeChoice(List patterns, Location _loc, Annotations _anno)
           
 CommentList makeCommentList()
           
 DataPatternBuilder makeDataPatternBuilder(String datatypeLibrary, String type, Location _loc)
           
 ParsedPattern makeElement(ParsedNameClass _nc, ParsedPattern _p, Location _loc, Annotations _anno)
           
 ElementAnnotationBuilder makeElementAnnotationBuilder(String ns, String localName, String prefix, Location _loc, CommentList _comments, Context context)
           
 ParsedPattern makeEmpty(Location _loc, Annotations _anno)
           
 ParsedPattern makeErrorPattern()
           
 ParsedPattern makeExternalRef(Parseable current, String uri, String ns, Scope _scope, Location _loc, Annotations _anno)
           
 Grammar makeGrammar(Scope _parent)
           
 ParsedPattern makeGroup(List patterns, Location _loc, Annotations _anno)
           
 ParsedPattern makeInterleave(List patterns, Location _loc, Annotations _anno)
           
 ParsedPattern makeList(ParsedPattern _p, Location _loc, Annotations _anno)
           
 Location makeLocation(String systemId, int lineNumber, int columnNumber)
           
 ParsedPattern makeMixed(ParsedPattern _p, Location _loc, Annotations _anno)
           
 ParsedPattern makeNotAllowed(Location _loc, Annotations _anno)
           
 ParsedPattern makeOneOrMore(ParsedPattern _p, Location _loc, Annotations _anno)
           
 ParsedPattern makeOptional(ParsedPattern _p, Location _loc, Annotations _anno)
           
 ParsedPattern makeText(Location _loc, Annotations _anno)
           
 ParsedPattern makeValue(String datatypeLibrary, String type, String value, Context c, String ns, Location _loc, Annotations _anno)
           
 ParsedPattern makeZeroOrMore(ParsedPattern _p, Location _loc, Annotations _anno)
           
 boolean usesComments()
          If this SchemaBuilderis interested in actually parsing comments, this method returns true.
 
Methods inherited from class org.kohsuke.rngom.parse.host.Base
cast, cast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaBuilderHost

public SchemaBuilderHost(SchemaBuilder lhs,
                         SchemaBuilder rhs)
Method Detail

annotate

public ParsedPattern annotate(ParsedPattern _p,
                              Annotations _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
Throws:
BuildException

annotateAfter

public ParsedPattern annotateAfter(ParsedPattern _p,
                                   ParsedElementAnnotation _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
Throws:
BuildException

commentAfter

public ParsedPattern commentAfter(ParsedPattern _p,
                                  CommentList _comments)
                           throws BuildException
Specified by:
commentAfter in interface SchemaBuilder
Throws:
BuildException

expandPattern

public ParsedPattern expandPattern(ParsedPattern _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
Throws:
BuildException
IllegalSchemaException

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
Returns:
always return a non-null valid object. This method can (and probably should) always return the same object.
Throws:
BuildException

makeAnnotations

public Annotations makeAnnotations(CommentList _comments,
                                   Context context)
Description copied from interface: SchemaBuilder
Creates Annotations object to parse annotations on patterns.

Specified by:
makeAnnotations in interface SchemaBuilder
Returns:
must be non-null.

makeAttribute

public ParsedPattern makeAttribute(ParsedNameClass _nc,
                                   ParsedPattern _p,
                                   Location _loc,
                                   Annotations _anno)
                            throws BuildException
Specified by:
makeAttribute in interface SchemaBuilder
Throws:
BuildException

makeChoice

public ParsedPattern makeChoice(List patterns,
                                Location _loc,
                                Annotations _anno)
                         throws BuildException
Specified by:
makeChoice in interface SchemaBuilder
Throws:
BuildException

makeCommentList

public CommentList makeCommentList()
Specified by:
makeCommentList in interface SchemaBuilder

makeDataPatternBuilder

public DataPatternBuilder makeDataPatternBuilder(String datatypeLibrary,
                                                 String type,
                                                 Location _loc)
                                          throws BuildException
Specified by:
makeDataPatternBuilder in interface SchemaBuilder
Throws:
BuildException

makeElement

public ParsedPattern makeElement(ParsedNameClass _nc,
                                 ParsedPattern _p,
                                 Location _loc,
                                 Annotations _anno)
                          throws BuildException
Specified by:
makeElement in interface SchemaBuilder
Throws:
BuildException

makeElementAnnotationBuilder

public ElementAnnotationBuilder makeElementAnnotationBuilder(String ns,
                                                             String localName,
                                                             String prefix,
                                                             Location _loc,
                                                             CommentList _comments,
                                                             Context context)
Specified by:
makeElementAnnotationBuilder in interface SchemaBuilder

makeEmpty

public ParsedPattern makeEmpty(Location _loc,
                               Annotations _anno)
Specified by:
makeEmpty in interface SchemaBuilder

makeErrorPattern

public ParsedPattern makeErrorPattern()
Specified by:
makeErrorPattern in interface SchemaBuilder

makeExternalRef

public ParsedPattern makeExternalRef(Parseable current,
                                     String uri,
                                     String ns,
                                     Scope _scope,
                                     Location _loc,
                                     Annotations _anno)
                              throws BuildException,
                                     IllegalSchemaException
Specified by:
makeExternalRef in interface SchemaBuilder
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

makeGrammar

public Grammar makeGrammar(Scope _parent)
Specified by:
makeGrammar in interface SchemaBuilder
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.

makeGroup

public ParsedPattern makeGroup(List patterns,
                               Location _loc,
                               Annotations _anno)
                        throws BuildException
Specified by:
makeGroup in interface SchemaBuilder
Throws:
BuildException

makeInterleave

public ParsedPattern makeInterleave(List patterns,
                                    Location _loc,
                                    Annotations _anno)
                             throws BuildException
Specified by:
makeInterleave in interface SchemaBuilder
Throws:
BuildException

makeList

public ParsedPattern makeList(ParsedPattern _p,
                              Location _loc,
                              Annotations _anno)
                       throws BuildException
Specified by:
makeList in interface SchemaBuilder
Throws:
BuildException

makeLocation

public Location makeLocation(String systemId,
                             int lineNumber,
                             int columnNumber)
Specified by:
makeLocation in interface SchemaBuilder

makeMixed

public ParsedPattern makeMixed(ParsedPattern _p,
                               Location _loc,
                               Annotations _anno)
                        throws BuildException
Specified by:
makeMixed in interface SchemaBuilder
Throws:
BuildException

makeNotAllowed

public ParsedPattern makeNotAllowed(Location _loc,
                                    Annotations _anno)
Specified by:
makeNotAllowed in interface SchemaBuilder

makeOneOrMore

public ParsedPattern makeOneOrMore(ParsedPattern _p,
                                   Location _loc,
                                   Annotations _anno)
                            throws BuildException
Specified by:
makeOneOrMore in interface SchemaBuilder
Throws:
BuildException

makeZeroOrMore

public ParsedPattern makeZeroOrMore(ParsedPattern _p,
                                    Location _loc,
                                    Annotations _anno)
                             throws BuildException
Specified by:
makeZeroOrMore in interface SchemaBuilder
Throws:
BuildException

makeOptional

public ParsedPattern makeOptional(ParsedPattern _p,
                                  Location _loc,
                                  Annotations _anno)
                           throws BuildException
Specified by:
makeOptional in interface SchemaBuilder
Throws:
BuildException

makeText

public ParsedPattern makeText(Location _loc,
                              Annotations _anno)
Specified by:
makeText in interface SchemaBuilder

makeValue

public ParsedPattern makeValue(String datatypeLibrary,
                               String type,
                               String value,
                               Context c,
                               String ns,
                               Location _loc,
                               Annotations _anno)
                        throws BuildException
Specified by:
makeValue in interface SchemaBuilder
Throws:
BuildException

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


Copyright © 2011. All Rights Reserved.