ezvcard.util
Class DataUri

java.lang.Object
  extended by ezvcard.util.DataUri

public final class DataUri
extends Object

Represents a URI for encoding binary data.

Example: data:image/jpeg;base64,[base64 string]

Author:
Michael Angstadt

Constructor Summary
DataUri(String uri)
          Parses a data URI string.
DataUri(String contentType, byte[] data)
          Creates a data URI.
 
Method Summary
 String getContentType()
          Sets the content type.
 byte[] getData()
          Gets the binary data.
 String toString()
           
 URI toUri()
          Creates a URI object from this data URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataUri

public DataUri(String contentType,
               byte[] data)
Creates a data URI.

Parameters:
contentType - the content type (e.g. "image/jpeg")
data - the binary data

DataUri

public DataUri(String uri)
Parses a data URI string.

Parameters:
uri - the data URI to parse (e.g. "data:image/jpeg;base64,[base64 string]")
Throws:
IllegalArgumentException - if the given URI is not a valid data URI
Method Detail

getData

public byte[] getData()
Gets the binary data.

Returns:
the binary data

getContentType

public String getContentType()
Sets the content type.

Returns:
the content type (e.g. "image/jpeg")

toUri

public URI toUri()
Creates a URI object from this data URI.

Returns:
the URI object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012-2014 Michael Angstadt. All Rights Reserved.