View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.support.model;
17  
18  import org.fourthline.cling.model.ModelUtil;
19  import org.fourthline.cling.model.action.ActionArgumentValue;
20  
21  import java.util.Map;
22  
23  /**
24   * @author Christian Bauer
25   */
26  public class DeviceCapabilities {
27  
28      private StorageMedium[] playMedia;
29      private StorageMedium[] recMedia = new StorageMedium[] {StorageMedium.NOT_IMPLEMENTED};
30      private RecordQualityMode[] recQualityModes = new RecordQualityMode[] {RecordQualityMode.NOT_IMPLEMENTED};
31  
32      public DeviceCapabilities(Map<String, ActionArgumentValue> args) {
33          this(
34                  StorageMedium.valueOfCommaSeparatedList((String) args.get("PlayMedia").getValue()),
35                  StorageMedium.valueOfCommaSeparatedList((String) args.get("RecMedia").getValue()),
36                  RecordQualityMode.valueOfCommaSeparatedList((String) args.get("RecQualityModes").getValue())
37          );
38      }
39  
40      public DeviceCapabilities(StorageMedium[] playMedia) {
41          this.playMedia = playMedia;
42      }
43  
44      public DeviceCapabilities(StorageMedium[] playMedia, StorageMedium[] recMedia, RecordQualityMode[] recQualityModes) {
45          this.playMedia = playMedia;
46          this.recMedia = recMedia;
47          this.recQualityModes = recQualityModes;
48      }
49  
50      public StorageMedium[] getPlayMedia() {
51          return playMedia;
52      }
53  
54      public StorageMedium[] getRecMedia() {
55          return recMedia;
56      }
57  
58      public RecordQualityMode[] getRecQualityModes() {
59          return recQualityModes;
60      }
61  
62      public String getPlayMediaString() {
63          return ModelUtil.toCommaSeparatedList(playMedia);
64      }
65  
66      public String getRecMediaString() {
67          return ModelUtil.toCommaSeparatedList(recMedia);
68      }
69  
70      public String getRecQualityModesString() {
71          return ModelUtil.toCommaSeparatedList(recQualityModes);
72      }
73  }