jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java
author joehw
Wed, 14 Sep 2016 13:18:17 -0700
changeset 41021 444f2b1bcc8c
parent 26516 8e6a45c22cea
permissions -rw-r--r--
8165784: Deprecate the internal Catalog API in JDK 9 Reviewed-by: dfuchs, rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
     2
 * Licensed to the Apache Software Foundation (ASF) under one or more
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
     3
 * contributor license agreements.  See the NOTICE file distributed with
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
     4
 * this work for additional information regarding copyright ownership.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
     5
 * The ASF licenses this file to You under the Apache License, Version 2.0
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
     6
 * (the "License"); you may not use this file except in compliance with
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
     7
 * the License.  You may obtain a copy of the License at
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 *      http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
package com.sun.org.apache.xml.internal.resolver;
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
16953
a44e04deb948 6657673: Issues with JAXP
joehw
parents: 12458
diff changeset
    20
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
22415
4e3bef0828af 8022935: Enhance Apache resolver classes
joehw
parents: 16953
diff changeset
    21
import com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver;
4e3bef0828af 8022935: Enhance Apache resolver classes
joehw
parents: 16953
diff changeset
    22
import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
import java.io.InputStream;
22415
4e3bef0828af 8022935: Enhance Apache resolver classes
joehw
parents: 16953
diff changeset
    24
import java.net.MalformedURLException;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import java.net.URL;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import java.util.MissingResourceException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import java.util.PropertyResourceBundle;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import java.util.ResourceBundle;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import java.util.StringTokenizer;
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import java.util.Vector;
22415
4e3bef0828af 8022935: Enhance Apache resolver classes
joehw
parents: 16953
diff changeset
    31
import sun.reflect.misc.ReflectUtil;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
 * CatalogManager provides an interface to the catalog properties.
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 * <p>Properties can come from two places: from system properties or
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
 * from a <i>CatalogManager.properties</i> file. This class provides a transparent
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 * interface to both, with system properties preferred over property file values.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 * <p>The following table summarizes the properties:</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * <table border="1">
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * <thead>
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * <tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 * <td>System Property</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * <td>CatalogManager.properties<br/>Property</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 * <td>Description</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
 * </tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
 * </thead>
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 * <tbody>
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
 * <tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
 * <td>xml.catalog.ignoreMissing</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
 * <td>&#160;</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
 * <td>If true, a missing <i>CatalogManager.properties</i> file or missing properties
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
 * within that file will not generate warning messages. See also the
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
 * <i>ignoreMissingProperties</i> method.</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
 * </tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
 * <tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
 * <td>xml.catalog.files</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
 * <td>catalogs</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
 * <td>The <emph>semicolon-delimited</emph> list of catalog files.</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
 * </tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
 * <tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
 * <td>&#160;</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
 * <td>relative-catalogs</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
 * <td>If false, relative catalog URIs are made absolute with respect to the base URI of
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
 * the <i>CatalogManager.properties</i> file. This setting only applies to catalog
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
 * URIs obtained from the <i>catalogs</i> property <emph>in the</emph>
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
 * <i>CatalogManager.properties</i> file</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
 * </tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
 * <tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
 * <td>xml.catalog.verbosity</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
 * <td>verbosity</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
 * <td>If non-zero, the Catalog classes will print informative and debugging messages.
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
 * The higher the number, the more messages.</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
 * </tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
 * <tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
 * <td>xml.catalog.prefer</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
 * <td>prefer</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
 * <td>Which identifier is preferred, "public" or "system"?</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
 * </tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
 * <tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
 * <td>xml.catalog.staticCatalog</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
 * <td>static-catalog</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
 * <td>Should a single catalog be constructed for all parsing, or should a different
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
 * catalog be created for each parser?</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
 * </tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
 * <tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
 * <td>xml.catalog.allowPI</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
 * <td>allow-oasis-xml-catalog-pi</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
 * <td>If the source document contains "oasis-xml-catalog" processing instructions,
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
 * should they be used?</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
 * </tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
 * <tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
 * <td>xml.catalog.className</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
 * <td>catalog-class-name</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
 * <td>If you're using the convenience classes
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
 * <tt>com.sun.org.apache.xml.internal.resolver.tools.*</tt>), this setting
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
 * allows you to specify an alternate class name to use for the underlying
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
 * catalog.</td>
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
 * </tr>
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
 * </tbody>
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
 * </table>
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
 * @see Catalog
41021
444f2b1bcc8c 8165784: Deprecate the internal Catalog API in JDK 9
joehw
parents: 26516
diff changeset
   113
 * @deprecated The JDK internal Catalog API in package
444f2b1bcc8c 8165784: Deprecate the internal Catalog API in JDK 9
joehw
parents: 26516
diff changeset
   114
 * {@code com.sun.org.apache.xml.internal.resolver}
444f2b1bcc8c 8165784: Deprecate the internal Catalog API in JDK 9
joehw
parents: 26516
diff changeset
   115
 * is encapsulated in JDK 9. The entire implementation under the package is now
444f2b1bcc8c 8165784: Deprecate the internal Catalog API in JDK 9
joehw
parents: 26516
diff changeset
   116
 * deprecated and subject to removal in a future release. Users of the API
444f2b1bcc8c 8165784: Deprecate the internal Catalog API in JDK 9
joehw
parents: 26516
diff changeset
   117
 * should migrate to the {@linkplain javax.xml.catalog new public API}.
444f2b1bcc8c 8165784: Deprecate the internal Catalog API in JDK 9
joehw
parents: 26516
diff changeset
   118
 * <p>
444f2b1bcc8c 8165784: Deprecate the internal Catalog API in JDK 9
joehw
parents: 26516
diff changeset
   119
 * The new Catalog API is supported throughout the JDK XML Processors, which allows
444f2b1bcc8c 8165784: Deprecate the internal Catalog API in JDK 9
joehw
parents: 26516
diff changeset
   120
 * the use of Catalog by simply setting a path to a Catalog file as a property.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
 * @author Norman Walsh
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
 * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
 *
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   125
 * @version 1.0
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
 */
41021
444f2b1bcc8c 8165784: Deprecate the internal Catalog API in JDK 9
joehw
parents: 26516
diff changeset
   127
@Deprecated(since="9", forRemoval=true)
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
public class CatalogManager {
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   129
    private static final String pFiles         = "xml.catalog.files";
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   130
    private static final String pVerbosity     = "xml.catalog.verbosity";
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   131
    private static final String pPrefer        = "xml.catalog.prefer";
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   132
    private static final String pStatic        = "xml.catalog.staticCatalog";
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   133
    private static final String pAllowPI       = "xml.catalog.allowPI";
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   134
    private static final String pClassname     = "xml.catalog.className";
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   135
    private static final String pIgnoreMissing = "xml.catalog.ignoreMissing";
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   137
    /** A static CatalogManager instance for sharing */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   138
    private static final CatalogManager staticManager = new CatalogManager();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   140
    /** The bootstrap resolver to use when loading XML Catalogs. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   141
    private BootstrapResolver bResolver = new BootstrapResolver();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   143
    /** Flag to ignore missing property files and/or properties */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   144
    private boolean ignoreMissingProperties
16953
a44e04deb948 6657673: Issues with JAXP
joehw
parents: 12458
diff changeset
   145
    = (SecuritySupport.getSystemProperty(pIgnoreMissing) != null
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   146
    || SecuritySupport.getSystemProperty(pFiles) != null);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   148
    /** Holds the resources after they are loaded from the file. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   149
    private ResourceBundle resources;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   151
    /** The name of the CatalogManager properties file. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   152
    private String propertyFile = "CatalogManager.properties";
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   154
    /** The location of the propertyFile */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   155
    private URL propertyFileURI = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   157
    /** Default catalog files list. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   158
    private String defaultCatalogFiles = "./xcatalog";
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   160
    /** Current catalog files list. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   161
    private String catalogFiles = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   163
    /** Did the catalogFiles come from the properties file? */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   164
    private boolean fromPropertiesFile = false;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   166
    /** Default verbosity level if there is no property setting for it. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   167
    private int defaultVerbosity = 1;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   169
    /** Current verbosity level. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   170
    private Integer verbosity = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   172
    /** Default preference setting. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   173
    private boolean defaultPreferPublic = true;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   175
    /** Current preference setting. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   176
    private Boolean preferPublic = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   178
    /** Default setting of the static catalog flag. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   179
    private boolean defaultUseStaticCatalog = true;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   181
    /** Current setting of the static catalog flag. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   182
    private Boolean useStaticCatalog = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   184
    /** The static catalog used by this manager. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   185
    private static volatile Catalog staticCatalog = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   187
    /** Default setting of the oasisXMLCatalogPI flag. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   188
    private boolean defaultOasisXMLCatalogPI = true;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   190
    /** Current setting of the oasisXMLCatalogPI flag. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   191
    private Boolean oasisXMLCatalogPI = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   193
    /** Default setting of the relativeCatalogs flag. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   194
    private boolean defaultRelativeCatalogs = true;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   196
    /** Current setting of the relativeCatalogs flag. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   197
    private Boolean relativeCatalogs = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   199
    /** Current catalog class name. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   200
    private String catalogClassName = null;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   201
    /**
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   202
     * Indicates whether implementation parts should use
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   203
     *   service loader (or similar).
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   204
     * Note the default value (false) is the safe option..
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   205
     */
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   206
    private boolean useServicesMechanism;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   208
    /** The manager's debug object. Used for printing debugging messages.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   209
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   210
     * <p>This field is public so that objects that have access to this
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   211
     * CatalogManager can use this debug object.</p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   212
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   213
    public Debug debug = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   215
    /** Constructor. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   216
    public CatalogManager() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   217
        init();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   218
    }
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   219
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   220
    /** Constructor that specifies an explicit property file. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   221
    public CatalogManager(String propertyFile) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   222
        this.propertyFile = propertyFile;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   223
        init();
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   224
  }
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   225
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   226
  private void init() {
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   227
        debug = new Debug();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
    // Note that we don't setDebug() here; we do that lazily. Either the
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
    // user will set it explicitly, or we'll do it automagically if they
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
    // read from the propertyFile for some other reason. That way, there's
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
    // no attempt to read from the file before the caller has had a chance
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
    // to avoid it.
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   233
    if (System.getSecurityManager() == null) {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   234
        useServicesMechanism = true;
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   235
    }
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   236
        // Make sure verbosity is set by xml.catalog.verbosity sysprop
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   237
        // setting, if defined.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   238
        queryVerbosityFromSysProp();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   239
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   241
    /** Set the bootstrap resolver
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   242
     * @param resolver the bootstrap resolver
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   243
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   244
    public void setBootstrapResolver(BootstrapResolver resolver) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   245
        bResolver = resolver;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   246
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   248
    /** Get the bootstrap resolver
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   249
     * @return the bootstrap resolver
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   250
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   251
    public BootstrapResolver getBootstrapResolver() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   252
        return bResolver;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   253
    }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   254
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   255
    /** Query system property for verbosity level. */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   256
    private void queryVerbosityFromSysProp() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   257
        String verbStr = SecuritySupport.getSystemProperty(pVerbosity);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   258
        if (verbStr != null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   259
            try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   260
                int verb = Integer.parseInt(verbStr.trim());
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   261
                verbosity = new Integer(verb);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   262
                debug.setDebug(verb);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   263
            } catch (Exception e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   264
                System.err.println("Cannot parse verbosity: \"" + verbStr + "\"");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   265
            }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   269
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   270
     * Load the properties from the propertyFile and build the
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   271
     * resources from it.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   272
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   273
    private synchronized void readProperties() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   274
        try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   275
            propertyFileURI = CatalogManager.class.getResource("/"+propertyFile);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   276
            InputStream in =
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   277
                    CatalogManager.class.getResourceAsStream("/"+propertyFile);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   278
            if (in==null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   279
                if (!ignoreMissingProperties) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   280
                    System.err.println("Cannot find "+propertyFile);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   281
                    // there's no reason to give this warning more than once
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   282
                    ignoreMissingProperties = true;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   283
                }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   284
                return;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   285
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   286
            resources = new PropertyResourceBundle(in);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   287
        } catch (MissingResourceException mre) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   288
            if (!ignoreMissingProperties) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   289
                System.err.println("Cannot read "+propertyFile);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   290
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   291
        } catch (java.io.IOException e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   292
            if (!ignoreMissingProperties) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   293
                System.err.println("Failure trying to read "+propertyFile);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   294
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   295
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   297
        // This is a bit of a hack. After we've successfully read the properties,
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   298
        // use them to set the default debug level, if the user hasn't already set
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   299
        // the default debug level.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   300
        if (verbosity == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   301
            try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   302
                String verbStr = resources.getString("verbosity");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   303
                int verb = Integer.parseInt(verbStr.trim());
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   304
                debug.setDebug(verb);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   305
                verbosity = new Integer(verb);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   306
            } catch (Exception e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   307
                // nop
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   308
            }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   312
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   313
     * Allow access to the static CatalogManager
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   314
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   315
    public static CatalogManager getStaticManager() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   316
        return staticManager;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   317
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   319
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   320
     * How are missing properties handled?
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   321
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   322
     * <p>If true, missing or unreadable property files will
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   323
     * not be reported. Otherwise, a message will be sent to System.err.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   324
     * </p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   325
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   326
    public boolean getIgnoreMissingProperties() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   327
        return ignoreMissingProperties;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   330
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   331
     * How should missing properties be handled?
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   332
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   333
     * <p>If ignore is true, missing or unreadable property files will
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   334
     * not be reported. Otherwise, a message will be sent to System.err.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   335
     * </p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   336
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   337
    public void setIgnoreMissingProperties(boolean ignore) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   338
        ignoreMissingProperties = ignore;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   339
    }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   340
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   341
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   342
     * How are missing properties handled?
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   343
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   344
     * <p>If ignore is true, missing or unreadable property files will
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   345
     * not be reported. Otherwise, a message will be sent to System.err.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   346
     * </p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   347
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   348
     * @deprecated No longer static; use get/set methods.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   349
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   350
    public void ignoreMissingProperties(boolean ignore) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   351
        setIgnoreMissingProperties(ignore);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   354
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   355
     * Obtain the verbosity setting from the properties.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   356
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   357
     * @return The verbosity level from the propertyFile or the
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   358
     * defaultVerbosity.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   359
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   360
    private int queryVerbosity () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   361
        String defaultVerbStr = Integer.toString(defaultVerbosity);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   362
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   363
        String verbStr = SecuritySupport.getSystemProperty(pVerbosity);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   365
        if (verbStr == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   366
            if (resources==null) readProperties();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   367
            if (resources != null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   368
                try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   369
                    verbStr = resources.getString("verbosity");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   370
                } catch (MissingResourceException e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   371
                    verbStr = defaultVerbStr;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   372
                }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   373
            } else {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   374
                verbStr = defaultVerbStr;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   375
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   376
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   377
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   378
        int verb = defaultVerbosity;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   379
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   380
        try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   381
            verb = Integer.parseInt(verbStr.trim());
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   382
        } catch (Exception e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   383
            System.err.println("Cannot parse verbosity: \"" + verbStr + "\"");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   384
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   385
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   386
        // This is a bit of a hack. After we've successfully got the verbosity,
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   387
        // we have to use it to set the default debug level,
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   388
        // if the user hasn't already set the default debug level.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   389
        if (verbosity == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   390
            debug.setDebug(verb);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   391
            verbosity = new Integer(verb);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   392
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   393
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   394
        return verb;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   397
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   398
     * What is the current verbosity?
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   399
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   400
    public int getVerbosity() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   401
        if (verbosity == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   402
            verbosity = new Integer(queryVerbosity());
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   403
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   405
        return verbosity.intValue();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   406
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   407
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   408
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   409
     * Set the current verbosity.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   410
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   411
    public void setVerbosity (int verbosity) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   412
        this.verbosity = new Integer(verbosity);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   413
        debug.setDebug(verbosity);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   414
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   415
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   416
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   417
     * What is the current verbosity?
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   418
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   419
     * @deprecated No longer static; use get/set methods.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   420
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   421
    public int verbosity () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   422
        return getVerbosity();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   423
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   425
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   426
     * Obtain the relativeCatalogs setting from the properties.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   427
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   428
     * @return The relativeCatalogs setting from the propertyFile or the
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   429
     * defaultRelativeCatalogs.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   430
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   431
    private boolean queryRelativeCatalogs () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   432
        if (resources==null) readProperties();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   433
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   434
        if (resources==null) return defaultRelativeCatalogs;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   435
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   436
        try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   437
            String allow = resources.getString("relative-catalogs");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   438
            return (allow.equalsIgnoreCase("true")
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   439
                    || allow.equalsIgnoreCase("yes")
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   440
                    || allow.equalsIgnoreCase("1"));
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   441
        } catch (MissingResourceException e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   442
            return defaultRelativeCatalogs;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   443
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   445
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   446
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   447
     * Get the relativeCatalogs setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   448
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   449
     * <p>This property is used when the catalogFiles property is
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   450
     * interrogated. If true, then relative catalog entry file names
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   451
     * are returned. If false, relative catalog entry file names are
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   452
     * made absolute with respect to the properties file before returning
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   453
     * them.</p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   454
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   455
     * <p>This property <emph>only applies</emph> when the catalog files
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   456
     * come from a properties file. If they come from a system property or
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   457
     * the default list, they are never considered relative. (What would
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   458
     * they be relative to?)</p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   459
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   460
     * <p>In the properties, a value of 'yes', 'true', or '1' is considered
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   461
     * true, anything else is false.</p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   462
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   463
     * @return The relativeCatalogs setting from the propertyFile or the
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   464
     * defaultRelativeCatalogs.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   465
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   466
    public boolean getRelativeCatalogs () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   467
        if (relativeCatalogs == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   468
            relativeCatalogs = queryRelativeCatalogs() ? Boolean.TRUE : Boolean.FALSE;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   469
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   470
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   471
        return relativeCatalogs.booleanValue();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   472
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   473
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   474
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   475
     * Set the relativeCatalogs setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   476
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   477
     * @see #getRelativeCatalogs()
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   478
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   479
    public void setRelativeCatalogs (boolean relative) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   480
        relativeCatalogs = relative ? Boolean.TRUE : Boolean.FALSE;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   481
    }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   482
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   483
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   484
     * Get the relativeCatalogs setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   485
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   486
     * @deprecated No longer static; use get/set methods.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   487
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   488
    public boolean relativeCatalogs () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   489
        return getRelativeCatalogs();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   490
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   491
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   492
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   493
     * Obtain the list of catalog files from the properties.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   494
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   495
     * @return A semicolon delimited list of catlog file URIs
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   496
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   497
    private String queryCatalogFiles () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   498
        String catalogList = SecuritySupport.getSystemProperty(pFiles);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   499
        fromPropertiesFile = false;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   500
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   501
        if (catalogList == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   502
            if (resources == null) readProperties();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   503
            if (resources != null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   504
                try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   505
                    catalogList = resources.getString("catalogs");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   506
                    fromPropertiesFile = true;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   507
                } catch (MissingResourceException e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   508
                    System.err.println(propertyFile + ": catalogs not found.");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   509
                    catalogList = null;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   510
                }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   511
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   512
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   513
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   514
        if (catalogList == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   515
            catalogList = defaultCatalogFiles;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   516
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   517
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   518
        return catalogList;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   519
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   520
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   521
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   522
     * Return the current list of catalog files.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   523
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   524
     * @return A vector of the catalog file names or null if no catalogs
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   525
     * are available in the properties.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   526
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   527
    public Vector getCatalogFiles() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   528
        if (catalogFiles == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   529
            catalogFiles = queryCatalogFiles();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   530
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   531
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   532
        StringTokenizer files = new StringTokenizer(catalogFiles, ";");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   533
        Vector catalogs = new Vector();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   534
        while (files.hasMoreTokens()) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   535
            String catalogFile = files.nextToken();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   536
            URL absURI = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   537
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   538
            if (fromPropertiesFile && !relativeCatalogs()) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   539
                try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   540
                    absURI = new URL(propertyFileURI, catalogFile);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   541
                    catalogFile = absURI.toString();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   542
                } catch (MalformedURLException mue) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   543
                    absURI = null;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   544
                }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   545
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   546
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   547
            catalogs.add(catalogFile);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   548
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   549
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   550
        return catalogs;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   551
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   552
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   553
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   554
     * Set the list of catalog files.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   555
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   556
    public void setCatalogFiles(String fileList) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   557
        catalogFiles = fileList;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   558
        fromPropertiesFile = false;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   559
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   560
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   561
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   562
     * Return the current list of catalog files.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   563
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   564
     * @return A vector of the catalog file names or null if no catalogs
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   565
     * are available in the properties.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   566
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   567
     * @deprecated No longer static; use get/set methods.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   568
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   569
    public Vector catalogFiles() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   570
        return getCatalogFiles();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   571
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   572
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   573
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   574
     * Obtain the preferPublic setting from the properties.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   575
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   576
     * <p>In the properties, a value of 'public' is true,
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   577
     * anything else is false.</p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   578
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   579
     * @return True if prefer is public or the
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   580
     * defaultPreferSetting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   581
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   582
    private boolean queryPreferPublic () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   583
        String prefer = SecuritySupport.getSystemProperty(pPrefer);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   584
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   585
        if (prefer == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   586
            if (resources==null) readProperties();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   587
            if (resources==null) return defaultPreferPublic;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   588
            try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   589
                prefer = resources.getString("prefer");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   590
            } catch (MissingResourceException e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   591
                return defaultPreferPublic;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   592
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   593
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   594
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   595
        if (prefer == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   596
            return defaultPreferPublic;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   597
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   598
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   599
        return (prefer.equalsIgnoreCase("public"));
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   600
    }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   601
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   602
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   603
     * Return the current prefer public setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   604
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   605
     * @return True if public identifiers are preferred.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   606
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   607
    public boolean getPreferPublic () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   608
        if (preferPublic == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   609
            preferPublic = queryPreferPublic() ? Boolean.TRUE : Boolean.FALSE;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   610
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   611
        return preferPublic.booleanValue();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   612
    }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   613
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   614
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   615
     * Set the prefer public setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   616
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   617
    public void setPreferPublic (boolean preferPublic) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   618
        this.preferPublic = preferPublic ? Boolean.TRUE : Boolean.FALSE;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   619
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   620
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   621
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   622
     * Return the current prefer public setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   623
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   624
     * @return True if public identifiers are preferred.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   625
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   626
     * @deprecated No longer static; use get/set methods.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   627
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   628
    public boolean preferPublic () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   629
        return getPreferPublic();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   630
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   631
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   632
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   633
     * Obtain the static-catalog setting from the properties.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   634
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   635
     * <p>In the properties, a value of 'yes', 'true', or '1' is considered
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   636
     * true, anything else is false.</p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   637
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   638
     * @return The static-catalog setting from the propertyFile or the
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   639
     * defaultUseStaticCatalog.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   640
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   641
    private boolean queryUseStaticCatalog () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   642
        String staticCatalog = SecuritySupport.getSystemProperty(pStatic);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   643
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   644
        if (staticCatalog == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   645
            if (resources==null) readProperties();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   646
            if (resources==null) return defaultUseStaticCatalog;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   647
            try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   648
                staticCatalog = resources.getString("static-catalog");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   649
            } catch (MissingResourceException e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   650
                return defaultUseStaticCatalog;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   651
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   652
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   653
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   654
        if (staticCatalog == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   655
            return defaultUseStaticCatalog;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   656
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   657
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   658
        return (staticCatalog.equalsIgnoreCase("true")
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   659
                || staticCatalog.equalsIgnoreCase("yes")
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   660
                || staticCatalog.equalsIgnoreCase("1"));
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   661
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   662
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   663
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   664
     * Get the current use static catalog setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   665
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   666
    public boolean getUseStaticCatalog() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   667
        if (useStaticCatalog == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   668
            useStaticCatalog = queryUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   669
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   670
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   671
        return useStaticCatalog.booleanValue();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   672
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   673
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   674
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   675
     * Set the use static catalog setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   676
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   677
    public void setUseStaticCatalog(boolean useStatic) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   678
        useStaticCatalog = useStatic ? Boolean.TRUE : Boolean.FALSE;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   679
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   680
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   681
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   682
     * Get the current use static catalog setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   683
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   684
     * @deprecated No longer static; use get/set methods.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   685
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   686
    public boolean staticCatalog() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   687
        return getUseStaticCatalog();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   688
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   689
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   690
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   691
     * Get a new catalog instance.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   692
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   693
     * This method always returns a new instance of the underlying catalog class.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   694
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   695
    public Catalog getPrivateCatalog() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   696
        Catalog catalog = staticCatalog;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   697
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   698
        if (useStaticCatalog == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   699
            useStaticCatalog = getUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   700
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   701
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   702
        if (catalog == null || !useStaticCatalog.booleanValue()) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   703
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   704
            try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   705
                String catalogClassName = getCatalogClassName();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   706
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   707
                if (catalogClassName == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   708
                    catalog = new Catalog();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   709
                } else {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   710
                    try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   711
                        catalog = (Catalog) ReflectUtil.forName(catalogClassName).newInstance();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   712
                    } catch (ClassNotFoundException cnfe) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   713
                        debug.message(1,"Catalog class named '"
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   714
                                + catalogClassName
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   715
                                + "' could not be found. Using default.");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   716
                        catalog = new Catalog();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   717
                    } catch (ClassCastException cnfe) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   718
                        debug.message(1,"Class named '"
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   719
                                + catalogClassName
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   720
                                + "' is not a Catalog. Using default.");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   721
                        catalog = new Catalog();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   722
                    }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   723
                }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   724
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   725
                catalog.setCatalogManager(this);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   726
                catalog.setupReaders();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   727
                catalog.loadSystemCatalogs();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   728
            } catch (Exception ex) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   729
                ex.printStackTrace();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   730
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   731
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   732
            if (useStaticCatalog.booleanValue()) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   733
                staticCatalog = catalog;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   734
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   735
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   736
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   737
        return catalog;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   738
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   739
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   740
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   741
     * Get a catalog instance.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   742
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   743
     * If this manager uses static catalogs, the same static catalog will
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   744
     * always be returned. Otherwise a new catalog will be returned.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   745
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   746
    public Catalog getCatalog() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   747
        Catalog catalog = staticCatalog;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   748
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   749
        if (useStaticCatalog == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   750
            useStaticCatalog = getUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   751
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   752
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   753
        if (catalog == null || !useStaticCatalog.booleanValue()) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   754
            catalog = getPrivateCatalog();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   755
            if (useStaticCatalog.booleanValue()) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   756
                staticCatalog = catalog;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   757
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   758
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   759
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   760
        return catalog;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   761
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   762
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   763
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   764
     * <p>Obtain the oasisXMLCatalogPI setting from the properties.</p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   765
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   766
     * <p>In the properties, a value of 'yes', 'true', or '1' is considered
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   767
     * true, anything else is false.</p>
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   768
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   769
     * @return The oasisXMLCatalogPI setting from the propertyFile or the
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   770
     * defaultOasisXMLCatalogPI.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   771
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   772
    public boolean queryAllowOasisXMLCatalogPI () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   773
        String allow = SecuritySupport.getSystemProperty(pAllowPI);
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   774
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   775
        if (allow == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   776
            if (resources==null) readProperties();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   777
            if (resources==null) return defaultOasisXMLCatalogPI;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   778
            try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   779
                allow = resources.getString("allow-oasis-xml-catalog-pi");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   780
            } catch (MissingResourceException e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   781
                return defaultOasisXMLCatalogPI;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   782
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   783
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   784
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   785
        if (allow == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   786
            return defaultOasisXMLCatalogPI;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   787
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   788
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   789
        return (allow.equalsIgnoreCase("true")
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   790
                || allow.equalsIgnoreCase("yes")
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   791
                || allow.equalsIgnoreCase("1"));
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   792
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   793
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   794
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   795
     * Get the current XML Catalog PI setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   796
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   797
    public boolean getAllowOasisXMLCatalogPI () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   798
        if (oasisXMLCatalogPI == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   799
            oasisXMLCatalogPI = queryAllowOasisXMLCatalogPI() ? Boolean.TRUE : Boolean.FALSE;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   800
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   801
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   802
        return oasisXMLCatalogPI.booleanValue();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   803
    }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   804
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   805
    public boolean useServicesMechanism() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   806
        return useServicesMechanism;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   807
    }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   808
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   809
     * Set the XML Catalog PI setting
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   810
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   811
    public void setAllowOasisXMLCatalogPI(boolean allowPI) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   812
        oasisXMLCatalogPI = allowPI ? Boolean.TRUE : Boolean.FALSE;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   813
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   814
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   815
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   816
     * Get the current XML Catalog PI setting.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   817
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   818
     * @deprecated No longer static; use get/set methods.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   819
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   820
    public boolean allowOasisXMLCatalogPI() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   821
        return getAllowOasisXMLCatalogPI();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   822
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   823
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   824
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   825
     * Obtain the Catalog class name setting from the properties.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   826
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   827
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   828
    public String queryCatalogClassName () {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   829
        String className = SecuritySupport.getSystemProperty(pClassname);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   830
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   831
        if (className == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   832
            if (resources==null) readProperties();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   833
            if (resources==null) return null;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   834
            try {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   835
                return resources.getString("catalog-class-name");
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   836
            } catch (MissingResourceException e) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   837
                return null;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   838
            }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   839
        }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   840
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   841
        return className;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   842
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   843
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   844
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   845
     * Get the current Catalog class name.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   846
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   847
    public String getCatalogClassName() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   848
        if (catalogClassName == null) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   849
            catalogClassName = queryCatalogClassName();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   850
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   851
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   852
        return catalogClassName;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   853
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   854
26516
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   855
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   856
     * Set the Catalog class name.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   857
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   858
    public void setCatalogClassName(String className) {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   859
        catalogClassName = className;
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   860
    }
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   861
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   862
    /**
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   863
     * Get the current Catalog class name.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   864
     *
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   865
     * @deprecated No longer static; use get/set methods.
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   866
     */
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   867
    public String catalogClassName() {
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   868
        return getCatalogClassName();
8e6a45c22cea 8056202: Xerces Update: Catalog Resolver
joehw
parents: 25868
diff changeset
   869
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   870
}