FileDocCategorySizeDatePackage
AddonVersionImpl.javaAPI DocGlassfish v2 API6963Fri May 04 22:30:24 BST 2007com.sun.enterprise.addons

AddonVersionImpl

public class AddonVersionImpl extends Object implements com.sun.appserv.addons.AddonVersion
Parse the given addon name into majr, minor and patch levels and return those component versions to the callers.
since
9.1
authod
sreenivas.munnangi@sun.com

Fields Summary
private String
addonName
private String
namePart
private String
version
private int
major
private int
minor
private int
patch
private final String
DEFAULT_VERSION
private final String
VERSION_PATTERN
private final String
VERSION_SEPARATOR
Constructors Summary
AddonVersionImpl(String addonName)
Constructor


          
        
        this.addonName = addonName;
        if (addonName.matches(VERSION_PATTERN)) {
            version = addonName.substring((addonName.length() - DEFAULT_VERSION.length()));
            namePart = addonName.substring(0, (addonName.length() - (DEFAULT_VERSION.length() + 1)));
        } else {
            version = DEFAULT_VERSION;
            namePart = addonName;
        }
        parseVersion(version);
    
Methods Summary
public intgetMajor()
Get the majr version, for example. If the addon is named as am_components_installer_01_02_03.jar then the value of 1 will be returned.

return
int major

        return this.major;
    
public intgetMinor()
Get the minor version, for example. If the addon is named as am_components_installer_01_02_03.jar then the value of 2 will be returned.

return
int minor

        return this.minor;
    
protected java.lang.StringgetName()

        return addonName;
    
protected java.lang.StringgetNamePart()

        return namePart;
    
public intgetPatch()
Get the patch version, for example. If the addon is named as am_components_installer_01_02_03.jar then the value of 3 will be returned.

return
int patch

        return this.patch;
    
public java.lang.StringgetVersion()
Get the full version as string, for example. If the addon is named as am_components_installer_01_02_03.jar then the version output will be "01_02_03" in String format.

return
String version

        return version;
    
protected booleanisHigher(com.sun.enterprise.addons.AddonVersionImpl newVersion)


        if (newVersion.getMajor() > getMajor()) {
            return true;
        } else if (newVersion.getMajor() < getMajor()) {
            return false;
        }

        if (newVersion.getMinor() > getMinor()) {
            return true;
        } else if (newVersion.getMinor() < getMinor()) {
            return false;
        }

        if (newVersion.getPatch() > getPatch()) {
            return true;
        }

        return false;
    
protected booleanisLower(com.sun.enterprise.addons.AddonVersionImpl newVersion)


        if (newVersion.getMajor() < getMajor()) {
            return true;
        } else if (newVersion.getMajor() > getMajor()) {
            return false;
        }

        if (newVersion.getMinor() < getMinor()) {
            return true;
        } else if (newVersion.getMinor() > getMinor()) {
            return false;
        }

        if (newVersion.getPatch() < getPatch()) {
            return true;
        }

        return false;
    
private voidparseVersion(java.lang.String versionPart)

        String [] strArr = versionPart.split(VERSION_SEPARATOR);
        setMajor(strArr[0]);
        setMinor(strArr[1]);
        setPatch(strArr[2]);
    
private voidsetMajor(java.lang.String major)

        try {
            this.major = (Integer.valueOf(major)).intValue();
        } catch (Exception e) {
            throw new AddonException(e);
        }
    
private voidsetMinor(java.lang.String minor)

        try {
            this.minor = (Integer.valueOf(minor)).intValue();
        } catch (Exception e) {
            throw new AddonException(e);
        }
    
private voidsetPatch(java.lang.String patch)

        try {
            this.patch = (Integer.valueOf(patch)).intValue();
        } catch (Exception e) {
            throw new AddonException(e);
        }
    
public java.lang.StringtoString()

        StringBuffer sb = new StringBuffer("");
        try {
        sb.append("Version details for the AddOn " + addonName + ":"); 
        sb.append("version = " + getVersion() + ":");
        sb.append("major = " + getMajor() + ":");
        sb.append("minor = " + getMinor() + ":");
        sb.append("patch = " + getPatch());
        } catch (Exception e) {
        }
        return sb.toString();