Search in sources :

Example 1 with MetaInfTldSource

use of freemarker.ext.jsp.TaglibFactory.MetaInfTldSource in project freemarker by apache.

the class FreemarkerServlet method parseAsMetaInfTldLocations.

private List parseAsMetaInfTldLocations(String value) throws ParseException {
    List /*<MetaInfTldSource>*/
    metaInfTldSources = null;
    List /*<String>*/
    values = InitParamParser.parseCommaSeparatedList(value);
    for (Iterator it = values.iterator(); it.hasNext(); ) {
        final String itemStr = (String) it.next();
        final MetaInfTldSource metaInfTldSource;
        if (itemStr.equals(META_INF_TLD_LOCATION_WEB_INF_PER_LIB_JARS)) {
            metaInfTldSource = WebInfPerLibJarMetaInfTldSource.INSTANCE;
        } else if (itemStr.startsWith(META_INF_TLD_LOCATION_CLASSPATH)) {
            String itemRightSide = itemStr.substring(META_INF_TLD_LOCATION_CLASSPATH.length()).trim();
            if (itemRightSide.length() == 0) {
                metaInfTldSource = new ClasspathMetaInfTldSource(Pattern.compile(".*", Pattern.DOTALL));
            } else if (itemRightSide.startsWith(":")) {
                final String regexpStr = itemRightSide.substring(1).trim();
                if (regexpStr.length() == 0) {
                    throw new ParseException("Empty regular expression after \"" + META_INF_TLD_LOCATION_CLASSPATH + ":\"", -1);
                }
                metaInfTldSource = new ClasspathMetaInfTldSource(Pattern.compile(regexpStr));
            } else {
                throw new ParseException("Invalid \"" + META_INF_TLD_LOCATION_CLASSPATH + "\" value syntax: " + value, -1);
            }
        } else if (itemStr.startsWith(META_INF_TLD_LOCATION_CLEAR)) {
            metaInfTldSource = ClearMetaInfTldSource.INSTANCE;
        } else {
            throw new ParseException("Item has no recognized source type prefix: " + itemStr, -1);
        }
        if (metaInfTldSources == null) {
            metaInfTldSources = new ArrayList();
        }
        metaInfTldSources.add(metaInfTldSource);
    }
    return metaInfTldSources;
}
Also used : ClearMetaInfTldSource(freemarker.ext.jsp.TaglibFactory.ClearMetaInfTldSource) ClasspathMetaInfTldSource(freemarker.ext.jsp.TaglibFactory.ClasspathMetaInfTldSource) WebInfPerLibJarMetaInfTldSource(freemarker.ext.jsp.TaglibFactory.WebInfPerLibJarMetaInfTldSource) MetaInfTldSource(freemarker.ext.jsp.TaglibFactory.MetaInfTldSource) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ParseException(java.text.ParseException) ClasspathMetaInfTldSource(freemarker.ext.jsp.TaglibFactory.ClasspathMetaInfTldSource)

Aggregations

ClasspathMetaInfTldSource (freemarker.ext.jsp.TaglibFactory.ClasspathMetaInfTldSource)1 ClearMetaInfTldSource (freemarker.ext.jsp.TaglibFactory.ClearMetaInfTldSource)1 MetaInfTldSource (freemarker.ext.jsp.TaglibFactory.MetaInfTldSource)1 WebInfPerLibJarMetaInfTldSource (freemarker.ext.jsp.TaglibFactory.WebInfPerLibJarMetaInfTldSource)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1