当前位置: 首页>>代码示例>>Java>>正文


Java Page类代码示例

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


Page类属于com.google.api.gax.paging包,在下文中一共展示了Page类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tearDownClass

import com.google.api.gax.paging.Page; //导入依赖的package包/类
@AfterClass
public static void tearDownClass() {
  // Clear the datastore
  Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
  Batch batch = datastore.newBatch();
  StructuredQuery<Key> query = Query.newKeyQueryBuilder()
      .setKind("Book3").build();
  for (QueryResults<Key> keys = datastore.run(query); keys.hasNext(); ) {
    batch.delete(keys.next());
  }
  batch.submit();

  // Delete any objects in the bucket
  Storage storage = StorageOptions.getDefaultInstance().getService();
  Page<Blob> blobs = storage.list(System.getProperty("bookshelf.bucket"));
  List<BlobId> blobIds = new ArrayList<BlobId>();
  for (Blob b : blobs.iterateAll()) {
    blobIds.add(b.getBlobId());
  }
  storage.delete(blobIds);

  service.stop();
}
 
开发者ID:GoogleCloudPlatform,项目名称:getting-started-java,代码行数:24,代码来源:UserJourneyTestIT.java

示例2: tearDownClass

import com.google.api.gax.paging.Page; //导入依赖的package包/类
@AfterClass
public static void tearDownClass() {
  // Delete any objects in the bucket
  Storage storage = StorageOptions.getDefaultInstance().getService();
  Page<Blob> blobs = storage.list(System.getProperty("bookshelf.bucket"));
  List<BlobId> blobIds = new ArrayList<BlobId>();
  for (Blob b : blobs.iterateAll()) {
    blobIds.add(b.getBlobId());
  }
  storage.delete(blobIds);

  // Clear the datastore if we're not using the local emulator
  if (!LOCAL_TEST) {
    Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
    Batch batch = datastore.newBatch();
    StructuredQuery<Key> query = Query.newKeyQueryBuilder()
        .setKind("Book3").build();
    for (QueryResults<Key> keys = datastore.run(query); keys.hasNext(); ) {
      batch.delete(keys.next());
    }
    batch.submit();
  }

  service.stop();
}
 
开发者ID:GoogleCloudPlatform,项目名称:getting-started-java,代码行数:26,代码来源:UserJourneyTestIT.java

示例3: main

import com.google.api.gax.paging.Page; //导入依赖的package包/类
/** Expects an existing Stackdriver log name as an argument. */
public static void main(String... args) throws Exception {
  // [START listlogs]
  // Instantiates a client
  LoggingOptions options = LoggingOptions.getDefaultInstance();

  String logName = args[0];

  try (Logging logging = options.getService()) {

    String logFilter = "logName=projects/" + options.getProjectId() + "/logs/" + logName;

    // List all log entries
    Page<LogEntry> entries = logging.listLogEntries(
        EntryListOption.filter(logFilter));
    do {
      for (LogEntry logEntry : entries.iterateAll()) {
        System.out.println(logEntry);
      }
      entries = entries.getNextPage();
    } while (entries != null);

  }
  // [END listlogs]
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:26,代码来源:ListLogs.java

示例4: setupVirtualFileWithBucketMocks

import com.google.api.gax.paging.Page; //导入依赖的package包/类
static GcsBucketVirtualFile setupVirtualFileWithBucketMocks(
    GcsBucketVirtualFile gcsBucketVirtualFile) {
  Bucket bucket = mock(Bucket.class);
  Page<Blob> page = mock(Page.class);
  Iterable<Blob> blobIterable = mock(Iterable.class);
  Iterator<Blob> blobIterator = mock(Iterator.class);

  when(gcsBucketVirtualFile.getBucket()).thenReturn(bucket);
  when(bucket.list()).thenReturn(page);
  when(bucket.list(any(BlobListOption.class), any(BlobListOption.class))).thenReturn(page);
  when(page.iterateAll()).thenReturn(blobIterable);
  when(blobIterable.iterator()).thenReturn(blobIterator);

  return gcsBucketVirtualFile;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:16,代码来源:GcsTestUtils.java

示例5: getScripts

import com.google.api.gax.paging.Page; //导入依赖的package包/类
/**
 * Gives the raw JS Scripts sepcified
 * @return list of raw JS Script data as strings
 */
public List<String> getScripts() {
  if (Strings.isNullOrEmpty(gcsJSPath())) {
    return new ArrayList<>();
  }

  String bucketName = gcsJSPath().replace("gs://", "").split("/")[0];
  String prefixPath = gcsJSPath().replace("gs://" + bucketName + "/", "");

  Bucket bucket = getStorageService().get(bucketName);
  if (bucket == null || !bucket.exists()) {
    throw new IllegalArgumentException(
        "Bucket does not exist, or do not have adequate permissions");
  }

  ArrayList<String> filePaths = new ArrayList<>();
  if (prefixPath.endsWith(".js")) {
    filePaths.add(prefixPath);
  } else {
    Page<Blob> blobs = bucket.list(BlobListOption.prefix(prefixPath));
    blobs.iterateAll().forEach((Blob blob) -> {
      if (blob.getName().endsWith(".js")) {
        filePaths.add(blob.getName());
      }
    });
  }

  List<String> scripts = new ArrayList<>();
  for (String filePath : filePaths) {
    Blob b = bucket.get(filePath);
    if (b == null || !b.exists()) {
      throw new IllegalArgumentException(
          "File does not exist, or do not have adequate permissions");
    }
    scripts.add(new String(b.getContent()));
  }

  return scripts;
}
 
开发者ID:cobookman,项目名称:teleport,代码行数:43,代码来源:JSTransform.java

示例6: blobExistsInner

import com.google.api.gax.paging.Page; //导入依赖的package包/类
private static Blob blobExistsInner(URI uri) {
  final String bucketName = uri.getAuthority();
  final String prefix = uri.getPath().startsWith("/") ? uri.getPath().substring(1) : uri.getPath();

  final Page<Blob> list = STORAGE.list(bucketName, prefix(prefix));
  for (final Blob blob : list.iterateAll()) {
    if (blob.getName().equals(prefix)) {
      return blob;
    }
  }

  throw new NotReady();
}
 
开发者ID:spotify,项目名称:flo,代码行数:14,代码来源:GcsTasks.java

示例7: poolForFiles

import com.google.api.gax.paging.Page; //导入依赖的package包/类
private void poolForFiles(long minTimeStamp) {
  Page<Blob> blobs = storage.list(
      gcsOriginConfig.bucketTemplate,
      Storage.BlobListOption.prefix(GcsUtil.normalizePrefix(gcsOriginConfig.commonPrefix))
  );
  blobs.iterateAll().forEach(blob ->  {
    if (isBlobEligible(blob, minTimeStamp)) {
      minMaxPriorityQueue.add(blob);
    }
  });
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:12,代码来源:GoogleCloudStorageSource.java

示例8: listBucket

import com.google.api.gax.paging.Page; //导入依赖的package包/类
public Page<Blob> listBucket(String bucketName, String directory) {
  Bucket bucket = Objects.requireNonNull(storage.get(bucketName, Storage.BucketGetOption.fields()),
          "Please provide bucket name.");
  Page<Blob> blobs = bucket.list(Storage.BlobListOption.prefix(directory));
  return blobs;
}
 
开发者ID:spotify,项目名称:spydra,代码行数:7,代码来源:GcpUtils.java

示例9: setBlobs

import com.google.api.gax.paging.Page; //导入依赖的package包/类
private void setBlobs(Blob... blobs) {
  List<Blob> blobList = Lists.newArrayList(blobs);
  Page<Blob> blobPage = bucketVirtualFile.getBucket().list();
  when(blobPage.iterateAll()).thenReturn(blobList);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:6,代码来源:GcsBucketContentEditorPanelTest.java


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