01: package org.relaxng.datatype.helpers;
02:
03: import org.relaxng.datatype.*;
04:
05: /**
06: * Dummy implementation of {@link DatatypeBuilder}.
07: *
08: * This implementation can be used for Datatypes which have no parameters.
09: * 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
26: DatatypeBuilder {
27:
28: /** This type object is returned for the derive method. */
29: private final Datatype baseType;
30:
31: public ParameterlessDatatypeBuilder(Datatype baseType) {
32: this .baseType = baseType;
33: }
34:
35: public void addParameter(String name, String strValue,
36: ValidationContext context) throws DatatypeException {
37: throw new DatatypeException();
38: }
39:
40: public Datatype createDatatype() throws DatatypeException {
41: return baseType;
42: }
43: }
|