< prev index next >
src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java
Print this page
*** 133,143 ****
}
/**
* Constructs a GroupEntry
*
! * @param type The type of the entry
*/
public GroupEntry(CatalogEntryType type, CatalogImpl parent) {
super(type);
this.parent = parent;
}
--- 133,144 ----
}
/**
* Constructs a GroupEntry
*
! * @param type the type of the entry
! * @param parent the parent Catalog
*/
public GroupEntry(CatalogEntryType type, CatalogImpl parent) {
super(type);
this.parent = parent;
}
*** 163,183 ****
longestSuffixMatch = 0;
systemEntrySearched = false;
}
/**
* Constructs a group entry.
! * @param catalog The catalog this GroupEntry belongs
! * @param base The baseURI attribute
! * @param attributes The attributes
*/
public GroupEntry(CatalogImpl catalog, String base, String... attributes) {
super(CatalogEntryType.GROUP, base);
setPrefer(attributes[ATTRIBUTE_PREFER]);
this.catalog = catalog;
}
/**
* Adds an entry.
*
* @param entry The entry to be added.
*/
public void addEntry(BaseEntry entry) {
--- 164,193 ----
longestSuffixMatch = 0;
systemEntrySearched = false;
}
/**
* Constructs a group entry.
! * @param catalog the catalog this GroupEntry belongs to
! * @param base the baseURI attribute
! * @param attributes the attributes
*/
public GroupEntry(CatalogImpl catalog, String base, String... attributes) {
super(CatalogEntryType.GROUP, base);
setPrefer(attributes[ATTRIBUTE_PREFER]);
this.catalog = catalog;
}
/**
+ * Sets the catalog for this GroupEntry.
+ *
+ * @param catalog the catalog this GroupEntry belongs to
+ */
+ void setCatalog(CatalogImpl catalog) {
+ this.catalog = catalog;
+ }
+
+ /**
* Adds an entry.
*
* @param entry The entry to be added.
*/
public void addEntry(BaseEntry entry) {
*** 380,393 ****
}
/**
* Matches delegatePublic or delegateSystem against the specified id
*
! * @param isSystem The flag to indicate whether the delegate is system or
! * public
! * @param id The system or public id to be matched
! * @return The URI string if a mapping is found, or null otherwise.
*/
private String matchDelegate(CatalogEntryType type, String id) {
String match = null;
int longestMatch = 0;
URI catalogId = null;
--- 390,402 ----
}
/**
* Matches delegatePublic or delegateSystem against the specified id
*
! * @param type the type of the Catalog entry
! * @param id the system or public id to be matched
! * @return the URI string if a mapping is found, or null otherwise.
*/
private String matchDelegate(CatalogEntryType type, String id) {
String match = null;
int longestMatch = 0;
URI catalogId = null;
*** 410,420 ****
}
}
//Check delegate Catalogs
if (catalogId != null) {
! Catalog delegateCatalog = loadCatalog(catalogId);
if (delegateCatalog != null) {
if (type == CatalogEntryType.DELEGATESYSTEM) {
match = delegateCatalog.matchSystem(id);
} else if (type == CatalogEntryType.DELEGATEPUBLIC) {
--- 419,429 ----
}
}
//Check delegate Catalogs
if (catalogId != null) {
! Catalog delegateCatalog = loadDelegateCatalog(catalog, catalogId);
if (delegateCatalog != null) {
if (type == CatalogEntryType.DELEGATESYSTEM) {
match = delegateCatalog.matchSystem(id);
} else if (type == CatalogEntryType.DELEGATEPUBLIC) {
*** 428,461 ****
return match;
}
/**
* Loads all delegate catalogs.
*/
! void loadDelegateCatalogs() {
entries.stream()
.filter((entry) -> (entry.type == CatalogEntryType.DELEGATESYSTEM ||
entry.type == CatalogEntryType.DELEGATEPUBLIC ||
entry.type == CatalogEntryType.DELEGATEURI))
.map((entry) -> (AltCatalog)entry)
.forEach((altCatalog) -> {
! loadCatalog(altCatalog.getCatalogURI());
});
}
/**
* Loads a delegate catalog by the catalogId specified.
! * @param catalogId the catalog Id
*/
! Catalog loadCatalog(URI catalogURI) {
CatalogImpl delegateCatalog = null;
if (catalogURI != null) {
String catalogId = catalogURI.toASCIIString();
delegateCatalog = getLoadedCatalog(catalogId);
if (delegateCatalog == null) {
! if (verifyCatalogFile(catalogURI)) {
! delegateCatalog = new CatalogImpl(catalog, features, catalogURI);
delegateCatalog.load();
delegateCatalogs.put(catalogId, delegateCatalog);
}
}
}
--- 437,474 ----
return match;
}
/**
* Loads all delegate catalogs.
+ *
+ * @param parent the parent catalog of the delegate catalogs
*/
! void loadDelegateCatalogs(CatalogImpl parent) {
entries.stream()
.filter((entry) -> (entry.type == CatalogEntryType.DELEGATESYSTEM ||
entry.type == CatalogEntryType.DELEGATEPUBLIC ||
entry.type == CatalogEntryType.DELEGATEURI))
.map((entry) -> (AltCatalog)entry)
.forEach((altCatalog) -> {
! loadDelegateCatalog(parent, altCatalog.getCatalogURI());
});
}
/**
* Loads a delegate catalog by the catalogId specified.
! *
! * @param parent the parent catalog of the delegate catalog
! * @param catalogURI the URI to the catalog
*/
! Catalog loadDelegateCatalog(CatalogImpl parent, URI catalogURI) {
CatalogImpl delegateCatalog = null;
if (catalogURI != null) {
String catalogId = catalogURI.toASCIIString();
+ if (verifyCatalogFile(parent, catalogURI)) {
delegateCatalog = getLoadedCatalog(catalogId);
if (delegateCatalog == null) {
! delegateCatalog = new CatalogImpl(parent, features, catalogURI);
delegateCatalog.load();
delegateCatalogs.put(catalogId, delegateCatalog);
}
}
}
*** 471,481 ****
* list
*/
CatalogImpl getLoadedCatalog(String catalogId) {
CatalogImpl c = null;
! //checl delegate Catalogs
c = delegateCatalogs.get(catalogId);
if (c == null) {
//check other loaded Catalogs
c = loadedCatalogs.get(catalogId);
}
--- 484,494 ----
* list
*/
CatalogImpl getLoadedCatalog(String catalogId) {
CatalogImpl c = null;
! //check delegate Catalogs
c = delegateCatalogs.get(catalogId);
if (c == null) {
//check other loaded Catalogs
c = loadedCatalogs.get(catalogId);
}
*** 490,504 ****
* specification, section 8. Resource Failures.
* <p>
* Verifies that the catalog represented by the catalogId has not been
* searched or is not circularly referenced.
*
! * @param catalogId The URI to a catalog
* @throws CatalogException if circular reference is found.
* @return true if the catalogId passed verification, false otherwise
*/
! final boolean verifyCatalogFile(URI catalogURI) {
if (catalogURI == null) {
return false;
}
//Ignore it if it doesn't exist
--- 503,518 ----
* specification, section 8. Resource Failures.
* <p>
* Verifies that the catalog represented by the catalogId has not been
* searched or is not circularly referenced.
*
! * @param parent the parent of the catalog to be loaded
! * @param catalogURI the URI to the catalog
* @throws CatalogException if circular reference is found.
* @return true if the catalogId passed verification, false otherwise
*/
! final boolean verifyCatalogFile(CatalogImpl parent, URI catalogURI) {
if (catalogURI == null) {
return false;
}
//Ignore it if it doesn't exist
*** 506,535 ****
!Util.isFileUriExist(catalogURI, false)) {
return false;
}
String catalogId = catalogURI.toASCIIString();
! if (catalogsSearched.contains(catalogId) || isCircular(catalogId)) {
CatalogMessages.reportRunTimeError(CatalogMessages.ERR_CIRCULAR_REFERENCE,
new Object[]{CatalogMessages.sanitize(catalogId)});
}
return true;
}
/**
* Checks whether the catalog is circularly referenced
* @param systemId the system identifier of the catalog to be loaded
* @return true if is circular, false otherwise
*/
! boolean isCircular(String systemId) {
if (parent == null) {
return false;
}
if (parent.systemId.equals(systemId)) {
return true;
}
! return parent.isCircular(systemId);
}
}
--- 520,553 ----
!Util.isFileUriExist(catalogURI, false)) {
return false;
}
String catalogId = catalogURI.toASCIIString();
! if (catalogsSearched.contains(catalogId) || isCircular(parent, catalogId)) {
CatalogMessages.reportRunTimeError(CatalogMessages.ERR_CIRCULAR_REFERENCE,
new Object[]{CatalogMessages.sanitize(catalogId)});
}
return true;
}
/**
* Checks whether the catalog is circularly referenced
+ *
+ * @param parent the parent of the catalog to be loaded
* @param systemId the system identifier of the catalog to be loaded
* @return true if is circular, false otherwise
*/
! boolean isCircular(CatalogImpl parent, String systemId) {
! // first, check the parent of the catalog to be loaded
if (parent == null) {
return false;
}
if (parent.systemId.equals(systemId)) {
return true;
}
! // next, check parent's parent
! return parent.isCircular(parent.parent, systemId);
}
}
< prev index next >