<commit_before>package com.akjava.gwt.html5.client.download;

import com.google.gwt.user.client.ui.Anchor;



public class HTML5Download {
	public static  native final DownloadURL URL()/*-{
	return   window.webkitURL || window.URL;
	}-*/;
	
	public static  native final DownloadBlobBuilder BlobBuilder()/*-{
	$wnd.BlobBuilder=   $wnd.BlobBuilder || $wnd.WebKitBlobBuilder ||
                       $wnd.MozBlobBuilder;
    return new $wnd.BlobBuilder();
	}-*/;
	
	public static Anchor generateTextDownloadLink(String text,String fileName,String anchorText){
		DownloadBlobBuilder bb=HTML5Download.BlobBuilder();
		String mimeType="text/plain";
		bb.append(text);
		
		final Anchor link=new Anchor(anchorText);
		String url=HTML5Download.URL().createObjectURL(bb.getBlob(mimeType));
		link.setHref(url);
		link.getElement().setAttribute("download", fileName);
		link.getElement().setAttribute("dataset.downloadurl", mimeType+":"+fileName+":"+url);
		return link;
	}
	
	public static Anchor generateDownloadLink(DownloadBlobBuilder blob,String mimeType,String fileName,String anchorText){
		final Anchor link=new Anchor(anchorText);
		String url=HTML5Download.URL().createObjectURL(blob.getBlob(mimeType));
		link.setHref(url);
		link.getElement().setAttribute("download", fileName);
		link.getElement().setAttribute("dataset.downloadurl", mimeType+":"+fileName+":"+url);
		return link;
	}
	

}<commit_msg>improve download<commit_after>package com.akjava.gwt.html5.client.download;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Anchor;



public class HTML5Download {
	public static  native final DownloadURL URL()/*-{
	return   window.webkitURL || window.URL;
	}-*/;
	
	public static  native final DownloadBlobBuilder BlobBuilder()/*-{
	$wnd.BlobBuilder=   $wnd.BlobBuilder || $wnd.WebKitBlobBuilder ||
                       $wnd.MozBlobBuilder;
    return new $wnd.BlobBuilder();
	}-*/;
	
	public static Anchor generateTextDownloadLink(String text,String fileName,String anchorText){
		return generateTextDownloadLink(text,fileName,anchorText,false);
	}
	public static Anchor generateTextDownloadLink(String text,String fileName,String anchorText,boolean autoRemove){
		DownloadBlobBuilder bb=HTML5Download.BlobBuilder();
		String mimeType="text/plain";
		bb.append(text);
		
		final Anchor link=new Anchor(anchorText);
		String url=HTML5Download.URL().createObjectURL(bb.getBlob(mimeType));
		link.setHref(url);
		link.getElement().setAttribute("download", fileName);
		link.getElement().setAttribute("dataset.downloadurl", mimeType+":"+fileName+":"+url);
		if(autoRemove){
			link.addClickHandler(new ClickHandler() {
				
				@Override
				public void onClick(ClickEvent event) {
					link.removeFromParent();
				}
			});
		}
		return link;
	}
	
	public static Anchor generateDownloadLink(DownloadBlobBuilder blob,String mimeType,String fileName,String anchorText){
		final Anchor link=new Anchor(anchorText);
		String url=HTML5Download.URL().createObjectURL(blob.getBlob(mimeType));
		link.setHref(url);
		link.getElement().setAttribute("download", fileName);
		link.getElement().setAttribute("dataset.downloadurl", mimeType+":"+fileName+":"+url);
		return link;
	}
	

}
{'fraction_non_alphanumeric': 0.132640586797066, 'fraction_numerical': 0.003056234718826406, 'mean_word_length': 5.30635838150289, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 33, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1789831', 'n_tokens_mistral': 1068, 'n_tokens_neox': 992, 'n_words': 174}