19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one
39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file
49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information
59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file
69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the  "License");
79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License.
89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at
99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     http://www.apache.org/licenses/LICENSE-2.0
119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software
139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and
169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License.
179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id$
209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xalan;
229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/**
249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Administrative class to keep track of the version number of
259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the Xalan release.
269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <P>This class implements the upcoming standard of having
279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * org.apache.project-name.Version.getVersion() be a standard way
289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to get version information.  This class will replace the older
299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * org.apache.xalan.processor.Version class.</P>
309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <P>See also: org/apache/xalan/res/XSLTInfo.properties for
319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * information about the version of the XSLT spec we support.</P>
329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @xsl.usage general
339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic class Version
359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{
369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Get the basic version string for the current Xalan release.
399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Version String formatted like
409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <CODE>"<B>Xalan</B> <B>Java</B> v.r[.dd| <B>D</B>nn]"</CODE>.
419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Futurework: have this read version info from jar manifest.
439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return String denoting our current version
459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public static String getVersion()
479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     return getProduct()+" "+getImplementationLanguage()+" "
499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           +getMajorVersionNum()+"."+getReleaseVersionNum()+"."
509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           +( (getDevelopmentVersionNum() > 0) ?
519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson               ("D"+getDevelopmentVersionNum()) : (""+getMaintenanceVersionNum()));
529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Print the processor version to the command line.
569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param argv command line arguments, unused.
589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public static void main(String argv[])
609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    System.out.println(getVersion());
629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Name of product: Xalan.
669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public static String getProduct()
689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return "Xalan";
709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Implementation Language: Java.
749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public static String getImplementationLanguage()
769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return "Java";
789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Major version number.
839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Version number. This changes only when there is a
849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          significant, externally apparent enhancement from
859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          the previous release. 'n' represents the n'th
869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          version.
879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          Clients should carefully consider the implications
899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          of new versions as external interfaces and behaviour
909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          may have changed.
919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public static int getMajorVersionNum()
939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return @version.VERSION@;
959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Release Number.
1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Release number. This changes when:
1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *            -  a new set of functionality is to be added, eg,
1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *               implementation of a new W3C specification.
1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *            -  API or behaviour change.
1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *            -  its designated as a reference release.
1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public static int getReleaseVersionNum()
1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return @version.RELEASE@;
1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Maintenance Drop Number.
1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Optional identifier used to designate maintenance
1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          drop applied to a specific release and contains
1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          fixes for defects reported. It maintains compatibility
1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          with the release and contains no API changes.
1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          When missing, it designates the final and complete
1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          development drop for a release.
1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public static int getMaintenanceVersionNum()
1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return @version.MINOR@;
1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Development Drop Number.
1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Optional identifier designates development drop of
1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          a specific release. D01 is the first development drop
1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          of a new release.
1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          Development drops are works in progress towards a
1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          compeleted, final release. A specific development drop
1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          may not completely implement all aspects of a new
1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          feature, which may take several development drops to
1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          complete. At the point of the final drop for the
1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          release, the D suffix will be omitted.
1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          Each 'D' drops can contain functional enhancements as
1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          well as defect fixes. 'D' drops may not be as stable as
1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          the final releases.
1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public static int getDevelopmentVersionNum()
1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    try {
1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        if ((new String("@version.DEVELOPER@")).length() == 0)
1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          return 0;
1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        else
1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          return Integer.parseInt("@version.DEVELOPER@");
1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    } catch (NumberFormatException nfe) {
1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           return 0;
1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson}
154