Simplify jfw::VersionInfo

Change-Id: I2cc1071bbaf9c68fbd621d6c0c6953b7646b1a62
diff --git a/jvmfwk/inc/elements.hxx b/jvmfwk/inc/elements.hxx
index a2c17bf..f99861a 100644
--- a/jvmfwk/inc/elements.hxx
+++ b/jvmfwk/inc/elements.hxx
@@ -318,27 +318,11 @@ public:
};


class VersionInfo
struct VersionInfo
{
    ::std::vector< OUString> vecExcludeVersions;
    rtl_uString ** arVersions;

public:
    VersionInfo();
    ~VersionInfo();

    void addExcludeVersion(const OUString& sVersion);

    OUString sMinVersion;
    OUString sMaxVersion;

    /** The caller DOES NOT get ownership of the strings. That is he
        does not need to release the strings.
        The array exists as long as this object exists.
    */

    rtl_uString** getExcludeVersions();
    sal_Int32 getExcludeVersionSize();
};

} //end namespace
diff --git a/jvmfwk/inc/vendorplugin.hxx b/jvmfwk/inc/vendorplugin.hxx
index d4febd7..d456fe7 100644
--- a/jvmfwk/inc/vendorplugin.hxx
+++ b/jvmfwk/inc/vendorplugin.hxx
@@ -88,9 +88,7 @@ enum class javaPluginError
        [in] represents the maximum version of a JRE. The string can be empty.
    @param arExcludeList
        [in] contains a list of &quot;bad&quot; versions. JREs which have one of these
        versions must not be returned by this function. It can be NULL.
    @param nSizeExcludeList
        [in] the number of version strings contained in <code>arExcludeList</code>.
        versions must not be returned by this function.
    @param parJavaInfo
        [out] if the function runs successfully then <code>parJavaInfo</code> contains
        on return an array of pointers to <code>JavaInfo</code> objects.
@@ -111,8 +109,7 @@ javaPluginError jfw_plugin_getAllJavaInfos(
    OUString const& sVendor,
    OUString const& sMinVersion,
    OUString const& sMaxVersion,
    rtl_uString * * arExcludeList,
    sal_Int32  nSizeExcludeList,
    std::vector<OUString> const & arExcludeList,
    JavaInfo*** parJavaInfo,
    sal_Int32 *nSizeJavaInfo,
    std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos);
@@ -136,9 +133,7 @@ javaPluginError jfw_plugin_getAllJavaInfos(
       [in] represents the maximum version of a JRE.
   @param arExcludeList
       [in] contains a list of &quot;bad&quot; versions. JREs which have one of these
        versions must not be returned by this function. It can be NULL.
   @param nSizeExcludeList
       [in] the number of version strings contained in <code>arExcludeList</code>.
        versions must not be returned by this function.
   @param ppInfo
       [out] if the function runs successfully then <code>ppInfo</code> contains
        on return a pointer to a <code>JavaInfo</code> object.
@@ -162,8 +157,7 @@ javaPluginError jfw_plugin_getJavaInfoByPath(
    OUString const& sVendor,
    OUString const& sMinVersion,
    OUString const& sMaxVersion,
    rtl_uString * *arExcludeList,
    sal_Int32  nSizeExcludeList,
    std::vector<OUString> const &arExcludeList,
    JavaInfo ** ppInfo);


diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index 9f3822a..7ade439 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -32,6 +32,8 @@

#include <cassert>
#include <memory>
#include <vector>

#include "config_options.h"
#include "osl/diagnose.h"
#include "rtl/ustring.hxx"
@@ -208,9 +210,7 @@ extern "C" void JNICALL abort_handler()
        [in] represents the maximum version of a JRE. The string can be empty.
    @param arExcludeList
        [in] contains a list of &quot;bad&quot; versions. JREs which have one of these
        versions must not be returned by this function. It can be NULL.
    @param nLenList
        [in] the number of version strings contained in <code>arExcludeList</code>.
        versions must not be returned by this function.

   @return
    javaPluginError::NONE the function ran successfully and the version requirements are met
@@ -225,8 +225,7 @@ javaPluginError checkJavaVersionRequirements(
    rtl::Reference<VendorBase> const & aVendorInfo,
    OUString const& sMinVersion,
    OUString const& sMaxVersion,
    rtl_uString * * arExcludeList,
    sal_Int32  nLenList)
    std::vector<OUString> const & arExcludeList)
{
    if (!aVendorInfo->isValidArch())
    {
@@ -270,9 +269,7 @@ javaPluginError checkJavaVersionRequirements(
        }
    }

    for (int i = 0; i < nLenList; i++)
    {
        OUString sExVer(arExcludeList[i]);
    for (auto const & sExVer: arExcludeList) {
        try
        {
            if (aVendorInfo->compareVersions(sExVer) == 0)
@@ -300,8 +297,7 @@ javaPluginError jfw_plugin_getAllJavaInfos(
    OUString const& sVendor,
    OUString const& sMinVersion,
    OUString const& sMaxVersion,
    rtl_uString  * *arExcludeList,
    sal_Int32  nLenList,
    std::vector<OUString> const &arExcludeList,
    JavaInfo*** parJavaInfo,
    sal_Int32 *nLenInfoList,
    std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos)
@@ -309,10 +305,6 @@ javaPluginError jfw_plugin_getAllJavaInfos(
    assert(parJavaInfo);
    assert(nLenInfoList);

    //nLenlist contains the number of elements in arExcludeList.
    //If no exclude list is provided then nLenList must be 0
    assert( ! (arExcludeList == nullptr && nLenList > 0));

    OSL_ASSERT(!sVendor.isEmpty());
    if (sVendor.isEmpty())
        return javaPluginError::InvalidArg;
@@ -333,7 +325,7 @@ javaPluginError jfw_plugin_getAllJavaInfos(
            continue;

        javaPluginError err = checkJavaVersionRequirements(
            cur, sMinVersion, sMaxVersion, arExcludeList, nLenList);
            cur, sMinVersion, sMaxVersion, arExcludeList);

        if (err == javaPluginError::FailedVersion || err == javaPluginError::WrongArch)
            continue;
@@ -363,8 +355,7 @@ javaPluginError jfw_plugin_getJavaInfoByPath(
    OUString const& sVendor,
    OUString const& sMinVersion,
    OUString const& sMaxVersion,
    rtl_uString  *  *arExcludeList,
    sal_Int32  nLenList,
    std::vector<OUString> const &arExcludeList,
    JavaInfo ** ppInfo)
{
    assert(ppInfo != nullptr);
@@ -372,10 +363,6 @@ javaPluginError jfw_plugin_getJavaInfoByPath(
    if (sPath.isEmpty())
        return javaPluginError::InvalidArg;

    //nLenlist contains the number of elements in arExcludeList.
    //If no exclude list is provided then nLenList must be 0
    assert( ! (arExcludeList == nullptr && nLenList > 0));

    OSL_ASSERT(!sVendor.isEmpty());
    if (sVendor.isEmpty())
        return javaPluginError::InvalidArg;
@@ -388,7 +375,7 @@ javaPluginError jfw_plugin_getJavaInfoByPath(
    if (!sVendor.equals(aVendorInfo->getVendor()))
        return javaPluginError::NoJre;
    javaPluginError errorcode = checkJavaVersionRequirements(
            aVendorInfo, sMinVersion, sMaxVersion, arExcludeList, nLenList);
            aVendorInfo, sMinVersion, sMaxVersion, arExcludeList);

    if (errorcode == javaPluginError::NONE)
        *ppInfo = createJavaInfo(aVendorInfo);
@@ -422,8 +409,7 @@ javaPluginError jfw_plugin_getJavaInfoFromJavaHome(
                infoJavaHome[0],
                versionInfo.sMinVersion,
                versionInfo.sMaxVersion,
                versionInfo.getExcludeVersions(),
                versionInfo.getExcludeVersionSize());
                versionInfo.vecExcludeVersions);

            if (errorcode == javaPluginError::NONE)
            {
@@ -457,7 +443,7 @@ javaPluginError jfw_plugin_getJavaInfosFromPath(
        for (ci_pl vendorInfo = vecVendorInfos.begin(); vendorInfo != vecVendorInfos.end(); ++vendorInfo)
        {
            const OUString& vendor = vendorInfo->first;
            jfw::VersionInfo versionInfo = vendorInfo->second;
            jfw::VersionInfo const & versionInfo = vendorInfo->second;

            if (vendor.equals(currentInfo->getVendor()))
            {
@@ -465,8 +451,7 @@ javaPluginError jfw_plugin_getJavaInfosFromPath(
                    currentInfo,
                    versionInfo.sMinVersion,
                    versionInfo.sMaxVersion,
                    versionInfo.getExcludeVersions(),
                    versionInfo.getExcludeVersionSize());
                    versionInfo.vecExcludeVersions);

                if (errorcode == javaPluginError::NONE)
                {
diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx
index 70c38e8..b25c49f 100644
--- a/jvmfwk/source/elements.cxx
+++ b/jvmfwk/source/elements.cxx
@@ -171,43 +171,6 @@ void createSettingsStructure(xmlDoc * document, bool * bNeedsSave)
    xmlAddChild(root, nodeCrLf);
}


VersionInfo::VersionInfo(): arVersions(nullptr)
{
}

VersionInfo::~VersionInfo()
{
}

void VersionInfo::addExcludeVersion(const OUString& sVersion)
{
    vecExcludeVersions.push_back(sVersion);
}

rtl_uString** VersionInfo::getExcludeVersions()
{
    osl::MutexGuard guard(FwkMutex::get());
    if (arVersions != nullptr)
        return arVersions;

    arVersions = new rtl_uString*[vecExcludeVersions.size()];
    int j=0;
    typedef std::vector<OUString>::const_iterator it;
    for (it i = vecExcludeVersions.begin(); i != vecExcludeVersions.end();
         ++i, ++j)
    {
        arVersions[j] = vecExcludeVersions[j].pData;
    }
    return arVersions;
}

sal_Int32 VersionInfo::getExcludeVersionSize()
{
    return vecExcludeVersions.size();
}


NodeJava::NodeJava(Layer layer):
    m_layer(layer)
{
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx
index 5ae4c87..99b3e5e 100644
--- a/jvmfwk/source/framework.cxx
+++ b/jvmfwk/source/framework.cxx
@@ -93,8 +93,7 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI
                vendor,
                versionInfo.sMinVersion,
                versionInfo.sMaxVersion,
                versionInfo.getExcludeVersions(),
                versionInfo.getExcludeVersionSize(),
                versionInfo.vecExcludeVersions,
                & arInfos,
                & cInfos,
                infos);
@@ -121,8 +120,7 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI
                    vendor,
                    versionInfo.sMinVersion,
                    versionInfo.sMaxVersion,
                    versionInfo.getExcludeVersions(),
                    versionInfo.getExcludeVersionSize(),
                    versionInfo.vecExcludeVersions,
                    & aInfo.pInfo);
                if (plerr == javaPluginError::NoJre)
                    continue;
@@ -480,8 +478,7 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo)
                    vendor,
                    versionInfo.sMinVersion,
                    versionInfo.sMaxVersion,
                    versionInfo.getExcludeVersions(),
                    versionInfo.getExcludeVersionSize(),
                    versionInfo.vecExcludeVersions,
                    & arInfos,
                    & cInfos,
                    infos);
@@ -551,8 +548,7 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo)
                            vendor,
                            versionInfo.sMinVersion,
                            versionInfo.sMaxVersion,
                            versionInfo.getExcludeVersions(),
                            versionInfo.getExcludeVersionSize(),
                            versionInfo.vecExcludeVersions,
                            & aInfo.pInfo);
                        if (err == javaPluginError::NoJre)
                            continue;
@@ -717,8 +713,7 @@ javaFrameworkError jfw_getJavaInfoByPath(OUString const & pPath, std::unique_ptr
                vendor,
                versionInfo.sMinVersion,
                versionInfo.sMaxVersion,
                versionInfo.getExcludeVersions(),
                versionInfo.getExcludeVersionSize(),
                versionInfo.vecExcludeVersions,
                & pInfo);

            if (plerr == javaPluginError::NONE)
diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx
index df2e41e..27950eb 100644
--- a/jvmfwk/source/fwkbase.cxx
+++ b/jvmfwk/source/fwkbase.cxx
@@ -191,7 +191,7 @@ VersionInfo VendorSettings::getVersionInformation(const OUString & sVendor)
                    OString osVersion(sVersion);
                    OUString usVersion = OStringToOUString(
                        osVersion, RTL_TEXTENCODING_UTF8);
                    aVersionInfo.addExcludeVersion(usVersion);
                    aVersionInfo.vecExcludeVersions.push_back(usVersion);
                }
            }
            cur = cur->next;