com.google.caja.plugin
Class DataUriFetcher

java.lang.Object
  extended by com.google.caja.plugin.DataUriFetcher
All Implemented Interfaces:
UriFetcher

public class DataUriFetcher
extends java.lang.Object
implements UriFetcher

Supports cross-browser support for fetching content from data uri

Author:
Jasvir Nagra

Nested Class Summary
private static class DataUriFetcher.DATA_URI
           
 
Nested classes/interfaces inherited from interface com.google.caja.plugin.UriFetcher
UriFetcher.ChainingUriFetcher, UriFetcher.UriFetchException
 
Field Summary
private  java.lang.String DATA_URI_DEFAULT_CHARSET
           
private  java.util.regex.Pattern DATA_URI_RE
          From http://tools.ietf.org/html/rfc2397 dataurl := "data:" [ mediatype ] [ ";base64" ] "," data mediatype := [ type "/" subtype ] *( ";" parameter ) data := *urlchar parameter := attribute "=" value
 
Fields inherited from interface com.google.caja.plugin.UriFetcher
NULL_NETWORK
 
Constructor Summary
DataUriFetcher()
           
 
Method Summary
private  java.lang.String charsetFromMime(java.lang.String mime)
           
 FetchedData fetch(ExternalReference ref, java.lang.String mimeType)
          Loads an external resource such as the src of a script tag or a stylesheet.
 byte[] fetchBinary(ExternalReference ref, java.lang.String mimeType)
           
private  boolean isDataUri(java.net.URI uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_URI_RE

private final java.util.regex.Pattern DATA_URI_RE
From http://tools.ietf.org/html/rfc2397 dataurl := "data:" [ mediatype ] [ ";base64" ] "," data mediatype := [ type "/" subtype ] *( ";" parameter ) data := *urlchar parameter := attribute "=" value


DATA_URI_DEFAULT_CHARSET

private final java.lang.String DATA_URI_DEFAULT_CHARSET
See Also:
Constant Field Values
Constructor Detail

DataUriFetcher

public DataUriFetcher()
Method Detail

isDataUri

private boolean isDataUri(java.net.URI uri)

charsetFromMime

private java.lang.String charsetFromMime(java.lang.String mime)

fetch

public FetchedData fetch(ExternalReference ref,
                         java.lang.String mimeType)
                  throws UriFetcher.UriFetchException
Description copied from interface: UriFetcher
Loads an external resource such as the src of a script tag or a stylesheet.

Specified by:
fetch in interface UriFetcher
Returns:
non-null resource
Throws:
UriFetcher.UriFetchException - if the resource could not be loaded

fetchBinary

public final byte[] fetchBinary(ExternalReference ref,
                                java.lang.String mimeType)
                         throws UriFetcher.UriFetchException
Throws:
UriFetcher.UriFetchException


Copyright (C) 2008 Google Inc.
Licensed under the Apache License, Version 2.0