2 * jSite - PriorityClass.java - Copyright © 2006–2012 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 de.todesbaum.util.freenet.fcp2;
22 * The possible priority classes. Possible values are, in order of descending
23 * priority: <code>maximum</code> (anything more important than fproxy),
24 * <code>interactive</code> (fproxy), <code>semi-interactive</code> (fproxy
25 * immediate mode large file downloads, not to disk), <code>updatable</code>
26 * (updatable site checks), <code>bulk</code> (large file downloads to disk),
27 * <code>prefetch</code>, <code>minimum</code>.
29 * @author David Roden <droden@gmail.com>
32 public final class PriorityClass {
34 /** Denotes <code>maximum</code> priority class. */
35 public static final PriorityClass MAXIMUM = new PriorityClass("maximum", 0);
37 /** Denotes <code>interactive</code> priority class. */
38 public static final PriorityClass INTERACTIVE = new PriorityClass("interactive", 1);
40 /** Denotes <code>semi-interactive</code> priority class. */
41 public static final PriorityClass SEMI_INTERACTIVE = new PriorityClass("semiInteractive", 2);
43 /** Denotes <code>updatable</code> priority class. */
44 public static final PriorityClass UPDATABLE = new PriorityClass("updatable", 3);
46 /** Denotes <code>bulk</code> priority class. */
47 public static final PriorityClass BULK = new PriorityClass("bulk", 4);
49 /** Denotes <code>prefetch</code> priority class. */
50 public static final PriorityClass PREFETCH = new PriorityClass("prefetch", 5);
52 /** Denotes <code>minimum</code> priority class. */
53 public static final PriorityClass MINIMUM = new PriorityClass("minimum", 6);
55 /** The name of the priority class. */
58 /** The value of the priority class. */
62 * Creates a new priority class with the specified name and value.
65 * The name of the priority class
67 * The value of the priority class
69 private PriorityClass(String name, int value) {
75 * Returns the name of this priority class.
77 * @return The name of this priority class
79 public String getName() {
84 * Returns the value of this priority class.
86 * @return The value of this priority class
88 public int getValue() {
97 * Returns the priority class with the given name, matched case-insensitive.
100 * The name of the priority
101 * @return The priority with the given name, or {@code null} if no priority
102 * matches the given name
104 public static PriorityClass valueOf(String value) {
105 for (PriorityClass priorityClass : new PriorityClass[] { MINIMUM, PREFETCH, BULK, UPDATABLE, SEMI_INTERACTIVE, INTERACTIVE, MAXIMUM }) {
106 if (priorityClass.getName().equalsIgnoreCase(value)) {
107 return priorityClass;
121 public String toString() {