X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Futil%2Ffreenet%2Ffcp2%2FPriorityClass.java;h=623bc5b1166511fdf5b591db14903e87f6ea6d80;hb=953de352675a4ad91fe307d816a4ea7780c94274;hp=13b149e34ed4831190371cfc068708728b3a210f;hpb=e4f461213da0e30faf9e9eb2e97626abff320618;p=jSite.git diff --git a/src/de/todesbaum/util/freenet/fcp2/PriorityClass.java b/src/de/todesbaum/util/freenet/fcp2/PriorityClass.java index 13b149e..623bc5b 100644 --- a/src/de/todesbaum/util/freenet/fcp2/PriorityClass.java +++ b/src/de/todesbaum/util/freenet/fcp2/PriorityClass.java @@ -1,6 +1,5 @@ /* - * todesbaum-lib - - * Copyright (C) 2006 David Roden + * jSite - PriorityClass.java - Copyright © 2006–2012 David Roden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +25,7 @@ package de.todesbaum.util.freenet.fcp2; * immediate mode large file downloads, not to disk), updatable * (updatable site checks), bulk (large file downloads to disk), * prefetch, minimum. - * + * * @author David Roden <droden@gmail.com> * @version $Id$ */ @@ -61,7 +60,7 @@ public final class PriorityClass { /** * Creates a new priority class with the specified name and value. - * + * * @param name * The name of the priority class * @param value @@ -74,7 +73,7 @@ public final class PriorityClass { /** * Returns the name of this priority class. - * + * * @return The name of this priority class */ public String getName() { @@ -83,11 +82,44 @@ public final class PriorityClass { /** * Returns the value of this priority class. - * + * * @return The value of this priority class */ public int getValue() { return value; } + // + // STATIC METHODS + // + + /** + * Returns the priority class with the given name, matched case-insensitive. + * + * @param value + * The name of the priority + * @return The priority with the given name, or {@code null} if no priority + * matches the given name + */ + public static PriorityClass valueOf(String value) { + for (PriorityClass priorityClass : new PriorityClass[] { MINIMUM, PREFETCH, BULK, UPDATABLE, SEMI_INTERACTIVE, INTERACTIVE, MAXIMUM }) { + if (priorityClass.getName().equalsIgnoreCase(value)) { + return priorityClass; + } + } + return null; + } + + // + // OBJECT METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return name; + } + }