-
Notifications
You must be signed in to change notification settings - Fork 0
/
HtmlResource.java
52 lines (45 loc) · 1.26 KB
/
HtmlResource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.dynamicpdf.api;
import java.io.UnsupportedEncodingException;
import java.util.UUID;
/**
* Represents a Html resource object that is created using the Html file and a name.
*/
public class HtmlResource extends Resource{
/**
* Initializes a new instance of the <code>HtmlResource</code> class
* @param html The input html string.
* @param resourceName The name of the resource.
*/
public HtmlResource(String html, String resourceName) {
super();
try {
setData(html.getBytes("UTF8"));
} catch (UnsupportedEncodingException ex) {
}
if (resourceName == null)
setResourceName(UUID.randomUUID().toString() + getFileExtension());
else
setResourceName(resourceName);
}
/**
* Initializes a new instance of the <code>HtmlResource</code> class
* @param html The input html string.
*/
public HtmlResource(String html) {
super();
try {
setData(html.getBytes("UTF8"));
} catch (UnsupportedEncodingException ex) {
}
setResourceName(UUID.randomUUID().toString() + getFileExtension());
}
ResourceType getType() {
return ResourceType.HTML;
}
String getFileExtension() {
return ".html";
}
String getMimeType() {
return "text/html";
}
}