View Javadoc

1   /*
2    * Copyright (c) 2010.  The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package org.apache.hadoop.hbase.hbql.util;
22  
23  /**
24   * This class finds the package info for hbase and the VersionAnnotation
25   * information.  Taken from hadoop.  Only name of annotation is different.
26   */
27  public class VersionInfo {
28      private static Package myPackage;
29      private static VersionAnnotation version;
30  
31      static {
32          myPackage = VersionAnnotation.class.getPackage();
33          version = myPackage.getAnnotation(VersionAnnotation.class);
34      }
35  
36      /**
37       * Get the meta-data for the hbase package.
38       *
39       * @return
40       */
41      static Package getPackage() {
42          return myPackage;
43      }
44  
45      /**
46       * Get the hbase version.
47       *
48       * @return the hbase version string, eg. "0.6.3-dev"
49       */
50      public static String getVersion() {
51          return version != null ? version.version() : "Unknown";
52      }
53  
54      /**
55       * Get the subversion revision number for the root directory
56       *
57       * @return the revision number, eg. "451451"
58       */
59      public static String getRevision() {
60          return version != null ? version.revision() : "Unknown";
61      }
62  
63      /**
64       * The date that hbase was compiled.
65       *
66       * @return the compilation date in unix date format
67       */
68      public static String getDate() {
69          return version != null ? version.date() : "Unknown";
70      }
71  
72      /**
73       * The user that compiled hbase.
74       *
75       * @return the username of the user
76       */
77      public static String getUser() {
78          return version != null ? version.user() : "Unknown";
79      }
80  
81      /**
82       * Get the subversion URL for the root hbase directory.
83       *
84       * @return the url
85       */
86      public static String getUrl() {
87          return version != null ? version.url() : "Unknown";
88      }
89  
90      /**
91       * @param args
92       */
93      public static void main(String[] args) {
94          System.out.println("HBql " + getVersion());
95      }
96  }