org.apache.isis.applib.value.Blob类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.apache.isis.applib.value.Blob类的一些代码示例,展示了Blob类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Blob类的具体详情如下:
包路径:org.apache.isis.applib.value.Blob
类名称:Blob

Blob介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

var blob = new Blob([byteArray], {type: contentType});

代码示例来源:origin: org.apache.isis.core/isis-core-applib

@Override
public String toString() {
  return getName() + " [" + getMimeType().getBaseType() + "]: " + getBytes().length + " bytes";
}

代码示例来源:origin: org.apache.isis.core/isis-core-applib

@Test
public void when_blob_is_not_null() {
  final Blob val = new Blob("image.png", "image/png", new byte[]{1,2,3,4,5});
  CommonDtoUtils.setValueOn(valueDto, ValueType.BLOB, val, mockBookmarkService);
  final BlobDto blobDto = valueDto.getBlob();
  Assert.assertThat(blobDto, is(notNullValue()));
  Assert.assertThat(blobDto.getBytes(), is(val.getBytes()));
  Assert.assertThat(blobDto.getName(), is(val.getName()));
  Assert.assertThat(blobDto.getMimeType(), is(val.getMimeType().toString()));
}

代码示例来源:origin: org.incode.example.document/incode-example-document-dom

@Action(
    semantics = SemanticsOf.IDEMPOTENT,
    domainEvent = ActionDomainEvent.class
)
@ActionLayout(contributed = Contributed.AS_ACTION)
public DocumentTemplate $$(
    @ParameterLayout(named = "File")
    final Blob blob
) {
  documentTemplate.setMimeType(blob.getMimeType().toString());
  documentTemplate.setBlobBytes(blob.getBytes());
  return documentTemplate;
}

代码示例来源:origin: org.incode.module.document/incode-module-document-dom

@Override
  public byte[] asBytes(final DocumentAbstract<?> document) {
    final FactoryService factoryService = document.factoryService;
    final Blob blob = factoryService.mixin(Document_downloadExternalUrlAsBlob.class, document).$$();
    return blob.getBytes();
  }
},

代码示例来源:origin: org.incode.module.document/incode-module-document-dom

private static String determineName(
    final Blob document,
    final String fileName) {
  String name = fileName != null ? fileName : document.getName();
  if(!name.toLowerCase().endsWith(".pdf")) {
    name = name + ".pdf";
  }
  return name;
}

代码示例来源:origin: org.apache.isis.core/isis-core-applib

public Blob(String name, String primaryType, String subtype, byte[] bytes) {
  this(name, newMimeType(primaryType, subtype), bytes);
}

代码示例来源:origin: org.apache.isis.core/isis-core-runtime

public Object getValueForDatastoreMapping(NucleusContext nucleusCtx, int index, Object value)
{
  Blob blob = ((Blob)value);
  switch (index) {
    case 0: return blob.getName();
    case 1: return blob.getMimeType().getBaseType();
    case 2: return blob.getBytes();
  }
  throw new IndexOutOfBoundsException();
}

代码示例来源:origin: org.incode.module.document/incode-module-document-dom

@Action(
    semantics = SemanticsOf.IDEMPOTENT,
    domainEvent = ActionDomainEvent.class
)
@ActionLayout(contributed = Contributed.AS_ACTION)
public DocumentTemplate $$(
    @ParameterLayout(named = "File")
    final Blob blob
) {
  documentTemplate.setMimeType(blob.getMimeType().toString());
  documentTemplate.setBlobBytes(blob.getBytes());
  return documentTemplate;
}

代码示例来源:origin: org.incode.example.document/incode-example-document-dom

@Override
  public byte[] asBytes(final DocumentAbstract<?> document) {
    final FactoryService factoryService = document.factoryService;
    final Blob blob = factoryService.mixin(Document_downloadExternalUrlAsBlob.class, document).$$();
    return blob.getBytes();
  }
},

代码示例来源:origin: org.incode.example.document/incode-example-document-dom

private static String determineName(
    final Blob document,
    final String fileName) {
  String name = fileName != null ? fileName : document.getName();
  if(!name.toLowerCase().endsWith(".pdf")) {
    name = name + ".pdf";
  }
  return name;
}

代码示例来源:origin: org.apache.isis.core/isis-core-applib

public Blob(String name, String mimeTypeBase, byte[] bytes) {
  this(name, newMimeType(mimeTypeBase), bytes);
}

代码示例来源:origin: stackoverflow.com

var textFile = null,
makeTextFile = function (text) {
 var data = new Blob([text], {type: 'text/plain'});
 // If we are replacing a previously generated file we need to
 // manually revoke the object URL to avoid memory leaks.
 if (textFile !== null) {
  window.URL.revokeObjectURL(textFile);
 }
 textFile = window.URL.createObjectURL(data);
 // returns a URL you can use as a href
 return textFile;
};

代码示例来源:origin: org.incode.module.document/incode-module-document-dom

@Programmatic
public void modifyBlob(Blob blob) {
  setName(blob.getName());
  setMimeType(blob.getMimeType().toString());
  setBlobBytes(blob.getBytes());
  setSort(DocumentSort.BLOB);
}
public boolean hideBlob() {

代码示例来源:origin: org.incode.module.document/incode-module-document-dom

@Action(
    semantics = SemanticsOf.NON_IDEMPOTENT,
    domainEvent = ActionDomainEvent.class
)
@ActionLayout(
    contributed = Contributed.AS_ACTION,
    cssClassFa = "paperclip",
    named = "Attach supporting PDF"
)
public Document exec(
    final DocumentType documentType,
    @Parameter(fileAccept = "application/pdf")
    final Blob document,
    @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "File name")
    final String fileName,
    @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "Role name")
    final String roleName
  ) throws IOException {
  String name = determineName(document, fileName);
  final Document doc = documentRepository.create(
              documentType, this.document.getAtPath(), name, document.getMimeType().getBaseType());
  // unlike documents that are generated from a template (where we call documentTemplate#render), in this case
  // we have the actual bytes; so we just set up the remaining state of the document manually.
  doc.setRenderedAt(clockService.nowAsDateTime());
  doc.setState(DocumentState.RENDERED);
  doc.setSort(DocumentSort.BLOB);
  doc.setBlobBytes(document.getBytes());
  paperclipRepository.attach(doc, roleName, this.document);
  return this.document;
}

代码示例来源:origin: stackoverflow.com

var blob = new Blob(["some text"], {
  type: "text/plain;charset=utf-8;",
});
saveAs(blob, "thing.txt");

代码示例来源:origin: org.incode.example.document/incode-example-document-dom

@Programmatic
public void modifyBlob(Blob blob) {
  setName(blob.getName());
  setMimeType(blob.getMimeType().toString());
  setBlobBytes(blob.getBytes());
  setSort(DocumentSort.BLOB);
}
public boolean hideBlob() {

代码示例来源:origin: org.incode.example.document/incode-example-document-dom

@Action(
    semantics = SemanticsOf.NON_IDEMPOTENT,
    domainEvent = ActionDomainEvent.class
)
@ActionLayout(
    contributed = Contributed.AS_ACTION,
    cssClassFa = "paperclip",
    named = "Attach supporting PDF"
)
public Document exec(
    final DocumentType documentType,
    @Parameter(fileAccept = "application/pdf")
    final Blob document,
    @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "File name")
    final String fileName,
    @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "Role name")
    final String roleName
  ) throws IOException {
  String name = determineName(document, fileName);
  final Document doc = documentRepository.create(
              documentType, this.document.getAtPath(), name, document.getMimeType().getBaseType());
  // unlike documents that are generated from a template (where we call documentTemplate#render), in this case
  // we have the actual bytes; so we just set up the remaining state of the document manually.
  doc.setRenderedAt(clockService.nowAsDateTime());
  doc.setState(DocumentState.RENDERED);
  doc.setSort(DocumentSort.BLOB);
  doc.setBlobBytes(document.getBytes());
  paperclipRepository.attach(doc, roleName, this.document);
  return this.document;
}

代码示例来源:origin: stackoverflow.com

var data = {a:1, b:2, c:3};
var json = JSON.stringify(data);
var blob = new Blob([json], {type: "application/json"});
var url  = URL.createObjectURL(blob);

var a = document.createElement('a');
a.download    = "backup.json";
a.href        = url;
a.textContent = "Download backup.json";

代码示例来源:origin: org.incode.module.document/incode-module-document-dom

/**
 * @param documentName - override the name of the blob (if null, then uses the blob's name)
 */
@Programmatic
public Document createForBlob(
    final DocumentType documentType,
    final String documentAtPath,
    String documentName,
    final Blob blob) {
  documentName = documentName != null? documentName: blob.getName();
  final Document document = documentRepository.create(
      documentType, documentAtPath, documentName, blob.getMimeType().getBaseType());
  document.setRenderedAt(clockService.nowAsDateTime());
  document.setState(DocumentState.RENDERED);
  document.setSort(DocumentSort.BLOB);
  document.setBlobBytes(blob.getBytes());
  return document;
}

相关文章