You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Version.java 2.9KB

21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
13 years ago
21 years ago
13 years ago
21 years ago
13 years ago
21 years ago
21 years ago
21 years ago
21 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* ********************************************************************
  2. * Copyright (c) 1998-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * *******************************************************************/
  13. package org.aspectj.bridge;
  14. import java.text.ParsePosition;
  15. import java.text.SimpleDateFormat;
  16. import java.util.Date;
  17. /** release-specific version information */
  18. public class Version {
  19. // generated from build/lib/BridgeVersion.java
  20. /** default version value for development version */
  21. public static final String DEVELOPMENT = "DEVELOPMENT";
  22. // VersionUptodate.java depends on this value
  23. /** default time value for development version */
  24. public static final long NOTIME = 0L;
  25. /** set by build script */
  26. public static final String text = "DEVELOPMENT";
  27. // VersionUptodate.java scans for "static final String text = "
  28. /**
  29. * Time text set by build script using SIMPLE_DATE_FORMAT.
  30. * (if DEVELOPMENT version, invalid)
  31. */
  32. public static final String time_text = "";
  33. /**
  34. * time in seconds-since-... format, used by programmatic clients.
  35. * (if DEVELOPMENT version, NOTIME)
  36. */
  37. private static long time = -1; // -1 = uninitialized
  38. /** format used by build script to set time_text */
  39. public static final String SIMPLE_DATE_FORMAT = "EEEE MMM d, yyyy 'at' HH:mm:ss z";
  40. public static long getTime() {
  41. if (time==-1) {
  42. long foundTime = NOTIME;
  43. // if not DEVELOPMENT version, read time text using format used to set time
  44. try {
  45. SimpleDateFormat format = new SimpleDateFormat(SIMPLE_DATE_FORMAT);
  46. ParsePosition pos = new ParsePosition(0);
  47. Date date = format.parse(time_text, pos);
  48. if (date!=null) foundTime = date.getTime();
  49. } catch (Throwable t) {
  50. }
  51. time = foundTime;
  52. }
  53. return time;
  54. }
  55. /**
  56. * Test whether the version is as specified by any first argument.
  57. * Emit text to System.err on failure
  58. * @param args String[] with first argument equal to Version.text
  59. * @see Version#text
  60. */
  61. public static void main(String[] args) {
  62. if ((null != args) && (0 < args.length)) {
  63. if (!Version.text.equals(args[0])) {
  64. System.err.println("version expected: \""
  65. + args[0]
  66. + "\" actual=\""
  67. + Version.text
  68. + "\"");
  69. }
  70. }
  71. }
  72. }