org.apache.commons.lang3.StringUtils#EMPTY源码实例Demo

下面列出了org.apache.commons.lang3.StringUtils#EMPTY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: azure-cosmosdb-java   文件: SessionContainer.java
public String resolveGlobalSessionToken(RxDocumentServiceRequest request) {
    ConcurrentHashMap<String, ISessionToken> partitionKeyRangeIdToTokenMap = this.getPartitionKeyRangeIdToTokenMap(request);
    if (partitionKeyRangeIdToTokenMap != null) {
        return SessionContainer.getCombinedSessionToken(partitionKeyRangeIdToTokenMap);
    }

    return StringUtils.EMPTY;
}
 
源代码2 项目: vjtools   文件: ExceptionUtil.java
/**
 * 拼装 短异常类名: 异常信息 <-- RootCause的短异常类名: 异常信息
 */
public static String toStringWithRootCause(@Nullable Throwable t) {
	if (t == null) {
		return StringUtils.EMPTY;
	}

	final String clsName = ClassUtils.getShortClassName(t, null);
	final String message = StringUtils.defaultString(t.getMessage());
	Throwable cause = getRootCause(t);

	StringBuilder sb = new StringBuilder(128).append(clsName).append(": ").append(message);
	if (cause != t) {
		sb.append("; <---").append(toStringWithShortName(cause));
	}

	return sb.toString();
}
 
源代码3 项目: jackdaw   文件: JPredicateCodeGenerator.java
private CodeBlock createInitializer(
    final JPredicateType type, final boolean reverse, final boolean nullable,
    final TypeName predicateTypeName, final Element element, final TypeElement typeElement
) {
    final String operation = reverse ? "!" : StringUtils.EMPTY;
    final String caller = ModelUtils.getCaller(element);
    final String nullableGuard = nullable ? "input != null && " : StringUtils.EMPTY;

    switch (type) {
        case JAVA:
        case GUAVA:
            return CodeBlock.builder().add(
                SourceTextUtils.lines(
                    "new $T() {",
                        "@Override",
                        "public boolean apply(final $T input) {",
                            "return " + nullableGuard + operation + "input.$L;",
                        "}",
                    "}"
                ),
                predicateTypeName, typeElement, caller
            ).build();
        case COMMONS:
            return CodeBlock.builder().add(
                SourceTextUtils.lines(
                    "new $T() {",
                        "@Override",
                        "public boolean evaluate(final $T input) {",
                            "return " + nullableGuard + operation + "(($T) input).$L;",
                        "}",
                    "}"
                ),
                predicateTypeName, Object.class, typeElement, caller
            ).build();
        default:
            throw new UnsupportedOperationException();
    }
}
 
源代码4 项目: openemm   文件: PatternScheduleBuilderService.java
@Override
public List<TimeScheduledEntry> parse(String parameter) {
    if (parameter == null) {
        return Collections.emptyList();
    }

    Map<String, TimeScheduledEntry> entries = new HashMap<>();

    for (String value : parameter.split(SEMICOLON)) {
        String day, scheduledTime;

        String[] dayTime = value.split(COLON);
        if (dayTime.length == 2) {
            day = dayTime[0];
            scheduledTime = formatTime(dayTime[1], toFormat, fromFormat);
        } else {
            day = StringUtils.EMPTY;
            scheduledTime = formatTime(dayTime[0], toFormat, fromFormat);
        }

        TimeScheduledEntry entry = entries.get(day);
        if (entry == null) {
            entry = toTimeScheduledEntry(reverseWeekDays.get(day), scheduledTime);
            entries.put(day, entry);
        } else {
            List<ScheduledTime> times = entry.getScheduledTime();
            ScheduledTime time = new ScheduledTime();
            time.setTime(scheduledTime);
            time.setActive(true);
            times.add(time);
        }

        entry.setScheduledInterval(new ScheduledInterval(1));
    }

    return new ArrayList<>(entries.values());
}
 
源代码5 项目: olingo-odata4   文件: Demo.java
@PUT
@Produces({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM })
@Path("/{entitySetName}({entityId})/$value")
@Override
public Response replaceMediaEntity(
    @Context final UriInfo uriInfo,
    @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
    @PathParam("entitySetName") final String entitySetName,
    @PathParam("entityId") final String entityId,
    final String value) {

  return super.replaceMediaEntity(uriInfo, prefer, entitySetName, entityId, value);
}
 
源代码6 项目: olingo-odata4   文件: Services.java
@GET
@Path("/ComputerDetail({entityId})")
public Response getComputerDetail(
    @Context final UriInfo uriInfo,
    @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
    @PathParam("entityId") final String entityId,
    @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {

  final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);

  final Response internal = getEntityInternal(
      uriInfo.getRequestUri().toASCIIString(), accept, "ComputerDetail", entityId, format, null, null);
  if (internal.getStatus() == 200) {
    InputStream entity = (InputStream) internal.getEntity();
    try {
      if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) {
        entity = utils.getValue().addOperation(entity,
            "ResetComputerDetailsSpecifications", "#DefaultContainer.ResetComputerDetailsSpecifications",
            uriInfo.getAbsolutePath().toASCIIString() + "/ResetComputerDetailsSpecifications");
      }

      return utils.getValue().createResponse(
          uriInfo.getRequestUri().toASCIIString(),
          entity,
          internal.getHeaderString("ETag"),
          utils.getKey());
    } catch (Exception e) {
      LOG.error("Error retrieving entity", e);
      return xml.createFaultResponse(accept, e);
    }
  } else {
    return internal;
  }
}
 
源代码7 项目: zeppelin   文件: ZeppelinhubRestApiHandler.java
private String sendToZeppelinHubWithoutResponseBody(Request request) throws IOException {
  request.send(new Response.CompleteListener() {
    @Override
    public void onComplete(Result result) {
      Request req = result.getRequest();
      LOG.info("ZeppelinHub {} {} returned with status {}: {}", req.getMethod(),
          req.getURI(), result.getResponse().getStatus(), result.getResponse().getReason());
    }
  });
  return StringUtils.EMPTY;
}
 
源代码8 项目: ja-micro   文件: RpcCallException.java
private static String getMessage(JsonObject object) {
    String message = StringUtils.EMPTY;
    if (object.has(MESSAGE)) {
        message = object.get(MESSAGE).getAsString();
    } else if (object.has(DETAIL)) {
        message = object.get(DETAIL).getAsString();
    }
    return message;
}
 
/**
 * {@inheritDoc} This implementation creates an XPATH expression that
 * selects the given node (under the assumption that the passed in parent
 * key is valid). As the {@code nodeKey()} implementation of
 * {@link org.apache.commons.configuration2.tree.DefaultExpressionEngine
 * DefaultExpressionEngine} this method does not return indices for nodes.
 * So all child nodes of a given parent with the same name have the same
 * key.
 */
@Override
public <T> String nodeKey(final T node, final String parentKey, final NodeHandler<T> handler)
{
    if (parentKey == null)
    {
        // name of the root node
        return StringUtils.EMPTY;
    }
    else if (handler.nodeName(node) == null)
    {
        // paranoia check for undefined node names
        return parentKey;
    }

    else
    {
        final StringBuilder buf =
                new StringBuilder(parentKey.length()
                        + handler.nodeName(node).length()
                        + PATH_DELIMITER.length());
        if (parentKey.length() > 0)
        {
            buf.append(parentKey);
            buf.append(PATH_DELIMITER);
        }
        buf.append(handler.nodeName(node));
        return buf.toString();
    }
}
 
源代码10 项目: olingo-odata4   文件: AbstractUtilities.java
public Response createResponse(
    final String location,
    final InputStream entity,
    final String etag,
    final Accept accept,
    final Response.Status status) {

  final Response.ResponseBuilder builder = Response.ok();
  if (StringUtils.isNotBlank(etag)) {
    builder.header("ETag", etag);
  }

  if (status != null) {
    builder.status(status);
  }

  int contentLength = 0;

  String contentTypeEncoding = StringUtils.EMPTY;

  if (entity != null) {
    try {
      final InputStream toBeStreamedBack;

      if (Accept.JSON == accept || Accept.JSON_NOMETA == accept) {
        toBeStreamedBack = Commons.changeFormat(entity, accept);
      } else {
        toBeStreamedBack = entity;
      }

      final ByteArrayOutputStream bos = new ByteArrayOutputStream();
      IOUtils.copy(toBeStreamedBack, bos);
      IOUtils.closeQuietly(toBeStreamedBack);

      contentLength = bos.size();
      builder.entity(new ByteArrayInputStream(bos.toByteArray()));

      contentTypeEncoding = ";odata.streaming=true;charset=utf-8";
    } catch (IOException ioe) {
      LOG.error("Error streaming response entity back", ioe);
    }
  }

  builder.header("Content-Length", contentLength);
  builder.header("Content-Type", (accept == null ? "*/*" : accept.toString()) + contentTypeEncoding);

  if (StringUtils.isNotBlank(location)) {
    builder.header("Location", location);
  }

  return builder.build();
}
 
源代码11 项目: warnings-ng-plugin   文件: SourceDirectory.java
@NonNull
@Override
public String getDisplayName() {
    return StringUtils.EMPTY;
}
 
源代码12 项目: sakai   文件: ImportController.java
@RequestMapping(value = "/importConfirmation")
public String showImportConfirmation(Model model, Map<String, List<String>> importedGroupMap) {
    log.debug("showImportConfirmation() called with {} items to import.", importedGroupMap.entrySet().size());

    Optional<Site> siteOptional = sakaiService.getCurrentSite();
    if (!siteOptional.isPresent()) {
        return GroupManagerConstants.REDIRECT_MAIN_TEMPLATE;
    }

    Site site = siteOptional.get();

    // List of groups of the site, excluding the ones which GROUP_PROP_WSETUP_CREATED property is false.
    List<Group> groupList = (List<Group>) site.getGroups().stream().filter(group -> group.getProperties().getProperty(Group.GROUP_PROP_WSETUP_CREATED) != null && Boolean.valueOf(group.getProperties().getProperty(Group.GROUP_PROP_WSETUP_CREATED)).booleanValue()).collect(Collectors.toList());
    // Variable definition that will be sent to the model
    Map<String, Boolean> importedGroups = new HashMap<String, Boolean>();
    Map<String, String> nonExistingMemberMap = new HashMap<String, String>();
    Map<String, String> nonMemberMap = new HashMap<String, String>();
    Map<String, String> existingMemberMap = new HashMap<String, String>();
    Map<String, String> newMemberMap = new HashMap<String, String>();
    boolean membershipErrors = false;

    //For each entry we must process the members and catalogue them
    for (Entry<String, List<String>> importedGroup : importedGroupMap.entrySet()) {
        StringJoiner nonExistingUsers = new StringJoiner(", ");
        StringJoiner nonMemberUsers = new StringJoiner(", ");
        StringJoiner existingMembers = new StringJoiner(", ");
        StringJoiner newMembers = new StringJoiner(", ");

        String groupTitle = importedGroup.getKey();
        Optional<Group> existingGroupOptional = groupList.stream().filter(g -> groupTitle.equalsIgnoreCase(g.getTitle())).findAny();

        // The UI shows a message if the group already exists.
        importedGroups.put(groupTitle, Boolean.valueOf(existingGroupOptional.isPresent()));
        List<String> importedGroupUsers = importedGroup.getValue();

        //For every imported user, check if exists, if is member of the site, if already a member or is new. 
        for (String userEid : importedGroupUsers) {
            Optional<User> userOptional = sakaiService.getUserByEid(userEid);
            
            // The user doesn't exist in Sakai.
            if (!userOptional.isPresent()) {
                nonExistingUsers.add(userEid);
                membershipErrors = true;
                continue;
            }

            User user = userOptional.get();
            String userDisplayName = String.format("%s (%s)", user.getDisplayName(), user.getEid());

            //The user is not a member of the site.
            if (site.getMember(user.getId()) == null) {
                nonMemberUsers.add(userDisplayName);
                membershipErrors = true;
                continue;
            }

            if (existingGroupOptional.isPresent()) {
                Group existingGroup = existingGroupOptional.get();
                if (existingGroup.getMember(user.getId()) != null) {
                    //The user is already member of the group
                    existingMembers.add(userDisplayName);
                } else {
                    //The user is not member of the group
                    newMembers.add(userDisplayName);
                }
            } else {
                //The group does not exist so the user is new to that group
                newMembers.add(userDisplayName);
            }
        }

        //Add the catalogued users to the maps.
        nonExistingMemberMap.put(groupTitle, nonExistingUsers.toString());
        nonMemberMap.put(groupTitle, nonMemberUsers.toString());
        existingMemberMap.put(groupTitle, existingMembers.toString());
        newMemberMap.put(groupTitle, newMembers.toString());
    }

    //Fill the model
    model.addAttribute("importedGroups", importedGroups);
    model.addAttribute("membershipErrors", membershipErrors);
    model.addAttribute("nonExistingMemberMap", nonExistingMemberMap);
    model.addAttribute("nonMemberMap", nonMemberMap);
    model.addAttribute("existingMemberMap", existingMemberMap);    
    model.addAttribute("newMemberMap", newMemberMap);
    //Serialize as json the group map to send it back to the controller after the confirmation.
    ObjectMapper objectMapper = new ObjectMapper();
    String importedGroupMapJson = StringUtils.EMPTY;
    try {
            importedGroupMapJson = objectMapper.writer().writeValueAsString(importedGroupMap);
    } catch (JsonProcessingException e) {
        log.error("Fatal error serializing the imported group map.", e);
    }
    model.addAttribute("importedGroupMap", importedGroupMapJson);

    return GroupManagerConstants.IMPORT_CONFIRMATION_TEMPLATE;
}
 
源代码13 项目: syncope   文件: AbstractPasswordRuleConf.java
public AbstractPasswordRuleConf() {
    this(StringUtils.EMPTY);
    setName(getClass().getName());
}
 
源代码14 项目: osmanthus   文件: RuleException.java
public RuleException() {
    super(StringUtils.EMPTY);
    this.code = INTERNAL_ERROR_CODE;
    this.msg = StringUtils.EMPTY;

}
 
源代码15 项目: WiFiAnalyzer   文件: InRangePredicateTest.java
private WiFiDetail makeWiFiDetail(int frequency) {
    WiFiSignal wiFiSignal = new WiFiSignal(frequency + 20, frequency, WiFiWidth.MHZ_20, -10, true);
    return new WiFiDetail("SSID", "BSSID", StringUtils.EMPTY, wiFiSignal, WiFiAdditional.EMPTY);
}
 
源代码16 项目: azure-cosmosdb-java   文件: RxDocumentClientImpl.java
public RxDocumentClientImpl(URI serviceEndpoint,
                            String masterKeyOrResourceToken,
                            List<Permission> permissionFeed,
                            ConnectionPolicy connectionPolicy,
                            ConsistencyLevel consistencyLevel,
                            Configs configs) {
    this(serviceEndpoint, masterKeyOrResourceToken, connectionPolicy, consistencyLevel, configs);
    if (permissionFeed != null && permissionFeed.size() > 0) {
        this.resourceTokensMap = new HashMap<>();
        for (Permission permission : permissionFeed) {
            String[] segments = StringUtils.split(permission.getResourceLink(),
                    Constants.Properties.PATH_SEPARATOR.charAt(0));

            if (segments.length <= 0) {
                throw new IllegalArgumentException("resourceLink");
            }

            List<PartitionKeyAndResourceTokenPair> partitionKeyAndResourceTokenPairs = null;
            PathInfo pathInfo = new PathInfo(false, StringUtils.EMPTY, StringUtils.EMPTY, false);
            if (!PathsHelper.tryParsePathSegments(permission.getResourceLink(), pathInfo, null)) {
                throw new IllegalArgumentException(permission.getResourceLink());
            }

            partitionKeyAndResourceTokenPairs = resourceTokensMap.get(pathInfo.resourceIdOrFullName);
            if (partitionKeyAndResourceTokenPairs == null) {
                partitionKeyAndResourceTokenPairs = new ArrayList<>();
                this.resourceTokensMap.put(pathInfo.resourceIdOrFullName, partitionKeyAndResourceTokenPairs);
            }

            PartitionKey partitionKey = permission.getResourcePartitionKey();
            partitionKeyAndResourceTokenPairs.add(new PartitionKeyAndResourceTokenPair(
                    partitionKey != null ? partitionKey.getInternalPartitionKey() : PartitionKeyInternal.Empty,
                    permission.getToken()));
            logger.debug("Initializing resource token map  , with map key [{}] , partition key [{}] and resource token",
                    pathInfo.resourceIdOrFullName, partitionKey != null ? partitionKey.toString() : null, permission.getToken());

        }

        if(this.resourceTokensMap.isEmpty()) {
            throw new IllegalArgumentException("permissionFeed");
        }

        String firstToken = permissionFeed.get(0).getToken();
        if(ResourceTokenAuthorizationHelper.isResourceToken(firstToken)) {
            this.firstResourceTokenFromPermissionFeed = firstToken;
        }
    }
}
 
源代码17 项目: cs-actions   文件: HttpClientTest.java
@Test
public void execute_requestIsValid_success() throws Exception {
    //Arrange
    final String returnResult = "return result";
    final String exception = StringUtils.EMPTY;
    final String statusCode = "status code";
    final String responseHeaders = "response headers";
    final String returnCode = "return code";

    Map<String, String> rawResponse = new HashMap<>();
    rawResponse.put(HttpClientOutputNames.RETURN_RESULT, returnResult);
    rawResponse.put(HttpClientOutputNames.EXCEPTION, exception);
    rawResponse.put(HttpClientOutputNames.STATUS_CODE, statusCode);
    rawResponse.put(HttpClientOutputNames.RESPONSE_HEADERS, responseHeaders);
    rawResponse.put(HttpClientOutputNames.RETURN_CODE, returnCode);
    HttpClientAction httpClientActionMock = PowerMockito.mock(HttpClientAction.class);
    PowerMockito.whenNew(HttpClientAction.class).withAnyArguments().thenReturn(httpClientActionMock);
    when(httpClientActionMock.execute(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(),
            anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(),
            anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(),
            anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(),
            anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(),
            anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(),
            any(SerializableSessionObject.class), any(GlobalSessionObject.class))).thenReturn(rawResponse);

    HttpClientResponse.Builder httpClientResponseBuilderSpy = new HttpClientResponse.Builder();
    httpClientResponseBuilderSpy = PowerMockito.spy(httpClientResponseBuilderSpy);
    when(httpClientResponseBuilderSpy.build()).thenReturn(null);
    PowerMockito.whenNew(HttpClientResponse.Builder.class).withAnyArguments().thenReturn(httpClientResponseBuilderSpy);

    //Act
    HttpClient.execute(httpRequestMock);

    //Assert
    verify(httpClientActionMock).execute(eq(url), eq(tlsVersion), eq(allowedCyphers), eq(authType), eq(preemptiveAuth.toString()),
            eq(username), eq(password), eq(kerberosConfigFile), eq(kerberosLoginConfFile), eq(kerberosSkipPortForLookup),
            eq(proxyHost), eq(proxyPort.toString()), eq(proxyUsername), eq(proxyPassword), eq(trustAllRoots.toString()), eq(x509HostnameVerifier),
            eq(trustKeystore), eq(trustPassword), eq(keystore), eq(keystorePassword), eq(connectTimeout.toString()), eq(socketTimeout.toString()),
            eq(useCookies.toString()), eq(keepAlive.toString()), eq(connectionsMaxPerRoute.toString()), eq(connectionsMaxTotal.toString()), eq(headers),
            eq(responseCharacterSet), eq(destinationFile.toAbsolutePath().toString()), eq(followedRedirects.toString()), eq(queryParams),
            eq(queryParamsAreURLEncoded.toString()), eq(queryParamsAreFormEncoded.toString()), eq(formParams), eq(formParamsAreURLEncoded.toString()),
            eq(sourceFile.toAbsolutePath().toString()), eq(body), eq(contentType), eq(requestCharacterSet), eq(multipartBodies),
            eq(multipartBodiesContentType), eq(multipartFiles), eq(multipartFilesContentType),
            eq(multipartValuesAreURLEncoded.toString()), eq(chunkedRequestEntity.toString()), eq(method), eq(httpClientCookieSession),
            eq(httpClientPoolingConnectionManager)
    );

    verify(httpClientResponseBuilderSpy).returnResult(returnResult);
    verify(httpClientResponseBuilderSpy).exception(exception);
    verify(httpClientResponseBuilderSpy).statusCode(statusCode);
    verify(httpClientResponseBuilderSpy).responseHeaders(responseHeaders);
    verify(httpClientResponseBuilderSpy).returnCode(returnCode);
}
 
源代码18 项目: cyberduck   文件: IRODSSession.java
public URIEncodingIRODSAccount(final String user, final String password, final String home, final String region, final String resource) {
    super(host.getHostname(), host.getPort(), StringUtils.isBlank(user) ? StringUtils.EMPTY : user, password, home, region, resource);
    this.setUserName(user);
}
 
@Override
public String evaluate(PropertyAccess propertyAccess) {
    return StringUtils.EMPTY;
}
 
源代码20 项目: lb-karaf-examples-jpa   文件: Item.java
public Item() {
    this(StringUtils.EMPTY,StringUtils.EMPTY);
}
 
 同类方法