jaxp/src/share/classes/javax/xml/validation/Schema.java
author dav
Thu, 27 Mar 2008 12:31:18 +0300
changeset 428 79b6854acb4a
parent 6 7f561c08de6b
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
 * have any questions.
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
package javax.xml.validation;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
 * Immutable in-memory representation of grammar.
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
 * This object represents a set of constraints that can be checked/
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
 * enforced against an XML document.
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 * A {@link Schema} object is thread safe and applications are
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
 * encouraged to share it across many parsers in many threads.
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
 * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 * A {@link Schema} object is immutable in the sense that it shouldn't
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 * change the set of constraints once it is created. In other words,
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * if an application validates the same document twice against the same
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * {@link Schema}, it must always produce the same result.
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * A {@link Schema} object is usually created from {@link SchemaFactory}.
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
 * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
 * Two kinds of validators can be created from a {@link Schema} object.
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 * One is {@link Validator}, which provides highly-level validation
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
 * operations that cover typical use cases. The other is
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
 * {@link ValidatorHandler}, which works on top of SAX for better
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
 * modularity.
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
 * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
 * This specification does not refine
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
 * the {@link java.lang.Object#equals(java.lang.Object)} method.
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
 * In other words, if you parse the same schema twice, you may
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
 * still get <code>!schemaA.equals(schemaB)</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
 * @author <a href="mailto:Kohsuke.Kawaguchi@Sun.com">Kohsuke Kawaguchi</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
 * @see <a href="http://www.w3.org/TR/xmlschema-1/">XML Schema Part 1: Structures</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
 * @see <a href="http://www.w3.org/TR/xml11/">Extensible Markup Language (XML) 1.1</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
 * @see <a href="http://www.w3.org/TR/REC-xml">Extensible Markup Language (XML) 1.0 (Second Edition)</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
 * @since 1.5
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
public abstract class Schema {
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
     * Constructor for the derived class.
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
     * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
     * The constructor does nothing.
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
    protected Schema() {
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
     * Creates a new {@link Validator} for this {@link Schema}.
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
     * <p>A validator enforces/checks the set of constraints this object
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
     * represents.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
     * <p>Implementors should assure that the properties set on the
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
     * {@link SchemaFactory} that created this {@link Schema} are also
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
     * set on the {@link Validator} constructed.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
     * @return
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
     *      Always return a non-null valid object.
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
    public abstract Validator newValidator();
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
     * Creates a new {@link ValidatorHandler} for this {@link Schema}.
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
     * <p>Implementors should assure that the properties set on the
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
     * {@link SchemaFactory} that created this {@link Schema} are also
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
     * set on the {@link ValidatorHandler} constructed.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
     * @return
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
     *      Always return a non-null valid object.
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
    public abstract ValidatorHandler newValidatorHandler();
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
}