private void processVersions()

in modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.java [872:1122]


    private void processVersions(Element record, Element target)
    {
        String langVersion = "";
        boolean versionFound = false;

        Element langVersionElement = asDocUtil.getElementByTagName(record, "langversion");
        if (langVersionElement != null)
        {
            versionFound = true;
            langVersion = langVersionElement.getTextContent().replaceAll("\n", "").replaceAll("\r", "");
        }

        ArrayList<String[]> playerVersion = new ArrayList<String[]>();

        NodeList playerVersionList = record.getElementsByTagName("playerversion");
        if (playerVersionList != null && playerVersionList.getLength() != 0)
        {
            versionFound = true;
            for (int ix = 0; ix < playerVersionList.getLength(); ix++)
            {
                if (!playerVersionList.item(ix).getParentNode().equals(record))
                {
                    continue;
                }

                String playerVersionStr = playerVersionList.item(ix).getTextContent();
                playerVersionStr = playerVersionStr.replaceAll("\\A\\s+", "");
                playerVersionStr = playerVersionStr.replaceAll("\\Z\\s+", "");
                playerVersionStr = playerVersionStr.replaceAll("\\s+", " ");
                String[] playerVersionArr = playerVersionStr.split(" ");
                playerVersion.add(playerVersionArr);
            }
        }

        ArrayList<String[]> productVersion = new ArrayList<String[]>();

        NodeList productVersionList = record.getElementsByTagName("productversion");
        if (productVersionList != null && productVersionList.getLength() != 0)
        {
            versionFound = true;
            for (int ix = 0; ix < productVersionList.getLength(); ix++)
            {
                if (!productVersionList.item(ix).getParentNode().equals(record))
                {
                    continue;
                }

                String productVersionStr = productVersionList.item(ix).getTextContent();
                productVersionStr = productVersionStr.replaceAll("\\A\\s+", "");
                productVersionStr = productVersionStr.replaceAll("\\Z\\s+", "");
                productVersionStr = productVersionStr.replaceAll("\\s+", " ");
                String[] productVersionArr = productVersionStr.split(" ");
                productVersion.add(productVersionArr);
            }
        }

        ArrayList<String[]> toolVersion = new ArrayList<String[]>();

        NodeList toolVersionList = record.getElementsByTagName("toolversion");
        if (toolVersionList != null && toolVersionList.getLength() != 0)
        {
            versionFound = true;
            for (int ix = 0; ix < toolVersionList.getLength(); ix++)
            {
                if (!toolVersionList.item(ix).getParentNode().equals(record))
                {
                    continue;
                }

                String toolVersionStr = toolVersionList.item(ix).getTextContent();
                toolVersionStr = toolVersionStr.replaceAll("\\A\\s+", "");
                toolVersionStr = toolVersionStr.replaceAll("\\Z\\s+", "");
                toolVersionStr = toolVersionStr.replaceAll("\\s+", " ");
                String[] toolVersionArr = toolVersionStr.split(" ");
                toolVersion.add(toolVersionArr);
            }
        }

        String sinceVersion = null;

        NodeList sinceList = record.getElementsByTagName("since");
        if (sinceList != null && sinceList.getLength() != 0)
        {
            versionFound = true;
            for (int ix = 0; ix < sinceList.getLength(); ix++)
            {
                if (!sinceList.item(ix).getParentNode().equals(record))
                {
                    continue;
                }

                sinceVersion = sinceList.item(ix).getTextContent();
                sinceVersion = sinceVersion.trim();
            }
        }

        // if version info not found.. then don't bother.
        if (!versionFound)
        {
            return;
        }

        Element asMetadata = null;
        Element apiVersion = null;

        // we need to get to the apiVersion Node. if not present then create
        // it.. it should go to prolog.asMetadata.apiVersion.
        // if prolog or asMetadata are not present then create them and add
        // apiVersion.
        Element prolog = asDocUtil.getElementByTagName(target, "prolog");
        if (prolog != null)
        {
            asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");
            if (asMetadata != null)
            {
                apiVersion = asDocUtil.getElementByTagName(asMetadata, "apiVersion");
                if (apiVersion == null)
                {
                    apiVersion = outputObject.createElement("apiVersion");
                    asMetadata.appendChild(apiVersion);
                }
            }
            else
            {
                asMetadata = outputObject.createElement("asMetadata");
                apiVersion = outputObject.createElement("apiVersion");
                asMetadata.appendChild(apiVersion);
                prolog.appendChild(asMetadata);
            }
        }
        else
        {
            asMetadata = outputObject.createElement("asMetadata");
            apiVersion = outputObject.createElement("apiVersion");
            asMetadata.appendChild(apiVersion);

            prolog = outputObject.createElement("prolog");
            prolog.appendChild(asMetadata);

            target.appendChild(prolog);
        }

        if (langVersion.length() > 0)
        {
            Element apiLanguage = outputObject.createElement("apiLanguage");

            langVersion = langVersion.replaceAll("^\\s+", "");
            langVersion = langVersion.replaceAll("^\\s+$", "");
            langVersion = langVersion.replaceAll("\\s+", " ");

            String[] langVersionArr = langVersion.split(" ");

            if (langVersionArr.length > 1)
            {
                apiLanguage.setAttribute("name", langVersionArr[0]);
                apiLanguage.setAttribute("version", langVersionArr[1]);
            }
            else
            {
                apiLanguage.setAttribute("version", langVersionArr[0]);
            }
            apiVersion.appendChild(apiLanguage);
        }

        for (int ix = 0; ix < playerVersion.size(); ix++)
        {
            String[] playerVersionArr = playerVersion.get(ix);
            StringBuilder versionDescription = new StringBuilder();

            if (playerVersionArr.length > 2)
            {
                for (int iy = 2; iy < playerVersionArr.length; iy++)
                {
                    if (!"".equals(playerVersionArr[iy]) && !"\n".equals(playerVersionArr[iy]))
                    {
                        if ((iy != playerVersionArr.length - 1) && !playerVersionArr[iy].matches("\\s"))
                        {
                            versionDescription.append(playerVersionArr[iy].replaceAll("\\s", ""));
                            versionDescription.append(" ");
                        }
                        else
                        {
                            versionDescription.append(playerVersionArr[iy].replaceAll("\\s", ""));
                        }
                    }
                }
            }

            if (playerVersionArr.length > 1)
            {
                Element apiPlatform = outputObject.createElement("apiPlatform");
                apiPlatform.setAttribute("name", playerVersionArr[0]);
                apiPlatform.setAttribute("version", playerVersionArr[1].replaceAll("\\s", ""));
                apiPlatform.setAttribute("description", versionDescription.toString());
                apiVersion.appendChild(apiPlatform);
            }
        }

        for (int ix = 0; ix < productVersion.size(); ix++)
        {
            String[] productVersionArr = productVersion.get(ix);
            StringBuilder versionDescription = new StringBuilder();

            if (productVersionArr.length > 2)
            {
                for (int iy = 2; iy < productVersionArr.length; iy++)
                {
                    if (!"".equals(productVersionArr[iy]) && !"\n".equals(productVersionArr[iy]))
                    {
                        if ((iy != productVersionArr.length - 1) && !productVersionArr[iy].matches("\\s"))
                        {
                            versionDescription.append(productVersionArr[iy].replaceAll("\\s", ""));
                            versionDescription.append(" ");
                        }
                        else
                        {
                            versionDescription.append(productVersionArr[iy].replaceAll("\\s", ""));
                        }
                    }
                }
            }
            
            if (productVersionArr.length > 1)
            {
                Element apiTool = outputObject.createElement("apiTool");
                apiTool.setAttribute("name", productVersionArr[0]);
                apiTool.setAttribute("version", productVersionArr[1].replaceAll("\\s", ""));
                apiTool.setAttribute("description", versionDescription.toString());
                apiVersion.appendChild(apiTool);
            }
        }

        for (int ix = 0; ix < toolVersion.size(); ix++)
        {
            String[] toolVersionArr = toolVersion.get(ix);
            if (toolVersionArr.length > 1)
            {
                Element apiTool = outputObject.createElement("apiTool");
                apiTool.setAttribute("name", toolVersionArr[0]);
                apiTool.setAttribute("version", toolVersionArr[1].replaceAll("\\s", ""));
                apiVersion.appendChild(apiTool);
            }
        }

        if (sinceVersion != null)
        {
            Element apiSince = outputObject.createElement("apiSince");
            apiSince.setAttribute("version", sinceVersion);
            apiVersion.appendChild(apiSince);
        }
    }