View Javadoc

1   /*
2    * Licensed to the University Corporation for Advanced Internet Development, 
3    * Inc. (UCAID) under one or more contributor license agreements.  See the 
4    * NOTICE file distributed with this work for additional information regarding
5    * copyright ownership. The UCAID licenses this file to You under the Apache 
6    * License, Version 2.0 (the "License"); you may not use this file except in 
7    * compliance with the License.  You may obtain a copy of the License at
8    *
9    *    http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package edu.internet2.middleware.shibboleth.idp;
19  
20  /** Class for printing the version of this IdP. */
21  public final class Version {
22  
23      /** Name of the IdP. */
24      private static final String NAME;
25  
26      /** IdP version. */
27      private static final String VERSION;
28  
29      /** IdP major version number. */
30      private static final int MAJOR_VERSION;
31  
32      /** IdP minor version number. */
33      private static final int MINOR_VERSION;
34  
35      /** IdP micro version number. */
36      private static final int MICRO_VERSION;
37  
38      /** Constructor. */
39      private Version() {
40      }
41  
42      /**
43       * Main entry point to program.
44       * 
45       * @param args command line arguments
46       */
47      public static void main(String[] args) {
48          Package pkg = Version.class.getPackage();
49          System.out.println(NAME + " version " + VERSION);
50      }
51  
52      /**
53       * Gets the name of the IdP.
54       * 
55       * @return name of the IdP
56       */
57      public static String getName() {
58          return NAME;
59      }
60  
61      /**
62       * Gets the version of the IdP.
63       * 
64       * @return version of the IdP
65       */
66      public static String getVersion() {
67          return VERSION;
68      }
69  
70      /**
71       * Gets the major version number of the IdP.
72       * 
73       * @return major version number of the IdP
74       */
75      public static int getMajorVersion() {
76          return MAJOR_VERSION;
77      }
78  
79      /**
80       * Gets the minor version number of the IdP.
81       * 
82       * @return minor version number of the IdP
83       */
84      public static int getMinorVersion() {
85          return MINOR_VERSION;
86      }
87  
88      /**
89       * Gets the micro version number of the IdP.
90       * 
91       * @return micro version number of the IdP
92       */
93      public static int getMicroVersion() {
94          return MICRO_VERSION;
95      }
96  
97      static {
98          Package pkg = Version.class.getPackage();
99          NAME = pkg.getImplementationTitle().intern();
100         VERSION = pkg.getImplementationVersion().intern();
101         String[] versionParts = VERSION.split("\\.");
102         MAJOR_VERSION = Integer.parseInt(versionParts[0]);
103         MINOR_VERSION = Integer.parseInt(versionParts[1]);
104         MICRO_VERSION = Integer.parseInt(versionParts[2]);
105     }
106 }