public class SVGInputStream extends IlvInputStream
IlvInputStream
that allows you to read the
contents of an XML file using SVG grammar specifications.SVGStreamFactory
Constructor and Description |
---|
SVGInputStream(InputStream stream,
SVGStreamFactory factory)
Creates an
SVGInputStream from an InputStream and
linked to an SVGStreamFactory . |
Modifier and Type | Method and Description |
---|---|
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.
|
getDocumentBase, getGraphicBag, getObjects, getVersion, invokeConstructor, isASCIIMode, isDoubleVersion, readBoolean, readBooleanArray, readColor, readColorArray, readComponentOrientation, readDouble, readDoubleArray, readDoubleOrFloat, readDoubleOrFloatArray, readExtensions, readFloat, readFloatArray, readFont, readFontArray, readGradient, readInt, readIntArray, readLocale, readLong, readLongArray, readObject, readObject, readObjectArray, readObjects, readPaint, readPattern, readPersistentObject, readPersistentObjects, readPoint, readPointArray, readRect, readRectArray, readShape, readShort, readShortArray, readString, readStringArray, readStroke, readTexture, readTransformer, readTransformerArray, readULocale, registerGraphic, setCopyPasteMode, setDocumentBase, setVersion
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
public void read(IlvGraphicBag bag) throws IOException, IlvReadFileException
SVGInputStream
and puts the read objects into the
given IlvGraphicBag
.read
in class IlvInputStream
bag
- 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)
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.