Refine search
public Source resolveURI(String uri) { try { ParsedURL url = new ParsedURL(baseURI, uri); InputStream in = url.openStream(); StreamSource source = new StreamSource(in, url.toString()); return source; } catch (IOException ioe) { userAgent.displayError(ioe); return null; } }
/** * Factory method to construct an appropriate subclass of ParsedURLData, * for a sub url. * @param baseURL The base ParsedURL to parse. * @param urlStr the sub URL string to parse. */ public static ParsedURLData parseURL(ParsedURL baseURL, String urlStr) { if (baseURL == null) return parseURL(urlStr); String protocol = getProtocol(urlStr); if (protocol == null) protocol = baseURL.getProtocol(); ParsedURLProtocolHandler handler = getHandler(protocol); return handler.parseURL(baseURL, urlStr); } }
if (baseURI == null) purl = new ParsedURL(uriStr); else purl = new ParsedURL(baseURI, uriStr); Document doc = e.getOwnerDocument(); Element imgElem = doc.createElementNS(SVG_NAMESPACE_URI, SVG_IMAGE_TAG); imgElem.setAttributeNS(XLINK_NAMESPACE_URI, XLINK_HREF_ATTRIBUTE, purl.toString()); NamedNodeMap attrs = e.getAttributes(); int len = attrs.getLength(); for (int i = 0; i < len; i++) {
@Override public Node cloneNode(Document doc, Node eold) { Node enew = null; if(eold instanceof Element) { Element e = (Element) eold; if(e.getTagName().equals(SVGConstants.SVG_IMAGE_TAG)) { String url = e.getAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE); ParsedURL urldata = new ParsedURL(url); if(ThumbnailRegistryEntry.isCompatibleURLStatic(urldata)) { enew = inlineThumbnail(doc, urldata, eold); } else if("file".equals(urldata.getProtocol())) { enew = inlineExternal(doc, urldata, eold); } } } if(enew != null) { return enew; } return super.cloneNode(doc, eold); }
(SVGOMDocument)patternElement.getOwnerDocument(); ParsedURL purl = new ParsedURL(doc.getURL(), uri); if (!purl.complete()) throw new BridgeException(ctx, patternElement, ERR_URI_MALFORMED, patternElement = ctx.getReferencedElement(patternElement, uri);
SVGOMDocument doc = (SVGOMDocument)paintElement.getOwnerDocument(); ParsedURL purl = new ParsedURL(doc.getURL(), uri); paintElement = ctx.getReferencedElement(paintElement, uri);
File in = new File(urldata.getPath()); if(!in.exists()) { LoggingUtil.warning("Referencing non-existant file: " + urldata.toString()); return null; i.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE, os.toString().replaceAll("\\s*[\\r\\n]+\\s*", "")); return i;
/** * Inline a referenced thumbnail. * * @param doc Document (element factory) * @param urldata URL * @param eold Existing node * @return Replacement node, or {@code null} */ protected Node inlineThumbnail(Document doc, ParsedURL urldata, Node eold) { RenderableImage img = ThumbnailRegistryEntry.handleURL(urldata); if(img == null) { LoggingUtil.warning("Image not found in registry: " + urldata.toString()); return null; } ByteArrayOutputStream os = new ByteArrayOutputStream(); try { os.write(SVGSyntax.DATA_PROTOCOL_PNG_PREFIX.getBytes()); Base64EncoderStream encoder = new Base64EncoderStream(os); ImageIO.write(img.createDefaultRendering(), "png", encoder); encoder.close(); } catch(IOException e) { LoggingUtil.exception("Exception serializing image to png", e); return null; } Element i = (Element) super.cloneNode(doc, eold); i.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE, os.toString().replaceAll("\\s*[\\r\\n]+\\s*", "")); return i; }
/** * Parses and fills the given style-sheet. * @param ss The stylesheet to fill. * @param rules The style-sheet rules to parse. * @param uri The base URI. */ public void parseStyleSheet(StyleSheet ss, String rules, ParsedURL uri) throws DOMException { try { parseStyleSheet(ss, new InputSource(new StringReader(rules)), uri); } catch (Exception e) { // e.printStackTrace(); String m = e.getMessage(); if (m == null) m = ""; String s = Messages.formatMessage ("stylesheet.syntax.error", new Object[] { uri.toString(), rules, m }); DOMException de = new DOMException(DOMException.SYNTAX_ERR, s); if (userAgent == null) throw de; userAgent.displayError(de); } }
ParsedURL purl = new ParsedURL(baseURI, uri); documentURI = document.getURL(); String frag = purl.getRef(); if ((frag != null) && (documentURI != null)) { ParsedURL pDocURL = new ParsedURL(documentURI); if (pDocURL.sameFile(purl)) { pDocURL = new ParsedURL(documentURI); userAgent.checkLoadExternalResource(purl, pDocURL); String purlStr = purl.toString(); if (frag != null) { purlStr = purlStr.substring(0, purlStr.length()-(frag.length()+1));
"".equals(securityPolicyProperty)) { ParsedURL policyURL = new ParsedURL(securityEnforcer.getPolicyURL()); Reader r = new BufferedReader(new InputStreamReader(policyURL.openStream())); Writer w = new FileWriter(policyFile);
public void run() { userAgent.setSVGCursor(holder.getCursor()); String href = elt.getHref().getAnimVal(); ParsedURL purl = new ParsedURL(elt.getBaseURI(), href); SVGOMDocument doc = (SVGOMDocument) elt.getOwnerDocument(); ParsedURL durl = doc.getParsedURL(); if (purl.sameFile(durl)) { String frag = purl.getRef(); if (frag != null && frag.length() != 0) { Element refElt = doc.getElementById(frag); if (refElt instanceof SVGOMAnimationElement) { SVGOMAnimationElement aelt = (SVGOMAnimationElement) refElt; float t = aelt.getHyperlinkBeginTime(); if (Float.isNaN(t)) { aelt.beginElement(); } else { doc.getRootElement().setCurrentTime(t); } return; } } } userAgent.openLink(elt); } }
/** * Creates a new BaseScriptingEnvironment. * @param ctx the bridge context */ public BaseScriptingEnvironment(BridgeContext ctx) { bridgeContext = ctx; document = ctx.getDocument(); docPURL = new ParsedURL(((SVGDocument)document).getURL()); userAgent = bridgeContext.getUserAgent(); }
String baseURI = paintElement.getBaseURI(); ParsedURL purl = new ParsedURL(baseURI, uri); paintElement = ctx.getReferencedElement(paintElement, uri);
public void run() { String url = newURI.toString(); fragmentIdentifier = newURI.getRef(); loader = new DocumentLoader(userAgent); nextDocumentLoader = new SVGDocumentLoader(url, loader); nextDocumentLoader.setPriority(Thread.MIN_PRIORITY); Iterator it = svgDocumentLoaderListeners.iterator(); while (it.hasNext()) { nextDocumentLoader.addSVGDocumentLoaderListener ((SVGDocumentLoaderListener)it.next()); } startDocumentLoader(); } });
/** * <b>DOM</b>: Implements {@link org.w3c.dom.Document#setDocumentURI(String)}. */ public void setDocumentURI(String uri) { documentURI = uri; url = uri == null ? null : new ParsedURL(uri); }