Fields Summary |
---|
private static String | pFiles |
private static String | pVerbosity |
private static String | pPrefer |
private static String | pStatic |
private static String | pAllowPI |
private static String | pClassname |
private static String | pIgnoreMissing |
private static CatalogManager | staticManagerA static CatalogManager instance for sharing |
private com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver | bResolverThe bootstrap resolver to use when loading XML Catalogs. |
private boolean | ignoreMissingPropertiesFlag to ignore missing property files and/or properties |
private ResourceBundle | resourcesHolds the resources after they are loaded from the file. |
private String | propertyFileThe name of the CatalogManager properties file. |
private URL | propertyFileURIThe location of the propertyFile |
private String | defaultCatalogFilesDefault catalog files list. |
private String | catalogFilesCurrent catalog files list. |
private boolean | fromPropertiesFileDid the catalogFiles come from the properties file? |
private int | defaultVerbosityDefault verbosity level if there is no property setting for it. |
private Integer | verbosityCurrent verbosity level. |
private boolean | defaultPreferPublicDefault preference setting. |
private Boolean | preferPublicCurrent preference setting. |
private boolean | defaultUseStaticCatalogDefault setting of the static catalog flag. |
private Boolean | useStaticCatalogCurrent setting of the static catalog flag. |
private static com.sun.org.apache.xml.internal.resolver.Catalog | staticCatalogThe static catalog used by this manager. |
private boolean | defaultOasisXMLCatalogPIDefault setting of the oasisXMLCatalogPI flag. |
private Boolean | oasisXMLCatalogPICurrent setting of the oasisXMLCatalogPI flag. |
private boolean | defaultRelativeCatalogsDefault setting of the relativeCatalogs flag. |
private Boolean | relativeCatalogsCurrent setting of the relativeCatalogs flag. |
private String | catalogClassNameCurrent catalog class name. |
public com.sun.org.apache.xml.internal.resolver.helpers.Debug | debugThe 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. |
Methods Summary |
---|
public boolean | allowOasisXMLCatalogPI()Get the current XML Catalog PI setting.
return getAllowOasisXMLCatalogPI();
|
public java.lang.String | catalogClassName()Get the current Catalog class name.
return getCatalogClassName();
|
public java.util.Vector | catalogFiles()Return the current list of catalog files.
return getCatalogFiles();
|
public boolean | getAllowOasisXMLCatalogPI()Get the current XML Catalog PI setting.
if (oasisXMLCatalogPI == null) {
oasisXMLCatalogPI = new Boolean(queryAllowOasisXMLCatalogPI());
}
return oasisXMLCatalogPI.booleanValue();
|
public com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver | getBootstrapResolver()Get the bootstrap resolver.
return bResolver;
|
public com.sun.org.apache.xml.internal.resolver.Catalog | getCatalog()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.
Catalog catalog = staticCatalog;
if (useStaticCatalog == null) {
useStaticCatalog = new Boolean(getUseStaticCatalog());
}
if (catalog == null || !useStaticCatalog.booleanValue()) {
catalog = getPrivateCatalog();
if (useStaticCatalog.booleanValue()) {
staticCatalog = catalog;
}
}
return catalog;
|
public java.lang.String | getCatalogClassName()Get the current Catalog class name.
if (catalogClassName == null) {
catalogClassName = queryCatalogClassName();
}
return catalogClassName;
|
public java.util.Vector | getCatalogFiles()Return the current list of catalog files.
if (catalogFiles == null) {
catalogFiles = queryCatalogFiles();
}
StringTokenizer files = new StringTokenizer(catalogFiles, ";");
Vector catalogs = new Vector();
while (files.hasMoreTokens()) {
String catalogFile = files.nextToken();
URL absURI = null;
if (fromPropertiesFile && !relativeCatalogs()) {
try {
absURI = new URL(propertyFileURI, catalogFile);
catalogFile = absURI.toString();
} catch (MalformedURLException mue) {
absURI = null;
}
}
catalogs.add(catalogFile);
}
return catalogs;
|
public boolean | getIgnoreMissingProperties()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.
return ignoreMissingProperties;
|
public boolean | getPreferPublic()Return the current prefer public setting.
if (preferPublic == null) {
preferPublic = new Boolean(queryPreferPublic());
}
return preferPublic.booleanValue();
|
public com.sun.org.apache.xml.internal.resolver.Catalog | getPrivateCatalog()Get a new catalog instance.
This method always returns a new instance of the underlying catalog class.
Catalog catalog = staticCatalog;
if (useStaticCatalog == null) {
useStaticCatalog = new Boolean(getUseStaticCatalog());
}
if (catalog == null || !useStaticCatalog.booleanValue()) {
try {
String catalogClassName = getCatalogClassName();
if (catalogClassName == null) {
catalog = new Catalog();
} else {
try {
catalog = (Catalog) Class.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();
}
}
catalog.setCatalogManager(this);
catalog.setupReaders();
catalog.loadSystemCatalogs();
} catch (Exception ex) {
ex.printStackTrace();
}
if (useStaticCatalog.booleanValue()) {
staticCatalog = catalog;
}
}
return catalog;
|
public boolean | getRelativeCatalogs()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.
if (relativeCatalogs == null) {
relativeCatalogs = new Boolean(queryRelativeCatalogs());
}
return relativeCatalogs.booleanValue();
|
public static com.sun.org.apache.xml.internal.resolver.CatalogManager | getStaticManager()Allow access to the static CatalogManager
return staticManager;
|
public boolean | getUseStaticCatalog()Get the current use static catalog setting.
if (useStaticCatalog == null) {
useStaticCatalog = new Boolean(queryUseStaticCatalog());
}
return useStaticCatalog.booleanValue();
|
public int | getVerbosity()What is the current verbosity?
if (verbosity == null) {
verbosity = new Integer(queryVerbosity());
}
return verbosity.intValue();
|
public void | ignoreMissingProperties(boolean 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.
setIgnoreMissingProperties(ignore);
|
public boolean | preferPublic()Return the current prefer public setting.
return getPreferPublic();
|
public boolean | queryAllowOasisXMLCatalogPI()Obtain the oasisXMLCatalogPI setting from the properties.
In the properties, a value of 'yes', 'true', or '1' is considered
true, anything else is false.
String allow = System.getProperty(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"));
|
public java.lang.String | queryCatalogClassName()Obtain the Catalog class name setting from the properties.
String className = System.getProperty(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;
}
}
return className;
|
private java.lang.String | queryCatalogFiles()Obtain the list of catalog files from the properties.
String catalogList = System.getProperty(pFiles);
fromPropertiesFile = false;
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;
}
}
}
if (catalogList == null) {
catalogList = defaultCatalogFiles;
}
return catalogList;
|
private boolean | queryPreferPublic()Obtain the preferPublic setting from the properties.
In the properties, a value of 'public' is true,
anything else is false.
String prefer = System.getProperty(pPrefer);
if (prefer == null) {
if (resources==null) readProperties();
if (resources==null) return defaultPreferPublic;
try {
prefer = resources.getString("prefer");
} catch (MissingResourceException e) {
return defaultPreferPublic;
}
}
if (prefer == null) {
return defaultPreferPublic;
}
return (prefer.equalsIgnoreCase("public"));
|
private boolean | queryRelativeCatalogs()Obtain the relativeCatalogs setting from the properties.
if (resources==null) readProperties();
if (resources==null) return defaultRelativeCatalogs;
try {
String allow = resources.getString("relative-catalogs");
return (allow.equalsIgnoreCase("true")
|| allow.equalsIgnoreCase("yes")
|| allow.equalsIgnoreCase("1"));
} catch (MissingResourceException e) {
return defaultRelativeCatalogs;
}
|
private boolean | queryUseStaticCatalog()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.
String staticCatalog = System.getProperty(pStatic);
if (staticCatalog == null) {
if (resources==null) readProperties();
if (resources==null) return defaultUseStaticCatalog;
try {
staticCatalog = resources.getString("static-catalog");
} catch (MissingResourceException e) {
return defaultUseStaticCatalog;
}
}
if (staticCatalog == null) {
return defaultUseStaticCatalog;
}
return (staticCatalog.equalsIgnoreCase("true")
|| staticCatalog.equalsIgnoreCase("yes")
|| staticCatalog.equalsIgnoreCase("1"));
|
private int | queryVerbosity()Obtain the verbosity setting from the properties.
String defaultVerbStr = Integer.toString(defaultVerbosity);
String verbStr = System.getProperty(pVerbosity);
if (verbStr == null) {
if (resources==null) readProperties();
if (resources != null) {
try {
verbStr = resources.getString("verbosity");
} catch (MissingResourceException e) {
verbStr = defaultVerbStr;
}
} else {
verbStr = defaultVerbStr;
}
}
int verb = defaultVerbosity;
try {
verb = Integer.parseInt(verbStr.trim());
} catch (Exception e) {
System.err.println("Cannot parse verbosity: \"" + verbStr + "\"");
}
// 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;
|
private synchronized void | readProperties()Load the properties from the propertyFile and build the
resources from it.
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);
}
}
// 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
}
}
|
public boolean | relativeCatalogs()Get the relativeCatalogs setting.
return getRelativeCatalogs();
|
public void | setAllowOasisXMLCatalogPI(boolean allowPI)Set the XML Catalog PI setting
oasisXMLCatalogPI = new Boolean(allowPI);
|
public void | setBootstrapResolver(com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver resolver)Set the bootstrap resolver.
bResolver = resolver;
|
public void | setCatalogClassName(java.lang.String className)Set the Catalog class name.
catalogClassName = className;
|
public void | setCatalogFiles(java.lang.String fileList)Set the list of catalog files.
catalogFiles = fileList;
fromPropertiesFile = false;
|
public void | setIgnoreMissingProperties(boolean ignore)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.
ignoreMissingProperties = ignore;
|
public void | setPreferPublic(boolean preferPublic)Set the prefer public setting.
this.preferPublic = new Boolean(preferPublic);
|
public void | setRelativeCatalogs(boolean relative)Set the relativeCatalogs setting.
relativeCatalogs = new Boolean(relative);
|
public void | setUseStaticCatalog(boolean useStatic)Set the use static catalog setting.
useStaticCatalog = new Boolean(useStatic);
|
public void | setVerbosity(int verbosity)Set the current verbosity.
this.verbosity = new Integer(verbosity);
debug.setDebug(verbosity);
|
public boolean | staticCatalog()Get the current use static catalog setting.
return getUseStaticCatalog();
|
public int | verbosity()What is the current verbosity?
return getVerbosity();
|