org.webmacro.directive
Class DirectiveBuilder

java.lang.Object
  |
  +--org.webmacro.directive.DirectiveBuilder
All Implemented Interfaces:
Builder, DirectiveArgs

public final class DirectiveBuilder
extends java.lang.Object
implements Builder, DirectiveArgs

DirectiveBuilder manages the building of directives. It is created by the parser, which populates it with the directive arguments, and the DirectiveBuilder.build() method calls the build() method for the appropriate directive.

Author:
Brian Goetz

Constructor Summary
DirectiveBuilder(DirectiveDescriptor desc)
           
 
Method Summary
 java.lang.Object build(BuildContext bc)
          Build the directive.
 java.lang.Object getArg(int argId)
          Retrieve the argument whose id is the specified id.
 java.lang.Object getArg(int argId, BuildContext bc)
          Retrieve the argument whose id is the specified id, and if it is a Builder, build it with the specified build context.
 java.lang.String getName()
          Get the name this directive was registered as
 ArgsHolder[] getRepeatingSubdirective(int subdId)
          Retrieves an array of ArgsHolders for the associated subdirective so that the subdirective arguments can be retrieved.
 ArgsHolder getSubdirective(int subdId)
          Retrieves the ArgsHolder for the associated subdirective so that the subdirective arguments can be retrieved.
 int getSubdirectiveCount(int subdId)
          Find out how many subdirectives of the specified id were present.
 DirectiveArgs newSubdirective(int subdId)
          Create a new subdirective of the specified id and create an ArgsHolder for its arguments.
 void setArg(int argId, java.lang.Object arg)
          Set the argument whose id is the specified id.
 boolean subdirectiveOk(int subdId)
          Check to see if the specified subdirective is OK at this point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectiveBuilder

public DirectiveBuilder(DirectiveDescriptor desc)
Method Detail

getArg

public java.lang.Object getArg(int argId)
                        throws BuildException
Retrieve the argument whose id is the specified id.
Specified by:
getArg in interface DirectiveArgs

getArg

public java.lang.Object getArg(int argId,
                               BuildContext bc)
                        throws BuildException
Retrieve the argument whose id is the specified id, and if it is a Builder, build it with the specified build context.
Specified by:
getArg in interface DirectiveArgs

getSubdirectiveCount

public int getSubdirectiveCount(int subdId)
                         throws BuildException
Find out how many subdirectives of the specified id were present.

setArg

public void setArg(int argId,
                   java.lang.Object arg)
            throws BuildException
Set the argument whose id is the specified id. If the argument has already been set, it is overwritten. Generally not used by directives, only used by the parser.
Specified by:
setArg in interface DirectiveArgs

newSubdirective

public DirectiveArgs newSubdirective(int subdId)
                              throws BuildException
Create a new subdirective of the specified id and create an ArgsHolder for its arguments. Not used by directives.

subdirectiveOk

public boolean subdirectiveOk(int subdId)
                       throws BuildException
Check to see if the specified subdirective is OK at this point. The only reason it wouldn't be is because we've already got one and its not a repeating subdirective

getSubdirective

public ArgsHolder getSubdirective(int subdId)
                           throws BuildException
Retrieves the ArgsHolder for the associated subdirective so that the subdirective arguments can be retrieved. Only valid if the specified subdirective is not repeating.

getRepeatingSubdirective

public ArgsHolder[] getRepeatingSubdirective(int subdId)
                                      throws BuildException
Retrieves an array of ArgsHolders for the associated subdirective so that the subdirective arguments can be retrieved. Only valid if the specified subdirective is repeating.

build

public java.lang.Object build(BuildContext bc)
                       throws BuildException
Build the directive. Calls the build() method of the directive.
Specified by:
build in interface Builder

getName

public java.lang.String getName()
Get the name this directive was registered as