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 package org.relaxng.datatype;
26
27 /**
28 * Creates a user-defined type by adding parameters to
29 * the pre-defined type.
30 *
31 * @author <a href="mailto:jjc@jclark.com">James Clark</a>
32 * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
33 */
34 public interface DatatypeBuilder {
35
36 /**
37 * Adds a new parameter.
38 *
39 * @param name
40 * The name of the parameter to be added.
41 * @param strValue
42 * The raw value of the parameter. Caller may not normalize
43 * this value because any white space is potentially significant.
44 * @param context
45 * The context information which can be used by the callee to
46 * acquire additional information. This context object is
47 * valid only during this method call. The callee may not
48 * keep a reference to this object.
49 * @exception DatatypeException
50 * When the given parameter is inappropriate for some reason.
51 * The callee is responsible to recover from this error.
52 * That is, the object should behave as if no such error
53 * was occured.
54 */
55 void addParameter( String name, String strValue, ValidationContext context )
56 throws DatatypeException;
57
58 /**
59 * Derives a new Datatype from a Datatype by parameters that
60 * were already set through the addParameter method.
61 *
62 * @exception DatatypeException
63 * DatatypeException must be thrown if the derivation is
64 * somehow invalid. For example, a required parameter is missing,
65 * etc. The exception should contain a diagnosis message
66 * if possible.
67 */
68 Datatype createDatatype() throws DatatypeException;
69 }