private void processCustoms()

in modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.java [1129:1577]


    private void processCustoms(Element record, Element target, boolean useParams, String paramNames, String paramTypes, String paramDefaults, AsClass fromClass)
    {
        NodeList childNodes = record.getChildNodes();
        if (childNodes != null && childNodes.getLength() != 0)
        {
            ArrayList<String> handledTags = new ArrayList<String>();
            handledTags.add("path");
            handledTags.add("relativePath");
            handledTags.add("href");
            handledTags.add("author");
            handledTags.add("langversion");
            handledTags.add("playerversion");
            handledTags.add("productversion");
            handledTags.add("toolversion");
            handledTags.add("taghref");
            handledTags.add("description");
            handledTags.add("result");
            handledTags.add("return");
            handledTags.add("example");
            handledTags.add("throws");
            handledTags.add("canThrow");
            handledTags.add("event");
            handledTags.add("eventType");
            handledTags.add("metadata");
            handledTags.add("since");

            boolean customsFound = false;
            boolean seeFound = false;
            boolean paramFound = false;
            boolean includeExamplesFound = false;
            boolean tipTextFound = false;

            Element customData = null;

            Element relatedLinks = outputObject.createElement("related-links");
            ArrayList<Element> includeExamples = new ArrayList<Element>();
            Element params = outputObject.createElement("params");
            Element apiTipTexts = outputObject.createElement("apiTipTexts");

            int lastParamName = 0;
            int lastParamType = 0;
            int lastParamDefault = 0;

            for (int ix = 0; ix < childNodes.getLength(); ix++)
            {
                Node elementNode = childNodes.item(ix);
                if (elementNode.getNodeType() != Node.ELEMENT_NODE)
                {
                    continue;
                }

                Element child = (Element)elementNode;
                String tagName = child.getNodeName();

                if (handledTags.contains(tagName))
                {
                    continue;
                }

                if (tagName.equals("see"))
                {
                    seeFound = true;
                    relatedLinks.appendChild(processSeeTag(record.getAttribute("fullname"), child.getTextContent()));
                }
                else if (useParams && tagName.equals("param"))
                {
                    if (!child.getTextContent().equals("none"))
                    {
                        int nextParam = paramNames.indexOf(";", lastParamName);
                        if (nextParam == -1)
                        {
                            nextParam = paramNames.length();
                        }
                        if (lastParamName > nextParam)
                        {
                            lastParamName = nextParam;
                        }

                        String nextName = paramNames.substring(lastParamName, nextParam);
                        lastParamName = nextParam + 1;

                        nextParam = paramTypes.indexOf(";", lastParamType);
                        if (nextParam == -1)
                        {
                            nextParam = paramTypes.length();
                        }

                        if (lastParamType > nextParam)
                        {
                            lastParamType = nextParam;
                        }

                        String nextType = paramTypes.substring(lastParamType, nextParam);
                        lastParamType = nextParam + 1;

                        nextParam = paramDefaults.indexOf(";", lastParamDefault);
                        if (nextParam == -1)
                        {
                            nextParam = paramDefaults.length();
                        }

                        if (lastParamDefault > nextParam)
                        {
                            lastParamDefault = nextParam;
                        }

                        String nextDefault = paramDefaults.substring(lastParamDefault, nextParam);
                        lastParamDefault = nextParam + 1;

                        if (nextName.equals(""))
                        {
                            continue;
                        }

                        Element apiParam = outputObject.createElement("apiParam");
                        Element apiItemName = outputObject.createElement("apiItemName");
                        apiItemName.setTextContent(nextName);
                        apiParam.appendChild(apiItemName);

                        AsClass paramClass = classTable.get(nextType);
                        if (paramClass != null)
                        {
                            Element apiOperationClassifier = outputObject.createElement("apiOperationClassifier");
                            apiOperationClassifier.setTextContent(paramClass.getFullName());
                            apiParam.appendChild(apiOperationClassifier);
                        }
                        else
                        {
                            Element apiType = outputObject.createElement("apiType");

                            if (nextType.equals("*"))
                            {
                                apiType.setAttribute("value", "any");
                            }
                            else
                            {
                                apiType.setAttribute("value", nextType);
                            }

                            apiParam.appendChild(apiType);
                        }

                        if (nextDefault != null && !nextDefault.equals("undefined"))
                        {
                            Element apiData = outputObject.createElement("apiData");
                            apiData.setTextContent(nextDefault);
                            apiParam.appendChild(apiData);
                        }

                        String desc = child.getTextContent();

                        int tabIndex = desc.indexOf('\t');
                        int spaceIndex = desc.indexOf(" ");

                        if (tabIndex != -1 && tabIndex < spaceIndex)
                        {
                            spaceIndex = tabIndex;
                        }

                        if (spaceIndex != -1)
                        {
                            desc = desc.substring(spaceIndex + 1);
                        }
                        Element apiDesc = outputObject.createElement("apiDesc");
                        CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(desc, "param", record.getAttribute("fullname")));
                        apiDesc.appendChild(cdata);
                        apiParam.appendChild(apiDesc);

                        asDocUtil.convertDescToDITA(apiDesc, oldNewNamesMap);

                        params.appendChild(apiParam);
                        paramFound = true;
                    }
                }
                else if (tagName.equals("param"))
                {
                }
                else if (tagName.equals("includeExample"))
                {
                    includeExamplesFound = true;

                    // get the <example> element after reading the file and
                    // creating a <codeblock>
                    // add the <example> to the detail node..
                    includeExamples.add(processIncludeExampleTag(record.getAttribute("fullname"), child.getTextContent()));
                }
                else if (tagName.equals("tiptext"))
                {
                    tipTextFound = true;

                    Element apiTipText = outputObject.createElement("apiTipText");
                    CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(child.getTextContent(), "tiptext", record.getAttribute("fullname")));
                    apiTipText.appendChild(cdata);
                    asDocUtil.convertDescToDITA(apiTipText, oldNewNamesMap);
                    apiTipTexts.appendChild(apiTipText);
                }
                else if (tagName.equals("copy"))
                {
                    String copyRef = child.getTextContent();
                    copyRef = copyRef.replaceAll("[\\n\\s]", "");

                    if (copyRef.equals(""))
                    {
                        continue;
                    }

                    Element shortDescElement = asDocUtil.getElementByTagName(target, "shortdesc");
                    if (shortDescElement == null)
                    {
                        shortDescElement = outputObject.createElement("shortdesc");
                        target.appendChild(shortDescElement);
                    }

                    shortDescElement.setAttribute("conref", copyRef);
                    Element detailNode = asDocUtil.getDetailNode(target);

                    if (detailNode == null)
                    {
                        continue;
                    }

                    Element apiDesc = asDocUtil.getElementImmediateChildByTagName(detailNode, "apiDesc");

                    if (apiDesc != null)
                    {
                        apiDesc.setAttribute("conref", copyRef);
                    }
                }
                else if (tagName.equals("default"))
                {

                    Element apiDefaultValue = outputObject.createElement("apiDefaultValue");
                    apiDefaultValue.setTextContent(child.getTextContent());
                    Element defNode = asDocUtil.getDefNode(target);
                    defNode.appendChild(apiDefaultValue);
                }
                else if (tagName.equals("inheritDoc"))
                {

                    Element apiInheritDoc = outputObject.createElement("apiInheritDoc");
                    target.appendChild(apiInheritDoc);
                }
                else
                {
                    customsFound = true;
                    customData = outputObject.createElement(child.getNodeName());
                    NodeList customsChildren = child.getChildNodes();
                    if (customsChildren != null && customsChildren.getLength() != 0)
                    {
                        if (customsChildren.item(0).getNodeType() == Node.CDATA_SECTION_NODE)
                        {
                            CDATASection cdata = outputObject.createCDATASection(child.getTextContent());
                            cdata.setData(((CDATASection)customsChildren.item(0)).getData());
                            customData.appendChild(cdata);
                        }
                        else
                        {
                            CDATASection cdata = outputObject.createCDATASection(child.getTextContent());
                            customData.appendChild(cdata);
                        }
                    }

                }
            }

            if (useParams && lastParamName < paramNames.length())
            {
                if (verbose)
                {
                    System.out.println("     more params declared than found @param tags for, inventing param elements");
                    System.out.println("        params to synth docs for: " + paramNames.substring(lastParamName));
                }

                while (lastParamName < paramNames.length())
                {
                    int nextParam = paramNames.indexOf(";", lastParamName);
                    if (nextParam == -1)
                    {
                        nextParam = paramNames.length();
                    }

                    if (lastParamName > nextParam)
                    {
                        lastParamName = nextParam;
                    }

                    String nextName = paramNames.substring(lastParamName, nextParam);
                    lastParamName = nextParam + 1;

                    nextParam = paramTypes.indexOf(";", lastParamType);
                    if (nextParam == -1)
                    {
                        nextParam = paramTypes.length();
                    }
                    if (lastParamType > nextParam)
                    {
                        lastParamType = nextParam;
                    }

                    String nextType = paramTypes.substring(lastParamType, nextParam);
                    lastParamType = nextParam + 1;

                    nextParam = paramDefaults.indexOf(";", lastParamDefault);
                    if (nextParam == -1)
                    {
                        nextParam = paramDefaults.length();
                    }
                    if (lastParamDefault > nextParam)
                    {
                        lastParamDefault = nextParam;
                    }

                    String nextDefault = paramDefaults.substring(lastParamDefault, nextParam);
                    lastParamDefault = nextParam + 1;

                    Element apiParam = outputObject.createElement("apiParam");
                    Element apiItemName = outputObject.createElement("apiItemName");
                    apiItemName.setTextContent(nextName);
                    apiParam.appendChild(apiItemName);

                    AsClass paramClass = classTable.get(nextType);
                    if (paramClass != null)
                    {
                        Element apiOperationClassifier = outputObject.createElement("apiOperationClassifier");
                        apiOperationClassifier.setTextContent(paramClass.getFullName());
                        apiParam.appendChild(apiOperationClassifier);
                    }
                    else
                    {
                        Element apiType = outputObject.createElement("apiType");

                        if (nextType.equals("*"))
                        {
                            apiType.setAttribute("value", "any");
                        }
                        else
                        {
                            apiType.setAttribute("value", nextType);
                        }

                        apiParam.appendChild(apiType);
                    }

                    if (nextDefault != null && !nextDefault.equals("undefined"))
                    {
                        Element apiData = outputObject.createElement("apiData");
                        apiData.setTextContent(nextDefault);
                        apiParam.appendChild(apiData);
                    }

                    params.appendChild(apiParam);
                    paramFound = true;
                }
            }

            if (seeFound)
            {
                target.appendChild(relatedLinks);
            }

            if (paramFound)
            {
                Element apiOperationDetail = asDocUtil.getElementByTagName(target, "apiOperationDetail");
                if (apiOperationDetail != null)
                {
                    Element apiOperationDef = asDocUtil.getElementByTagName(apiOperationDetail, "apiOperationDef");
                    if (apiOperationDef == null)
                    {
                        apiOperationDef = outputObject.createElement("apiOperationDef");
                    }

                    NodeList listofChilds = params.getElementsByTagName("apiParam");
                    for (int iChild = 0; iChild < listofChilds.getLength(); iChild++)
                    {
                        Node node = listofChilds.item(iChild);
                        apiOperationDef.appendChild(node.cloneNode(true));
                    }
                }
                else
                {
                    Element apiConstructorDetail = asDocUtil.getElementByTagName(target, "apiConstructorDetail");
                    if (apiConstructorDetail != null)
                    {
                        Element apiConstructorDef = asDocUtil.getElementByTagName(apiConstructorDetail, "apiConstructorDef");
                        if (apiConstructorDef == null)
                        {
                            apiConstructorDef = outputObject.createElement("apiConstructorDef");
                        }

                        NodeList listofChilds = params.getElementsByTagName("apiParam");
                        for (int iChild = 0; iChild < listofChilds.getLength(); iChild++)
                        {
                            Node node = listofChilds.item(iChild);
                            apiConstructorDef.appendChild(node.cloneNode(true));
                        }
                    }
                    else
                    {
                        if (verbose)
                        {
                            System.out.println("Error neither operationdetail nor constructordetail exists for " + target.getNodeName());
                        }
                    }
                }
            }

            if (includeExamplesFound)
            {
                Element detailNode = asDocUtil.getDetailNode(target);
                for (int ix = 0; ix < includeExamples.size(); ix++)
                {
                    detailNode.appendChild(includeExamples.get(ix));
                }
            }

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

                asCustoms.appendChild(customData);
            }

            if (tipTextFound)
            {
                Element defNode = asDocUtil.getDefNode(target);
                defNode.appendChild(apiTipTexts);
            }
        }
    }