|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectilog.views.io.IlvInputStream
ilog.views.svg.SVGInputStream
public class SVGInputStream
This class is an IlvInputStream that allows you to read the
contents of an XML file using SVG grammar specifications.
SVGStreamFactory| Constructor Summary | |
|---|---|
SVGInputStream(InputStream stream,
SVGStreamFactory factory)
Creates an SVGInputStream from an InputStream and
linked to an SVGStreamFactory. |
|
| Method Summary | |
|---|---|
static EntityResolver |
getEntityResolver()
Returns the XML entity resolver for reading SVG files. |
void |
read(IlvGraphicBag bag)
Reads the SVGInputStream and puts the read objects into the
given IlvGraphicBag. |
static void |
setEntityResolver(EntityResolver resolver)
Sets the XML entity resolver for reading SVG files. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SVGInputStream(InputStream stream,
SVGStreamFactory factory)
SVGInputStream from an InputStream and
linked to an SVGStreamFactory. The factory could be
null, in which case the default options will be used.
stream - The input stream.factory - The SVG stream factory.SVGStreamFactory| Method Detail |
|---|
public void read(IlvGraphicBag bag)
throws IOException,
IlvReadFileException
SVGInputStream and puts the read objects into the
given IlvGraphicBag.
read in class IlvInputStreambag - The IlvGraphicBag in which objects will be added.
IOException - if there are any I/O errors.
IlvReadFileException - if the the file is not correctly SVG
formatted.public static void setEntityResolver(EntityResolver resolver)
Here is a simple example of an entity resolver that ensures that the svg11.dtd is always loaded from a local resource instead of the internet:
class MyResolver implements org.xml.sax.EntityResolver
{
private final static String SVG11_DTD_URI =
"svg11.dtd";
private final static String SVG11_PUBLIC_ID =
"-//W3C//DTD SVG 1.1//EN";
private EntityResolver parent;
public MyResolver(EntityResolver parent)
{
this.parent = parent;
}
public InputSource resolveEntity(String publicId, String systemId)
throws IOException, SAXException
{
InputSource is = null;
if ((publicId != null && publicId.equals(SVG11_PUBLIC_ID)) ||
systemId.endsWith("svg11.dtd")) {
is = new InputSource(
MyResolver.class.getResource(SVG11_DTD_URI).toString());
}
if (is == null && parent != null)
is = parent.resolveEntity(publicId, systemId);
if (is == null)
is = new InputSource(systemId);
if (publicId != null && is != null)
is.setPublicId(publicId);
return is;
}
}
To install this entity resolver, call:
SVGInputStream.setEntityResolver(
new MyResolver(SVGInputStream.getEntityResolver()));
Calling this method with null argument reinstalls the
default standard entity resolver.
getEntityResolver()public static EntityResolver getEntityResolver()
setEntityResolver(org.xml.sax.EntityResolver)
|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||