All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.globallink.api.pss.rewriters.ScriptRewriter Maven / Gradle / Ivy

Go to download

The newest version!
package com.globallink.api.pss.rewriters;

import java.util.ArrayList;
import java.util.List;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.globallink.api.pss.DownloadedFileInfo;
import com.globallink.api.pss.DownloadedFileInfo.Types;

public class ScriptRewriter implements IFileTagRewriter {
    public List RewriteLinks(Document document)
    {
        List fileInfos = new ArrayList();
        Elements els = document.select("script[src]");
        int i=0;
        for(Element el : els){
            i++;
        	String sourceUrl = el.attr("abs:src");
                DownloadedFileInfo fileInfo = new DownloadedFileInfo(sourceUrl, Types.SCRIPT, i);
                el.attr("src", fileInfo.ResolvedFilePath);
                fileInfos.add(fileInfo);
        }

        return fileInfos;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy