1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.fourthline.cling.support.model.dlna.message.header;
16
17 import java.util.EnumMap;
18 import org.fourthline.cling.model.message.header.InvalidHeaderException;
19 import org.fourthline.cling.support.model.dlna.DLNAAttribute;
20
21
22
23
24 public class ContentFeaturesHeader extends DLNAHeader<EnumMap<DLNAAttribute.Type, DLNAAttribute>> {
25
26 public ContentFeaturesHeader() {
27 setValue(new EnumMap<DLNAAttribute.Type, DLNAAttribute>(DLNAAttribute.Type.class));
28 }
29
30 @Override
31 public void setString(String s) throws InvalidHeaderException {
32 if (s.length() != 0) {
33 String[] atts = s.split(";");
34 for (String att : atts) {
35 String[] attNameValue = att.split("=");
36 if (attNameValue.length == 2) {
37 DLNAAttribute.Type type = DLNAAttribute.Type.valueOfAttributeName(attNameValue[0]);
38 if (type != null) {
39 DLNAAttribute dlnaAttrinute = DLNAAttribute.newInstance(type, attNameValue[1], "");
40 getValue().put(type, dlnaAttrinute);
41 }
42 }
43 }
44 }
45 }
46
47 @Override
48 public String getString() {
49 String s = "";
50 for (DLNAAttribute.Type type : DLNAAttribute.Type.values()) {
51 String value = getValue().containsKey(type) ? getValue().get(type).getString() : null;
52 if (value != null && value.length() != 0) {
53 s += (s.length() == 0 ? "" : ";") + type.getAttributeName() + "=" + value;
54 }
55 }
56 return s;
57 }
58 }