2 * jFCPlib - SubscribeUSK.java - Copyright © 2008 David Roden
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.
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.
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.
19 package net.pterodactylus.fcp;
21 import java.util.Optional;
24 * With a “SubscribeUSK” a client requests to be notified if the edition number
27 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
29 public class SubscribeUSK extends FcpMessage implements Identifiable {
31 public SubscribeUSK(String identifier) {
32 super("SubscribeUSK");
33 setField("Identifier", identifier);
36 public SubscribeUSK(String uri, String identifier) {
42 public String getIdentifier() {
43 return getField("Identifier");
46 public String getUri() {
47 return getField("URI");
50 public void setUri(String uri) {
54 public boolean isActive() {
55 return !Boolean.parseBoolean(getField("DontPoll"));
59 * Sets whether updates for the USK are actively searched.
62 * <code>true</code> to actively search for newer editions,
63 * <code>false</code> to only watch for newer editions that are
64 * found from other requests
66 public void setActive(boolean active) {
67 setField("DontPoll", String.valueOf(!active));
70 public boolean isSparse() {
71 return Boolean.valueOf(getField("SparsePoll"));
74 public void setSparse(boolean sparse) {
75 setField("SparsePoll", String.valueOf(sparse));
78 public Priority getPriority() {
79 return Optional.ofNullable(getField("PriorityClass")).map(Priority::valueOf).orElse(Priority.bulkSplitfile);
82 public void setPriority(Priority priority) {
83 setField("PriorityClass", priority.toString());
86 public Priority getActivePriority() {
87 return Optional.ofNullable(getField("PriorityClassProgress")).map(Priority::valueOf).orElse(Priority.update);
90 public void setActivePriority(Priority activePriority) {
91 setField("PriorityClassProgress", activePriority.toString());
94 public boolean isRealTime() {
95 return Boolean.valueOf(getField("RealTimeFlag"));
98 public void setRealTime(boolean realTime) {
99 setField("RealTimeFlag", String.valueOf(realTime));
102 public boolean isIgnoreDateHints() {
103 return Boolean.valueOf(getField("IgnoreUSKDatehints"));
106 public void setIgnoreDateHints(boolean ignoreDateHints) {
107 setField("IgnoreUSKDatehints", String.valueOf(ignoreDateHints));