本文整理汇总了Java中com.google.api.client.util.Strings类的典型用法代码示例。如果您正苦于以下问题:Java Strings类的具体用法?Java Strings怎么用?Java Strings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Strings类属于com.google.api.client.util包,在下文中一共展示了Strings类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: newBaseOperation
import com.google.api.client.util.Strings; //导入依赖的package包/类
private static Operation.Builder newBaseOperation(String logName, int responseCode) {
Operation.Builder res = Operation
.newBuilder()
.setConsumerId("api_key:" + TEST_API_KEY)
.setImportance(Importance.LOW)
.setOperationId(TEST_OPERATION_ID)
.setOperationName(TEST_OPERATION_NAME)
.setEndTime(REALLY_EARLY)
.setStartTime(REALLY_EARLY)
.putLabels(OperationInfo.SCC_USER_AGENT, "ESP")
.putLabels(OperationInfo.SCC_SERVICE_AGENT, KnownLabels.SERVICE_AGENT)
.putLabels(KnownLabels.SCC_PLATFORM.getName(), "Unknown");
if (!Strings.isNullOrEmpty(logName)) {
res.addLogEntries(newTestLogEntry(logName, responseCode));
}
return res;
}
开发者ID:cloudendpoints,项目名称:endpoints-management-java,代码行数:18,代码来源:ReportRequestInfoTest.java
示例2: start
import com.google.api.client.util.Strings; //导入依赖的package包/类
/**
* Starts the server, which will listen to the given path going forward.
* @throws Exception
*/
public void start() throws Exception {
logger.info("Starting API server on {}:{}{}", HOST, port, contextPath);
server = new Server();
server.addListener(String.format("%s:%d", HOST, port));
ServletHttpContext context = (ServletHttpContext) server.getContext(contextPath);
context.addServlet(SERVLET_NAME, SERVLET_PATH, ServletContainer.class.getName());
context.getServletHandler().getServletHolder(SERVLET_NAME)
.setInitParameter(INIT_PARAM_PACKAGES, getClass().getPackage().getName());
if (!Strings.isNullOrEmpty(adsPropertiesPath)) {
context.getServletHandler().getServletHolder(SERVLET_NAME)
.setInitParameter(INIT_PARAM_ADS_PROPERTIES, adsPropertiesPath);
}
if (!Strings.isNullOrEmpty(propertiesPath)) {
context.getServletHandler().getServletHolder(SERVLET_NAME)
.setInitParameter(INIT_PARAM_PROPERTIES, propertiesPath);
}
server.start();
}
开发者ID:googleads,项目名称:keyword-optimizer,代码行数:28,代码来源:ApiServer.java
示例3: checkIssuerAudiences
import com.google.api.client.util.Strings; //导入依赖的package包/类
private static String checkIssuerAudiences(
ApiIssuerConfigs issuerConfigs, ApiIssuerAudienceConfig issuerAudiences) {
if (!issuerAudiences.isEmpty()) {
return null;
}
for (Map.Entry<String, Collection<String>> entry : issuerAudiences.asMap().entrySet()) {
if (!issuerConfigs.hasIssuer(entry.getKey())) {
return "cannot specify audiences for unknown issuer '" + entry.getKey() + "'";
}
for (String audience : entry.getValue()) {
if (Strings.isNullOrEmpty(audience)) {
return "issuer '" + entry.getKey() + "' cannot have null or blank audiences";
}
}
}
return null;
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:18,代码来源:ApiConfigValidator.java
示例4: createContentChunk
import com.google.api.client.util.Strings; //导入依赖的package包/类
static Chunk createContentChunk(
String familyName, String columnQualifier, byte[] value, long timestamp) {
Preconditions.checkArgument(
!Strings.isNullOrEmpty(familyName), "Family name may not be null or empty");
Family.Builder familyBuilder = Family.newBuilder()
.setName(familyName);
if (columnQualifier != null) {
Column.Builder columnBuilder = Column.newBuilder();
columnBuilder.setQualifier(ByteString.copyFromUtf8(columnQualifier));
familyBuilder.addColumns(columnBuilder);
if (value != null) {
Cell.Builder cellBuilder = Cell.newBuilder();
cellBuilder.setTimestampMicros(timestamp);
cellBuilder.setValue(ByteString.copyFrom(value));
columnBuilder.addCells(cellBuilder);
}
}
return Chunk.newBuilder().setRowContents(familyBuilder).build();
}
开发者ID:dmmcerlean,项目名称:cloud-bigtable-client,代码行数:24,代码来源:StreamingBigtableResultScannerTest.java
示例5: retrieveReferenceBases
import com.google.api.client.util.Strings; //导入依赖的package包/类
private String retrieveReferenceBases(Genomics genomics, Annotation annotation) throws IOException {
StringBuilder b = new StringBuilder();
String pageToken = "";
while (true) {
// TODO: Support full request parameterization for Paginator.References.Bases.
ListBasesResponse response = genomics.references().bases()
.list(annotation.getReferenceId())
.setStart(annotation.getStart())
.setEnd(annotation.getEnd())
.setPageToken(pageToken)
.execute();
b.append(response.getSequence());
pageToken = response.getNextPageToken();
if (Strings.isNullOrEmpty(pageToken)) {
break;
}
}
return b.toString();
}
开发者ID:googlegenomics,项目名称:dataflow-java,代码行数:20,代码来源:AnnotateVariants.java
示例6: attemptAuthentication
import com.google.api.client.util.Strings; //导入依赖的package包/类
@Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) {
final String authToken = request.getHeader(TOKEN_HEADER);
if (Strings.isNullOrEmpty(authToken)) {
throw new RuntimeException("Invaild auth token");
}
return getAuthenticationManager().authenticate(new FirebaseAuthenticationToken(authToken));
}
开发者ID:awaters1,项目名称:spring-security-firebase,代码行数:10,代码来源:FirebaseAuthenticationTokenFilter.java
示例7: requireParam
import com.google.api.client.util.Strings; //导入依赖的package包/类
/**
* Tests if a URL parameter is empty and throws an exception if that's the case. Empty here means
* either <code>null</code>, an empty string or and empty list.
*/
private static void requireParam(String name, Object value) throws KeywordOptimizerException {
if (value == null
|| (value instanceof Collection<?> && ((Collection<?>) value).isEmpty())
|| (value instanceof String && Strings.isNullOrEmpty((String) value))) {
throw new KeywordOptimizerException("Parameter '" + name + "' is required");
}
}
开发者ID:googleads,项目名称:keyword-optimizer,代码行数:12,代码来源:OptimizeResource.java
示例8: checkIssuers
import com.google.api.client.util.Strings; //导入依赖的package包/类
private static String checkIssuers(ApiIssuerConfigs issuers) {
if (!issuers.isSpecified()) {
return null;
}
for (IssuerConfig issuer : issuers.asMap().values()) {
if (Strings.isNullOrEmpty(issuer.getName())) {
return "issuer name cannot be blank";
} else if (Strings.isNullOrEmpty(issuer.getIssuer())) {
return "issuer '" + issuer.getName() + "' cannot have a blank issuer value";
}
}
return null;
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:14,代码来源:ApiConfigValidator.java
示例9: adapt
import com.google.api.client.util.Strings; //导入依赖的package包/类
/**
* <p>Adapt a single instance of an HBase {@link HColumnDescriptor} to
* an instance of {@link com.google.bigtable.admin.table.v1.ColumnFamily.Builder}.</p>
*
* <p>NOTE: This method does not set the name of the ColumnFamily.Builder. The assumption is
* that the CreateTableRequest or CreateColumFamilyRequest takes care of the naming. As of now
* (3/11/2015), the server insists on having a blank name.</p>
*/
public ColumnFamily.Builder adapt(HColumnDescriptor columnDescriptor) {
throwIfRequestingUnknownFeatures(columnDescriptor);
throwIfRequestingUnsupportedFeatures(columnDescriptor);
ColumnFamily.Builder resultBuilder = ColumnFamily.newBuilder();
String gcExpression = buildGarbageCollectionExpression(columnDescriptor);
if (!Strings.isNullOrEmpty(gcExpression)) {
resultBuilder.setGcExpression(gcExpression);
}
return resultBuilder;
}
开发者ID:dmmcerlean,项目名称:cloud-bigtable-client,代码行数:20,代码来源:ColumnDescriptorAdapter.java
示例10: AppEngineLocationSelectorItem
import com.google.api.client.util.Strings; //导入依赖的package包/类
public AppEngineLocationSelectorItem(@NotNull Location location) {
this.location = location;
// TODO(alexsloan) when b/33458530 is addressed, we can just use location.getLocationId()
String locationIdLabel =
location.getLabels() != null
? location.getLabels().get("cloud.googleapis.com/region")
: null;
if (Strings.isNullOrEmpty(location.getLocationId())
&& !Strings.isNullOrEmpty(locationIdLabel)) {
location.setLocationId(locationIdLabel);
}
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:14,代码来源:AppEngineLocationSelectorItem.java
示例11: processElement
import com.google.api.client.util.Strings; //导入依赖的package包/类
@ProcessElement
public void processElement(DoFn<String, String>.ProcessContext c) throws Exception {
String readGroupSetId = c.element();
String referenceSetId = GenomicsUtils.getReferenceSetId(readGroupSetId, auth);
if (Strings.isNullOrEmpty(referenceSetId)) {
throw new IllegalArgumentException("No ReferenceSetId associated with ReadGroupSetId "
+ readGroupSetId
+ ". All ReadGroupSets in given input must have an associated ReferenceSet.");
}
if (!referenceSetIdForAllReadGroupSets.equals(referenceSetId)) {
throw new IllegalArgumentException("ReadGroupSets in given input must all be associated with"
+ " the same ReferenceSetId : " + referenceSetId);
}
c.output(readGroupSetId);
}
开发者ID:googlegenomics,项目名称:dataflow-java,代码行数:16,代码来源:CalculateCoverage.java
示例12: getStrictVariantPredicate
import com.google.api.client.util.Strings; //导入依赖的package包/类
/**
* Predicate expressing the logic for which variants should and should not be included in the shard.
*
* @param start The start position of the shard.
* @return Whether the variant would be included in a strict shard boundary.
*/
public static Predicate<Variant> getStrictVariantPredicate(final long start, String fields) {
Preconditions
.checkArgument(Strings.isNullOrEmpty(fields)
|| VARIANT_FIELD_PATTERN.matcher(fields).matches(),
"Insufficient fields requested in partial response. At a minimum "
+ "include 'variants(start)' to enforce a strict shard boundary.");
return new Predicate<Variant>() {
@Override
public boolean apply(Variant variant) {
return variant.getStart() >= start;
}
};
}
开发者ID:googlegenomics,项目名称:utils-java,代码行数:20,代码来源:ShardBoundary.java
示例13: getStrictReadPredicate
import com.google.api.client.util.Strings; //导入依赖的package包/类
/**
* Predicate expressing the logic for which reads should and should not be included in the shard.
*
* @param start The start position of the shard.
* @return Whether the read would be included in a strict shard boundary.
*/
public static Predicate<Read> getStrictReadPredicate(final long start, final String fields) {
Preconditions
.checkArgument(Strings.isNullOrEmpty(fields)
|| READ_FIELD_PATTERN.matcher(fields).matches(),
"Insufficient fields requested in partial response. At a minimum "
+ "include 'alignments(alignment)' to enforce a strict shard boundary.");
return new Predicate<Read>() {
@Override
public boolean apply(Read read) {
return read.getAlignment().getPosition().getPosition() >= start;
}
};
}
开发者ID:googlegenomics,项目名称:utils-java,代码行数:20,代码来源:ShardBoundary.java
示例14: BigtableOptions
import com.google.api.client.util.Strings; //导入依赖的package包/类
private BigtableOptions(
InetAddress clusterAdminHost,
InetAddress adminHost,
InetAddress host,
int port,
Credentials credential,
String projectId,
String zone,
String cluster,
boolean retriesEnabled,
boolean retryOnDeadlineExceeded,
String callTimingReportPath,
String callStatusReportPath,
ScheduledExecutorService rpcRetryExecutorService,
EventLoopGroup customEventLoopGroup,
int channelCount,
long timeoutMs) {
Preconditions.checkArgument(
!Strings.isNullOrEmpty(projectId), "ProjectId must not be empty or null.");
Preconditions.checkArgument(
!Strings.isNullOrEmpty(zone), "Zone must not be empty or null.");
Preconditions.checkArgument(
!Strings.isNullOrEmpty(cluster), "Cluster must not be empty or null.");
this.adminHost = Preconditions.checkNotNull(adminHost);
this.clusterAdminHost = clusterAdminHost;
this.host = Preconditions.checkNotNull(host);
this.port = port;
this.credential = credential;
this.projectId = projectId;
this.retriesEnabled = retriesEnabled;
this.retryOnDeadlineExceeded = retryOnDeadlineExceeded;
this.callTimingReportPath = callTimingReportPath;
this.callStatusReportPath = callStatusReportPath;
this.zone = zone;
this.cluster = cluster;
this.rpcRetryExecutorService = rpcRetryExecutorService;
this.customEventLoopGroup = customEventLoopGroup;
this.channelCount = channelCount;
this.timeoutMs = timeoutMs;
LOG.debug("Connection Configuration: project: %s, cluster: %s, host:port %s:%s, "
+ "admin host:port %s:%s, using transport %s.",
getProjectId(),
cluster,
host,
port,
adminHost,
port,
TransportOptions.BigtableTransports.HTTP2_NETTY_TLS);
if (clusterAdminHost != null) {
LOG.debug("Cluster API host: %s" , clusterAdminHost);
}
}
开发者ID:dmmcerlean,项目名称:cloud-bigtable-client,代码行数:54,代码来源:BigtableOptions.java
示例15: filter
import com.google.api.client.util.Strings; //导入依赖的package包/类
/**
* Matches Google Cloud Storage's delimiter filtering.
*
* @param items the mutable list of items to filter. Items matching the filter conditions will be
* removed from this list.
* @param bucketName the bucket name to filter for.
* @param prefix the object name prefix to filter for.
* @param delimiter the delimiter to filter on.
*/
private void filter(
List<GoogleCloudStorageItemInfo> items,
String bucketName,
@Nullable String prefix,
@Nullable String delimiter) {
prefix = prefix == null ? "" : prefix;
if (Strings.isNullOrEmpty(delimiter)) {
return;
}
HashSet<String> dirs = new HashSet<String>();
Iterator<GoogleCloudStorageItemInfo> itr = items.iterator();
while (itr.hasNext()) {
String objectName = itr.next().getObjectName();
// Remove if doesn't start with the prefix.
if (!objectName.startsWith(prefix)) {
itr.remove();
} else {
// Retain if missing the delimiter after the prefix.
int firstIndex = objectName.indexOf(delimiter, prefix.length());
if (firstIndex != -1) {
// Remove if the first occurrence of the delimiter after the prefix isn't the last.
// Remove if the last occurrence of the delimiter isn't the end of the string.
int lastIndex = objectName.lastIndexOf(delimiter);
if (firstIndex != lastIndex) {
itr.remove();
dirs.add(objectName.substring(0, firstIndex + 1));
} else if (lastIndex != objectName.length() - 1) {
itr.remove();
dirs.add(objectName.substring(0, firstIndex + 1));
}
}
}
}
if (inferImplicitDirectoriesEnabled) {
for (String dir : dirs) {
items.add(
GoogleCloudStorageImpl.createItemInfoForInferredDirectory(
new StorageResourceId(bucketName, dir)));
}
}
}
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:53,代码来源:PerformanceCachingGoogleCloudStorage.java
示例16: hasPermission
import com.google.api.client.util.Strings; //导入依赖的package包/类
@PreAuthorize("hasRole('ROLE_ADMIN') or hasPermission(#groupCode, 'users_create')")
@RequestMapping(value = "/{groupCode}/users", method = RequestMethod.POST)
public List<CreateUsersView> createUsers(@PathVariable("groupCode") String groupCode,
@RequestParam(value = "preview", required = false) Boolean preview,
@RequestBody String usersInfo) throws FormException {
final ArrayList<CreateUsersView> usersViews = new ArrayList<>();
final ArrayList<String> wrongLines = new ArrayList<>();
for (final String line : usersInfo.split("\\r?\\n")) {
final CreateUsersView teamView = new CreateUsersView();
for (final String part : line.split("(?<=[^\\\\]);")) {
String cleanPart = part.trim().replaceAll("\\\\;", ";");
if (cleanPart.startsWith("@TAG:")) {
final String tags = cleanPart.replace("@TAG:", "").trim();
teamView.getTags().addAll(Arrays.asList(tags.split(" +")));
} else if (Strings.isNullOrEmpty(teamView.getName())) {
teamView.setName(cleanPart);
} else {
teamView.getUsers().add(cleanPart);
}
}
if (Strings.isNullOrEmpty(teamView.getName()) || teamView.getUsers().isEmpty()) {
wrongLines.add(line);
} else {
final int lastIndex = teamView.getUsers().size() - 1;
teamView.setCode(teamPrefix + teamView.getUsers().get(lastIndex));
teamView.getUsers().remove(lastIndex);
usersViews.add(teamView);
}
}
if (!wrongLines.isEmpty()) {
throw new FormException().addError("usersdata", wrongLines.stream().collect(Collectors.joining("\n")));
}
if (preview == null || !preview) {
return groupsDao.createUsersForGroup(groupCode, usersViews);
}
return usersViews;
}
开发者ID:kTT,项目名称:adjule,代码行数:46,代码来源:GroupsEndpoint.java
注:本文中的com.google.api.client.util.Strings类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论