Author: scabanovich
Date: 2007-07-20 10:49:55 -0400 (Fri, 20 Jul 2007)
New Revision: 2554
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java
Log:
EXIN-86 NullPointerException prevented when registering missing resources.
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java 2007-07-20
14:49:42 UTC (rev 2553)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java 2007-07-20
14:49:55 UTC (rev 2554)
@@ -5,7 +5,11 @@
package org.jboss.tools.common.xml;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URL;
import java.util.Properties;
+
+import org.eclipse.core.runtime.FileLocator;
import org.xml.sax.*;
/**
@@ -20,10 +24,25 @@
publicEntities.setProperty(publicId, url);
}
+ public static void registerPublicEntity(String publicId, Class<?> loader,
String resourceName) throws IOException {
+ URL url = resolve(loader, resourceName);
+ if(url != null) registerPublicEntity(publicId, url.toString());
+ }
+
public static void registerSystemEntity(String systemId, String url) {
systemEntities.setProperty(systemId, url);
}
+ public static void registerSystemEntity(String systemId, Class<?> loader,
String resourceName) throws IOException {
+ URL url = resolve(loader, resourceName);
+ if(url != null) registerSystemEntity(systemId, url.toString());
+ }
+
+ static URL resolve(Class<?> loader, String resourceName) throws IOException {
+ URL url = loader.getResource(resourceName);
+ return (url == null) ? null : FileLocator.resolve(url);
+ }
+
public static XMLEntityResolver getInstance() {
return new XMLEntityResolver();
}
Show replies by date