X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Ffcp%2FVersion.java;fp=src%2Fnet%2Fpterodactylus%2Ffcp%2FVersion.java;h=0000000000000000000000000000000000000000;hb=508624458578f01a393f8b44f32b98b40054fdc8;hp=0f1d5cbb8f7f8ca1416d9de6f5e16a233a7648c8;hpb=dd605aee444057a874fabf7fb0045b8448b0d1cd;p=jFCPlib.git diff --git a/src/net/pterodactylus/fcp/Version.java b/src/net/pterodactylus/fcp/Version.java deleted file mode 100644 index 0f1d5cb..0000000 --- a/src/net/pterodactylus/fcp/Version.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * jFCPlib - Version.java - Copyright © 2008 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.fcp; - -import java.util.StringTokenizer; - -/** - * Container for the “lastGoodVersion” field. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - */ -public class Version { - - /** The name of the node implementation. */ - private final String nodeName; - - /** The tree version of the node. */ - private final String treeVersion; - - /** The protocol version of the node. */ - private final String protocolVersion; - - /** The build number of the node. */ - private final int buildNumber; - - /** - * Creates a new Version from the given string. The string consists of the - * four required fields node name, tree version, protocol version, and build - * number, separated by a comma. - * - * @param version - * The version string - * @throws NullPointerException - * if version is null - * @throws IllegalArgumentException - * if version is not in the right format - */ - public Version(String version) { - if (version == null) { - throw new NullPointerException("version must not be null"); - } - StringTokenizer versionTokens = new StringTokenizer(version, ","); - if (versionTokens.countTokens() != 4) { - throw new IllegalArgumentException("version must consist of four fields"); - } - this.nodeName = versionTokens.nextToken(); - this.treeVersion = versionTokens.nextToken(); - this.protocolVersion = versionTokens.nextToken(); - try { - this.buildNumber = Integer.valueOf(versionTokens.nextToken()); - } catch (NumberFormatException nfe1) { - throw new IllegalArgumentException("last part of version must be numeric", nfe1); - } - } - - /** - * Creates a new Version from the given parts. - * - * @param nodeName - * The name of the node implementation - * @param treeVersion - * The tree version - * @param protocolVersion - * The protocol version - * @param buildNumber - * The build number of the node - */ - public Version(String nodeName, String treeVersion, String protocolVersion, int buildNumber) { - this.nodeName = nodeName; - this.treeVersion = treeVersion; - this.protocolVersion = protocolVersion; - this.buildNumber = buildNumber; - } - - /** - * Returns the name of the node implementation. - * - * @return The node name - */ - public String getNodeName() { - return nodeName; - } - - /** - * The tree version of the node. - * - * @return The tree version of the node - */ - public String getTreeVersion() { - return treeVersion; - } - - /** - * The protocol version of the node - * - * @return The protocol version of the node - */ - public String getProtocolVersion() { - return protocolVersion; - } - - /** - * The build number of the node. - * - * @return The build number of the node - */ - public int getBuildNumber() { - return buildNumber; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return nodeName + "," + treeVersion + "," + protocolVersion + "," + buildNumber; - } - -}