Package com.granule.parser

Examples of com.granule.parser.Attributes


    }

  private void testInclude(String text,int tagPosition) {
    TagReader s;
    Element includeTag;
    Attributes includeAttributes;
    s = new TagReader(text);
        includeTag = s.getAllElements().get(tagPosition);
        includeAttributes = s.parseAttributes(includeTag);
        assertEquals(includeAttributes.isValueExists("include"), true);
        assertEquals(includeAttributes.getValue("file"), "ff.inc");
  }
View Full Code Here


            if (e.getName() != null && e.getName().equalsIgnoreCase("%"))
                jspTags++;
            else if (e.getName() != null && e.getName().equals("g:compress")) gCompressPos = all.indexOf(e);
        assertEquals(jspTags, 3);
        Element pageTag = all.get(1);
        Attributes pageAttributes = s.parseAttributes(pageTag);
        assertEquals(pageAttributes.isValueExists("include"), false);
        assertEquals(pageAttributes.isValueExists("file"), false);

        Element includeTag = all.get(2);
        Attributes includeAttributes = s.parseAttributes(includeTag);
        assertEquals(includeAttributes.isValueExists("include"), true);
        assertEquals(includeAttributes.isValueExists("file"), true);
        assertEquals(includeTag.getBegin(), text.indexOf("<%@ include"));
        assertEquals(includeTag.getEnd(), text.indexOf("<%@ include") + "<%@ include file=\"includes/test1.inc\"%>".length());

        Element gCompress = all.get(gCompressPos);
        Attributes gCompressAttrs = s.parseAttributes(gCompress);
        assertEquals(gCompressAttrs.isValueExists("dsdsd"), false);
        assertEquals(gCompressAttrs.isValueExists("method"), true);
        assertEquals(gCompressAttrs.get("method").getBegin(), text.indexOf("method="));
        assertEquals(gCompressAttrs.get("method").getEnd(), text.indexOf("method=") + "method=\"closure-compiler\"".length());
        assertEquals(gCompress.getBegin(), text.indexOf("<g:compress"));
        assertEquals(gCompress.getEnd(), text.indexOf("</g:compress>") + "</g:compress>".length());
    }
View Full Code Here

                    int correction = 0;
                    List<FragmentDescriptor> fragmentDescriptors = new ArrayList<FragmentDescriptor>();
                    for (Element e : scripts) {
                        FragmentDescriptor desc = null;
                        boolean addFile = true;
                        Attributes attrs = e.getAttributes();
                        if (attrs.isValueExists("src")) {
                            String src = attrs.getValue("src");
                            if (PathUtils.isWebAddress(src) || !PathUtils.isValidJs(src))
                                throw new JSCompileException("Dynamic or remote scripts can not be combined. src="+src);

                            String path = PathUtils.calcPath
                                    (src, requestProxy, bp);
View Full Code Here

                }
            }
            HashMap<String, MediaInfo> mediae = new HashMap<String, MediaInfo>();
            for (int i = 0; i < links.size(); i++) {
                Element link = links.get(i);
                Attributes attrs = link.getAttributes();
                if (attrs.isValueExists("rel") && attrs.getValue("rel").equalsIgnoreCase("stylesheet")
                        && attrs.isValueExists("href")) {
                    String media = "";
                    if (attrs.isValueExists("media"))
                        media = attrs.getValue("media");
                    MediaInfo md = mediae.get(media);
                    if (md == null) {
                        md = new MediaInfo();
                        mediae.put(media, md);
                    }
                    String href = attrs.getValue("href");
                    if (PathUtils.isWebAddress(href) || !PathUtils.isValidCss(href))
                        throw new JSCompileException("Dynamic or remote stylesheets can not be combined. href="+href);
                    String path = PathUtils.calcPath(href, requestProxy, bp);
          if (settings.isCleanCssDuplicates()
                            && cssDuplicates.contains(media + path)) {
View Full Code Here

        List<Element> els = source.getAllElements();
        for (Element el : els) {
            if (el.getName().equals(settings.getTagName())) {
                try {
                    String body = el.getContentAsString();
                    Attributes attrs = source.parseAttributes(el);
                    String id = attrs.getValue("id");
                    String method = attrs.getValue("method");
                    String options = attrs.getValue("options");
                    String basepath = attrs.getValue("basepath");
                    if (body == null) body = "";
                    if (body.contains("<%--"))
                        body = removeJspComments(body);
                    if (body.contains("<%")) {
                        logger.warn("Dynamic content found, tag skipped in file " + filename);
                    } else {
                        CompressTagHandler tagHandler = new CompressTagHandler(id, method, options, basepath);
                        tagHandler.handleTag(request, null, body);
                    }
                } catch (JSCompileException e) {
                    errorCount++;
                    logger.error("Tag process exception:", e);
                }
            } else if (el.getName().equals("%")) {
                Attributes attrs = source.parseAttributes(el);
                if (attrs != null && attrs.isValueExists("include") && attrs.isValueExists("file")) {
                    String file = attrs.getValue("file");
                    String pa = "";
                    if (!file.trim().startsWith("/") && file.indexOf("/")>=0)
                        pa = file.substring(0, file.lastIndexOf("/")+1);
                    file =  webAppRootPath + "/" + PathUtils.calcPath(
                            (pathAddition.equals("")||file.startsWith("/")?"":(pathAddition+"/"))+file, request,"");
View Full Code Here

TOP

Related Classes of com.granule.parser.Attributes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.