akka.stream.javadsl.Source.asScala()方法的使用及代码示例

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

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

Source.asScala介绍

暂无

代码示例

代码示例来源:origin: com.typesafe.play/play

@Override
  public play.api.http.HttpEntity asScala() {
    return new play.api.http.HttpEntity.Chunked(chunks.asScala(), OptionConverters.toScala(contentType));
  }
}

代码示例来源:origin: com.typesafe.play/play_2.11

@Override
  public play.api.http.HttpEntity asScala() {
    return new play.api.http.HttpEntity.Chunked(chunks.asScala(), OptionConverters.toScala(contentType));
  }
}

代码示例来源:origin: com.typesafe.play/play_2.12

@Override
  public play.api.http.HttpEntity asScala() {
    return new play.api.http.HttpEntity.Chunked(chunks.asScala(), OptionConverters.toScala(contentType));
  }
}

代码示例来源:origin: com.typesafe.play/play_2.11

@Override
  @SuppressWarnings("unchecked")
  public play.api.http.HttpEntity asScala() {
    return new play.api.http.HttpEntity.Streamed(data.asScala(),
        /* scala Option[Long] produces a Java generic signature of Option<Object>, so we need to do an
          unchecked cast here to get it to typecheck */
        (scala.Option) OptionConverters.toScala(contentLength),
        OptionConverters.toScala(contentType));
  }
}

代码示例来源:origin: com.typesafe.play/play_2.12

@Override
  @SuppressWarnings("unchecked")
  public play.api.http.HttpEntity asScala() {
    return new play.api.http.HttpEntity.Streamed(data.asScala(),
        /* scala Option[Long] produces a Java generic signature of Option<Object>, so we need to do an
          unchecked cast here to get it to typecheck */
        (scala.Option) OptionConverters.toScala(contentLength),
        OptionConverters.toScala(contentType));
  }
}

代码示例来源:origin: com.typesafe.play/play

@Override
  @SuppressWarnings("unchecked")
  public play.api.http.HttpEntity asScala() {
    return new play.api.http.HttpEntity.Streamed(data.asScala(),
        /* scala Option[Long] produces a Java generic signature of Option<Object>, so we need to do an
          unchecked cast here to get it to typecheck */
        (scala.Option) OptionConverters.toScala(contentLength),
        OptionConverters.toScala(contentType));
  }
}

代码示例来源:origin: com.typesafe.play/play_2.11

public static Source<ByteString, ?> transform(Source<? super Http.MultipartFormData.Part<Source<ByteString, ?>>, ?> parts, String boundary) {
  Source<MultipartFormData.Part<akka.stream.scaladsl.Source<ByteString, ?>>, ?> source = parts.map((part) -> {
    if (part instanceof Http.MultipartFormData.DataPart) {
      Http.MultipartFormData.DataPart dp = (Http.MultipartFormData.DataPart) part;
      return (MultipartFormData.Part) new MultipartFormData.DataPart(dp.getKey(), dp.getValue());
    } else if (part instanceof Http.MultipartFormData.FilePart) {
      Http.MultipartFormData.FilePart fp = (Http.MultipartFormData.FilePart) part;
      if (fp.ref instanceof Source) {
        Source ref = (Source) fp.ref;
        Option<String> ct = Option.apply(fp.getContentType());
        return (MultipartFormData.Part)new MultipartFormData.FilePart<akka.stream.scaladsl.Source<ByteString, ?>>(fp.getKey(), fp.getFilename(), ct, ref.asScala(), fp.getFileSize(), fp.getDispositionType());
      }
    }
    throw new UnsupportedOperationException("Unsupported Part Class");
  });
  return source.via(Multipart.format(boundary, Charset.defaultCharset(), 4096));
}

代码示例来源:origin: com.typesafe.play/play

public static Source<ByteString, ?> transform(Source<? super Http.MultipartFormData.Part<Source<ByteString, ?>>, ?> parts, String boundary) {
  Source<MultipartFormData.Part<akka.stream.scaladsl.Source<ByteString, ?>>, ?> source = parts.map((part) -> {
    if (part instanceof Http.MultipartFormData.DataPart) {
      Http.MultipartFormData.DataPart dp = (Http.MultipartFormData.DataPart) part;
      return (MultipartFormData.Part) new MultipartFormData.DataPart(dp.getKey(), dp.getValue());
    } else if (part instanceof Http.MultipartFormData.FilePart) {
      Http.MultipartFormData.FilePart fp = (Http.MultipartFormData.FilePart) part;
      if (fp.ref instanceof Source) {
        Source ref = (Source) fp.ref;
        Option<String> ct = Option.apply(fp.getContentType());
        return (MultipartFormData.Part)new MultipartFormData.FilePart<akka.stream.scaladsl.Source<ByteString, ?>>(fp.getKey(), fp.getFilename(), ct, ref.asScala(), fp.getFileSize(), fp.getDispositionType());
      }
    }
    throw new UnsupportedOperationException("Unsupported Part Class");
  });
  return source.via(Multipart.format(boundary, Charset.defaultCharset(), 4096));
}

代码示例来源:origin: com.typesafe.play/play_2.12

public static Source<ByteString, ?> transform(Source<? super Http.MultipartFormData.Part<Source<ByteString, ?>>, ?> parts, String boundary) {
  Source<MultipartFormData.Part<akka.stream.scaladsl.Source<ByteString, ?>>, ?> source = parts.map((part) -> {
    if (part instanceof Http.MultipartFormData.DataPart) {
      Http.MultipartFormData.DataPart dp = (Http.MultipartFormData.DataPart) part;
      return (MultipartFormData.Part) new MultipartFormData.DataPart(dp.getKey(), dp.getValue());
    } else if (part instanceof Http.MultipartFormData.FilePart) {
      Http.MultipartFormData.FilePart fp = (Http.MultipartFormData.FilePart) part;
      if (fp.ref instanceof Source) {
        Source ref = (Source) fp.ref;
        Option<String> ct = Option.apply(fp.getContentType());
        return (MultipartFormData.Part)new MultipartFormData.FilePart<akka.stream.scaladsl.Source<ByteString, ?>>(fp.getKey(), fp.getFilename(), ct, ref.asScala(), fp.getFileSize(), fp.getDispositionType());
      }
    }
    throw new UnsupportedOperationException("Unsupported Part Class");
  });
  return source.via(Multipart.format(boundary, Charset.defaultCharset(), 4096));
}

代码示例来源:origin: com.typesafe.akka/akka-http-core_2.12

private static akka.stream.scaladsl.Source<ByteString,Object> toScala(Source<ByteString, ?> javaSource) {
    return (akka.stream.scaladsl.Source<ByteString,Object>)javaSource.asScala();
  }
}

代码示例来源:origin: com.typesafe.akka/akka-http-core

private static akka.stream.scaladsl.Source<ByteString,Object> toScala(Source<ByteString, ?> javaSource) {
    return (akka.stream.scaladsl.Source<ByteString,Object>)javaSource.asScala();
  }
}

代码示例来源:origin: com.typesafe.akka/akka-http-core_2.11

private static akka.stream.scaladsl.Source<ByteString,Object> toScala(Source<ByteString, ?> javaSource) {
    return (akka.stream.scaladsl.Source<ByteString,Object>)javaSource.asScala();
  }
}

代码示例来源:origin: com.typesafe.akka/akka-http-core_2.11

/**
 * Constructor for `multipart/form-data` content as defined in http://tools.ietf.org/html/rfc2388.
 * All parts must have distinct names. (This is not verified!)
 */
public static Multipart.FormData createFormDataFromSourceParts(Source<Multipart.FormData.BodyPart, ? extends Object> parts) {
  return akka.http.scaladsl.model.Multipart.FormData$.MODULE$.createSource(parts.asScala());
}

代码示例来源:origin: com.typesafe.akka/akka-http-core-experimental

public static HttpEntity.Chunked createChunked(ContentType contentType, Source<ByteString, Object> data) {
    return akka.http.scaladsl.model.HttpEntity.Chunked$.MODULE$.fromData(
        (akka.http.scaladsl.model.ContentType) contentType,
        data.asScala());
  }
}

代码示例来源:origin: com.typesafe.akka/akka-http-core

/**
 * Constructor for `multipart/form-data` content as defined in http://tools.ietf.org/html/rfc2388.
 * All parts must have distinct names. (This is not verified!)
 */
public static Multipart.FormData createFormDataFromSourceParts(Source<Multipart.FormData.BodyPart, ? extends Object> parts) {
  return akka.http.scaladsl.model.Multipart.FormData$.MODULE$.createSource(parts.asScala());
}

代码示例来源:origin: com.typesafe.akka/akka-http-core_2.12

/**
 * Constructor for `multipart/form-data` content as defined in http://tools.ietf.org/html/rfc2388.
 * All parts must have distinct names. (This is not verified!)
 */
public static Multipart.FormData createFormDataFromSourceParts(Source<Multipart.FormData.BodyPart, ? extends Object> parts) {
  return akka.http.scaladsl.model.Multipart.FormData$.MODULE$.createSource(parts.asScala());
}

代码示例来源:origin: com.typesafe.akka/akka-http-core-experimental

public static HttpEntity.Chunked create(ContentType contentType, Source<ByteString, Object> data) {
  return HttpEntity.Chunked$.MODULE$.fromData((akka.http.scaladsl.model.ContentType) contentType, data.asScala());
}

代码示例来源:origin: com.typesafe.akka/akka-http-core-experimental

public static HttpEntity.CloseDelimited createCloseDelimited(ContentType contentType, Source<ByteString, Object> data) {
  return new akka.http.scaladsl.model.HttpEntity.CloseDelimited((akka.http.scaladsl.model.ContentType) contentType, data.asScala());
}

代码示例来源:origin: com.typesafe.akka/akka-http-core-experimental

public static HttpEntity.IndefiniteLength createIndefiniteLength(ContentType contentType, Source<ByteString, Object> data) {
  return new akka.http.scaladsl.model.HttpEntity.IndefiniteLength((akka.http.scaladsl.model.ContentType) contentType, data.asScala());
}

代码示例来源:origin: com.typesafe.akka/akka-http-core-experimental

public static HttpEntity.Default create(ContentType contentType, long contentLength, Source<ByteString, Object> data) {
  return new akka.http.scaladsl.model.HttpEntity.Default((akka.http.scaladsl.model.ContentType) contentType, contentLength, data.asScala());
}

相关文章