org.modeshape.jcr.api.Binary.getStream()方法的使用及代码示例

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

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

Binary.getStream介绍

暂无

代码示例

代码示例来源:origin: ModeShape/modeshape

/**
 * Allows subclasses to process the stream of binary value property in "safe" fashion, making sure the stream is closed at the
 * end of the operation.
 * 
 * @param binary a {@link org.modeshape.jcr.api.Binary} who is expected to contain a non-null binary value.
 * @param operation a {@link org.modeshape.jcr.api.text.TextExtractor.BinaryOperation} which should work with the stream
 * @param <T> the return type of the binary operation
 * @return whatever type of result the stream operation returns
 * @throws Exception if there is an error processing the stream
 */
protected final <T> T processStream( Binary binary,
                   BinaryOperation<T> operation ) throws Exception {
  InputStream stream = binary.getStream();
  if (stream == null) {
    throw new IllegalArgumentException("The binary value is empty");
  }
  try {
    return operation.execute(stream);
  } finally {
    stream.close();
  }
}

代码示例来源:origin: org.modeshape/modeshape-jcr-api

/**
 * Allows subclasses to process the stream of binary value property in "safe" fashion, making sure the stream is closed at the
 * end of the operation.
 * 
 * @param binary a {@link org.modeshape.jcr.api.Binary} who is expected to contain a non-null binary value.
 * @param operation a {@link org.modeshape.jcr.api.text.TextExtractor.BinaryOperation} which should work with the stream
 * @param <T> the return type of the binary operation
 * @return whatever type of result the stream operation returns
 * @throws Exception if there is an error processing the stream
 */
protected final <T> T processStream( Binary binary,
                   BinaryOperation<T> operation ) throws Exception {
  InputStream stream = binary.getStream();
  if (stream == null) {
    throw new IllegalArgumentException("The binary value is empty");
  }
  try {
    return operation.execute(stream);
  } finally {
    stream.close();
  }
}

代码示例来源:origin: ModeShape/modeshape

protected void assertBinaryContains( Binary binaryValue,
                   byte[] expectedContent ) throws IOException, RepositoryException {
  byte[] actual = IoUtil.readBytes(binaryValue.getStream());
  assertThat(actual, is(expectedContent));
}

代码示例来源:origin: ModeShape/modeshape

String str = null;
if (value instanceof Binary) {
  byte[] bytes = IoUtil.readBytes(((Binary)value).getStream());
  str = StringUtil.getHexString(bytes);
} else {

代码示例来源:origin: org.fcrepo/modeshape-jcr

String str = null;
if (value instanceof Binary) {
  byte[] bytes = IoUtil.readBytes(((Binary)value).getStream());
  str = StringUtil.getHexString(bytes);
} else {

代码示例来源:origin: ModeShape/modeshape

try {
  FileOutputStream fos = new FileOutputStream(tempFile);
  InputStream is = storedValue.getStream();
  byte[] buff = new byte[100];
  int available;

代码示例来源:origin: ModeShape/modeshape

try (InputStream stream = binaryValue.getStream()) {
  sequencePowerpoint(sequencedNode, context.valueFactory(), stream);
  return true;
try (InputStream stream = binaryValue.getStream()) {
  sequenceWord(sequencedNode, context.valueFactory(), stream);
  return true;
try (InputStream stream = binaryValue.getStream()) {
  sequenceExcel(sequencedNode, context.valueFactory(), stream);
  return true;

代码示例来源:origin: org.modeshape/modeshape-sequencer-msoffice

try (InputStream stream = binaryValue.getStream()) {
  sequencePowerpoint(sequencedNode, context.valueFactory(), stream);
  return true;
try (InputStream stream = binaryValue.getStream()) {
  sequenceWord(sequencedNode, context.valueFactory(), stream);
  return true;
try (InputStream stream = binaryValue.getStream()) {
  sequenceExcel(sequencedNode, context.valueFactory(), stream);
  return true;

代码示例来源:origin: ModeShape/modeshape

private boolean processBasicMetadata( Node sequencedNode,
                   Binary binaryValue ) {
  VideoMetadata metadata = null;
  try (InputStream stream = binaryValue.getStream()) {
    metadata = new VideoMetadata(stream);
    if (metadata.check()) {
      setPropertyIfMetadataPresent(sequencedNode, DURATION, metadata.getDuration());
      setPropertyIfMetadataPresent(sequencedNode, BITRATE, metadata.getBitrate());
      setPropertyIfMetadataPresent(sequencedNode, TITLE, metadata.getTitle());
      setPropertyIfMetadataPresent(sequencedNode, COMMENT, metadata.getComment());
      setPropertyIfMetadataPresent(sequencedNode, ENCODER, metadata.getEncoder());
      int suffix = 0;
      for (StreamMetadata streamMetadata : metadata.getStreams()) {
        Node streamNode = sequencedNode.addNode(STREAM_NODE + String.valueOf(suffix), STREAM_NODE);
        processStreamMetadata(streamNode, streamMetadata);
        suffix += 1;
      }
      return true;
    }
  } catch (Exception e) {
    getLogger().error(e, "Couldn't process the stream.");
  }
  return false;
}

代码示例来源:origin: ModeShape/modeshape

protected Binary storeAndCheck( int contentIndex,
                Class<? extends Binary> valueClass ) throws Exception {
  String content = CONTENT[contentIndex];
  String sha1 = CONTENT_HASHES[contentIndex];
  InputStream stream = new ByteArrayInputStream(content.getBytes());
  Stopwatch sw = new Stopwatch();
  sw.start();
  Binary binary = store.storeValue(stream, false);
  sw.stop();
  if (print) System.out.println("Time to store 18MB file: " + sw.getTotalDuration());
  if (valueClass != null) {
    assertThat(binary, is(instanceOf(valueClass)));
  }
  if (content.length() == 0) {
    assertThat(binary, is(instanceOf(EmptyBinaryValue.class)));
  } else if (content.length() < MIN_BINARY_SIZE) {
    assertThat(binary, is(instanceOf(InMemoryBinaryValue.class)));
  } else {
    assertThat(binary, is(instanceOf(StoredBinaryValue.class)));
  }
  assertThat(binary.getHexHash(), is(sha1));
  String binaryContent = IoUtil.read(binary.getStream());
  assertThat(binaryContent, is(content));
  return binary;
}

代码示例来源:origin: ModeShape/modeshape

InputStream stream = binary.getStream();
String content = IoUtil.read(stream);
assertThat(content.length() != 0, is(true));

代码示例来源:origin: ModeShape/modeshape

InputStream actual = binary.getStream();
byte[] buffer1 = new byte[1024];
byte[] buffer2 = new byte[1024];

代码示例来源:origin: ModeShape/modeshape

boolean isValid = false;
AudioMetadata metadata = null;
try (InputStream stream = binaryValue.getStream()) {
  metadata = new AudioMetadata(stream, mimeType);
  isValid = metadata.check();

代码示例来源:origin: ModeShape/modeshape

private boolean processBasicMetadata( Node sequencedNode,
                   Binary binaryValue ) {
  EpubMetadata metadata = null;
  try (InputStream stream = binaryValue.getStream()) {
    metadata = new EpubMetadata(stream);
    if (metadata.check()) {
      addEpubMetadataProperties(sequencedNode, EpubMetadataLexicon.TITLE, metadata.getTitle());
      addEpubMetadataProperties(sequencedNode, EpubMetadataLexicon.CREATOR, metadata.getCreator());
      addEpubMetadataProperties(sequencedNode, EpubMetadataLexicon.CONTRIBUTOR, metadata.getContributor());
      addEpubMetadataProperties(sequencedNode, EpubMetadataLexicon.LANGUAGE, metadata.getLanguage());
      addEpubMetadataProperties(sequencedNode, EpubMetadataLexicon.IDENTIFIER, metadata.getIdentifier());
      addEpubMetadataProperties(sequencedNode, EpubMetadataLexicon.DESCRIPTION, metadata.getDescription());
      addEpubMetadataProperties(sequencedNode, EpubMetadataLexicon.PUBLISHER, metadata.getPublisher());
      addEpubMetadataProperties(sequencedNode, EpubMetadataLexicon.DATE, metadata.getDate());
      addEpubMetadataProperties(sequencedNode, EpubMetadataLexicon.RIGHTS, metadata.getRights());
      return true;
    }
  } catch (Exception e) {
    getLogger().error(e, "Couldn't process stream.");
  }
  return false;
}

代码示例来源:origin: ModeShape/modeshape

private boolean processBasicMetadata( Node sequencedNode,
                   Binary binaryValue ) {
  OdfMetadata metadata = null;
  try (InputStream stream = binaryValue.getStream()) {
    metadata = new OdfMetadata(stream);
    if (metadata.check()) {
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.PAGES, metadata.getPages());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.SHEETS, metadata.getSheets());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.CREATION_DATE, metadata.getCreationDate());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.CREATOR, metadata.getCreator());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.DESCRIPTION, metadata.getDescription());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.EDITING_CYCLES, metadata.getEditingCycles());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.EDITING_TIME, metadata.getEditingTime());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.GENERATOR, metadata.getGenerator());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.INITIAL_CREATOR, metadata.getInitialCreator());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.KEYWORDS, metadata.getKeywords());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.LANGUAGE, metadata.getLanguage());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.MODIFICATION_DATE, metadata.getModificationDate());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.PRINTED_BY, metadata.getPrintedBy());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.PRINT_DATE, metadata.getPrintDate());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.SUBJECT, metadata.getSubject());
      setPropertyIfMetadataPresent(sequencedNode, OdfMetadataLexicon.TITLE, metadata.getTitle());
      return true;
    }
  } catch (Exception e) {
    getLogger().error(e, "Couldn't process stream.");
  }
  return false;
}

相关文章