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.container;
17  
18  import org.fourthline.cling.support.model.StorageMedium;
19  
20  import static org.fourthline.cling.support.model.DIDLObject.Property.UPNP;
21  
22  /**
23   * @author Christian Bauer
24   */
25  public class StorageVolume extends Container {
26      
27      public static final Class CLASS = new Class("object.container.storageVolume");
28  
29      public StorageVolume() {
30          setClazz(CLASS);
31      }
32  
33      public StorageVolume(Container other) {
34          super(other);
35      }
36  
37      public StorageVolume(String id, Container parent, String title, String creator, Integer childCount,
38                           Long storageTotal, Long storageUsed, Long storageFree, StorageMedium storageMedium) {
39          this(id, parent.getId(), title, creator, childCount, storageTotal, storageUsed, storageFree, storageMedium);
40      }
41  
42      public StorageVolume(String id, String parentID, String title, String creator, Integer childCount,
43                           Long storageTotal, Long storageUsed, Long storageFree, StorageMedium storageMedium) {
44          super(id, parentID, title, creator, CLASS, childCount);
45          if (storageTotal != null)
46              setStorageTotal(storageTotal);
47          if (storageUsed!= null)
48              setStorageUsed(storageUsed);
49          if (storageFree != null)
50              setStorageFree(storageFree);
51          if (storageMedium != null)
52              setStorageMedium(storageMedium);
53      }
54  
55      public Long getStorageTotal() {
56          return getFirstPropertyValue(UPNP.STORAGE_TOTAL.class);
57      }
58  
59      public StorageVolume setStorageTotal(Long l) {
60          replaceFirstProperty(new UPNP.STORAGE_TOTAL(l));
61          return this;
62      }
63  
64      public Long getStorageUsed() {
65          return getFirstPropertyValue(UPNP.STORAGE_USED.class);
66      }
67  
68      public StorageVolume setStorageUsed(Long l) {
69          replaceFirstProperty(new UPNP.STORAGE_USED(l));
70          return this;
71      }
72  
73      public Long getStorageFree() {
74          return getFirstPropertyValue(UPNP.STORAGE_FREE.class);
75      }
76  
77      public StorageVolume setStorageFree(Long l) {
78          replaceFirstProperty(new UPNP.STORAGE_FREE(l));
79          return this;
80      }
81  
82      public StorageMedium getStorageMedium() {
83          return getFirstPropertyValue(UPNP.STORAGE_MEDIUM.class);
84      }
85  
86      public StorageVolume setStorageMedium(StorageMedium storageMedium) {
87          replaceFirstProperty(new UPNP.STORAGE_MEDIUM(storageMedium));
88          return this;
89      }
90      
91  }