1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package org.relaxng.datatype;
27
28 /**
29 * Creates a user-defined type by adding parameters to
30 * the pre-defined type.
31 *
32 * @author <a href="mailto:jjc@jclark.com">James Clark</a>
33 * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
34 */
35 public interface DatatypeBuilder {
36
37 /**
38 * Adds a new parameter.
39 *
40 * @param name
41 * The name of the parameter to be added.
42 * @param strValue
43 * The raw value of the parameter. Caller may not normalize
44 * this value because any white space is potentially significant.
45 * @param context
46 * The context information which can be used by the callee to
47 * acquire additional information. This context object is
48 * valid only during this method call. The callee may not
49 * keep a reference to this object.
50 * @exception DatatypeException
51 * When the given parameter is inappropriate for some reason.
52 * The callee is responsible to recover from this error.
53 * That is, the object should behave as if no such error
54 * was occured.
55 */
56 void addParameter( String name, String strValue, ValidationContext context )
57 throws DatatypeException;
58
59 /**
60 * Derives a new Datatype from a Datatype by parameters that
61 * were already set through the addParameter method.
62 *
63 * @exception DatatypeException
64 * DatatypeException must be thrown if the derivation is
65 * somehow invalid. For example, a required parameter is missing,
66 * etc. The exception should contain a diagnosis message
67 * if possible.
68 */
69 Datatype createDatatype() throws DatatypeException;
70 }