1*5ac42e1fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5ac42e1fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5ac42e1fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5ac42e1fSAndrew Rist * distributed with this work for additional information 6*5ac42e1fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5ac42e1fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5ac42e1fSAndrew Rist * "License"); you may not use this file except in compliance 9*5ac42e1fSAndrew Rist * with the License. You may obtain a copy of the License at 10*5ac42e1fSAndrew Rist * 11*5ac42e1fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5ac42e1fSAndrew Rist * 13*5ac42e1fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5ac42e1fSAndrew Rist * software distributed under the License is distributed on an 15*5ac42e1fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5ac42e1fSAndrew Rist * KIND, either express or implied. See the License for the 17*5ac42e1fSAndrew Rist * specific language governing permissions and limitations 18*5ac42e1fSAndrew Rist * under the License. 19*5ac42e1fSAndrew Rist * 20*5ac42e1fSAndrew Rist *************************************************************/ 21*5ac42e1fSAndrew Rist 22*5ac42e1fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #if !defined INCLUDED_JVMACCESS_SUNVERSION_HXX 25cdf0e10cSrcweir #define INCLUDED_JVMACCESS_SUNVERSION_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "rtl/ustring.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir namespace jfw_plugin { 30cdf0e10cSrcweir // Define OSL_DEBUG_LEVEL >= 2 to run a test when this lib is loaded 31cdf0e10cSrcweir 32cdf0e10cSrcweir /* SunVersion is used to compare java versions based on a string, as taken 33cdf0e10cSrcweir from the registry. The strings look like "1.3", "1.3.1", "1.3.1_02" etc. 34cdf0e10cSrcweir Versions such as "1.4.1_01a" are allowed although this is not specified. 35cdf0e10cSrcweir 1.4.1_01 < 1.4.1_01a < 1.4.1_01b < 1.4.1_02 36cdf0e10cSrcweir Pre - release versions, such as 1.4.1-ea, 1.4.1-beta, 1.4.1-rc are recognized, 37cdf0e10cSrcweir but are treated as minor to release versions: 38cdf0e10cSrcweir 1.4.0 > 1.4.2-beta 39cdf0e10cSrcweir Pre releases relate this way 40cdf0e10cSrcweir 1.4.1-ea < 1.4.1-beta < 1.4.1-rc1 41cdf0e10cSrcweir 42cdf0e10cSrcweir This class supports also a FreeBSD Java. This is currently necessary because 43cdf0e10cSrcweir it also has the vendor string "Sun Microsystems Inc.". 44cdf0e10cSrcweir 45cdf0e10cSrcweir An object acts as holder for the version string. That string may be present 46cdf0e10cSrcweir even if the version could not be parsed. Then the version may not be compatible 47cdf0e10cSrcweir to a SUN Java version. 48cdf0e10cSrcweir 49cdf0e10cSrcweir An invalid object, that is, operator bool returns false, will always be 50cdf0e10cSrcweir the lower version in a comparison. If two invalid objects are compared 51cdf0e10cSrcweir then they are considered equal. 52cdf0e10cSrcweir 53cdf0e10cSrcweir To test if the version is ok, that is this object can be compared to others, 54cdf0e10cSrcweir use the bool conversion operator. 55cdf0e10cSrcweir */ 56cdf0e10cSrcweir class SunVersion 57cdf0e10cSrcweir { 58cdf0e10cSrcweir protected: 59cdf0e10cSrcweir 60cdf0e10cSrcweir enum PreRelease 61cdf0e10cSrcweir { 62cdf0e10cSrcweir Rel_NONE, 63cdf0e10cSrcweir Rel_EA, 64cdf0e10cSrcweir Rel_EA1, 65cdf0e10cSrcweir Rel_EA2, 66cdf0e10cSrcweir Rel_EA3, 67cdf0e10cSrcweir Rel_BETA, 68cdf0e10cSrcweir Rel_BETA1, 69cdf0e10cSrcweir Rel_BETA2, 70cdf0e10cSrcweir Rel_BETA3, 71cdf0e10cSrcweir Rel_RC, 72cdf0e10cSrcweir Rel_RC1, 73cdf0e10cSrcweir Rel_RC2, 74cdf0e10cSrcweir Rel_RC3 75cdf0e10cSrcweir #if defined(FREEBSD) 76cdf0e10cSrcweir , 77cdf0e10cSrcweir Rel_FreeBSD 78cdf0e10cSrcweir #endif 79cdf0e10cSrcweir }; 80cdf0e10cSrcweir 81cdf0e10cSrcweir //contains major,minor,micro,update 82cdf0e10cSrcweir int m_arVersionParts[4]; 83cdf0e10cSrcweir // The update can be followed by a char, e.g. 1.4.1_01a 84cdf0e10cSrcweir char m_nUpdateSpecial; 85cdf0e10cSrcweir 86cdf0e10cSrcweir PreRelease m_preRelease; 87cdf0e10cSrcweir public: 88cdf0e10cSrcweir SunVersion(const char * szVer); 89cdf0e10cSrcweir SunVersion(const rtl::OUString& usVer); 90cdf0e10cSrcweir ~SunVersion(); 91cdf0e10cSrcweir 92cdf0e10cSrcweir /** 93cdf0e10cSrcweir Pre-release versions are taken into account. 94cdf0e10cSrcweir 1.5.0-beta > 1.5.0-ea > 1.4.2 95cdf0e10cSrcweir */ 96cdf0e10cSrcweir bool operator > (const SunVersion& ver) const; 97cdf0e10cSrcweir bool operator < (const SunVersion& ver) const; 98cdf0e10cSrcweir bool operator == (const SunVersion& ver) const; 99cdf0e10cSrcweir 100cdf0e10cSrcweir /** Test if the version is compatible tu SUN's versioning scheme 101cdf0e10cSrcweir */ 102cdf0e10cSrcweir operator bool (); 103cdf0e10cSrcweir 104cdf0e10cSrcweir /** Will always contain a value if the object has been constructed with 105cdf0e10cSrcweir a version string. 106cdf0e10cSrcweir */ 107cdf0e10cSrcweir rtl::OUString usVersion; 108cdf0e10cSrcweir 109cdf0e10cSrcweir protected: 110cdf0e10cSrcweir bool init(const char * szVer); 111cdf0e10cSrcweir 112cdf0e10cSrcweir bool m_bValid; 113cdf0e10cSrcweir 114cdf0e10cSrcweir /* Determines if a string constitutes a pre release. For example, if 115cdf0e10cSrcweir "ea" is passed then Rel_EA is returned. If the string is no pre release 116cdf0e10cSrcweir then Rel_NONE is returned. 117cdf0e10cSrcweir */ 118cdf0e10cSrcweir PreRelease getPreRelease(const char *szRel); 119cdf0e10cSrcweir }; 120cdf0e10cSrcweir 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir #endif // INCLUDED_JVMACCESS_SUNVERSION_HXX 124