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 * Datatype streaming validator.
30 *
31 * <p>
32 * The streaming validator is an optional feature that is useful for
33 * certain Datatypes. It allows the caller to incrementally provide
34 * the literal.
35 *
36 * @author <a href="mailto:jjc@jclark.com">James Clark</a>
37 * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
38 */
39 public interface DatatypeStreamingValidator {
40
41 /**
42 * Passes an additional fragment of the literal.
43 *
44 * <p>
45 * The application can call this method several times, then call
46 * the isValid method (or the checkValid method) to check the validity
47 * of the accumulated characters.
48 */
49 void addCharacters( char[] buf, int start, int len );
50
51 /**
52 * Tells if the accumulated literal is valid with respect to
53 * the underlying Datatype.
54 *
55 * @return
56 * True if it is valid. False if otherwise.
57 */
58 boolean isValid();
59
60 /**
61 * Similar to the isValid method, but this method throws
62 * Exception (with possibly diagnostic information), instead of
63 * returning false.
64 *
65 * @exception DatatypeException
66 * If the callee supports the diagnosis and the accumulated
67 * literal is invalid, then this exception that possibly
68 * contains diagnosis information is thrown.
69 */
70 void checkValid() throws DatatypeException;
71 }