Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CustomURIResolver.java
Go to the documentation of this file.
1 
2 package vmi1;
3 
4 import org.apache.ws.commons.schema.resolver.URIResolver;
5 import org.apache.ws.commons.schema.resolver.CollectionURIResolver;
6 
7 import org.xml.sax.InputSource;
8 
9 import java.io.InputStream;
10 import java.net.URL;
11 
12 public class CustomURIResolver implements CollectionURIResolver {
13  protected String baseURI;
14  protected URL baseURL;
15 
16  public CustomURIResolver(URL baseURL) {
17  this.baseURL = baseURL;
18  }
19 
20  public CustomURIResolver() {
21  super();
22  }
23 
24  public String getCollectionBaseURI() {
25  if (this.baseURL != null)
26  return this.baseURL.toString();
27  return this.baseURI;
28  }
29 
30  public void setCollectionBaseURI(String uri) {
31  this.baseURI = uri;
32  }
33 
34  public InputSource resolveEntity(String targetNamespace,String schemaLocation,
35  String baseUri) {
36  URL newImportedURL = null;
37  try {
38  //System.err.println("baseUri = " + baseUri);
39  URL parentLocationURL;
40  if (this.baseURL != null)
41  parentLocationURL = this.baseURL;
42  else
43  parentLocationURL = new URL(baseUri);
44  newImportedURL = new URL(parentLocationURL,schemaLocation);
45  InputStream newInputStream = newImportedURL.openStream();
46  return new InputSource(newInputStream);
47  }
48  catch (Exception ex) {
49  ex.printStackTrace();
50  return null;
51  }
52  }
53 }
InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri)
void setCollectionBaseURI(String uri)