1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #if !defined INCLUDED_JVMACCESS_SUNVERSION_HXX 29 #define INCLUDED_JVMACCESS_SUNVERSION_HXX 30 31 #include "rtl/ustring.hxx" 32 33 namespace jfw_plugin { 34 // Define OSL_DEBUG_LEVEL >= 2 to run a test when this lib is loaded 35 36 /* SunVersion is used to compare java versions based on a string, as taken 37 from the registry. The strings look like "1.3", "1.3.1", "1.3.1_02" etc. 38 Versions such as "1.4.1_01a" are allowed although this is not specified. 39 1.4.1_01 < 1.4.1_01a < 1.4.1_01b < 1.4.1_02 40 Pre - release versions, such as 1.4.1-ea, 1.4.1-beta, 1.4.1-rc are recognized, 41 but are treated as minor to release versions: 42 1.4.0 > 1.4.2-beta 43 Pre releases relate this way 44 1.4.1-ea < 1.4.1-beta < 1.4.1-rc1 45 46 This class supports also a FreeBSD Java. This is currently necessary because 47 it also has the vendor string "Sun Microsystems Inc.". 48 49 An object acts as holder for the version string. That string may be present 50 even if the version could not be parsed. Then the version may not be compatible 51 to a SUN Java version. 52 53 An invalid object, that is, operator bool returns false, will always be 54 the lower version in a comparison. If two invalid objects are compared 55 then they are considered equal. 56 57 To test if the version is ok, that is this object can be compared to others, 58 use the bool conversion operator. 59 */ 60 class SunVersion 61 { 62 protected: 63 64 enum PreRelease 65 { 66 Rel_NONE, 67 Rel_EA, 68 Rel_EA1, 69 Rel_EA2, 70 Rel_EA3, 71 Rel_BETA, 72 Rel_BETA1, 73 Rel_BETA2, 74 Rel_BETA3, 75 Rel_RC, 76 Rel_RC1, 77 Rel_RC2, 78 Rel_RC3 79 #if defined(FREEBSD) 80 , 81 Rel_FreeBSD 82 #endif 83 }; 84 85 //contains major,minor,micro,update 86 int m_arVersionParts[4]; 87 // The update can be followed by a char, e.g. 1.4.1_01a 88 char m_nUpdateSpecial; 89 90 PreRelease m_preRelease; 91 public: 92 SunVersion(const char * szVer); 93 SunVersion(const rtl::OUString& usVer); 94 ~SunVersion(); 95 96 /** 97 Pre-release versions are taken into account. 98 1.5.0-beta > 1.5.0-ea > 1.4.2 99 */ 100 bool operator > (const SunVersion& ver) const; 101 bool operator < (const SunVersion& ver) const; 102 bool operator == (const SunVersion& ver) const; 103 104 /** Test if the version is compatible tu SUN's versioning scheme 105 */ 106 operator bool (); 107 108 /** Will always contain a value if the object has been constructed with 109 a version string. 110 */ 111 rtl::OUString usVersion; 112 113 protected: 114 bool init(const char * szVer); 115 116 bool m_bValid; 117 118 /* Determines if a string constitutes a pre release. For example, if 119 "ea" is passed then Rel_EA is returned. If the string is no pre release 120 then Rel_NONE is returned. 121 */ 122 PreRelease getPreRelease(const char *szRel); 123 }; 124 125 } 126 127 #endif // INCLUDED_JVMACCESS_SUNVERSION_HXX 128