org.apache.isis.applib.value.Blob.getMimeType()方法的使用及代码示例

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

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

Blob.getMimeType介绍

暂无

代码示例

代码示例来源: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.apache.isis.core/isis-core-applib

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

代码示例来源: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

@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.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.apache.isis.core/isis-core-metamodel

@Test
public void testEncode_and_decode() {
  String encoded = value.toEncodedString(blob);
  assertEquals("myfile1.docx:application/vnd.ms-word:AQIDBA==", encoded);
  Blob decoded = value.fromEncodedString(encoded);
  assertThat(decoded.getName(), is("myfile1.docx"));
  assertThat(decoded.getMimeType().getPrimaryType(), is("application"));
  assertThat(decoded.getMimeType().getSubType(), is("vnd.ms-word"));
  assertThat(decoded.getBytes().length, is(4));
}

代码示例来源: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.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

/**
 * @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;
}

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

public void setObject(ExecutionContext ec, PreparedStatement preparedStmt, int[] exprIndex, Object value)
{
  Blob blob = ((Blob)value);
  if (blob == null) {
    getDatastoreMapping(0).setString(preparedStmt, exprIndex[0], null);
    getDatastoreMapping(1).setString(preparedStmt, exprIndex[1], null);
    // using:
    // getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], null);
    // fails for PostgreSQL, as interprets as a reference to an oid (pointer to offline blob)
    // rather than a bytea (inline blob)
    try {
      preparedStmt.setBytes(exprIndex[2], null);
    } catch (SQLException e) {
      // ignore
    }
  } else {
    getDatastoreMapping(0).setString(preparedStmt, exprIndex[0], blob.getName());
    getDatastoreMapping(1).setString(preparedStmt, exprIndex[1], blob.getMimeType().getBaseType());
    getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], blob.getBytes());
  }
}

代码示例来源: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;
}

代码示例来源: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: 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: org.apache.isis.core/isis-core-applib

blobDto.setName(blob.getName());
blobDto.setBytes(blob.getBytes());
blobDto.setMimeType(blob.getMimeType().toString());
valueDto.setBlob(blobDto);

相关文章