1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sunversion.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #if !defined INCLUDED_JVMACCESS_SUNVERSION_HXX
32 #define INCLUDED_JVMACCESS_SUNVERSION_HXX
34 #include "rtl/ustring.hxx"
36 namespace jfw_plugin
{
37 // Define OSL_DEBUG_LEVEL >= 2 to run a test when this lib is loaded
39 /* SunVersion is used to compare java versions based on a string, as taken
40 from the registry. The strings look like "1.3", "1.3.1", "1.3.1_02" etc.
41 Versions such as "1.4.1_01a" are allowed although this is not specified.
42 1.4.1_01 < 1.4.1_01a < 1.4.1_01b < 1.4.1_02
43 Pre - release versions, such as 1.4.1-ea, 1.4.1-beta, 1.4.1-rc are recognized,
44 but are treated as minor to release versions:
46 Pre releases relate this way
47 1.4.1-ea < 1.4.1-beta < 1.4.1-rc1
49 This class supports also a FreeBSD Java. This is currently necessary because
50 it also has the vendor string "Sun Microsystems Inc.".
52 An object acts as holder for the version string. That string may be present
53 even if the version could not be parsed. Then the version may not be compatible
54 to a SUN Java version.
56 An invalid object, that is, operator bool returns false, will always be
57 the lower version in a comparison. If two invalid objects are compared
58 then they are considered equal.
60 To test if the version is ok, that is this object can be compared to others,
61 use the bool conversion operator.
88 //contains major,minor,micro,update
89 int m_arVersionParts
[4];
90 // The update can be followed by a char, e.g. 1.4.1_01a
91 char m_nUpdateSpecial
;
93 PreRelease m_preRelease
;
96 SunVersion(const char * szVer
);
97 SunVersion(const rtl::OUString
& usVer
);
101 Pre-release versions are taken into account.
102 1.5.0-beta > 1.5.0-ea > 1.4.2
104 bool operator > (const SunVersion
& ver
) const;
105 bool operator < (const SunVersion
& ver
) const;
106 bool operator == (const SunVersion
& ver
) const;
108 /** Test if the version is compatible tu SUN's versioning scheme
112 /** Will always contain a value if the object has been constructed with
115 rtl::OUString usVersion
;
118 bool init(const char * szVer
);
122 /* Determines if a string constitutes a pre release. For example, if
123 "ea" is passed then Rel_EA is returned. If the string is no pre release
124 then Rel_NONE is returned.
126 PreRelease
getPreRelease(const char *szRel
);
131 #endif // INCLUDED_JVMACCESS_SUNVERSION_HXX