From de0ef057b31f1ac2b5b8a2a1a255b6f73c5a806f Mon Sep 17 00:00:00 2001 From: tinyz Date: Sat, 14 May 2016 14:11:47 +0800 Subject: [PATCH] =?UTF-8?q?Fixed=20:=20=E4=BF=AE=E5=A4=8Dlong[]=E5=92=8CSt?= =?UTF-8?q?ring[]=E8=BD=AC=E5=8C=96=E4=B8=BAversion=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E9=95=BF=E5=BA=A6=E8=BF=87=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/ogcs/utilities/Version.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/okra-utilities/src/main/java/org/ogcs/utilities/Version.java b/okra-utilities/src/main/java/org/ogcs/utilities/Version.java index db149f5..3922e35 100644 --- a/okra-utilities/src/main/java/org/ogcs/utilities/Version.java +++ b/okra-utilities/src/main/java/org/ogcs/utilities/Version.java @@ -30,7 +30,8 @@ *
* The long version code(like 98784968668 = 8 byte) is much smaller than string version code(like "23.10.65500" = 22 byte) * - * @author TinyZ on 2015/5/18. + * @author TinyZ. + * @since 1.0 */ public final class Version { @@ -51,6 +52,7 @@ private Version() { /** * Convert version code string to long version code *

Example ("23.10.65500") convert to 98784968668

+ * * @param codes The string version . org.ogcs.okra.example ["2", "23", "6500"] * @return The long version code */ @@ -61,10 +63,14 @@ public static long version(String codes) { /** * Convert version code string to long version code *

Example ["23", "10", "65500"] convert to 98784968668

+ * * @param codes The string version . * @return The long version code */ public static long version(String... codes) { + if (codes.length > 4) { + return -1L; + } long version = 0; int length = codes.length; for (int i = 0; i < length; i++) { @@ -81,10 +87,14 @@ public static long version(String... codes) { /** * Convert version int array code to long version code *

Example [23, 10, 65500] convert to 98784968668

+ * * @param codes The string version . * @return The long version code */ public static long version(int... codes) { + if (codes.length > 4) { + return -1L; + } long version = 0; int length = codes.length; for (int i = 0; i < length; i++) {