/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class holds all necessary information to install or
* upgrade a extension on the user's disk
*
* @author Jerome Dochez
*/
public class ExtensionInfo {
/**
* <p>
* public static values returned by the isCompatible method
* </p>
*/
/**
* <p>
* attributes fully describer an extension. The underlying described
* extension may be installed and requested.
* <p>
*/
// For I18N support
/**
* <p>
* Create a new uninitialized extension information object
* </p>
*/
public ExtensionInfo() {
}
/**
* <p>
* Create and initialize an extension information object.
* The initialization uses the attributes passed as being
* the content of a manifest file to load the extension
* information from.
* Since manifest file may contain information on several
* extension they may depend on, the extension key parameter
* is prepanded to the attribute name to make the key used
* to retrieve the attribute from the manifest file
* <p>
* @param extensionKey unique extension key in the manifest
* @param attr Attributes of a manifest file
*/
throws NullPointerException
{
String s;
if (extensionKey!=null) {
s = extensionKey + "-";
} else {
s ="";
}
if (specVersion != null)
if (specVendor != null)
if (implementationVersion != null)
}
/**
* <p>
* @return true if the extension described by this extension information
* is compatible with the extension described by the extension
* information passed as a parameter
* </p>
*
* @param the requested extension information to compare to
*/
return INCOMPATIBLE;
// is this true, if not spec version is specified, we consider
// the value as being "any".
return COMPATIBLE;
if (version<0) {
// this extension specification is "older"
return REQUIRE_VENDOR_SWITCH;
}
}
return REQUIRE_SPECIFICATION_UPGRADE;
} else {
// the extension spec is compatible, let's look at the
// implementation attributes
// They care who provides the extension
// They want to use another vendor implementation
return REQUIRE_VENDOR_SWITCH;
} else {
// Vendor matches, let's see the implementation version
// they care about the implementation version
if (version<0) {
// This extension is an older implementation
return REQUIRE_IMPLEMENTATION_UPGRADE;
}
}
}
}
// All othe cases, we consider the extensions to be compatible
return COMPATIBLE;
}
}
return INCOMPATIBLE;
}
/**
* <p>
* helper method to print sensible information on the undelying described
* extension
* </p>
*/
}
/*
* <p>
* helper method to compare two versions.
* version are in the x.y.z.t pattern.
* </p>
* @param source version to compare to
* @param target version used to compare against
* @return < 0 if source < version
* > 0 if source > version
* = 0 if source = version
*/
throws NumberFormatException
{
}
/*
* <p>
* helper method to compare two versions.
* version are in the x.y.z.t pattern.
* </p>
* @param source version to compare to
* @param target version used to compare against
* @return < 0 if source < version
* > 0 if source > version
* = 0 if source = version
*/
throws NumberFormatException
{
return 0;
// Compare number
// Convert token into meaning number for comparision
if (stk.hasMoreTokens())
// Convert token into meaning number for comparision
if (ttk.hasMoreTokens())
if (n > m)
return 1;
else if (m > n)
return -1;
else
{
// Look for index of "." in the string
if (sIdx == -1)
if (tIdx == -1)
}
}
{
return 0;
int charValue = 0;
int charVersion = 0;
int patchVersion = 0;
char lastChar;
// Look for "-" for pre-release
// Look for "_" for patch release
{
// This is a FCS release
try {
} catch (NumberFormatException e) {
return 0;
}
}
else if (patchIndex != -1)
{
// This is a patch (update) release
int prversion;
try {
// Obtain the version
// Check to see if the patch version is in the n.n.n_nnl format (special release)
// letters a-z have values from 10-35
// Obtain the patch version id
// This is a special release
} else {
// character is not a a-z letter, ignore
charVersion = 0;
}
} else {
// This is a regular update release. Obtain the patch version id
}
} catch (NumberFormatException e) {
return 0;
}
}
else
{
//This is a milestone release, either a early access, alpha, beta, or RC
// Obtain the version
int mrversion;
try {
} catch (NumberFormatException e) {
return 0;
}
// Obtain the patch version string, including the milestone + version
// Milestone version
int delta = 0;
{
delta = 50;
}
{
delta = 40;
}
{
delta = 30;
}
{
delta = 20;
}
{
// No version after the milestone, assume 0
}
else
{
// Convert the milestone version
try {
} catch (NumberFormatException e) {
return 0;
}
}
}
}
}