1 /*
   2  * Copyright (c) 2003, 2005, Oracle and/or its affiliates. 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.xml.validation;
  27 
  28 /**
  29  * Immutable in-memory representation of grammar.
  30  *
  31  * <p>
  32  * This object represents a set of constraints that can be checked/
  33  * enforced against an XML document.
  34  *
  35  * <p>
  36  * A {@link Schema} object is thread safe and applications are
  37  * encouraged to share it across many parsers in many threads.
  38  *
  39  * <p>
  40  * A {@link Schema} object is immutable in the sense that it shouldn't
  41  * change the set of constraints once it is created. In other words,
  42  * if an application validates the same document twice against the same
  43  * {@link Schema}, it must always produce the same result.
  44  *
  45  * <p>
  46  * A {@link Schema} object is usually created from {@link SchemaFactory}.
  47  *
  48  * <p>
  49  * Two kinds of validators can be created from a {@link Schema} object.
  50  * One is {@link Validator}, which provides highly-level validation
  51  * operations that cover typical use cases. The other is
  52  * {@link ValidatorHandler}, which works on top of SAX for better
  53  * modularity.
  54  *
  55  * <p>
  56  * This specification does not refine
  57  * the {@link java.lang.Object#equals(java.lang.Object)} method.
  58  * In other words, if you parse the same schema twice, you may
  59  * still get <code>!schemaA.equals(schemaB)</code>.
  60  *
  61  * @author Kohsuke Kawaguchi
  62  * @see <a href="http://www.w3.org/TR/xmlschema-1/">XML Schema Part 1: Structures</a>
  63  * @see <a href="http://www.w3.org/TR/xml11/">Extensible Markup Language (XML) 1.1</a>
  64  * @see <a href="http://www.w3.org/TR/REC-xml">Extensible Markup Language (XML) 1.0 (Second Edition)</a>
  65  * @since 1.5
  66  */
  67 public abstract class Schema {
  68 
  69     /**
  70      * Constructor for the derived class.
  71      *
  72      * <p>
  73      * The constructor does nothing.
  74      */
  75     protected Schema() {
  76     }
  77 
  78     /**
  79      * Creates a new {@link Validator} for this {@link Schema}.
  80      *
  81      * <p>A validator enforces/checks the set of constraints this object
  82      * represents.</p>
  83      *
  84      * <p>Implementors should assure that the properties set on the
  85      * {@link SchemaFactory} that created this {@link Schema} are also
  86      * set on the {@link Validator} constructed.</p>
  87      *
  88      * @return
  89      *      Always return a non-null valid object.
  90      */
  91     public abstract Validator newValidator();
  92 
  93     /**
  94      * Creates a new {@link ValidatorHandler} for this {@link Schema}.
  95      *
  96      * <p>Implementors should assure that the properties set on the
  97      * {@link SchemaFactory} that created this {@link Schema} are also
  98      * set on the {@link ValidatorHandler} constructed.</p>
  99      *
 100      * @return
 101      *      Always return a non-null valid object.
 102      */
 103     public abstract ValidatorHandler newValidatorHandler();
 104 }