jaxp/src/share/classes/javax/xml/parsers/DocumentBuilderFactory.java
author jjg
Thu, 19 Jun 2008 15:52:31 -0700
changeset 811 687d51cb403b
parent 6 7f561c08de6b
permissions -rw-r--r--
6716866: some javac regression tests fail to compile with re-orged file manager Reviewed-by: darcy
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 2000-2006 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.parsers;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import javax.xml.validation.Schema;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 * Defines a factory API that enables applications to obtain a
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
 * parser that produces DOM object trees from XML documents.
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
 * @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 * @author <a href="mailto:Neeraj.Bajaj@sun.com">Neeraj Bajaj</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
public abstract class DocumentBuilderFactory {
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
    /** The default property name according to the JAXP spec */
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
    private static final String DEFAULT_PROPERTY_NAME = "javax.xml.parsers.DocumentBuilderFactory";
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
    private boolean validating = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
    private boolean namespaceAware = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
    private boolean whitespace = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
    private boolean expandEntityRef = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
    private boolean ignoreComments = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
    private boolean coalescing = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
    private boolean canonicalState = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
     * <p>Protected constructor to prevent instantiation.
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
     * Use {@link #newInstance()}.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
    protected DocumentBuilderFactory () {
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
     * Obtain a new instance of a
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
     * <code>DocumentBuilderFactory</code>. This static method creates
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
     * a new factory instance.
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
     * This method uses the following ordered lookup procedure to determine
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
     * the <code>DocumentBuilderFactory</code> implementation class to
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
     * load:
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
     * <ul>
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
     * <li>
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
     * Use the <code>javax.xml.parsers.DocumentBuilderFactory</code> system
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
     * property.
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
     * </li>
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
     * <li>
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
     * Use the properties file "lib/jaxp.properties" in the JRE directory.
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
     * This configuration file is in standard <code>java.util.Properties
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
     * </code> format and contains the fully qualified name of the
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
     * implementation class with the key being the system property defined
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
     * above.
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
     * The jaxp.properties file is read only once by the JAXP implementation
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
     * and it's values are then cached for future use.  If the file does not exist
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
     * when the first attempt is made to read from it, no further attempts are
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
     * made to check for its existence.  It is not possible to change the value
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
     * of any property in jaxp.properties after it has been read for the first time.
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
     * </li>
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
     * <li>
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
     * Use the Services API (as detailed in the JAR specification), if
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
     * available, to determine the classname. The Services API will look
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
     * for a classname in the file
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
     * <code>META-INF/services/javax.xml.parsers.DocumentBuilderFactory</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
     * in jars available to the runtime.
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
     * </li>
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
     * <li>
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
     * Platform default <code>DocumentBuilderFactory</code> instance.
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
     * </li>
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
     * </ul>
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
     * Once an application has obtained a reference to a
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
     * <code>DocumentBuilderFactory</code> it can use the factory to
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
     * configure and obtain parser instances.
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
     * <h2>Tip for Trouble-shooting</h2>
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
     * <p>Setting the <code>jaxp.debug</code> system property will cause
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
     * this method to print a lot of debug messages
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
     * to <code>System.err</code> about what it is doing and where it is looking at.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
     * <p> If you have problems loading {@link DocumentBuilder}s, try:</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
     * <pre>
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
     * java -Djaxp.debug=1 YourProgram ....
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
     * </pre>
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
     * @return New instance of a <code>DocumentBuilderFactory</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
     * @throws FactoryConfigurationError if the implementation is not
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
     *   available or cannot be instantiated.
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
    public static DocumentBuilderFactory newInstance() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
        try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
            return (DocumentBuilderFactory) FactoryFinder.find(
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
                /* The default property name according to the JAXP spec */
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
                "javax.xml.parsers.DocumentBuilderFactory",
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
                /* The fallback implementation class name */
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
                "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
        } catch (FactoryFinder.ConfigurationError e) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
            throw new FactoryConfigurationError(e.getException(),
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
                                                e.getMessage());
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
     * <p>Obtain a new instance of a <code>DocumentBuilderFactory</code> from class name.
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
     * This function is useful when there are multiple providers in the classpath.
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
     * It gives more control to the application as it can specify which provider
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
     * should be loaded.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
     * <p>Once an application has obtained a reference to a <code>DocumentBuilderFactory</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
     * it can use the factory to configure and obtain parser instances.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
     * <h2>Tip for Trouble-shooting</h2>
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
     * <p>Setting the <code>jaxp.debug</code> system property will cause
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
     * this method to print a lot of debug messages
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
     * to <code>System.err</code> about what it is doing and where it is looking at.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
     * <p> If you have problems try:</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
     * <pre>
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
     * java -Djaxp.debug=1 YourProgram ....
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
     * </pre>
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
     * @param factoryClassName fully qualified factory class name that provides implementation of <code>javax.xml.parsers.DocumentBuilderFactory</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
     * @param classLoader <code>ClassLoader</code> used to load the factory class. If <code>null</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
     *                     current <code>Thread</code>'s context classLoader is used to load the factory class.
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
     * @return New instance of a <code>DocumentBuilderFactory</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
     * @throws FactoryConfigurationError if <code>factoryClassName</code> is <code>null</code>, or
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
     *                                   the factory class cannot be loaded, instantiated.
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
     * @see #newInstance()
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
     * @since 1.6
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
    public static DocumentBuilderFactory newInstance(String factoryClassName, ClassLoader classLoader){
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
        try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
            //do not fallback if given classloader can't find the class, throw exception
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
            return (DocumentBuilderFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
        } catch (FactoryFinder.ConfigurationError e) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
            throw new FactoryConfigurationError(e.getException(),
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
                                                e.getMessage());
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
     * Creates a new instance of a {@link javax.xml.parsers.DocumentBuilder}
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
     * using the currently configured parameters.
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
     * @return A new instance of a DocumentBuilder.
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
     * @throws ParserConfigurationException if a DocumentBuilder
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
     *   cannot be created which satisfies the configuration requested.
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
    public abstract DocumentBuilder newDocumentBuilder()
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
        throws ParserConfigurationException;
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
     * Specifies that the parser produced by this code will
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
     * provide support for XML namespaces. By default the value of this is set
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
     * to <code>false</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
     * @param awareness true if the parser produced will provide support
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
     *                  for XML namespaces; false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
    public void setNamespaceAware(boolean awareness) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
        this.namespaceAware = awareness;
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
     * Specifies that the parser produced by this code will
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
     * validate documents as they are parsed. By default the value of this
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
     * is set to <code>false</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
     * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
     * Note that "the validation" here means
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
     * <a href="http://www.w3.org/TR/REC-xml#proc-types">a validating
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
     * parser</a> as defined in the XML recommendation.
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
     * In other words, it essentially just controls the DTD validation.
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
     * (except the legacy two properties defined in JAXP 1.2.)
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
     * </p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
     * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
     * To use modern schema languages such as W3C XML Schema or
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
     * RELAX NG instead of DTD, you can configure your parser to be
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
     * a non-validating parser by leaving the {@link #setValidating(boolean)}
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
     * method <code>false</code>, then use the {@link #setSchema(Schema)}
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
     * method to associate a schema to a parser.
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
     * </p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
     * @param validating true if the parser produced will validate documents
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
     *                   as they are parsed; false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
    public void setValidating(boolean validating) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
        this.validating = validating;
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
     * Specifies that the parsers created by this  factory must eliminate
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
     * whitespace in element content (sometimes known loosely as
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
     * 'ignorable whitespace') when parsing XML documents (see XML Rec
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
     * 2.10). Note that only whitespace which is directly contained within
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
     * element content that has an element only content model (see XML
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
     * Rec 3.2.1) will be eliminated. Due to reliance on the content model
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
     * this setting requires the parser to be in validating mode. By default
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
     * the value of this is set to <code>false</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
     * @param whitespace true if the parser created must eliminate whitespace
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
     *                   in the element content when parsing XML documents;
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
     *                   false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
    public void setIgnoringElementContentWhitespace(boolean whitespace) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
        this.whitespace = whitespace;
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
     * Specifies that the parser produced by this code will
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
     * expand entity reference nodes. By default the value of this is set to
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
     * <code>true</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
     * @param expandEntityRef true if the parser produced will expand entity
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
     *                        reference nodes; false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
    public void setExpandEntityReferences(boolean expandEntityRef) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
        this.expandEntityRef = expandEntityRef;
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
     * <p>Specifies that the parser produced by this code will
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
     * ignore comments. By default the value of this is set to <code>false
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
     * </code>.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
     * @param ignoreComments <code>boolean</code> value to ignore comments during processing
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
    public void setIgnoringComments(boolean ignoreComments) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
        this.ignoreComments = ignoreComments;
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
7f561c08de6b Initial load
duke
parents:
diff changeset
   276
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
     * Specifies that the parser produced by this code will
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
     * convert CDATA nodes to Text nodes and append it to the
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
     * adjacent (if any) text node. By default the value of this is set to
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
     * <code>false</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
     * @param coalescing  true if the parser produced will convert CDATA nodes
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
     *                    to Text nodes and append it to the adjacent (if any)
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
     *                    text node; false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
    public void setCoalescing(boolean coalescing) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
        this.coalescing = coalescing;
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
     * Indicates whether or not the factory is configured to produce
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
     * parsers which are namespace aware.
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
     * @return  true if the factory is configured to produce parsers which
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
     *          are namespace aware; false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
    public boolean isNamespaceAware() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
        return namespaceAware;
7f561c08de6b Initial load
duke
parents:
diff changeset
   301
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   302
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   304
     * Indicates whether or not the factory is configured to produce
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
     * parsers which validate the XML content during parse.
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
     * @return  true if the factory is configured to produce parsers
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
     *          which validate the XML content during parse; false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
    public boolean isValidating() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   312
        return validating;
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   314
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   316
     * Indicates whether or not the factory is configured to produce
7f561c08de6b Initial load
duke
parents:
diff changeset
   317
     * parsers which ignore ignorable whitespace in element content.
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
     * @return  true if the factory is configured to produce parsers
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
     *          which ignore ignorable whitespace in element content;
7f561c08de6b Initial load
duke
parents:
diff changeset
   321
     *          false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   323
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
    public boolean isIgnoringElementContentWhitespace() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
        return whitespace;
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
     * Indicates whether or not the factory is configured to produce
7f561c08de6b Initial load
duke
parents:
diff changeset
   330
     * parsers which expand entity reference nodes.
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
     * @return  true if the factory is configured to produce parsers
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
     *          which expand entity reference nodes; false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
    public boolean isExpandEntityReferences() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
        return expandEntityRef;
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
7f561c08de6b Initial load
duke
parents:
diff changeset
   340
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   341
     * Indicates whether or not the factory is configured to produce
7f561c08de6b Initial load
duke
parents:
diff changeset
   342
     * parsers which ignores comments.
7f561c08de6b Initial load
duke
parents:
diff changeset
   343
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   344
     * @return  true if the factory is configured to produce parsers
7f561c08de6b Initial load
duke
parents:
diff changeset
   345
     *          which ignores comments; false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
    public boolean isIgnoringComments() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
        return ignoreComments;
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
     * Indicates whether or not the factory is configured to produce
7f561c08de6b Initial load
duke
parents:
diff changeset
   354
     * parsers which converts CDATA nodes to Text nodes and appends it to
7f561c08de6b Initial load
duke
parents:
diff changeset
   355
     * the adjacent (if any) Text node.
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
     * @return  true if the factory is configured to produce parsers
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
     *          which converts CDATA nodes to Text nodes and appends it to
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
     *          the adjacent (if any) Text node; false otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   360
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   361
7f561c08de6b Initial load
duke
parents:
diff changeset
   362
    public boolean isCoalescing() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   363
        return coalescing;
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   365
7f561c08de6b Initial load
duke
parents:
diff changeset
   366
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   367
     * Allows the user to set specific attributes on the underlying
7f561c08de6b Initial load
duke
parents:
diff changeset
   368
     * implementation.
7f561c08de6b Initial load
duke
parents:
diff changeset
   369
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   370
     * @param name The name of the attribute.
7f561c08de6b Initial load
duke
parents:
diff changeset
   371
     * @param value The value of the attribute.
7f561c08de6b Initial load
duke
parents:
diff changeset
   372
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   373
     * @throws IllegalArgumentException thrown if the underlying
7f561c08de6b Initial load
duke
parents:
diff changeset
   374
     *   implementation doesn't recognize the attribute.
7f561c08de6b Initial load
duke
parents:
diff changeset
   375
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   376
    public abstract void setAttribute(String name, Object value)
7f561c08de6b Initial load
duke
parents:
diff changeset
   377
                throws IllegalArgumentException;
7f561c08de6b Initial load
duke
parents:
diff changeset
   378
7f561c08de6b Initial load
duke
parents:
diff changeset
   379
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   380
     * Allows the user to retrieve specific attributes on the underlying
7f561c08de6b Initial load
duke
parents:
diff changeset
   381
     * implementation.
7f561c08de6b Initial load
duke
parents:
diff changeset
   382
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   383
     * @param name The name of the attribute.
7f561c08de6b Initial load
duke
parents:
diff changeset
   384
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   385
     * @return value The value of the attribute.
7f561c08de6b Initial load
duke
parents:
diff changeset
   386
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   387
     * @throws IllegalArgumentException thrown if the underlying
7f561c08de6b Initial load
duke
parents:
diff changeset
   388
     *   implementation doesn't recognize the attribute.
7f561c08de6b Initial load
duke
parents:
diff changeset
   389
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   390
    public abstract Object getAttribute(String name)
7f561c08de6b Initial load
duke
parents:
diff changeset
   391
                throws IllegalArgumentException;
7f561c08de6b Initial load
duke
parents:
diff changeset
   392
7f561c08de6b Initial load
duke
parents:
diff changeset
   393
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   394
         * <p>Set a feature for this <code>DocumentBuilderFactory</code> and <code>DocumentBuilder</code>s created by this factory.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
         * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   397
         * Feature names are fully qualified {@link java.net.URI}s.
7f561c08de6b Initial load
duke
parents:
diff changeset
   398
         * Implementations may define their own features.
7f561c08de6b Initial load
duke
parents:
diff changeset
   399
         * A {@link ParserConfigurationException} is thrown if this <code>DocumentBuilderFactory</code> or the
7f561c08de6b Initial load
duke
parents:
diff changeset
   400
         * <code>DocumentBuilder</code>s it creates cannot support the feature.
7f561c08de6b Initial load
duke
parents:
diff changeset
   401
         * It is possible for a <code>DocumentBuilderFactory</code> to expose a feature value but be unable to change its state.
7f561c08de6b Initial load
duke
parents:
diff changeset
   402
         * </p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   403
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
         * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   405
         * All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
7f561c08de6b Initial load
duke
parents:
diff changeset
   406
         * When the feature is:</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   407
         * <ul>
7f561c08de6b Initial load
duke
parents:
diff changeset
   408
         *   <li>
7f561c08de6b Initial load
duke
parents:
diff changeset
   409
         *     <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
7f561c08de6b Initial load
duke
parents:
diff changeset
   410
         *     Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
7f561c08de6b Initial load
duke
parents:
diff changeset
   411
         *     If XML processing is limited for security reasons, it will be reported via a call to the registered
7f561c08de6b Initial load
duke
parents:
diff changeset
   412
         *    {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
7f561c08de6b Initial load
duke
parents:
diff changeset
   413
         *     See {@link  DocumentBuilder#setErrorHandler(org.xml.sax.ErrorHandler errorHandler)}.
7f561c08de6b Initial load
duke
parents:
diff changeset
   414
         *   </li>
7f561c08de6b Initial load
duke
parents:
diff changeset
   415
         *   <li>
7f561c08de6b Initial load
duke
parents:
diff changeset
   416
         *     <code>false</code>: the implementation will processing XML according to the XML specifications without
7f561c08de6b Initial load
duke
parents:
diff changeset
   417
         *     regard to possible implementation limits.
7f561c08de6b Initial load
duke
parents:
diff changeset
   418
         *   </li>
7f561c08de6b Initial load
duke
parents:
diff changeset
   419
         * </ul>
7f561c08de6b Initial load
duke
parents:
diff changeset
   420
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   421
         * @param name Feature name.
7f561c08de6b Initial load
duke
parents:
diff changeset
   422
         * @param value Is feature state <code>true</code> or <code>false</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   423
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
         * @throws ParserConfigurationException if this <code>DocumentBuilderFactory</code> or the <code>DocumentBuilder</code>s
7f561c08de6b Initial load
duke
parents:
diff changeset
   425
         *   it creates cannot support this feature.
7f561c08de6b Initial load
duke
parents:
diff changeset
   426
     * @throws NullPointerException If the <code>name</code> parameter is null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   427
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   428
        public abstract void setFeature(String name, boolean value)
7f561c08de6b Initial load
duke
parents:
diff changeset
   429
                throws ParserConfigurationException;
7f561c08de6b Initial load
duke
parents:
diff changeset
   430
7f561c08de6b Initial load
duke
parents:
diff changeset
   431
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   432
         * <p>Get the state of the named feature.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   433
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   434
         * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   435
         * Feature names are fully qualified {@link java.net.URI}s.
7f561c08de6b Initial load
duke
parents:
diff changeset
   436
         * Implementations may define their own features.
7f561c08de6b Initial load
duke
parents:
diff changeset
   437
         * An {@link ParserConfigurationException} is thrown if this <code>DocumentBuilderFactory</code> or the
7f561c08de6b Initial load
duke
parents:
diff changeset
   438
         * <code>DocumentBuilder</code>s it creates cannot support the feature.
7f561c08de6b Initial load
duke
parents:
diff changeset
   439
         * It is possible for an <code>DocumentBuilderFactory</code> to expose a feature value but be unable to change its state.
7f561c08de6b Initial load
duke
parents:
diff changeset
   440
         * </p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   441
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   442
         * @param name Feature name.
7f561c08de6b Initial load
duke
parents:
diff changeset
   443
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
         * @return State of the named feature.
7f561c08de6b Initial load
duke
parents:
diff changeset
   445
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   446
         * @throws ParserConfigurationException if this <code>DocumentBuilderFactory</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   447
         *   or the <code>DocumentBuilder</code>s it creates cannot support this feature.
7f561c08de6b Initial load
duke
parents:
diff changeset
   448
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   449
        public abstract boolean getFeature(String name)
7f561c08de6b Initial load
duke
parents:
diff changeset
   450
                throws ParserConfigurationException;
7f561c08de6b Initial load
duke
parents:
diff changeset
   451
7f561c08de6b Initial load
duke
parents:
diff changeset
   452
7f561c08de6b Initial load
duke
parents:
diff changeset
   453
    /** <p>Get current state of canonicalization.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   454
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   455
     * @return current state canonicalization control
7f561c08de6b Initial load
duke
parents:
diff changeset
   456
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   457
    /*
7f561c08de6b Initial load
duke
parents:
diff changeset
   458
    public boolean getCanonicalization() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   459
        return canonicalState;
7f561c08de6b Initial load
duke
parents:
diff changeset
   460
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   461
    */
7f561c08de6b Initial load
duke
parents:
diff changeset
   462
7f561c08de6b Initial load
duke
parents:
diff changeset
   463
7f561c08de6b Initial load
duke
parents:
diff changeset
   464
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   465
     * Gets the {@link Schema} object specified through
7f561c08de6b Initial load
duke
parents:
diff changeset
   466
     * the {@link #setSchema(Schema schema)} method.
7f561c08de6b Initial load
duke
parents:
diff changeset
   467
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   468
     * @return
7f561c08de6b Initial load
duke
parents:
diff changeset
   469
     *      the {@link Schema} object that was last set through
7f561c08de6b Initial load
duke
parents:
diff changeset
   470
     *      the {@link #setSchema(Schema)} method, or null
7f561c08de6b Initial load
duke
parents:
diff changeset
   471
     *      if the method was not invoked since a {@link DocumentBuilderFactory}
7f561c08de6b Initial load
duke
parents:
diff changeset
   472
     *      is created.
7f561c08de6b Initial load
duke
parents:
diff changeset
   473
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   474
     * @throws UnsupportedOperationException When implementation does not
7f561c08de6b Initial load
duke
parents:
diff changeset
   475
     *   override this method.
7f561c08de6b Initial load
duke
parents:
diff changeset
   476
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   477
     * @since 1.5
7f561c08de6b Initial load
duke
parents:
diff changeset
   478
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   479
    public Schema getSchema() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   480
        throw new UnsupportedOperationException(
7f561c08de6b Initial load
duke
parents:
diff changeset
   481
            "This parser does not support specification \""
7f561c08de6b Initial load
duke
parents:
diff changeset
   482
            + this.getClass().getPackage().getSpecificationTitle()
7f561c08de6b Initial load
duke
parents:
diff changeset
   483
            + "\" version \""
7f561c08de6b Initial load
duke
parents:
diff changeset
   484
            + this.getClass().getPackage().getSpecificationVersion()
7f561c08de6b Initial load
duke
parents:
diff changeset
   485
            + "\""
7f561c08de6b Initial load
duke
parents:
diff changeset
   486
            );
7f561c08de6b Initial load
duke
parents:
diff changeset
   487
7f561c08de6b Initial load
duke
parents:
diff changeset
   488
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   489
7f561c08de6b Initial load
duke
parents:
diff changeset
   490
    /* <p>Set canonicalization control to <code>true</code> or
7f561c08de6b Initial load
duke
parents:
diff changeset
   491
     * </code>false</code>.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   492
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   493
     * @param state of canonicalization
7f561c08de6b Initial load
duke
parents:
diff changeset
   494
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   495
    /*
7f561c08de6b Initial load
duke
parents:
diff changeset
   496
    public void setCanonicalization(boolean state) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   497
        canonicalState = state;
7f561c08de6b Initial load
duke
parents:
diff changeset
   498
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   499
    */
7f561c08de6b Initial load
duke
parents:
diff changeset
   500
7f561c08de6b Initial load
duke
parents:
diff changeset
   501
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   502
     * <p>Set the {@link Schema} to be used by parsers created
7f561c08de6b Initial load
duke
parents:
diff changeset
   503
     * from this factory.
7f561c08de6b Initial load
duke
parents:
diff changeset
   504
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   505
     * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   506
     * When a {@link Schema} is non-null, a parser will use a validator
7f561c08de6b Initial load
duke
parents:
diff changeset
   507
     * created from it to validate documents before it passes information
7f561c08de6b Initial load
duke
parents:
diff changeset
   508
     * down to the application.
7f561c08de6b Initial load
duke
parents:
diff changeset
   509
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   510
     * <p>When errors are found by the validator, the parser is responsible
7f561c08de6b Initial load
duke
parents:
diff changeset
   511
     * to report them to the user-specified {@link org.xml.sax.ErrorHandler}
7f561c08de6b Initial load
duke
parents:
diff changeset
   512
     * (or if the error handler is not set, ignore them or throw them), just
7f561c08de6b Initial load
duke
parents:
diff changeset
   513
     * like any other errors found by the parser itself.
7f561c08de6b Initial load
duke
parents:
diff changeset
   514
     * In other words, if the user-specified {@link org.xml.sax.ErrorHandler}
7f561c08de6b Initial load
duke
parents:
diff changeset
   515
     * is set, it must receive those errors, and if not, they must be
7f561c08de6b Initial load
duke
parents:
diff changeset
   516
     * treated according to the implementation specific
7f561c08de6b Initial load
duke
parents:
diff changeset
   517
     * default error handling rules.
7f561c08de6b Initial load
duke
parents:
diff changeset
   518
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   519
     * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   520
     * A validator may modify the outcome of a parse (for example by
7f561c08de6b Initial load
duke
parents:
diff changeset
   521
     * adding default values that were missing in documents), and a parser
7f561c08de6b Initial load
duke
parents:
diff changeset
   522
     * is responsible to make sure that the application will receive
7f561c08de6b Initial load
duke
parents:
diff changeset
   523
     * modified DOM trees.
7f561c08de6b Initial load
duke
parents:
diff changeset
   524
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   525
     * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   526
     * Initialy, null is set as the {@link Schema}.
7f561c08de6b Initial load
duke
parents:
diff changeset
   527
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   528
     * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   529
     * This processing will take effect even if
7f561c08de6b Initial load
duke
parents:
diff changeset
   530
     * the {@link #isValidating()} method returns <code>false</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   531
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   532
     * <p>It is an error to use
7f561c08de6b Initial load
duke
parents:
diff changeset
   533
     * the <code>http://java.sun.com/xml/jaxp/properties/schemaSource</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   534
     * property and/or the <code>http://java.sun.com/xml/jaxp/properties/schemaLanguage</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   535
     * property in conjunction with a {@link Schema} object.
7f561c08de6b Initial load
duke
parents:
diff changeset
   536
     * Such configuration will cause a {@link ParserConfigurationException}
7f561c08de6b Initial load
duke
parents:
diff changeset
   537
     * exception when the {@link #newDocumentBuilder()} is invoked.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   538
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   539
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   540
     * <h4>Note for implmentors</h4>
7f561c08de6b Initial load
duke
parents:
diff changeset
   541
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   542
     * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   543
     * A parser must be able to work with any {@link Schema}
7f561c08de6b Initial load
duke
parents:
diff changeset
   544
     * implementation. However, parsers and schemas are allowed
7f561c08de6b Initial load
duke
parents:
diff changeset
   545
     * to use implementation-specific custom mechanisms
7f561c08de6b Initial load
duke
parents:
diff changeset
   546
     * as long as they yield the result described in the specification.
7f561c08de6b Initial load
duke
parents:
diff changeset
   547
     * </p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   548
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   549
     * @param schema <code>Schema</code> to use or <code>null</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   550
     *   to remove a schema.
7f561c08de6b Initial load
duke
parents:
diff changeset
   551
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   552
     * @throws UnsupportedOperationException When implementation does not
7f561c08de6b Initial load
duke
parents:
diff changeset
   553
     *   override this method.
7f561c08de6b Initial load
duke
parents:
diff changeset
   554
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   555
     * @since 1.5
7f561c08de6b Initial load
duke
parents:
diff changeset
   556
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   557
    public void setSchema(Schema schema) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   558
        throw new UnsupportedOperationException(
7f561c08de6b Initial load
duke
parents:
diff changeset
   559
            "This parser does not support specification \""
7f561c08de6b Initial load
duke
parents:
diff changeset
   560
            + this.getClass().getPackage().getSpecificationTitle()
7f561c08de6b Initial load
duke
parents:
diff changeset
   561
            + "\" version \""
7f561c08de6b Initial load
duke
parents:
diff changeset
   562
            + this.getClass().getPackage().getSpecificationVersion()
7f561c08de6b Initial load
duke
parents:
diff changeset
   563
            + "\""
7f561c08de6b Initial load
duke
parents:
diff changeset
   564
            );
7f561c08de6b Initial load
duke
parents:
diff changeset
   565
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   566
7f561c08de6b Initial load
duke
parents:
diff changeset
   567
7f561c08de6b Initial load
duke
parents:
diff changeset
   568
7f561c08de6b Initial load
duke
parents:
diff changeset
   569
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   570
     * <p>Set state of XInclude processing.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   571
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   572
     * <p>If XInclude markup is found in the document instance, should it be
7f561c08de6b Initial load
duke
parents:
diff changeset
   573
     * processed as specified in <a href="http://www.w3.org/TR/xinclude/">
7f561c08de6b Initial load
duke
parents:
diff changeset
   574
     * XML Inclusions (XInclude) Version 1.0</a>.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   575
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   576
     * <p>XInclude processing defaults to <code>false</code>.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   577
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   578
     * @param state Set XInclude processing to <code>true</code> or
7f561c08de6b Initial load
duke
parents:
diff changeset
   579
     *   <code>false</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   580
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   581
     * @throws UnsupportedOperationException When implementation does not
7f561c08de6b Initial load
duke
parents:
diff changeset
   582
     *   override this method.
7f561c08de6b Initial load
duke
parents:
diff changeset
   583
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   584
     * @since 1.5
7f561c08de6b Initial load
duke
parents:
diff changeset
   585
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   586
    public void setXIncludeAware(final boolean state) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   587
        throw new UnsupportedOperationException(
7f561c08de6b Initial load
duke
parents:
diff changeset
   588
            "This parser does not support specification \""
7f561c08de6b Initial load
duke
parents:
diff changeset
   589
            + this.getClass().getPackage().getSpecificationTitle()
7f561c08de6b Initial load
duke
parents:
diff changeset
   590
            + "\" version \""
7f561c08de6b Initial load
duke
parents:
diff changeset
   591
            + this.getClass().getPackage().getSpecificationVersion()
7f561c08de6b Initial load
duke
parents:
diff changeset
   592
            + "\""
7f561c08de6b Initial load
duke
parents:
diff changeset
   593
            );
7f561c08de6b Initial load
duke
parents:
diff changeset
   594
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   595
7f561c08de6b Initial load
duke
parents:
diff changeset
   596
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   597
     * <p>Get state of XInclude processing.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   598
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   599
     * @return current state of XInclude processing
7f561c08de6b Initial load
duke
parents:
diff changeset
   600
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   601
     * @throws UnsupportedOperationException When implementation does not
7f561c08de6b Initial load
duke
parents:
diff changeset
   602
     *   override this method.
7f561c08de6b Initial load
duke
parents:
diff changeset
   603
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   604
     * @since 1.5
7f561c08de6b Initial load
duke
parents:
diff changeset
   605
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   606
    public boolean isXIncludeAware() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   607
        throw new UnsupportedOperationException(
7f561c08de6b Initial load
duke
parents:
diff changeset
   608
            "This parser does not support specification \""
7f561c08de6b Initial load
duke
parents:
diff changeset
   609
            + this.getClass().getPackage().getSpecificationTitle()
7f561c08de6b Initial load
duke
parents:
diff changeset
   610
            + "\" version \""
7f561c08de6b Initial load
duke
parents:
diff changeset
   611
            + this.getClass().getPackage().getSpecificationVersion()
7f561c08de6b Initial load
duke
parents:
diff changeset
   612
            + "\""
7f561c08de6b Initial load
duke
parents:
diff changeset
   613
            );
7f561c08de6b Initial load
duke
parents:
diff changeset
   614
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   615
}