catalog.java
来自「JAVA 所有包」· Java 代码 · 共 1,991 行 · 第 1/5 页
JAVA
1,991 行
} if (systemId != null && systemId.startsWith("urn:publicid:")) { systemId = PublicId.decodeURN(systemId); if (publicId != null && !publicId.equals(systemId)) { catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier"); systemId = null; } else { publicId = systemId; systemId = null; } } if (systemId != null) { // If there's a SYSTEM entry in this catalog, use it resolved = resolveLocalSystem(systemId); if (resolved != null) { return resolved; } } if (publicId != null) { // If there's a PUBLIC entry in this catalog, use it resolved = resolveLocalPublic(DOCTYPE, entityName, publicId, systemId); if (resolved != null) { return resolved; } } // If there's a DOCTYPE entry in this catalog, use it boolean over = default_override; Enumeration en = catalogEntries.elements(); while (en.hasMoreElements()) { CatalogEntry e = (CatalogEntry) en.nextElement(); if (e.getEntryType() == OVERRIDE) { over = e.getEntryArg(0).equalsIgnoreCase("YES"); continue; } if (e.getEntryType() == DOCTYPE && e.getEntryArg(0).equals(entityName)) { if (over || systemId == null) { return e.getEntryArg(1); } } } // Otherwise, look in the subordinate catalogs return resolveSubordinateCatalogs(DOCTYPE, entityName, publicId, systemId); } /** * Return the applicable DOCUMENT entry. * * @return The system identifier to use for the doctype. * * @throws MalformedURLException The formal system identifier of a * subordinate catalog cannot be turned into a valid URL. * @throws IOException Error reading subordinate catalog file. */ public String resolveDocument() throws MalformedURLException, IOException { // If there's a DOCUMENT entry, return it catalogManager.debug.message(3, "resolveDocument"); Enumeration en = catalogEntries.elements(); while (en.hasMoreElements()) { CatalogEntry e = (CatalogEntry) en.nextElement(); if (e.getEntryType() == DOCUMENT) { return e.getEntryArg(0); } } return resolveSubordinateCatalogs(DOCUMENT, null, null, null); } /** * Return the applicable ENTITY system identifier. * * @param entityName The name of the entity for which * a system identifier is required. * @param publicId The nominal public identifier for the entity * (as provided in the source document). * @param systemId The nominal system identifier for the entity * (as provided in the source document). * * @return The system identifier to use for the entity. * * @throws MalformedURLException The formal system identifier of a * subordinate catalog cannot be turned into a valid URL. * @throws IOException Error reading subordinate catalog file. */ public String resolveEntity(String entityName, String publicId, String systemId) throws MalformedURLException, IOException { String resolved = null; catalogManager.debug.message(3, "resolveEntity(" +entityName+","+publicId+","+systemId+")"); systemId = normalizeURI(systemId); if (publicId != null && publicId.startsWith("urn:publicid:")) { publicId = PublicId.decodeURN(publicId); } if (systemId != null && systemId.startsWith("urn:publicid:")) { systemId = PublicId.decodeURN(systemId); if (publicId != null && !publicId.equals(systemId)) { catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier"); systemId = null; } else { publicId = systemId; systemId = null; } } if (systemId != null) { // If there's a SYSTEM entry in this catalog, use it resolved = resolveLocalSystem(systemId); if (resolved != null) { return resolved; } } if (publicId != null) { // If there's a PUBLIC entry in this catalog, use it resolved = resolveLocalPublic(ENTITY, entityName, publicId, systemId); if (resolved != null) { return resolved; } } // If there's a ENTITY entry in this catalog, use it boolean over = default_override; Enumeration en = catalogEntries.elements(); while (en.hasMoreElements()) { CatalogEntry e = (CatalogEntry) en.nextElement(); if (e.getEntryType() == OVERRIDE) { over = e.getEntryArg(0).equalsIgnoreCase("YES"); continue; } if (e.getEntryType() == ENTITY && e.getEntryArg(0).equals(entityName)) { if (over || systemId == null) { return e.getEntryArg(1); } } } // Otherwise, look in the subordinate catalogs return resolveSubordinateCatalogs(ENTITY, entityName, publicId, systemId); } /** * Return the applicable NOTATION system identifier. * * @param notationName The name of the notation for which * a doctype is required. * @param publicId The nominal public identifier for the notation * (as provided in the source document). * @param systemId The nominal system identifier for the notation * (as provided in the source document). * * @return The system identifier to use for the notation. * * @throws MalformedURLException The formal system identifier of a * subordinate catalog cannot be turned into a valid URL. * @throws IOException Error reading subordinate catalog file. */ public String resolveNotation(String notationName, String publicId, String systemId) throws MalformedURLException, IOException { String resolved = null; catalogManager.debug.message(3, "resolveNotation(" +notationName+","+publicId+","+systemId+")"); systemId = normalizeURI(systemId); if (publicId != null && publicId.startsWith("urn:publicid:")) { publicId = PublicId.decodeURN(publicId); } if (systemId != null && systemId.startsWith("urn:publicid:")) { systemId = PublicId.decodeURN(systemId); if (publicId != null && !publicId.equals(systemId)) { catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier"); systemId = null; } else { publicId = systemId; systemId = null; } } if (systemId != null) { // If there's a SYSTEM entry in this catalog, use it resolved = resolveLocalSystem(systemId); if (resolved != null) { return resolved; } } if (publicId != null) { // If there's a PUBLIC entry in this catalog, use it resolved = resolveLocalPublic(NOTATION, notationName, publicId, systemId); if (resolved != null) { return resolved; } } // If there's a NOTATION entry in this catalog, use it boolean over = default_override; Enumeration en = catalogEntries.elements(); while (en.hasMoreElements()) { CatalogEntry e = (CatalogEntry) en.nextElement(); if (e.getEntryType() == OVERRIDE) { over = e.getEntryArg(0).equalsIgnoreCase("YES"); continue; } if (e.getEntryType() == NOTATION && e.getEntryArg(0).equals(notationName)) { if (over || systemId == null) { return e.getEntryArg(1); } } } // Otherwise, look in the subordinate catalogs return resolveSubordinateCatalogs(NOTATION, notationName, publicId, systemId); } /** * Return the applicable PUBLIC or SYSTEM identifier. * * <p>This method searches the Catalog and returns the system * identifier specified for the given system or * public identifiers. If * no appropriate PUBLIC or SYSTEM entry is found in the Catalog, * null is returned.</p> * * @param publicId The public identifier to locate in the catalog. * Public identifiers are normalized before comparison. * @param systemId The nominal system identifier for the entity * in question (as provided in the source document). * * @throws MalformedURLException The formal system identifier of a * subordinate catalog cannot be turned into a valid URL. * @throws IOException Error reading subordinate catalog file. * * @return The system identifier to use. * Note that the nominal system identifier is not returned if a * match is not found in the catalog, instead null is returned * to indicate that no match was found. */ public String resolvePublic(String publicId, String systemId) throws MalformedURLException, IOException { catalogManager.debug.message(3, "resolvePublic("+publicId+","+systemId+")"); systemId = normalizeURI(systemId); if (publicId != null && publicId.startsWith("urn:publicid:")) { publicId = PublicId.decodeURN(publicId); } if (systemId != null && systemId.startsWith("urn:publicid:")) { systemId = PublicId.decodeURN(systemId); if (publicId != null && !publicId.equals(systemId)) { catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier"); systemId = null; } else { publicId = systemId; systemId = null; } } // If there's a SYSTEM entry in this catalog, use it if (systemId != null) { String resolved = resolveLocalSystem(systemId); if (resolved != null) { return resolved; } } // If there's a PUBLIC entry in this catalog, use it String resolved = resolveLocalPublic(PUBLIC, null, publicId, systemId); if (resolved != null) { return resolved; } // Otherwise, look in the subordinate catalogs return resolveSubordinateCatalogs(PUBLIC, null, publicId, systemId); } /** * Return the applicable PUBLIC or SYSTEM identifier. * * <p>This method searches the Catalog and returns the system * identifier specified for the given system or public identifiers. * If no appropriate PUBLIC or SYSTEM entry is found in the Catalog, * delegated Catalogs are interrogated.</p> * * <p>There are four possible cases:</p> * * <ul> * <li>If the system identifier provided matches a SYSTEM entry * in the current catalog, the SYSTEM entry is returned. * <li>If the system identifier is not null, the PUBLIC entries * that were encountered when OVERRIDE YES was in effect are * interrogated and the first matching entry is returned.</li> * <li>If the system identifier is null, then all of the PUBLIC * entries are interrogated and the first matching entry * is returned. This may not be the same as the preceding case, if * some PUBLIC entries are encountered when OVERRIDE NO is in effect. In * XML, the only place where a public identifier may occur without * a system identifier is in a notation declaration.</li> * <li>Finally, if the public identifier matches one of the partial * public identifiers specified in a DELEGATE* entry in * the Catalog, the delegated catalog is interrogated. The first * time that the delegated catalog is required, it will be * retrieved and parsed. It is subsequently cached. * </li> * </ul> * * @param entityType The CatalogEntry type for which this query is * being conducted. This is necessary in order to do the approprate * query on a delegated catalog. * @param entityName The name of the entity being searched for, if * appropriate. * @param publicId The public identifier of the entity in question. * @param systemId The nominal system identifier for the entity * in question (as provided in the source document). * * @throws MalformedURLException The formal system identifier of a * delegated catalog cannot be turned into a valid URL. * @throws IOException Error reading delegated catalog file. * * @return The system identifier to use. * Note that the nominal system identifier is not returned if a * match is not found in the catalog, instead null is returned * to indicate that no match was found. */ protected synchronized String resolveLocalPublic(int entityType, String entityName, String publicId, String systemId) throws MalformedURLException, IOException { // Always normalize the public identifier before attempting a match publicId = PublicId.normalize(publicId); // If there's a SYSTEM entry in this catalog, use it if (systemId != null) { String resolved = resolveLocalSystem(systemId); if (resolved != null) { return resolved; } } // If there's a PUBLIC entry in this catalog, use it boolean over = default_override; Enumeration en = catalogEntries.elements(); while (en.hasMoreElements()) { CatalogEntry e = (CatalogEntry) en.nextElement(); if (e.getEntryType() == OVERRIDE) { over = e.getEntryArg(0).equalsIgnoreCase("YES"); continue; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?