Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 package org.xbmc.android.jsonrpc.api;
00022
00023 import java.text.ParseException;
00024 import java.text.SimpleDateFormat;
00025 import java.util.Date;
00026 import java.util.Locale;
00027
00033 public class Version {
00034
00035 private final String hash;
00036 private final Date date;
00037 private final Branch branch;
00038 private final Type type;
00039
00040 private static Version VERSION;
00041
00046 public static Version get() {
00047 if (VERSION == null) {
00048 VERSION = new Version("72a7730", "2013-10-12 16:48:48 -0700", Branch.MASTER, Type.NIGHTLY);
00049 }
00050 return VERSION;
00051 }
00052
00061 private Version(String hash, String date, Branch branch, Type type) {
00062 final SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.US);
00063 this.hash = hash;
00064 try {
00065 this.date = sfd.parse(date);
00066 } catch (ParseException e) {
00067 throw new IllegalArgumentException("Date must be in the form: yyyy-MM-dd HH:mm:ss Z (like: 2012-11-10 09:33:15 +0100).");
00068 }
00069 this.branch = branch;
00070 this.type = type;
00071 }
00072
00077 public String getHash() {
00078 return hash;
00079 }
00080
00085 public Date getDate() {
00086 return date;
00087 }
00088
00093 public Branch getBranch() {
00094 return branch;
00095 }
00096
00097 public Type getType() {
00098 return type;
00099 }
00100
00101 @Override
00102 public String toString() {
00103 return hash + " (" + branch.toString().toLowerCase(Locale.US) + ")";
00104 }
00105
00110 public enum Branch {
00111 EDEN, FRODO, MASTER, UNKNOWN;
00112 }
00113
00118 public enum Type {
00119 SNAPSHOT, NIGHTLY, RELEASE, BETA, RC, UNKNOWN
00120 }
00121 }