• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Blob类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.egit.github.core.Blob的典型用法代码示例。如果您正苦于以下问题:Java Blob类的具体用法?Java Blob怎么用?Java Blob使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Blob类属于org.eclipse.egit.github.core包,在下文中一共展示了Blob类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createBlob

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
protected static String createBlob(DataService service, RepositoryId repository, String prefix, String path)
		throws Exception {
	File file = new File(prefix, path);
	final long length = file.length();
	final int size = length > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) length;
	ByteArrayOutputStream output = new ByteArrayOutputStream(size);
	FileInputStream stream = new FileInputStream(file);
	try {

		final byte[] buffer = new byte[8192];
		int read;
		while ((read = stream.read(buffer)) != -1)
			output.write(buffer, 0, read);
		Blob blob = new Blob().setEncoding(Blob.ENCODING_BASE64);
		String encoded = EncodingUtils.toBase64(output.toByteArray());
		blob.setContent(encoded);
		return service.createBlob(repository, blob);
	} finally {
		stream.close();
	}
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:22,代码来源:PublishHelper.java


示例2: process

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
public void process(Exchange exchange) throws Exception {
    CommitFile file = exchange.getIn().getBody(CommitFile.class);

    Blob response = dataService.getBlob(getRepository(), file.getSha());

    String text = response.getContent();

    // By default, if blob encoding is base64 then we convert to UTF-8. If
    // base64 encoding is required, then must be explicitly requested
    if (response.getEncoding().equals(Blob.ENCODING_BASE64) 
        && encoding != null && encoding.equalsIgnoreCase(Blob.ENCODING_UTF8)) {
        text = new String(Base64.decodeBase64(text));
    }

    // copy the header of in message to the out message
    exchange.getOut().copyFrom(exchange.getIn());
    exchange.getOut().setBody(text);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:GetCommitFileProducer.java


示例3: createBlob

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
private String createBlob(DataService service, RepositoryId repository, File outputDirectory, String path) throws GitHubException {
	try {
		Blob blob = new Blob().setEncoding(ENCODING_BASE64);
		if(NO_JEKYLL_FILE.equals(path)){
			blob.setContent("");
			//log.debug("Creating blob from " + NO_JEKYLL_FILE);
		}else{
			File file = new File(outputDirectory, path);
			byte[] bytes = FileUtils.readFileToByteArray(file);
			String encoded = EncodingUtils.toBase64(bytes);
			blob.setContent(encoded);
			//log.debug("Creating blob from " +  file.getAbsolutePath());
		}
		if(log.isDebugEnabled()){
			log.debug("Creating blob from " +  path);
		}
		return service.createBlob(repository, blob);
	} catch (IOException e) {
		throw new GitHubException("Error creating blob from '" + path + "': " + e.getMessage(), e);
	}
}
 
开发者ID:opoo,项目名称:opoopress,代码行数:22,代码来源:GitHub.java


示例4: getBlob

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
/**
 * Get blob for given SHA-1
 *
 * @param repository
 * @param sha
 * @return blob
 * @throws IOException
 */
public Blob getBlob(IRepositoryIdProvider repository, String sha)
		throws IOException {
	final String id = getId(repository);
	if (sha == null)
		throw new IllegalArgumentException("SHA-1 cannot be null"); //$NON-NLS-1$
	if (sha.length() == 0)
		throw new IllegalArgumentException("SHA-1 cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	uri.append(SEGMENT_BLOBS);
	uri.append('/').append(sha);
	GitHubRequest request = createRequest();
	request.setType(Blob.class);
	request.setUri(uri);
	return (Blob) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:28,代码来源:DataService.java


示例5: createBlob

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
/**
 * Create blob with given content
 *
 * @param repository
 * @param blob
 * @return SHA-1 of created blob
 * @throws IOException
 */
public String createBlob(IRepositoryIdProvider repository, Blob blob)
		throws IOException {
	final String id = getId(repository);
	if (blob == null)
		throw new IllegalArgumentException("Blob cannot be null"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	uri.append(SEGMENT_BLOBS);
	ShaResource created = client.post(uri.toString(), blob,
			ShaResource.class);
	return created != null ? created.getSha() : null;
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:24,代码来源:DataService.java


示例6: createTreeFromString

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
public static TreeEntry createTreeFromString(String prefix, String name, String content, DataService serv, RepositoryId id)
		throws Exception {
	TreeEntry entry = new TreeEntry();
	entry.setPath(prefix + name);
	entry.setType(TreeEntry.TYPE_BLOB);
	entry.setMode(TreeEntry.MODE_BLOB);
	Blob blob = new Blob().setEncoding(Blob.ENCODING_UTF8);
	blob.setContent(content);
	entry.setSha(serv.createBlob(id, blob));
	return entry;
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:12,代码来源:PublishHelper.java


示例7: setSource

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
/**
 * Bind blob content to current {@link WebView}
 *
 * @param name
 * @param blob
 * @return this editor
 */
public SourceEditor setSource(final String name, final Blob blob) {
    String content = blob.getContent();
    if (content == null)
        content = "";
    boolean encoded = !TextUtils.isEmpty(content)
            && ENCODING_BASE64.equals(blob.getEncoding());
    return setSource(name, content, encoded);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:16,代码来源:SourceEditor.java


示例8: getBlob

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
public Blob getBlob(Repository repository, String sha) throws IOException {
    return dataService.getBlob(repository, sha);
}
 
开发者ID:drifted-in,项目名称:txgh,代码行数:4,代码来源:GitHubApi.java


示例9: getFileContent

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
public String getFileContent(Repository repository, String sha) throws IOException {
    Blob blob = getBlob(repository, sha);
    return blob.getEncoding().equalsIgnoreCase("utf-8") ? blob.getContent() : new String(Base64.getDecoder().decode(blob.getContent().replace("\n", "")), StandardCharsets.UTF_8);
}
 
开发者ID:drifted-in,项目名称:txgh,代码行数:5,代码来源:GitHubApi.java


示例10: loadContent

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
private void loadContent() {
    new RefreshBlobTask(repo, sha, this) {

        @Override
        protected void onSuccess(Blob blob) throws Exception {
            super.onSuccess(blob);

            ViewUtils.setGone(loadingBar, true);
            ViewUtils.setGone(codeView, false);

            editor.setSource(path, blob);
            CommitFileViewActivity.this.blob = blob;

            if (markdownItem != null)
                markdownItem.setEnabled(true);

            if (isMarkdownFile
                    && PreferenceUtils.getCodePreferences(
                            CommitFileViewActivity.this).getBoolean(
                            RENDER_MARKDOWN, true))
                loadMarkdown();
            else {
                ViewUtils.setGone(loadingBar, true);
                ViewUtils.setGone(codeView, false);
                editor.setSource(path, blob);
            }
        }

        @Override
        protected void onException(Exception e) throws RuntimeException {
            super.onException(e);

            Log.d(TAG, "Loading commit file contents failed", e);

            ViewUtils.setGone(loadingBar, true);
            ViewUtils.setGone(codeView, false);
            ToastUtils.show(CommitFileViewActivity.this, e,
                    string.error_file_load);
        }
    }.execute();
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:42,代码来源:CommitFileViewActivity.java


示例11: loadContent

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
private void loadContent() {
    ViewUtils.setGone(loadingBar, false);
    ViewUtils.setGone(codeView, true);

    new RefreshBlobTask(repo, sha, this) {

        @Override
        protected void onSuccess(Blob blob) throws Exception {
            super.onSuccess(blob);

            BranchFileViewActivity.this.blob = blob;

            if (markdownItem != null)
                markdownItem.setEnabled(true);

            if (isMarkdownFile
                    && PreferenceUtils.getCodePreferences(
                            BranchFileViewActivity.this).getBoolean(
                            RENDER_MARKDOWN, true))
                loadMarkdown();
            else {
                ViewUtils.setGone(loadingBar, true);
                ViewUtils.setGone(codeView, false);

                editor.setMarkdown(false).setSource(file, blob);
            }
        }

        @Override
        protected void onException(Exception e) throws RuntimeException {
            super.onException(e);

            Log.d(TAG, "Loading file contents failed", e);

            ViewUtils.setGone(loadingBar, true);
            ViewUtils.setGone(codeView, false);
            ToastUtils.show(BranchFileViewActivity.this, e,
                    string.error_file_load);
        }
    }.execute();
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:42,代码来源:BranchFileViewActivity.java


示例12: run

import org.eclipse.egit.github.core.Blob; //导入依赖的package包/类
@Override
protected Blob run(Account account) throws Exception {
    return service.getBlob(repository, blobSha);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:5,代码来源:RefreshBlobTask.java



注:本文中的org.eclipse.egit.github.core.Blob类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Closure类代码示例发布时间:2022-05-23
下一篇:
Java ExecutionRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap