Package org.mycore.datamodel.common
Class MCRDataURL
java.lang.Object
org.mycore.datamodel.common.MCRDataURL
- All Implemented Interfaces:
Serializable
Represents the data URL scheme (RFC2397).
- Author:
- René Adler (eagle)
- See Also:
-
Constructor Summary
ConstructorDescriptionMCRDataURL
(byte[] data) Constructs a newMCRDataURL
.MCRDataURL
(byte[] data, MCRDataURLEncoding encoding) Constructs a newMCRDataURL
.MCRDataURL
(byte[] data, MCRDataURLEncoding encoding, String mimeType) Constructs a newMCRDataURL
.MCRDataURL
(byte[] data, MCRDataURLEncoding encoding, String mimeType, String charset) Constructs a newMCRDataURL
.MCRDataURL
(byte[] data, MCRDataURLEncoding encoding, String mimeType, Charset charset) Constructs a newMCRDataURL
.MCRDataURL
(byte[] data, MCRDataURLEncoding encoding, String mimeType, Map<String, String> parameters) Constructs a newMCRDataURL
. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Build a "data" URL for givenString
with mime-type based encoding,text/xml
as mime-type andUTF-8
as charset.static String
Build a "data" URL for givenString
, mime-type andUTF-8
as charset.static String
Build a "data" URL for givenString
, encoding, mime-type and charset.static String
Build a "data" URL for givenDocument
with mime-type based encoding,text/xml
as mime-type andUTF-8
as charset.static String
Build a "data" URL for givenDocument
, mime-type andUTF-8
as charset.static String
Build a "data" URL for givenDocument
, encoding, mime-type and charset.static String
Build a "data" URL for givenNodeList
with mime-type based encoding,text/xml
as mime-type andUTF-8
as charset.static String
Build a "data" URL for givenNodeList
, mime-type andUTF-8
as charset.static String
Build a "data" URL for givenNodeList
, encoding, mime-type and charset.boolean
byte[]
getData()
int
hashCode()
static MCRDataURL
Parse aString
toMCRDataURL
.toString()
Returns aString
of aMCRDataURL
object .
-
Constructor Details
-
MCRDataURL
public MCRDataURL(byte[] data, MCRDataURLEncoding encoding, String mimeType, Map<String, String> parameters) throws MalformedURLExceptionConstructs a newMCRDataURL
.- Parameters:
data
- the dataencoding
- the encoding of data urlmimeType
- the mimeType of data urlparameters
- a list of paramters of data url- Throws:
MalformedURLException
-
MCRDataURL
public MCRDataURL(byte[] data, MCRDataURLEncoding encoding, String mimeType, Charset charset) throws MalformedURLException Constructs a newMCRDataURL
.- Parameters:
data
- the dataencoding
- the encoding of data urlmimeType
- the mimeType of data urlcharset
- the charset of data url- Throws:
MalformedURLException
-
MCRDataURL
public MCRDataURL(byte[] data, MCRDataURLEncoding encoding, String mimeType, String charset) throws MalformedURLException Constructs a newMCRDataURL
.- Parameters:
data
- the dataencoding
- the encoding of data urlmimeType
- the mimeType of data urlcharset
- the charset of data url- Throws:
MalformedURLException
-
MCRDataURL
public MCRDataURL(byte[] data, MCRDataURLEncoding encoding, String mimeType) throws MalformedURLException Constructs a newMCRDataURL
.- Parameters:
data
- the dataencoding
- the encoding of data urlmimeType
- the mimeType of data url- Throws:
MalformedURLException
-
MCRDataURL
Constructs a newMCRDataURL
.- Parameters:
data
- the data of data urlencoding
- the encoding of data url- Throws:
MalformedURLException
-
MCRDataURL
Constructs a newMCRDataURL
.- Parameters:
data
- the data of data url- Throws:
MalformedURLException
-
-
Method Details
-
build
public static String build(Document document, String encoding, String mimeType, String charset) throws TransformerException, MalformedURLException Build a "data" URL for givenDocument
, encoding, mime-type and charset. Should encoding benull
, it is detect from mime-type.- Parameters:
document
- the documentencoding
- theMCRDataURLEncoding
mimeType
- the mime-typecharset
- the charset- Returns:
- a string with "data" URL
- Throws:
TransformerException
MalformedURLException
-
build
public static String build(NodeList nodeList, String encoding, String mimeType, String charset) throws TransformerException, MalformedURLException Build a "data" URL for givenNodeList
, encoding, mime-type and charset. Should encoding benull
, it is detect from mime-type.- Parameters:
nodeList
- the node listencoding
- theMCRDataURLEncoding
mimeType
- the mime-typecharset
- the charset- Returns:
- a string with "data" URL
- Throws:
TransformerException
MalformedURLException
-
build
public static String build(String str, String encoding, String mimeType, String charset) throws TransformerException, MalformedURLException Build a "data" URL for givenString
, encoding, mime-type and charset. Should encoding benull
, it is detect from mime-type.- Parameters:
str
- the valueencoding
- theMCRDataURLEncoding
mimeType
- the mime-typecharset
- the charset- Returns:
- a string with "data" URL
- Throws:
TransformerException
MalformedURLException
-
build
public static String build(Document document, String mimeType) throws TransformerException, MalformedURLException Build a "data" URL for givenDocument
, mime-type andUTF-8
as charset.- Parameters:
document
- the documentmimeType
- the mime-type- Returns:
- a string with "data" URL
- Throws:
TransformerException
MalformedURLException
-
build
public static String build(NodeList nodeList, String mimeType) throws TransformerException, MalformedURLException Build a "data" URL for givenNodeList
, mime-type andUTF-8
as charset.- Parameters:
nodeList
- the node listmimeType
- the mime-type- Returns:
- a string with "data" URL
- Throws:
TransformerException
MalformedURLException
-
build
public static String build(String str, String mimeType) throws TransformerException, MalformedURLException Build a "data" URL for givenString
, mime-type andUTF-8
as charset.- Parameters:
str
- the stringmimeType
- the mime-type- Returns:
- a string with "data" URL
- Throws:
TransformerException
MalformedURLException
-
build
Build a "data" URL for givenDocument
with mime-type based encoding,text/xml
as mime-type andUTF-8
as charset.- Parameters:
document
- the document- Returns:
- a string with "data" URL
- Throws:
TransformerException
MalformedURLException
-
build
Build a "data" URL for givenNodeList
with mime-type based encoding,text/xml
as mime-type andUTF-8
as charset.- Parameters:
nodeList
- the node list- Returns:
- a string with "data" URL
- Throws:
TransformerException
MalformedURLException
-
build
Build a "data" URL for givenString
with mime-type based encoding,text/xml
as mime-type andUTF-8
as charset.- Parameters:
str
- the node list- Returns:
- a string with "data" URL
- Throws:
TransformerException
MalformedURLException
-
parse
Parse aString
toMCRDataURL
.- Parameters:
dataURL
- the data url string- Returns:
- a
MCRDataURL
object - Throws:
MalformedURLException
-
getMimeType
- Returns:
- the mimeType
-
getParameters
- Returns:
- the parameters
-
getCharset
- Returns:
- the charset
-
getEncoding
- Returns:
- the encoding
-
getData
public byte[] getData()- Returns:
- the data
-
toString
Returns aString
of aMCRDataURL
object .- Overrides:
toString
in classObject
- Returns:
- the data url as string
- Throws:
RuntimeException
-
hashCode
public int hashCode() -
equals
-