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