Java Code Examples for javax.servlet.jsp.tagext.VariableInfo#getVarName()

The following examples show how to use javax.servlet.jsp.tagext.VariableInfo#getVarName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSPProcessor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected String createBeanVarDeclarations(List<String> localBeans) {
    //TODO: the parser data contains no information about offsets and
    //therefore it is not possible to create proper java embeddings
    //inside bean declarations. We need a similar solution to what was
    //done for imports, see issue #161246
    StringBuilder beanDeclarationsBuff = new StringBuilder();

    PageInfo pageInfo = getPageInfo();

    if (pageInfo != null) {
        PageInfo.BeanData[] beanData = getBeanData();

        if (beanData != null) {
            for (PageInfo.BeanData bean : beanData) {
                if (!localBeans.contains(bean.getId())) {
                    beanDeclarationsBuff.append(bean.getClassName() + " " + bean.getId() + ";\n"); //NOI18N
                }
            }
        }

        if (pageInfo.isTagFile()) {
            for (TagAttributeInfo info : pageInfo.getTagInfo().getAttributes()) {
                if (info.getTypeName() != null) { // will be null e.g. for fragment attrs
                    if (!localBeans.contains(info.getName())) {
                        beanDeclarationsBuff.append(info.getTypeName() + " " + info.getName() + ";\n"); //NOI18N
                    }
                }
            }
        }
    }

    JspSyntaxSupport syntaxSupport = JspSyntaxSupport.get(doc);
    JspColoringData coloringData = getParserData().getColoringData();

    if (coloringData != null && coloringData.getPrefixMapper() != null) {
        Collection<String> prefixes = coloringData.getPrefixMapper().keySet();
        TagData fooArg = new TagData((Object[][]) null);

        for (String prefix : prefixes) {
            List<TagInfo> tags = syntaxSupport.getAllTags(prefix, false); //do not require fresh data - #146762

            for (TagInfo tag : tags) {
                // #146754 - prevent NPE:
                if (tag == null) {
                    continue;
                }
                VariableInfo vars[] = tag.getVariableInfo(fooArg);

                if (vars != null) {
                    for (VariableInfo var : vars) {
                        // Create Variable Definitions
                        if (var != null && var.getVarName() != null && var.getClassName() != null && var.getDeclare()) {
                            String varDeclaration = var.getClassName() + " " + var.getVarName() + ";\n";
                            beanDeclarationsBuff.append(varDeclaration);
                        }
                    }
                }
            }
        }
    }

    return beanDeclarationsBuff.toString();
}