/* * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javax.xml.catalog; import java.util.stream.Stream; /** * The Catalog class represents an entity Catalog as defined by * * XML Catalogs, OASIS Standard V1.1, 7 October 2005. *

* A catalog is an XML file that contains a root {@code catalog} entry with a list * of catalog entries. The entries can also be grouped with a {@code group} entry. * The catalog and group entries may specify {@code prefer} and {@code xml:base} * attributes that set preference of public or system type of entries and base URI * to resolve relative URIs. * *

* A catalog can be used in two situations: *

*

* For case 1, the standard defines 6 External Identifier Entries:
* {@code public, system, rewriteSystem, systemSuffix, delegatePublic, and * delegateSystem}. *

* While for case 2, it defines 4 URI Entries:
* {@code uri, rewriteURI, uriSuffix and delegateURI}. *

* In addition to the above entry types, a catalog may define nextCatalog * entries to add additional catalog entry files. * * @since 9 */ public interface Catalog { /** * Attempts to find a matching entry in the catalog by systemId. * *

* The method searches through the system-type entries, including {@code system, * rewriteSystem, systemSuffix, delegateSystem}, and {@code group} entries in the * current catalog in order to find a match. *

* Resolution follows the steps listed below:
*

* * @param systemId the system identifier of the entity to be matched * * @return a URI string if a mapping is found, or null otherwise */ public String matchSystem(String systemId); /** * Attempts to find a matching entry in the catalog by publicId. The method * searches through the public-type entries, including {@code public, * delegatePublic}, and {@code group} entries in the current catalog in order to find * a match. *

* Refer to the description about * Feature PREFER in the table Catalog Features in class * {@link CatalogFeatures}. Public entries are only considered if the * {@code prefer} is {@code public} and {@code system} entries are not found. *

* Resolution follows the steps listed below:
*

* * @param publicId the public identifier of the entity to be matched * @see CatalogFeatures.Feature * @return a URI string if a mapping is found, or null otherwise */ public String matchPublic(String publicId); /** * Attempts to find a matching entry in the catalog by the uri element. * *

* The method searches through the uri-type entries, including {@code uri, * rewriteURI, uriSuffix, delegateURI} and {@code group} entries in the current * catalog in order to find a match. * *

* Resolution follows the steps listed below:
*

* * @param uri the URI reference of the entity to be matched * * @return a URI string if a mapping is found, or null otherwise */ public String matchURI(String uri); /** * Returns a sequential Stream of alternative Catalogs specified using the * {@code nextCatalog} entries in the current catalog, and as the input of * catalog files excluding the current catalog (that is, the first in the * input list) when the Catalog object is created by the {@link CatalogManager}. *

* The order of Catalogs in the returned stream is the same as the order * in which the corresponding {@code nextCatalog} entries appear in the * current catalog. The alternative catalogs from the input file list are * appended to the end of the stream in the order they are entered. * * @return a sequential Stream of Catalogs */ public Stream catalogs(); }