FileDocCategorySizeDatePackage
MyResolver.javaAPI DocExample1712Fri Feb 01 12:59:16 GMT 2002None

MyResolver

public class MyResolver extends Object implements EntityResolver
Entity Resolver, with Chaining

Fields Summary
private EntityResolver
next
private Dictionary
map
Constructors Summary
public MyResolver(EntityResolver n, Dictionary m)

 next = n; map = m; 
Methods Summary
public org.xml.sax.InputSourceresolveEntity(java.lang.String publicId, java.lang.String systemId)

	// magic URL?
	if ("http://localhost/xml/date".equals (systemId)) {
	    InputSource	  retval = new InputSource (systemId);
	    Reader 	  date;

	    date = new StringReader (new Date().toString ());
	    retval.setCharacterStream (date);
	    return retval;
	}

	// nonstandard URI scheme?
	if (systemId.startsWith ("blob:")) {
	    InputSource	  retval = new InputSource (systemId);
	    String        key = systemId.substring (5);
	    byte          data [] = Storage.keyToBlob (key);

	    retval.setByteStream (new ByteArrayInputStream (data));
	    return retval;
	}

	// use table to map public id to local URL?
	if (map != null && publicId != null) {
	    String url = (String) map.get (publicId);
	    if (url != null)
		return new InputSource (url);
	}

	// chain to next resolver?
	if (next != null)
	    return next.resolveEntity (publicId, systemId);
	return null;