} catch (Exception ex) {
/* Nothing to do */
}
/* Check the ImageTagRegistry Cache */
Filter img = reg.checkCache(purl, colorspace);
if (img != null) {
return createRasterImageNode(ctx, e, img);
}
}
/* The Protected Stream ensures that the stream doesn't
* get closed unless we want it to. It is also based on
* a Buffered Reader so in general we can mark the start
* and reset rather than reopening the stream. Finally
* it hides the mark/reset methods so only we get to
* use them.
*/
ProtectedStream reference = null;
try {
reference = openStream(e, purl);
} catch (SecurityException ex) {
throw new BridgeException(e, ERR_URI_UNSECURE,
new Object[] {purl});
} catch (IOException ioe) {
return createBrokenImageNode(ctx, e, purl.toString());
}
{
/**
* First see if we can id the file as a Raster via magic
* number. This is probably the fastest mechanism.
* We tell the registry what the source purl is but we
* tell it not to open that url.
*/
Filter img = reg.readURL(reference, purl, colorspace,
false, false);
if (img != null) {
// It's a bouncing baby Raster...
return createRasterImageNode(ctx, e, img);
}
}
try {
// Reset the stream for next try.
reference.retry();
} catch (IOException ioe) {
try {
// Couldn't reset stream so reopen it.
reference = openStream(e, purl);
} catch (IOException ioe2) {
// Since we already opened the stream this is unlikely.
return createBrokenImageNode(ctx, e, purl.toString());
}
}
try {
/**
* Next see if it's an XML document.
*/
Document doc = loader.loadDocument(purl.toString(), reference);
imgDocument = (SVGDocument)doc;
return createSVGImageNode(ctx, e, imgDocument);
} catch (BridgeException ex) {
throw ex;
} catch (SecurityException ex) {
throw new BridgeException(e, ERR_URI_UNSECURE,
new Object[] {purl});
} catch (Exception ex) {
/* Nothing to do */
// ex.printStackTrace();
}
try {
reference.retry();
} catch (IOException ioe) {
try {
// Couldn't reset stream so reopen it.
reference = openStream(e, purl);
} catch (IOException ioe2) {
return createBrokenImageNode(ctx, e, purl.toString());
}
}
try {
// Finally try to load the image as a raster image (JPG or
// PNG) allowing the registry to open the url (so the
// JDK readers can be checked).
Filter img = reg.readURL(reference, purl, colorspace,
true, true);
if (img != null) {
// It's a bouncing baby Raster...
return createRasterImageNode(ctx, e, img);
}