Expose lots of constructors and accessors
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / SubscribeUSK.java
1 /*
2  * jFCPlib - SubscribeUSK.java - Copyright © 2008 David Roden
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18
19 package net.pterodactylus.fcp;
20
21 /**
22  * With a “SubscribeUSK” a client requests to be notified if the edition number
23  * of a USK changes.
24  *
25  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
26  */
27 public class SubscribeUSK extends FcpMessage implements Identifiable {
28
29         public SubscribeUSK(String identifier) {
30                 super("SubscribeUSK");
31                 setField("Identifier", identifier);
32         }
33
34         public SubscribeUSK(String uri, String identifier) {
35                 this(identifier);
36                 setField("URI", uri);
37         }
38
39         @Override
40         public String getIdentifier() {
41                 return getField("Identifier");
42         }
43
44         public String getUri() {
45                 return getField("URI");
46         }
47
48         public void setUri(String uri) {
49                 setField("URI", uri);
50         }
51
52         public boolean isActive() {
53                 return !Boolean.parseBoolean(getField("DontPoll"));
54         }
55
56         /**
57          * Sets whether updates for the USK are actively searched.
58          *
59          * @param active
60          *            <code>true</code> to actively search for newer editions,
61          *            <code>false</code> to only watch for newer editions that are
62          *            found from other requests
63          */
64         public void setActive(boolean active) {
65                 setField("DontPoll", String.valueOf(!active));
66         }
67
68         public boolean isSparse() {
69                 return Boolean.valueOf(getField("SparsePoll"));
70         }
71
72         public void setSparse(boolean sparse) {
73                 setField("SparsePoll", String.valueOf(sparse));
74         }
75
76         public Priority getPriority() {
77                 String priorityClass = getField("PriorityClass");
78                 if (priorityClass != null) {
79                         return Priority.valueOf(priorityClass);
80                 }
81                 return Priority.bulkSplitfile;
82         }
83
84         public void setPriority(Priority priority) {
85                 setField("PriorityClass", priority.toString());
86         }
87
88         public Priority getActivePriority() {
89                 String priorityClass = getField("PriorityClassProgress");
90                 if (priorityClass != null) {
91                         return Priority.valueOf(priorityClass);
92                 }
93                 return Priority.update;
94         }
95
96         public void setActivePriority(Priority activePriority) {
97                 setField("PriorityClassProgress", activePriority.toString());
98         }
99
100         public boolean isRealTime() {
101                 return Boolean.valueOf(getField("RealTimeFlag"));
102         }
103
104         public void setRealTime(boolean realTime) {
105                 setField("RealTimeFlag", String.valueOf(realTime));
106         }
107
108         public boolean isIgnoreDateHints() {
109                 return Boolean.valueOf(getField("IgnoreUSKDatehints"));
110         }
111
112         public void setIgnoreDateHints(boolean ignoreDateHints) {
113                 setField("IgnoreUSKDatehints", String.valueOf(ignoreDateHints));
114         }
115
116 }