1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.model.message.header;
17
18 import org.seamless.util.MimeType;
19
20
21
22
23 public class ContentTypeHeader extends UpnpHeader<MimeType> {
24
25 public static final MimeType DEFAULT_CONTENT_TYPE = MimeType.valueOf("text/xml");
26 public static final MimeType DEFAULT_CONTENT_TYPE_UTF8 = MimeType.valueOf("text/xml;charset=\"utf-8\"");
27
28 public ContentTypeHeader() {
29 setValue(DEFAULT_CONTENT_TYPE);
30 }
31
32 public ContentTypeHeader(MimeType contentType) {
33 setValue(contentType);
34 }
35
36 public ContentTypeHeader(String s) throws InvalidHeaderException{
37 setString(s);
38 }
39
40 public void setString(String s) throws InvalidHeaderException {
41 setValue(MimeType.valueOf(s));
42 }
43
44 public String getString() {
45 return getValue().toString();
46 }
47
48 public boolean isUDACompliantXML() {
49
50 return isText() && getValue().getSubtype().equals(DEFAULT_CONTENT_TYPE.getSubtype());
51 }
52
53 public boolean isText() {
54 return getValue() != null && getValue().getType().equals(DEFAULT_CONTENT_TYPE.getType());
55 }
56 }