X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fmain%2FVersion.java;h=373703cb4dadee928a6d4440b352a9ba60f2d18b;hb=8bc7a8f2372639a9fbeea34f9cbee9697f34ba3f;hp=ec7df392b6f5b5ebe9e457069910c6f297f06ad8;hpb=da127cd41fa65b7ec217f8e9f525ed7534abf5e1;p=jSite.git diff --git a/src/de/todesbaum/jsite/main/Version.java b/src/de/todesbaum/jsite/main/Version.java index ec7df39..373703c 100644 --- a/src/de/todesbaum/jsite/main/Version.java +++ b/src/de/todesbaum/jsite/main/Version.java @@ -1,6 +1,5 @@ /* - * jSite - a tool for uploading websites into Freenet - * Copyright (C) 2006 David Roden + * jSite - Version.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,9 +25,6 @@ package de.todesbaum.jsite.main; */ public class Version implements Comparable { - /** The version. */ - private static final Version VERSION = new Version(0, 6, 2); - /** The components of the version information. */ private final int[] components; @@ -64,12 +60,25 @@ public class Version implements Comparable { } /** - * Returns the version. + * Parses a version from the given string. * - * @return The version + * @param versionString + * The version string to parse + * @return The parsed version, or null if the string could not + * be parsed */ - public static final String getVersion() { - return VERSION.toString(); + public static Version parse(String versionString) { + String[] componentStrings = versionString.split("\\."); + int[] components = new int[componentStrings.length]; + int index = -1; + for (String componentString : componentStrings) { + try { + components[++index] = Integer.parseInt(componentString); + } catch (NumberFormatException nfe1) { + return null; + } + } + return new Version(components); } /** @@ -90,6 +99,7 @@ public class Version implements Comparable { /** * {@inheritDoc} */ + @Override public int compareTo(Version version) { int lessComponents = Math.min(components.length, version.components.length); for (int index = 0; index < lessComponents; index++) {