--- old/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java Thu Aug 28 19:10:37 2014 +++ new/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java Thu Aug 28 19:10:37 2014 @@ -1,17 +1,11 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -// CatalogManager.java - Access CatalogManager.properties - -/* - * Copyright 2001-2004 The Apache Software Foundation or its licensors, - * as applicable. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -124,78 +118,78 @@ */ public class CatalogManager { - private static String pFiles = "xml.catalog.files"; - private static String pVerbosity = "xml.catalog.verbosity"; - private static String pPrefer = "xml.catalog.prefer"; - private static String pStatic = "xml.catalog.staticCatalog"; - private static String pAllowPI = "xml.catalog.allowPI"; - private static String pClassname = "xml.catalog.className"; - private static String pIgnoreMissing = "xml.catalog.ignoreMissing"; + private static final String pFiles = "xml.catalog.files"; + private static final String pVerbosity = "xml.catalog.verbosity"; + private static final String pPrefer = "xml.catalog.prefer"; + private static final String pStatic = "xml.catalog.staticCatalog"; + private static final String pAllowPI = "xml.catalog.allowPI"; + private static final String pClassname = "xml.catalog.className"; + private static final String pIgnoreMissing = "xml.catalog.ignoreMissing"; - /** A static CatalogManager instance for sharing */ - private static CatalogManager staticManager = new CatalogManager(); + /** A static CatalogManager instance for sharing */ + private static final CatalogManager staticManager = new CatalogManager(); - /** The bootstrap resolver to use when loading XML Catalogs. */ - private BootstrapResolver bResolver = new BootstrapResolver(); + /** The bootstrap resolver to use when loading XML Catalogs. */ + private BootstrapResolver bResolver = new BootstrapResolver(); - /** Flag to ignore missing property files and/or properties */ - private boolean ignoreMissingProperties + /** Flag to ignore missing property files and/or properties */ + private boolean ignoreMissingProperties = (SecuritySupport.getSystemProperty(pIgnoreMissing) != null - || SecuritySupport.getSystemProperty(pFiles) != null); + || SecuritySupport.getSystemProperty(pFiles) != null); - /** Holds the resources after they are loaded from the file. */ - private ResourceBundle resources; + /** Holds the resources after they are loaded from the file. */ + private ResourceBundle resources; - /** The name of the CatalogManager properties file. */ - private String propertyFile = "CatalogManager.properties"; + /** The name of the CatalogManager properties file. */ + private String propertyFile = "CatalogManager.properties"; - /** The location of the propertyFile */ - private URL propertyFileURI = null; + /** The location of the propertyFile */ + private URL propertyFileURI = null; - /** Default catalog files list. */ - private String defaultCatalogFiles = "./xcatalog"; + /** Default catalog files list. */ + private String defaultCatalogFiles = "./xcatalog"; - /** Current catalog files list. */ - private String catalogFiles = null; + /** Current catalog files list. */ + private String catalogFiles = null; - /** Did the catalogFiles come from the properties file? */ - private boolean fromPropertiesFile = false; + /** Did the catalogFiles come from the properties file? */ + private boolean fromPropertiesFile = false; - /** Default verbosity level if there is no property setting for it. */ - private int defaultVerbosity = 1; + /** Default verbosity level if there is no property setting for it. */ + private int defaultVerbosity = 1; - /** Current verbosity level. */ - private Integer verbosity = null; + /** Current verbosity level. */ + private Integer verbosity = null; - /** Default preference setting. */ - private boolean defaultPreferPublic = true; + /** Default preference setting. */ + private boolean defaultPreferPublic = true; - /** Current preference setting. */ - private Boolean preferPublic = null; + /** Current preference setting. */ + private Boolean preferPublic = null; - /** Default setting of the static catalog flag. */ - private boolean defaultUseStaticCatalog = true; + /** Default setting of the static catalog flag. */ + private boolean defaultUseStaticCatalog = true; - /** Current setting of the static catalog flag. */ - private Boolean useStaticCatalog = null; + /** Current setting of the static catalog flag. */ + private Boolean useStaticCatalog = null; - /** The static catalog used by this manager. */ - private static Catalog staticCatalog = null; + /** The static catalog used by this manager. */ + private static volatile Catalog staticCatalog = null; - /** Default setting of the oasisXMLCatalogPI flag. */ - private boolean defaultOasisXMLCatalogPI = true; + /** Default setting of the oasisXMLCatalogPI flag. */ + private boolean defaultOasisXMLCatalogPI = true; - /** Current setting of the oasisXMLCatalogPI flag. */ - private Boolean oasisXMLCatalogPI = null; + /** Current setting of the oasisXMLCatalogPI flag. */ + private Boolean oasisXMLCatalogPI = null; - /** Default setting of the relativeCatalogs flag. */ - private boolean defaultRelativeCatalogs = true; + /** Default setting of the relativeCatalogs flag. */ + private boolean defaultRelativeCatalogs = true; - /** Current setting of the relativeCatalogs flag. */ - private Boolean relativeCatalogs = null; + /** Current setting of the relativeCatalogs flag. */ + private Boolean relativeCatalogs = null; - /** Current catalog class name. */ - private String catalogClassName = null; + /** Current catalog class name. */ + private String catalogClassName = null; /** * Indicates whether implementation parts should use * service loader (or similar). @@ -203,26 +197,26 @@ */ private boolean useServicesMechanism; - /** The manager's debug object. Used for printing debugging messages. - * - *

This field is public so that objects that have access to this - * CatalogManager can use this debug object.

- */ - public Debug debug = null; + /** The manager's debug object. Used for printing debugging messages. + * + *

This field is public so that objects that have access to this + * CatalogManager can use this debug object.

+ */ + public Debug debug = null; - /** Constructor. */ - public CatalogManager() { - init(); - } + /** Constructor. */ + public CatalogManager() { + init(); + } - /** Constructor that specifies an explicit property file. */ - public CatalogManager(String propertyFile) { - this.propertyFile = propertyFile; - init(); + /** Constructor that specifies an explicit property file. */ + public CatalogManager(String propertyFile) { + this.propertyFile = propertyFile; + init(); } private void init() { - debug = new Debug(); + debug = new Debug(); // Note that we don't setDebug() here; we do that lazily. Either the // user will set it explicitly, or we'll do it automagically if they // read from the propertyFile for some other reason. That way, there's @@ -231,616 +225,638 @@ if (System.getSecurityManager() == null) { useServicesMechanism = true; } - } - /** Set the bootstrap resolver.*/ - public void setBootstrapResolver(BootstrapResolver resolver) { - bResolver = resolver; - } + // Make sure verbosity is set by xml.catalog.verbosity sysprop + // setting, if defined. + queryVerbosityFromSysProp(); + } - /** Get the bootstrap resolver.*/ - public BootstrapResolver getBootstrapResolver() { - return bResolver; - } + /** Set the bootstrap resolver + * @param resolver the bootstrap resolver + */ + public void setBootstrapResolver(BootstrapResolver resolver) { + bResolver = resolver; + } - /** - * Load the properties from the propertyFile and build the - * resources from it. - */ - private synchronized void readProperties() { - try { - propertyFileURI = CatalogManager.class.getResource("/"+propertyFile); - InputStream in = - CatalogManager.class.getResourceAsStream("/"+propertyFile); - if (in==null) { - if (!ignoreMissingProperties) { - System.err.println("Cannot find "+propertyFile); - // there's no reason to give this warning more than once - ignoreMissingProperties = true; - } - return; - } - resources = new PropertyResourceBundle(in); - } catch (MissingResourceException mre) { - if (!ignoreMissingProperties) { - System.err.println("Cannot read "+propertyFile); - } - } catch (java.io.IOException e) { - if (!ignoreMissingProperties) { - System.err.println("Failure trying to read "+propertyFile); - } + /** Get the bootstrap resolver + * @return the bootstrap resolver + */ + public BootstrapResolver getBootstrapResolver() { + return bResolver; } - // This is a bit of a hack. After we've successfully read the properties, - // use them to set the default debug level, if the user hasn't already set - // the default debug level. - if (verbosity == null) { - try { - String verbStr = resources.getString("verbosity"); - int verb = Integer.parseInt(verbStr.trim()); - debug.setDebug(verb); - verbosity = new Integer(verb); - } catch (Exception e) { - // nop - } + /** Query system property for verbosity level. */ + private void queryVerbosityFromSysProp() { + String verbStr = SecuritySupport.getSystemProperty(pVerbosity); + if (verbStr != null) { + try { + int verb = Integer.parseInt(verbStr.trim()); + verbosity = new Integer(verb); + debug.setDebug(verb); + } catch (Exception e) { + System.err.println("Cannot parse verbosity: \"" + verbStr + "\""); + } + } } - } - /** - * Allow access to the static CatalogManager - */ - public static CatalogManager getStaticManager() { - return staticManager; - } - - /** - * How are missing properties handled? - * - *

If true, missing or unreadable property files will - * not be reported. Otherwise, a message will be sent to System.err. - *

- */ - public boolean getIgnoreMissingProperties() { - return ignoreMissingProperties; - } - - /** - * How should missing properties be handled? - * - *

If ignore is true, missing or unreadable property files will - * not be reported. Otherwise, a message will be sent to System.err. - *

- */ - public void setIgnoreMissingProperties(boolean ignore) { - ignoreMissingProperties = ignore; - } - - /** - * How are missing properties handled? - * - *

If ignore is true, missing or unreadable property files will - * not be reported. Otherwise, a message will be sent to System.err. - *

- * - * @deprecated No longer static; use get/set methods. - */ - public void ignoreMissingProperties(boolean ignore) { - setIgnoreMissingProperties(ignore); - } - - /** - * Obtain the verbosity setting from the properties. - * - * @return The verbosity level from the propertyFile or the - * defaultVerbosity. - */ - private int queryVerbosity () { - String defaultVerbStr = Integer.toString(defaultVerbosity); - - String verbStr = SecuritySupport.getSystemProperty(pVerbosity); - - if (verbStr == null) { - if (resources==null) readProperties(); - if (resources != null) { + /** + * Load the properties from the propertyFile and build the + * resources from it. + */ + private synchronized void readProperties() { try { - verbStr = resources.getString("verbosity"); - } catch (MissingResourceException e) { - verbStr = defaultVerbStr; + propertyFileURI = CatalogManager.class.getResource("/"+propertyFile); + InputStream in = + CatalogManager.class.getResourceAsStream("/"+propertyFile); + if (in==null) { + if (!ignoreMissingProperties) { + System.err.println("Cannot find "+propertyFile); + // there's no reason to give this warning more than once + ignoreMissingProperties = true; + } + return; + } + resources = new PropertyResourceBundle(in); + } catch (MissingResourceException mre) { + if (!ignoreMissingProperties) { + System.err.println("Cannot read "+propertyFile); + } + } catch (java.io.IOException e) { + if (!ignoreMissingProperties) { + System.err.println("Failure trying to read "+propertyFile); + } } - } else { - verbStr = defaultVerbStr; - } + + // This is a bit of a hack. After we've successfully read the properties, + // use them to set the default debug level, if the user hasn't already set + // the default debug level. + if (verbosity == null) { + try { + String verbStr = resources.getString("verbosity"); + int verb = Integer.parseInt(verbStr.trim()); + debug.setDebug(verb); + verbosity = new Integer(verb); + } catch (Exception e) { + // nop + } + } } - int verb = defaultVerbosity; + /** + * Allow access to the static CatalogManager + */ + public static CatalogManager getStaticManager() { + return staticManager; + } - try { - verb = Integer.parseInt(verbStr.trim()); - } catch (Exception e) { - System.err.println("Cannot parse verbosity: \"" + verbStr + "\""); + /** + * How are missing properties handled? + * + *

If true, missing or unreadable property files will + * not be reported. Otherwise, a message will be sent to System.err. + *

+ */ + public boolean getIgnoreMissingProperties() { + return ignoreMissingProperties; } - // This is a bit of a hack. After we've successfully got the verbosity, - // we have to use it to set the default debug level, - // if the user hasn't already set the default debug level. - if (verbosity == null) { - debug.setDebug(verb); - verbosity = new Integer(verb); + /** + * How should missing properties be handled? + * + *

If ignore is true, missing or unreadable property files will + * not be reported. Otherwise, a message will be sent to System.err. + *

+ */ + public void setIgnoreMissingProperties(boolean ignore) { + ignoreMissingProperties = ignore; } - return verb; - } - - /** - * What is the current verbosity? - */ - public int getVerbosity() { - if (verbosity == null) { - verbosity = new Integer(queryVerbosity()); + /** + * How are missing properties handled? + * + *

If ignore is true, missing or unreadable property files will + * not be reported. Otherwise, a message will be sent to System.err. + *

+ * + * @deprecated No longer static; use get/set methods. + */ + public void ignoreMissingProperties(boolean ignore) { + setIgnoreMissingProperties(ignore); } - return verbosity.intValue(); - } + /** + * Obtain the verbosity setting from the properties. + * + * @return The verbosity level from the propertyFile or the + * defaultVerbosity. + */ + private int queryVerbosity () { + String defaultVerbStr = Integer.toString(defaultVerbosity); - /** - * Set the current verbosity. - */ - public void setVerbosity (int verbosity) { - this.verbosity = new Integer(verbosity); - debug.setDebug(verbosity); - } + String verbStr = SecuritySupport.getSystemProperty(pVerbosity); - /** - * What is the current verbosity? - * - * @deprecated No longer static; use get/set methods. - */ - public int verbosity () { - return getVerbosity(); - } + if (verbStr == null) { + if (resources==null) readProperties(); + if (resources != null) { + try { + verbStr = resources.getString("verbosity"); + } catch (MissingResourceException e) { + verbStr = defaultVerbStr; + } + } else { + verbStr = defaultVerbStr; + } + } - /** - * Obtain the relativeCatalogs setting from the properties. - * - * @return The relativeCatalogs setting from the propertyFile or the - * defaultRelativeCatalogs. - */ - private boolean queryRelativeCatalogs () { - if (resources==null) readProperties(); + int verb = defaultVerbosity; - if (resources==null) return defaultRelativeCatalogs; + try { + verb = Integer.parseInt(verbStr.trim()); + } catch (Exception e) { + System.err.println("Cannot parse verbosity: \"" + verbStr + "\""); + } - try { - String allow = resources.getString("relative-catalogs"); - return (allow.equalsIgnoreCase("true") - || allow.equalsIgnoreCase("yes") - || allow.equalsIgnoreCase("1")); - } catch (MissingResourceException e) { - return defaultRelativeCatalogs; + // This is a bit of a hack. After we've successfully got the verbosity, + // we have to use it to set the default debug level, + // if the user hasn't already set the default debug level. + if (verbosity == null) { + debug.setDebug(verb); + verbosity = new Integer(verb); + } + + return verb; } - } - /** - * Get the relativeCatalogs setting. - * - *

This property is used when the catalogFiles property is - * interrogated. If true, then relative catalog entry file names - * are returned. If false, relative catalog entry file names are - * made absolute with respect to the properties file before returning - * them.

- * - *

This property only applies when the catalog files - * come from a properties file. If they come from a system property or - * the default list, they are never considered relative. (What would - * they be relative to?)

- * - *

In the properties, a value of 'yes', 'true', or '1' is considered - * true, anything else is false.

- * - * @return The relativeCatalogs setting from the propertyFile or the - * defaultRelativeCatalogs. - */ - public boolean getRelativeCatalogs () { - if (relativeCatalogs == null) { - relativeCatalogs = new Boolean(queryRelativeCatalogs()); + /** + * What is the current verbosity? + */ + public int getVerbosity() { + if (verbosity == null) { + verbosity = new Integer(queryVerbosity()); + } + + return verbosity.intValue(); } - return relativeCatalogs.booleanValue(); - } + /** + * Set the current verbosity. + */ + public void setVerbosity (int verbosity) { + this.verbosity = new Integer(verbosity); + debug.setDebug(verbosity); + } - /** - * Set the relativeCatalogs setting. - * - * @see #getRelativeCatalogs() - */ - public void setRelativeCatalogs (boolean relative) { - relativeCatalogs = new Boolean(relative); - } + /** + * What is the current verbosity? + * + * @deprecated No longer static; use get/set methods. + */ + public int verbosity () { + return getVerbosity(); + } - /** - * Get the relativeCatalogs setting. - * - * @deprecated No longer static; use get/set methods. - */ - public boolean relativeCatalogs () { - return getRelativeCatalogs(); - } + /** + * Obtain the relativeCatalogs setting from the properties. + * + * @return The relativeCatalogs setting from the propertyFile or the + * defaultRelativeCatalogs. + */ + private boolean queryRelativeCatalogs () { + if (resources==null) readProperties(); - /** - * Obtain the list of catalog files from the properties. - * - * @return A semicolon delimited list of catlog file URIs - */ - private String queryCatalogFiles () { - String catalogList = SecuritySupport.getSystemProperty(pFiles); - fromPropertiesFile = false; + if (resources==null) return defaultRelativeCatalogs; - if (catalogList == null) { - if (resources == null) readProperties(); - if (resources != null) { try { - catalogList = resources.getString("catalogs"); - fromPropertiesFile = true; + String allow = resources.getString("relative-catalogs"); + return (allow.equalsIgnoreCase("true") + || allow.equalsIgnoreCase("yes") + || allow.equalsIgnoreCase("1")); } catch (MissingResourceException e) { - System.err.println(propertyFile + ": catalogs not found."); - catalogList = null; + return defaultRelativeCatalogs; } - } } - if (catalogList == null) { - catalogList = defaultCatalogFiles; + /** + * Get the relativeCatalogs setting. + * + *

This property is used when the catalogFiles property is + * interrogated. If true, then relative catalog entry file names + * are returned. If false, relative catalog entry file names are + * made absolute with respect to the properties file before returning + * them.

+ * + *

This property only applies when the catalog files + * come from a properties file. If they come from a system property or + * the default list, they are never considered relative. (What would + * they be relative to?)

+ * + *

In the properties, a value of 'yes', 'true', or '1' is considered + * true, anything else is false.

+ * + * @return The relativeCatalogs setting from the propertyFile or the + * defaultRelativeCatalogs. + */ + public boolean getRelativeCatalogs () { + if (relativeCatalogs == null) { + relativeCatalogs = queryRelativeCatalogs() ? Boolean.TRUE : Boolean.FALSE; + } + + return relativeCatalogs.booleanValue(); } - return catalogList; - } + /** + * Set the relativeCatalogs setting. + * + * @see #getRelativeCatalogs() + */ + public void setRelativeCatalogs (boolean relative) { + relativeCatalogs = relative ? Boolean.TRUE : Boolean.FALSE; + } - /** - * Return the current list of catalog files. - * - * @return A vector of the catalog file names or null if no catalogs - * are available in the properties. - */ - public Vector getCatalogFiles() { - if (catalogFiles == null) { - catalogFiles = queryCatalogFiles(); + /** + * Get the relativeCatalogs setting. + * + * @deprecated No longer static; use get/set methods. + */ + public boolean relativeCatalogs () { + return getRelativeCatalogs(); } - StringTokenizer files = new StringTokenizer(catalogFiles, ";"); - Vector catalogs = new Vector(); - while (files.hasMoreTokens()) { - String catalogFile = files.nextToken(); - URL absURI = null; + /** + * Obtain the list of catalog files from the properties. + * + * @return A semicolon delimited list of catlog file URIs + */ + private String queryCatalogFiles () { + String catalogList = SecuritySupport.getSystemProperty(pFiles); + fromPropertiesFile = false; - if (fromPropertiesFile && !relativeCatalogs()) { - try { - absURI = new URL(propertyFileURI, catalogFile); - catalogFile = absURI.toString(); - } catch (MalformedURLException mue) { - absURI = null; + if (catalogList == null) { + if (resources == null) readProperties(); + if (resources != null) { + try { + catalogList = resources.getString("catalogs"); + fromPropertiesFile = true; + } catch (MissingResourceException e) { + System.err.println(propertyFile + ": catalogs not found."); + catalogList = null; + } + } } - } - catalogs.add(catalogFile); + if (catalogList == null) { + catalogList = defaultCatalogFiles; + } + + return catalogList; } - return catalogs; - } + /** + * Return the current list of catalog files. + * + * @return A vector of the catalog file names or null if no catalogs + * are available in the properties. + */ + public Vector getCatalogFiles() { + if (catalogFiles == null) { + catalogFiles = queryCatalogFiles(); + } - /** - * Set the list of catalog files. - */ - public void setCatalogFiles(String fileList) { - catalogFiles = fileList; - fromPropertiesFile = false; - } + StringTokenizer files = new StringTokenizer(catalogFiles, ";"); + Vector catalogs = new Vector(); + while (files.hasMoreTokens()) { + String catalogFile = files.nextToken(); + URL absURI = null; - /** - * Return the current list of catalog files. - * - * @return A vector of the catalog file names or null if no catalogs - * are available in the properties. - * - * @deprecated No longer static; use get/set methods. - */ - public Vector catalogFiles() { - return getCatalogFiles(); - } + if (fromPropertiesFile && !relativeCatalogs()) { + try { + absURI = new URL(propertyFileURI, catalogFile); + catalogFile = absURI.toString(); + } catch (MalformedURLException mue) { + absURI = null; + } + } - /** - * Obtain the preferPublic setting from the properties. - * - *

In the properties, a value of 'public' is true, - * anything else is false.

- * - * @return True if prefer is public or the - * defaultPreferSetting. - */ - private boolean queryPreferPublic () { - String prefer = SecuritySupport.getSystemProperty(pPrefer); + catalogs.add(catalogFile); + } - if (prefer == null) { - if (resources==null) readProperties(); - if (resources==null) return defaultPreferPublic; - try { - prefer = resources.getString("prefer"); - } catch (MissingResourceException e) { - return defaultPreferPublic; - } + return catalogs; } - if (prefer == null) { - return defaultPreferPublic; + /** + * Set the list of catalog files. + */ + public void setCatalogFiles(String fileList) { + catalogFiles = fileList; + fromPropertiesFile = false; } - return (prefer.equalsIgnoreCase("public")); - } - - /** - * Return the current prefer public setting. - * - * @return True if public identifiers are preferred. - */ - public boolean getPreferPublic () { - if (preferPublic == null) { - preferPublic = new Boolean(queryPreferPublic()); + /** + * Return the current list of catalog files. + * + * @return A vector of the catalog file names or null if no catalogs + * are available in the properties. + * + * @deprecated No longer static; use get/set methods. + */ + public Vector catalogFiles() { + return getCatalogFiles(); } - return preferPublic.booleanValue(); - } - /** - * Set the prefer public setting. - */ - public void setPreferPublic (boolean preferPublic) { - this.preferPublic = new Boolean(preferPublic); - } + /** + * Obtain the preferPublic setting from the properties. + * + *

In the properties, a value of 'public' is true, + * anything else is false.

+ * + * @return True if prefer is public or the + * defaultPreferSetting. + */ + private boolean queryPreferPublic () { + String prefer = SecuritySupport.getSystemProperty(pPrefer); - /** - * Return the current prefer public setting. - * - * @return True if public identifiers are preferred. - * - * @deprecated No longer static; use get/set methods. - */ - public boolean preferPublic () { - return getPreferPublic(); - } + if (prefer == null) { + if (resources==null) readProperties(); + if (resources==null) return defaultPreferPublic; + try { + prefer = resources.getString("prefer"); + } catch (MissingResourceException e) { + return defaultPreferPublic; + } + } - /** - * Obtain the static-catalog setting from the properties. - * - *

In the properties, a value of 'yes', 'true', or '1' is considered - * true, anything else is false.

- * - * @return The static-catalog setting from the propertyFile or the - * defaultUseStaticCatalog. - */ - private boolean queryUseStaticCatalog () { - String staticCatalog = SecuritySupport.getSystemProperty(pStatic); + if (prefer == null) { + return defaultPreferPublic; + } - if (staticCatalog == null) { - if (resources==null) readProperties(); - if (resources==null) return defaultUseStaticCatalog; - try { - staticCatalog = resources.getString("static-catalog"); - } catch (MissingResourceException e) { - return defaultUseStaticCatalog; - } + return (prefer.equalsIgnoreCase("public")); } - if (staticCatalog == null) { - return defaultUseStaticCatalog; + /** + * Return the current prefer public setting. + * + * @return True if public identifiers are preferred. + */ + public boolean getPreferPublic () { + if (preferPublic == null) { + preferPublic = queryPreferPublic() ? Boolean.TRUE : Boolean.FALSE; + } + return preferPublic.booleanValue(); } - return (staticCatalog.equalsIgnoreCase("true") - || staticCatalog.equalsIgnoreCase("yes") - || staticCatalog.equalsIgnoreCase("1")); - } + /** + * Set the prefer public setting. + */ + public void setPreferPublic (boolean preferPublic) { + this.preferPublic = preferPublic ? Boolean.TRUE : Boolean.FALSE; + } - /** - * Get the current use static catalog setting. - */ - public boolean getUseStaticCatalog() { - if (useStaticCatalog == null) { - useStaticCatalog = new Boolean(queryUseStaticCatalog()); + /** + * Return the current prefer public setting. + * + * @return True if public identifiers are preferred. + * + * @deprecated No longer static; use get/set methods. + */ + public boolean preferPublic () { + return getPreferPublic(); } - return useStaticCatalog.booleanValue(); - } + /** + * Obtain the static-catalog setting from the properties. + * + *

In the properties, a value of 'yes', 'true', or '1' is considered + * true, anything else is false.

+ * + * @return The static-catalog setting from the propertyFile or the + * defaultUseStaticCatalog. + */ + private boolean queryUseStaticCatalog () { + String staticCatalog = SecuritySupport.getSystemProperty(pStatic); - /** - * Set the use static catalog setting. - */ - public void setUseStaticCatalog(boolean useStatic) { - useStaticCatalog = new Boolean(useStatic); - } + if (staticCatalog == null) { + if (resources==null) readProperties(); + if (resources==null) return defaultUseStaticCatalog; + try { + staticCatalog = resources.getString("static-catalog"); + } catch (MissingResourceException e) { + return defaultUseStaticCatalog; + } + } - /** - * Get the current use static catalog setting. - * - * @deprecated No longer static; use get/set methods. - */ - public boolean staticCatalog() { - return getUseStaticCatalog(); - } + if (staticCatalog == null) { + return defaultUseStaticCatalog; + } - /** - * Get a new catalog instance. - * - * This method always returns a new instance of the underlying catalog class. - */ - public Catalog getPrivateCatalog() { - Catalog catalog = staticCatalog; + return (staticCatalog.equalsIgnoreCase("true") + || staticCatalog.equalsIgnoreCase("yes") + || staticCatalog.equalsIgnoreCase("1")); + } - if (useStaticCatalog == null) { - useStaticCatalog = new Boolean(getUseStaticCatalog()); + /** + * Get the current use static catalog setting. + */ + public boolean getUseStaticCatalog() { + if (useStaticCatalog == null) { + useStaticCatalog = queryUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE; + } + + return useStaticCatalog.booleanValue(); } - if (catalog == null || !useStaticCatalog.booleanValue()) { + /** + * Set the use static catalog setting. + */ + public void setUseStaticCatalog(boolean useStatic) { + useStaticCatalog = useStatic ? Boolean.TRUE : Boolean.FALSE; + } - try { - String catalogClassName = getCatalogClassName(); + /** + * Get the current use static catalog setting. + * + * @deprecated No longer static; use get/set methods. + */ + public boolean staticCatalog() { + return getUseStaticCatalog(); + } - if (catalogClassName == null) { - catalog = new Catalog(); - } else { - try { - catalog = (Catalog) ReflectUtil.forName(catalogClassName).newInstance(); - } catch (ClassNotFoundException cnfe) { - debug.message(1,"Catalog class named '" - + catalogClassName - + "' could not be found. Using default."); - catalog = new Catalog(); - } catch (ClassCastException cnfe) { - debug.message(1,"Class named '" - + catalogClassName - + "' is not a Catalog. Using default."); - catalog = new Catalog(); - } + /** + * Get a new catalog instance. + * + * This method always returns a new instance of the underlying catalog class. + */ + public Catalog getPrivateCatalog() { + Catalog catalog = staticCatalog; + + if (useStaticCatalog == null) { + useStaticCatalog = getUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE; } - catalog.setCatalogManager(this); - catalog.setupReaders(); - catalog.loadSystemCatalogs(); - } catch (Exception ex) { - ex.printStackTrace(); - } + if (catalog == null || !useStaticCatalog.booleanValue()) { - if (useStaticCatalog.booleanValue()) { - staticCatalog = catalog; - } - } + try { + String catalogClassName = getCatalogClassName(); - return catalog; - } + if (catalogClassName == null) { + catalog = new Catalog(); + } else { + try { + catalog = (Catalog) ReflectUtil.forName(catalogClassName).newInstance(); + } catch (ClassNotFoundException cnfe) { + debug.message(1,"Catalog class named '" + + catalogClassName + + "' could not be found. Using default."); + catalog = new Catalog(); + } catch (ClassCastException cnfe) { + debug.message(1,"Class named '" + + catalogClassName + + "' is not a Catalog. Using default."); + catalog = new Catalog(); + } + } - /** - * Get a catalog instance. - * - * If this manager uses static catalogs, the same static catalog will - * always be returned. Otherwise a new catalog will be returned. - */ - public Catalog getCatalog() { - Catalog catalog = staticCatalog; + catalog.setCatalogManager(this); + catalog.setupReaders(); + catalog.loadSystemCatalogs(); + } catch (Exception ex) { + ex.printStackTrace(); + } - if (useStaticCatalog == null) { - useStaticCatalog = new Boolean(getUseStaticCatalog()); - } + if (useStaticCatalog.booleanValue()) { + staticCatalog = catalog; + } + } - if (catalog == null || !useStaticCatalog.booleanValue()) { - catalog = getPrivateCatalog(); - if (useStaticCatalog.booleanValue()) { - staticCatalog = catalog; - } + return catalog; } - return catalog; - } + /** + * Get a catalog instance. + * + * If this manager uses static catalogs, the same static catalog will + * always be returned. Otherwise a new catalog will be returned. + */ + public Catalog getCatalog() { + Catalog catalog = staticCatalog; - /** - *

Obtain the oasisXMLCatalogPI setting from the properties.

- * - *

In the properties, a value of 'yes', 'true', or '1' is considered - * true, anything else is false.

- * - * @return The oasisXMLCatalogPI setting from the propertyFile or the - * defaultOasisXMLCatalogPI. - */ - public boolean queryAllowOasisXMLCatalogPI () { - String allow = SecuritySupport.getSystemProperty(pAllowPI); + if (useStaticCatalog == null) { + useStaticCatalog = getUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE; + } - if (allow == null) { - if (resources==null) readProperties(); - if (resources==null) return defaultOasisXMLCatalogPI; - try { - allow = resources.getString("allow-oasis-xml-catalog-pi"); - } catch (MissingResourceException e) { - return defaultOasisXMLCatalogPI; - } + if (catalog == null || !useStaticCatalog.booleanValue()) { + catalog = getPrivateCatalog(); + if (useStaticCatalog.booleanValue()) { + staticCatalog = catalog; + } + } + + return catalog; } - if (allow == null) { - return defaultOasisXMLCatalogPI; + /** + *

Obtain the oasisXMLCatalogPI setting from the properties.

+ * + *

In the properties, a value of 'yes', 'true', or '1' is considered + * true, anything else is false.

+ * + * @return The oasisXMLCatalogPI setting from the propertyFile or the + * defaultOasisXMLCatalogPI. + */ + public boolean queryAllowOasisXMLCatalogPI () { + String allow = SecuritySupport.getSystemProperty(pAllowPI); + + if (allow == null) { + if (resources==null) readProperties(); + if (resources==null) return defaultOasisXMLCatalogPI; + try { + allow = resources.getString("allow-oasis-xml-catalog-pi"); + } catch (MissingResourceException e) { + return defaultOasisXMLCatalogPI; + } + } + + if (allow == null) { + return defaultOasisXMLCatalogPI; + } + + return (allow.equalsIgnoreCase("true") + || allow.equalsIgnoreCase("yes") + || allow.equalsIgnoreCase("1")); } - return (allow.equalsIgnoreCase("true") - || allow.equalsIgnoreCase("yes") - || allow.equalsIgnoreCase("1")); - } + /** + * Get the current XML Catalog PI setting. + */ + public boolean getAllowOasisXMLCatalogPI () { + if (oasisXMLCatalogPI == null) { + oasisXMLCatalogPI = queryAllowOasisXMLCatalogPI() ? Boolean.TRUE : Boolean.FALSE; + } - /** - * Get the current XML Catalog PI setting. - */ - public boolean getAllowOasisXMLCatalogPI () { - if (oasisXMLCatalogPI == null) { - oasisXMLCatalogPI = new Boolean(queryAllowOasisXMLCatalogPI()); + return oasisXMLCatalogPI.booleanValue(); } - return oasisXMLCatalogPI.booleanValue(); - } + public boolean useServicesMechanism() { + return useServicesMechanism; + } + /** + * Set the XML Catalog PI setting + */ + public void setAllowOasisXMLCatalogPI(boolean allowPI) { + oasisXMLCatalogPI = allowPI ? Boolean.TRUE : Boolean.FALSE; + } - public boolean useServicesMechanism() { - return useServicesMechanism; - } - /** - * Set the XML Catalog PI setting - */ - public void setAllowOasisXMLCatalogPI(boolean allowPI) { - oasisXMLCatalogPI = new Boolean(allowPI); - } + /** + * Get the current XML Catalog PI setting. + * + * @deprecated No longer static; use get/set methods. + */ + public boolean allowOasisXMLCatalogPI() { + return getAllowOasisXMLCatalogPI(); + } - /** - * Get the current XML Catalog PI setting. - * - * @deprecated No longer static; use get/set methods. - */ - public boolean allowOasisXMLCatalogPI() { - return getAllowOasisXMLCatalogPI(); - } + /** + * Obtain the Catalog class name setting from the properties. + * + */ + public String queryCatalogClassName () { + String className = SecuritySupport.getSystemProperty(pClassname); - /** - * Obtain the Catalog class name setting from the properties. - * - */ - public String queryCatalogClassName () { - String className = SecuritySupport.getSystemProperty(pClassname); + if (className == null) { + if (resources==null) readProperties(); + if (resources==null) return null; + try { + return resources.getString("catalog-class-name"); + } catch (MissingResourceException e) { + return null; + } + } - if (className == null) { - if (resources==null) readProperties(); - if (resources==null) return null; - try { - return resources.getString("catalog-class-name"); - } catch (MissingResourceException e) { - return null; - } + return className; } - return className; - } + /** + * Get the current Catalog class name. + */ + public String getCatalogClassName() { + if (catalogClassName == null) { + catalogClassName = queryCatalogClassName(); + } - /** - * Get the current Catalog class name. - */ - public String getCatalogClassName() { - if (catalogClassName == null) { - catalogClassName = queryCatalogClassName(); + return catalogClassName; } - return catalogClassName; - } + /** + * Set the Catalog class name. + */ + public void setCatalogClassName(String className) { + catalogClassName = className; + } - /** - * Set the Catalog class name. - */ - public void setCatalogClassName(String className) { - catalogClassName = className; - } - - /** - * Get the current Catalog class name. - * - * @deprecated No longer static; use get/set methods. - */ - public String catalogClassName() { - return getCatalogClassName(); - } + /** + * Get the current Catalog class name. + * + * @deprecated No longer static; use get/set methods. + */ + public String catalogClassName() { + return getCatalogClassName(); + } }