Source for org.relaxng.datatype.helpers.ParameterlessDatatypeBuilder

   1: package org.relaxng.datatype.helpers;
   2: 
   3: import org.relaxng.datatype.*;
   4: 
   5: /**
   6:  * Dummy implementation of {@link DatatypeBuilder}.
   7:  *
   8:  * This implementation can be used for Datatypes which have no parameters.
   9:  * Any attempt to add parameters will be rejected.
  10:  *
  11:  * <p>
  12:  * Typical usage would be:
  13:  * <PRE><XMP>
  14:  * class MyDatatypeLibrary implements DatatypeLibrary {
  15:  *     ....
  16:  *     DatatypeBuilder createDatatypeBuilder( String typeName ) {
  17:  *         return new ParameterleessDatatypeBuilder(createDatatype(typeName));
  18:  *     }
  19:  *     ....
  20:  * }
  21:  * </XMP></PRE>
  22:  *
  23:  * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
  24:  */
  25: public final class ParameterlessDatatypeBuilder implements DatatypeBuilder {
  26: 
  27:         /** This type object is returned for the derive method. */
  28:         private final Datatype baseType;
  29: 
  30:         public ParameterlessDatatypeBuilder( Datatype baseType ) {
  31:                 this.baseType = baseType;
  32:         }
  33: 
  34:         public void addParameter( String name, String strValue, ValidationContext context )
  35:                         throws DatatypeException {
  36:                 throw new DatatypeException();
  37:         }
  38: 
  39:         public Datatype createDatatype() throws DatatypeException {
  40:                 return baseType;
  41:         }
  42: }