Java Code Examples for org.apache.commons.lang3.StringUtils#upperCase()

The following examples show how to use org.apache.commons.lang3.StringUtils#upperCase() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: arcusplatform   File: IpcdRegistry.java    License: Apache License 2.0 6 votes vote down vote up
private List<com.iris.protocol.ipcd.message.model.Device> createDevicesFromBody(MessageBody body) {
   Map<String, String> attrs = readAttrs(body);

   String sn = attrs.get(IpcdProtocol.ATTR_SN);
   if(StringUtils.isBlank(sn)) {
      throw new ErrorEventException(Errors.invalidRequest(BridgeService.RegisterDeviceRequest.ATTR_ATTRS + " must contain " + IpcdProtocol.ATTR_SN));
   }
   sn = StringUtils.upperCase(sn);

   String devType = attrs.get(IpcdProtocol.ATTR_V1DEVICETYPE);
   List<com.iris.protocol.ipcd.message.model.Device> devices = IpcdDeviceTypeRegistry.INSTANCE.createDeviceForV1Type(devType, sn);
   if (null == devices || devices.isEmpty()) {
      throw new ErrorEventException(Errors.invalidRequest("The v1 device type [" + devType + "] and serial number [" + sn + "] failed to create any devices."));
   }

   return devices;
}
 
Example 2
@Override
public PriceHistory priceHistory(String symbol) {
  symbol = StringUtils.upperCase(symbol);
  LOGGER.info("price history for symbol: {}", symbol);
  if (StringUtils.isBlank(symbol)) {
    throw new IllegalArgumentException("symbol cannot be empty");
  }

  HttpUrl url = baseUrl("marketdata", symbol, "pricehistory").build();
  Request request = new Request.Builder().url(url).headers(defaultHeaders()).build();
  try (Response response = this.httpClient.newCall(request).execute()) {
    checkResponse(response, false);
    return tdaJsonParser.parsePriceHistory(response.body().byteStream());
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example 3
/**
 * @param description
 * @return
 */
private static String transformCase(String description, Options options) {
    String descTemp = description;
    switch (options.getCasingType()) {
        case Sentence:
            descTemp = StringUtils.upperCase("" + descTemp.charAt(0)) + descTemp.substring(1);
            break;
        case Title:
            descTemp = StringUtils.capitalize(descTemp);
            break;
        default:
            descTemp = descTemp.toLowerCase();
            break;
    }
    return descTemp;
}
 
Example 4
Source Project: jmeter-plugins   File: CaseFormat.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Change case using delimiter between words
 * 
 * @param str
 * @param delimiter
 * @param isAllUpper
 * @param isAllLower
 * @return string after change case
 */
private static String caseFormatWithDelimiter(String str, String delimiter, boolean isAllUpper, boolean isAllLower) {
	StringBuilder builder = new StringBuilder(str.length());
	String[] tokens = NOT_ALPHANUMERIC_REGEX.split(str);
	boolean shouldAddDelimiter = StringUtils.isNotEmpty(delimiter);
	for (int i = 0; i < tokens.length; i++) {
		String currentToken = tokens[i];
		builder.append(currentToken);
		boolean hasNextToken = i + 1 != tokens.length;
		if (hasNextToken && shouldAddDelimiter) {
			builder.append(delimiter);
		}
	}
	String outputString = builder.toString();
	if (isAllLower) {
		return StringUtils.lowerCase(outputString);
	} else if (isAllUpper) {
		return StringUtils.upperCase(outputString);
	}
	return outputString;
}
 
Example 5
private String generateDateEQL(String resolvedFieldName, String field, int operatorCode, String dateFormat, String value, boolean disableThreeValuedLogic) throws EQLCreationException {
    TargetOperator targetOperator = getValidOperator(TargetNodeDate.getValidOperators(), operatorCode);
    
    if (targetOperator == null) {
        throw new EQLCreationException("No or invalid primary operator defined");
    }
    
    if(targetOperator == OPERATOR_IS) {
        return String.format("%s %s", resolvedFieldName, EqlUtils.getIsEmptyOperatorValue(value));
    }
    
    String eql;
    String dateFormatEQL = EqlUtils.toEQLDateFormat(StringUtils.defaultIfEmpty(dateFormat, DEFAULT_EQL_DATE_PATTERN));

    if (DATE_CURRENT_TIMESTAMP.equalsIgnoreCase(field) || DATE_SYSDATE.equalsIgnoreCase(field) || DATE_NOW.equalsIgnoreCase(field)) {
        eql = String.format("TODAY %s %s DATEFORMAT %s", targetOperator.getOperatorSymbol(), StringUtil.makeEqlStringConstant(value), StringUtil.makeEqlStringConstant(dateFormatEQL));
    } else {
        value = StringUtils.upperCase(value);

        if (value.startsWith(DATE_CURRENT_TIMESTAMP)) {
            value = "TODAY" + value.substring(DATE_CURRENT_TIMESTAMP.length());
        } else if (value.startsWith(DATE_SYSDATE)) {
            value = "TODAY" + value.substring(DATE_SYSDATE.length());
        } else if (value.startsWith(DATE_NOW)) {
            value = "TODAY" + value.substring(DATE_NOW.length());
        } else {
            value = StringUtil.makeEqlStringConstant(value);
        }

        value += " DATEFORMAT '" + dateFormatEQL + "'";

        eql = EqlUtils.makeEquation(resolvedFieldName, targetOperator, value, disableThreeValuedLogic);
    }
		
    return eql;
}
 
Example 6
Source Project: SkaETL   File: UpperCaseTransformator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void apply(String idProcess, ParameterTransformation parameterTransformation, ObjectNode jsonValue) {
    if (has(parameterTransformation.getKeyField(),jsonValue)) {
        JsonNode valueField = at(parameterTransformation.getKeyField(), jsonValue);
        String capitalized = StringUtils.upperCase(valueField.textValue());
        put(jsonValue, parameterTransformation.getKeyField(), capitalized);
    }
}
 
Example 7
@Test
public void testAlternateSDUndoPruneParametersActuallyChangeData() {
    // This test simply tests that if we change the value of the parameter that the output is altered.

    final File output = createTempFile("gatkcnv.HCC1143", ".seg");
    final File outputNewParam = createTempFile("gatkcnv.HCC1143.sdundo", ".seg");

    final File tmpWeightsFile = IOUtils.createTempFile("integration-weight-file", ".txt");
    final double [] weights = new double[7677];
    Arrays.fill(weights, 1.0);
    ParamUtils.writeValuesToFile(weights, tmpWeightsFile);
    final String sampleName = "HCC1143";
    RCBSSegmenter.writeSegmentFile(sampleName, INPUT_FILE.getAbsolutePath(), output.getAbsolutePath(), true);
    final String[] arguments = {
            "-" + ExomeStandardArgumentDefinitions.TANGENT_NORMALIZED_COUNTS_FILE_SHORT_NAME, INPUT_FILE.getAbsolutePath(),
            "-" + ExomeStandardArgumentDefinitions.LOG2_SHORT_NAME,
            "-" + PerformSegmentation.TARGET_WEIGHT_FILE_SHORT_NAME, tmpWeightsFile.getAbsolutePath(),
            "-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME, output.getAbsolutePath(),
            "-" + PerformSegmentation.UNDOSPLITS_SHORT_NAME, StringUtils.upperCase(RCBSSegmenter.UndoSplits.PRUNE.toString())
    };
    runCommandLine(arguments);

    final String[] newArguments = {
            "-" + ExomeStandardArgumentDefinitions.TANGENT_NORMALIZED_COUNTS_FILE_SHORT_NAME, INPUT_FILE.getAbsolutePath(),
            "-" + ExomeStandardArgumentDefinitions.LOG2_SHORT_NAME,
            "-" + PerformSegmentation.TARGET_WEIGHT_FILE_SHORT_NAME, tmpWeightsFile.getAbsolutePath(),
            "-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME, outputNewParam.getAbsolutePath(),
            "-" + PerformSegmentation.UNDOSPLITS_SHORT_NAME, StringUtils.upperCase(RCBSSegmenter.UndoSplits.PRUNE.toString()),
            "-" + PerformSegmentation.UNDOPRUNE_SHORT_NAME, String.valueOf(0.1)
    };
    runCommandLine(newArguments);

    SegmenterUnitTest.assertNotEqualSegments(outputNewParam, output);
}
 
Example 8
Source Project: para   File: User.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets a preferred currency. Default is "EUR".
 * @param currency a 3-letter currency code
 */
public void setCurrency(String currency) {
	currency = StringUtils.upperCase(currency);
	if (!CurrencyUtils.getInstance().isValidCurrency(currency)) {
		currency = "EUR";
	}
	this.currency = currency;
}
 
Example 9
Source Project: para   File: App.java    License: Apache License 2.0 5 votes vote down vote up
final boolean isAllowed(String subjectid, String resourcePath, String httpMethod) {
	boolean allowed = false;
	if (subjectid != null && resourcePath != null && getResourcePermissions().containsKey(subjectid)) {
		httpMethod = StringUtils.upperCase(httpMethod);
		String wildcard = ALLOW_ALL;
		String exactPathToMatch = resourcePath;
		if (fromString(httpMethod) == GUEST) {
			// special case where we have wildcard permissions * but public access is not allowed
			wildcard = httpMethod;
		}
		if (StringUtils.contains(resourcePath, '/')) {
			// we assume that a full resource path is given like: 'users/something/123'
			// so we check to see if 'users/something' is in the list of resources.
			// we don't want 'users/someth' to match, but only the exact full path
			String fragment = resourcePath.substring(0, resourcePath.lastIndexOf('/'));
			for (String resource : getResourcePermissions().get(subjectid).keySet()) {
				if (StringUtils.startsWith(fragment, resource) &&
						pathMatches(subjectid, resource, httpMethod, wildcard)) {
					allowed = true;
					break;
				}
				// allow basic wildcard matching
				if (StringUtils.endsWith(resource, "/*") &&
						resourcePath.startsWith(resource.substring(0, resource.length() - 1))) {
					exactPathToMatch = resource;
					break;
				}
			}
		}
		if (!allowed && getResourcePermissions().get(subjectid).containsKey(exactPathToMatch)) {
			// check if exact resource path is accessible
			allowed = pathMatches(subjectid, exactPathToMatch, httpMethod, wildcard);
		} else if (!allowed && getResourcePermissions().get(subjectid).containsKey(ALLOW_ALL)) {
			// check if ALL resources are accessible
			allowed = pathMatches(subjectid, ALLOW_ALL, httpMethod, wildcard);
		}
	}
	return allowed;
}
 
Example 10
@Override
public String generate(String givenNames, String surname) {

    Assert.hasText(givenNames, "Given name is required");
    Assert.hasText(surname, "Surname is required");

    int wordsSize = 0;
    wordsSize += givenNames.length();
    wordsSize += surname.length();
    if (wordsSize < DEFAULT_SIZE) {
        return StringUtils.upperCase(new StringBuilder().append(givenNames).append(surname).toString());
    }

    // Character number to take from given names
    int fromGivenNames = 4;
    int fromSurname = 4;
    if (givenNames.length() < 4) {
        fromGivenNames = givenNames.length();
        fromSurname += (4 - givenNames.length());
    }
    if (surname.length() < 4) {
        fromSurname = surname.length();
        fromGivenNames += (4 - surname.length());
    }
    StringBuilder builder = new StringBuilder();
    builder.append(givenNames.substring(0, fromGivenNames));
    builder.append(surname.substring(0, fromSurname));
    return StringUtils.upperCase(builder.toString());
}
 
Example 11
Source Project: td-ameritrade-client   File: MiscTest.java    License: Apache License 2.0 4 votes vote down vote up
private String doesCopy(String param) {
  param = StringUtils.upperCase(param);
  return param;
}
 
Example 12
public String tableName() throws Exception {
	if (StringUtils.isEmpty(name)) {
		throw new Exception("name is empty.");
	}
	return TABLE_PREFIX + StringUtils.upperCase(name);
}
 
Example 13
Source Project: vscrawler   File: UpperCase.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected String handleSingleStr(String input) {
    return StringUtils.upperCase(input);
}
 
Example 14
Source Project: cuba   File: WebSearchField.java    License: Apache License 2.0 4 votes vote down vote up
protected void executeSearch(final String newFilter) {
    if (optionsBinding == null || optionsBinding.getSource() == null) {
        return;
    }

    String filterForDs = newFilter;
    if (mode == Mode.LOWER_CASE) {
        filterForDs = StringUtils.lowerCase(newFilter);
    } else if (mode == Mode.UPPER_CASE) {
        filterForDs = StringUtils.upperCase(newFilter);
    }

    if (escapeValueForLike && StringUtils.isNotEmpty(filterForDs)) {
        filterForDs = QueryUtils.escapeForLike(filterForDs);
    }

    CollectionDatasource optionsDatasource = ((DatasourceOptions) optionsBinding.getSource()).getDatasource();

    if (!isRequired() && StringUtils.isEmpty(filterForDs)) {
        setValue(null);
        if (optionsDatasource.getState() == Datasource.State.VALID) {
            optionsDatasource.clear();
        }
        return;
    }

    if (StringUtils.length(filterForDs) >= minSearchStringLength) {
        optionsDatasource.refresh(Collections.singletonMap(SEARCH_STRING_PARAM, filterForDs));

        if (optionsDatasource.getState() == Datasource.State.VALID) {
            if (optionsDatasource.size() == 0) {
                if (searchNotifications != null) {
                    searchNotifications.notFoundSuggestions(newFilter);
                }
            } else if (optionsDatasource.size() == 1) {
                setValue((V) optionsDatasource.getItems().iterator().next());
            }
        }
    } else {
        if (optionsDatasource.getState() == Datasource.State.VALID) {
            optionsDatasource.clear();
        }

        if (searchNotifications != null && StringUtils.length(newFilter) > 0) {
            searchNotifications.needMinSearchStringLength(newFilter, minSearchStringLength);
        }
    }
}
 
Example 15
Source Project: cuba   File: WebSearchPickerField.java    License: Apache License 2.0 4 votes vote down vote up
protected void executeSearch(final String newFilter) {
    if (optionsBinding == null || optionsBinding.getSource() == null) {
        return;
    }

    String filterForDs = newFilter;
    if (mode == Mode.LOWER_CASE) {
        filterForDs = StringUtils.lowerCase(newFilter);
    } else if (mode == Mode.UPPER_CASE) {
        filterForDs = StringUtils.upperCase(newFilter);
    }

    if (escapeValueForLike && StringUtils.isNotEmpty(filterForDs)) {
        filterForDs = QueryUtils.escapeForLike(filterForDs);
    }

    CollectionDatasource optionsDatasource = ((DatasourceOptions) optionsBinding.getSource()).getDatasource();

    if (!isRequired() && StringUtils.isEmpty(filterForDs)) {
        setValue(null);
        if (optionsDatasource.getState() == Datasource.State.VALID) {
            optionsDatasource.clear();
        }
        return;
    }

    if (StringUtils.length(filterForDs) >= minSearchStringLength) {
        optionsDatasource.refresh(Collections.singletonMap(SEARCH_STRING_PARAM, filterForDs));

        if (optionsDatasource.getState() == Datasource.State.VALID) {
            if (optionsDatasource.size() == 0) {
                if (searchNotifications != null) {
                    searchNotifications.notFoundSuggestions(newFilter);
                }
            } else if (optionsDatasource.size() == 1) {
                setValue((V) optionsDatasource.getItems().iterator().next());
            }
        }
    } else {
        if (optionsDatasource.getState() == Datasource.State.VALID) {
            optionsDatasource.clear();
        }

        if (searchNotifications != null && StringUtils.length(newFilter) > 0) {
            searchNotifications.needMinSearchStringLength(newFilter, minSearchStringLength);
        }
    }
}
 
Example 16
Source Project: cuba   File: DesktopSearchField.java    License: Apache License 2.0 4 votes vote down vote up
protected void handleSearch(final String newFilter) {
    clearSearchVariants();

    String filterForDs = newFilter;
    if (mode == Mode.LOWER_CASE) {
        filterForDs = StringUtils.lowerCase(newFilter);
    } else if (mode == Mode.UPPER_CASE) {
        filterForDs = StringUtils.upperCase(newFilter);
    }

    if (escapeValueForLike && StringUtils.isNotEmpty(filterForDs)) {
        filterForDs = QueryUtils.escapeForLike(filterForDs);
    }

    if (!isRequired() && StringUtils.isEmpty(filterForDs)) {
        if (optionsDatasource.getState() == Datasource.State.VALID) {
            optionsDatasource.clear();
        }

        setValue(null);
        updateOptionsDsItem();
        return;
    }

    if (StringUtils.length(filterForDs) >= minSearchStringLength) {
        optionsDatasource.refresh(
                Collections.singletonMap(SearchField.SEARCH_STRING_PARAM, (Object) filterForDs));

        if (optionsDatasource.getState() == Datasource.State.VALID) {
            if (optionsDatasource.size() == 0) {
                if (searchNotifications != null)
                    searchNotifications.notFoundSuggestions(newFilter);
            } else if (optionsDatasource.size() == 1) {
                setValue(optionsDatasource.getItems().iterator().next());
                updateOptionsDsItem();
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        updateComponent(getValue());
                    }
                });
            } else {
                initSearchVariants();
                comboBox.showSearchPopup();
            }
        }
    } else {
        if (optionsDatasource.getState() == Datasource.State.VALID) {
            optionsDatasource.clear();
        }

        if (searchNotifications != null && StringUtils.length(filterForDs) > 0) {
            searchNotifications.needMinSearchStringLength(newFilter, minSearchStringLength);
        }
    }
}
 
Example 17
public String buildNamespace() {
    return "modules#" + name + "#" + version + "#" + StringUtils.upperCase(versionType);
}
 
Example 18
@Override
public String upperCase(String text) {
	return StringUtils.upperCase(text);
}
 
Example 19
Source Project: OpenEstate-IO   File: TrovitUtils.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Write a {@link String} value for a country code into XML output.
 * <p>
 * The country has to be represendet by a ISO-Code wirh two or three
 * characters.
 *
 * @param value value to write
 * @return XML string
 * @throws IllegalArgumentException if a validation error occurred
 */
public static String printCountryValue(String value) {
    value = StringUtils.trimToNull(value);
    if (value == null)
        throw new IllegalArgumentException("Can't print empty country value!");
    if (value.length() != 2 && value.length() != 3)
        throw new IllegalArgumentException("Can't print country value '" + value + "' because it is neither an ISO-2-Code nor an ISO-3-Code!");

    return StringUtils.upperCase(value, Locale.ENGLISH);
}
 
Example 20
/**
 * md5加密
 * @param text
 * @param salt
 * @return
 * @author sly
 * @time 2018年12月12日
 */
public static String encodeMD5(String text,String salt) {
	return StringUtils.upperCase(DigestUtils.md5Hex(text + salt));
}