List of usage examples for org.apache.commons.lang3 StringUtils upperCase
public static String upperCase(final String str)
Converts a String to upper case as per String#toUpperCase() .
A null input String returns null .
StringUtils.upperCase(null) = null StringUtils.upperCase("") = "" StringUtils.upperCase("aBc") = "ABC"
Note: As described in the documentation for String#toUpperCase() , the result of this method is affected by the current locale.
From source file:org.goko.common.bindings.AbstractController.java
/** * Make sure the setter for the given property exists * @param source the source object//from w w w .j a va2s. c o m * @param property the property to search for * @throws GkException GkException */ private void verifySetter(Object source, String property) throws GkException { String firstLetter = StringUtils.substring(property, 0, 1); String otherLetters = StringUtils.substring(property, 1); String setterName = "set" + StringUtils.upperCase(firstLetter) + otherLetters; boolean found = false; Method getMethod = verifyGetter(source, property); Method[] methodArray = source.getClass().getMethods(); for (Method method : methodArray) { if (StringUtils.equals(setterName, method.getName())) { Class<?>[] paramsArray = method.getParameterTypes(); if (paramsArray != null && paramsArray.length == 1 && paramsArray[0] == getMethod.getReturnType()) { found = true; break; } } } //source.getClass().getDeclaredMethod(setterName, getMethod.getReturnType()); if (!found) { throw new GkTechnicalException( "Cannot find setter (looking for '" + setterName + "') for property '" + property + "' on object " + source.getClass() + ". Make sure it's public and correctly spelled"); } }
From source file:org.goko.controller.tinyg.controller.TinyGCommunicator.java
private void handleCoordinateSystemOffsetReport(String offsetName, JsonValue jsonOffset) throws GkException { EnumCoordinateSystem cs = EnumCoordinateSystem.valueOf(StringUtils.upperCase(offsetName)); JsonObject offsetObj = (JsonObject) jsonOffset; JsonValue xOffset = offsetObj.get("x"); JsonValue yOffset = offsetObj.get("y"); JsonValue zOffset = offsetObj.get("z"); JsonValue aOffset = offsetObj.get("a"); Tuple6b offset = new Tuple6b().setZero(); offset.setX(Length.valueOf(xOffset.asBigDecimal(), tinyg.getCurrentUnit())); offset.setY(Length.valueOf(yOffset.asBigDecimal(), tinyg.getCurrentUnit())); offset.setZ(Length.valueOf(zOffset.asBigDecimal(), tinyg.getCurrentUnit())); if (aOffset != null) { offset.setA(Angle.valueOf(aOffset.asBigDecimal(), AngleUnit.DEGREE_ANGLE)); }/*from w ww.j a v a 2 s. co m*/ tinyg.setCoordinateSystemOffset(cs, offset); }
From source file:org.goko.tinyg.controller.TinyGCommunicator.java
private void handleCoordinateSystemOffsetReport(String offsetName, JsonValue jsonOffset) throws GkException { EnumCoordinateSystem cs = EnumCoordinateSystem.valueOf(StringUtils.upperCase(offsetName)); JsonObject offsetObj = (JsonObject) jsonOffset; JsonValue xOffset = offsetObj.get("x"); JsonValue yOffset = offsetObj.get("y"); JsonValue zOffset = offsetObj.get("z"); JsonValue aOffset = offsetObj.get("a"); Tuple6b offset = new Tuple6b().setZero(); offset.setX(NumberQuantity.of(xOffset.asBigDecimal(), tinyg.getCurrentUnit())); offset.setY(NumberQuantity.of(yOffset.asBigDecimal(), tinyg.getCurrentUnit())); offset.setZ(NumberQuantity.of(zOffset.asBigDecimal(), tinyg.getCurrentUnit())); if (aOffset != null) { offset.setA(NumberQuantity.of(aOffset.asBigDecimal(), SI.DEGREE_ANGLE)); }/*from w w w. ja v a 2s .co m*/ tinyg.setCoordinateSystemOffset(cs, offset); }
From source file:org.gvnix.addon.datatables.addon.DatatablesMetadata.java
/** * Returns export method for a specific format for a render-a-view * visualization mode./*from www. j a v a 2 s . c om*/ * <p /> * This method handles datatables AJAX request for export data to a format * specified in the @{code exportType} parameter. * * @param exportType the export type: csv, xml, pdf, etc. * @param exportTypeJavaType the @{code JavaType} of the export type. * @return */ private MethodMetadata getExportFormatMethod(String exportType, JavaType exportTypeJavaType) { String exportTypeUpperCase = StringUtils.upperCase(exportType); String exportTypeCapitalized = StringUtils.capitalize(exportType); /* * @RequestMapping(value = "/exportcsv", produces = "text/csv") public * void PetController.exportCsv( * * @DatatablesParams DatatablesCriterias criterias, * * @ModelAttribute Pet pet, HttpServletRequest request, * HttpServletResponse response) throws ServletException, IOException, * ExportException { ... } */ // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); parameterTypes.add(new AnnotatedJavaType(DATATABLES_CRITERIA_TYPE, new AnnotationMetadataBuilder(DATATABLES_PARAMS).build())); parameterTypes.add(new AnnotatedJavaType(entity, new AnnotationMetadataBuilder(MODEL_ATTRIBUTE).build())); parameterTypes.add(AnnotatedJavaType.convertFromJavaType(HTTP_SERVLET_REQUEST)); parameterTypes.add(AnnotatedJavaType.convertFromJavaType(HTTP_SERVLET_RESPONSE)); // Building method name JavaSymbolName methodName = new JavaSymbolName("export".concat(exportTypeCapitalized)); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(methodName, parameterTypes); if (method != null) { // If it already exists, just return the method and omit its // generation via the ITD return method; } // Define method annotations List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); AnnotationMetadataBuilder methodAnnotation = new AnnotationMetadataBuilder(); methodAnnotation.setAnnotationType(REQUEST_MAPPING); methodAnnotation.addStringAttribute(DatatablesConstants.RQST_MAP_ANN_VAL_NAME, "/export".concat(exportType)); methodAnnotation.addStringAttribute(DatatablesConstants.RQST_MAP_ANN_PROD_NAME, "text/".concat(exportType)); annotations.add(methodAnnotation); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(); throwsTypes.add(SERVLET_EXCEPTION); throwsTypes.add(IO_EXCEPTION); throwsTypes.add(DATATABLES_EXPORT_EXCEPTION); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(CRITERIA_PARAM_NAME); parameterNames.add(new JavaSymbolName(StringUtils.uncapitalize(entityName))); parameterNames.add(REQUEST_PARAM_NAME); parameterNames.add(RESPONSE_PARAM_NAME); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); /* * export(criterias, pet, ExportType.CSV, new CsvExport(), request, * response); */ String format = "export(%s, %s, %s.".concat(exportTypeUpperCase).concat(", new %s(), %s, %s);"); bodyBuilder.appendFormalLine(String.format(format, CRITERIA_PARAM_NAME.getSymbolName(), StringUtils.uncapitalize(entityName), helper.getFinalTypeName(DATATABLES_EXPORT_TYPE), helper.getFinalTypeName(exportTypeJavaType), REQUEST_PARAM_NAME.getSymbolName(), RESPONSE_PARAM_NAME.getSymbolName())); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, JavaType.VOID_PRIMITIVE, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:org.hawaiiframework.sample.web.HelloController.java
@Get(path = "/greet", produces = APPLICATION_JSON_VALUE) public ResponseEntity<JSONObject> greet(@RequestParam(required = false) String name, @RequestParam(required = false) String language) { logger.info("greet called with name: {}, language: {}", name, language); // Validate language if (StringUtils.isNotBlank(language)) { language = StringUtils.upperCase(language); if (!EnumUtils.isValidEnum(Language.class, language)) { throw new ValidationException(new ValidationError("language", "invalid")); }//w w w . j a v a2s . co m } // Create resource to be returned to client JSONObject resource = new JSONObject(); resource.put("timestamp", hawaiiTime.zonedDateTime()); resource.put("greeting", helloService.greet(name, EnumUtils.getEnum(Language.class, language))); return ResponseEntity.ok().body(resource); }
From source file:org.kuali.coeus.propdev.impl.s2s.S2sSubmissionServiceImpl.java
/** * This method is to find the list of available opportunities for a given * cfda number, opportunity ID and competition ID. * * @param cfdaNumber//from w w w. ja va 2 s . c o m * of the opportunity. * @param opportunityId * parameter for the opportunity. * @param competitionId * parameter for the opportunity. * @return List<S2sOpportunity> a list containing the available * opportunities for the corresponding parameters. * @throws S2sCommunicationException */ @Override public List<S2sOpportunity> searchOpportunity(String providerCode, String cfdaNumber, String opportunityId, String competitionId) throws S2sCommunicationException { //The OpportunityID and CompetitionID element definitions were changed from a string with //a length between 1 and 100 (StringMin1Max100Type) to an uppercase alphanumeric value with a maximum length //of 40 characters ([A-Z0-9\-]{1,40}). opportunityId = StringUtils.upperCase(opportunityId); opportunityId = StringUtils.isBlank(opportunityId) ? null : opportunityId; cfdaNumber = StringUtils.isBlank(cfdaNumber) ? null : cfdaNumber; competitionId = StringUtils.upperCase(competitionId); competitionId = StringUtils.isBlank(competitionId) ? null : competitionId; S2sProviderContract provider = s2sProviderService.findS2SProviderByCode(providerCode); if (provider == null) { throw new S2sCommunicationException( "An invalid provider code was provided when attempting to search for opportunities."); } S2SConnectorService connectorService = KcServiceLocator.getService(provider.getConnectorServiceName()); if (connectorService == null) { throw new S2sCommunicationException("The connector service '" + provider.getConnectorServiceName() + "' required by '" + provider.getDescription() + "' S2S provider is not configured."); } List<S2sOpportunity> s2sOpportunityList = convertToArrayList(provider.getCode(), connectorService.getOpportunityList(cfdaNumber, opportunityId, competitionId)); return s2sOpportunityList; }
From source file:org.kuali.kra.test.OjbRepositoryMappingTest.java
@Before public void setUp() throws Exception { dsUrl = (String) configFileParms.get(DATASOURCE_URL_NAME); dsUser = (String) configFileParms.get(DATASOURCE_USERNAME_NAME); dsPass = (String) configFileParms.get(DATASOURCE_PASSWORD_NAME); dsDriver = (String) configFileParms.get(DATASOURCE_DRIVER_NAME); dsSchema = StringUtils.upperCase(dsUser); LOG.debug(String.format("dsUrl = %s\n", dsUrl)); LOG.debug(String.format("dsUser = %s\n", dsUser)); LOG.debug(String.format("dsDriver = %s\n", dsDriver)); LOG.debug(String.format("dsSchema = %s\n", dsSchema)); }
From source file:org.ligoj.app.plugin.prov.aws.in.ProvAwsPriceImportResource.java
/** * Install or update a EC2 price//from ww w. j a v a 2s . c o m */ private ProvInstancePrice newInstancePrice(final UpdateContext context, final AwsEc2Price csv, final ProvLocation region) { final VmOs os = VmOs.valueOf(csv.getOs().toUpperCase(Locale.ENGLISH)); final ProvInstanceType instance = installInstanceType(context, csv); final String license = StringUtils.trimToNull(StringUtils.remove( csv.getLicenseModel().replace("License Included", StringUtils.defaultString(csv.getSoftware(), "")) .replace("NA", "License Included"), "No License required")); final ProvTenancy tenancy = ProvTenancy.valueOf(StringUtils.upperCase(csv.getTenancy())); final ProvInstancePriceTerm term = context.getPriceTypes().computeIfAbsent(csv.getOfferTermCode(), k -> newInstancePriceTerm(context, csv)); final String code = toCode(csv); return context.getPrevious().computeIfAbsent(code, c -> { final ProvInstancePrice p = new ProvInstancePrice(); p.setLocation(region); p.setCode(code); p.setOs(os); p.setTenancy(tenancy); p.setLicense(license); p.setType(instance); p.setTerm(term); return p; }); }
From source file:org.lockss.exporter.biblio.BibliographicUtil.java
/** * Generate a series of strings, producing a set covering the range from the * start string to the end string inclusive. If the start and end values are * equal, an array containing the single value is returned. * <p>//from www .jav a 2s .c om * The method can handle different types of identifier. Arabic and Roman * number sequences are easily generated; string-based sequences are much * harder to generate based purely on analysis, but if the form of the start * and end identifiers is not known in advance we have to take a best guess * approach. Roman numbers must be in normalised form or they are assumed to * be alphabetic tokens. * <p> * The method looks in the start and end strings for a common substring * comprised of a series of alphabetical or numerical (not Roman) tokens, and * then attempts to create a sequence by varying the final tokens, that follow * the common prefix. The changing part of the identifiers must occur in the * final part of the string. Ranges like sI to sIII are not supported, though * we could create tokens based on case as well as character type. * <p> * Exceptions will be thrown if there are inconsistent or unsupported * arguments. All sequences can be generated in both ascending and descending * orientations and with a variety of values for the delta, including * Arabic- or Roman-numerical sequences, and alphabetical sequences. * * @param start the start string * @param end the end string * @param delta the magnitude of the increment or decrement, expressed as a positive integer * @return a sequence of strings, incrementing or decrementing in the changeable token * @throws NumberFormatException if number formats do not allow a consistent and unambiguous sequence to be created * @throws IllegalArgumentException if the parameters are inconsistent */ public static List<String> constructSequence(String start, String end, int delta) throws IllegalArgumentException { List<String> seq = new ArrayList<String>(); String pre = commonTokenBasedPrefix(start, end); // Assume that the changing sequential token is the rest of the string String seqTokS = start.substring(pre.length()); String seqTokE = end.substring(pre.length()); // Create a sequence based on the type of these tokens // Simple integer sequence //if (NumberUtil.isInteger(seqTokS) && NumberUtil.isInteger(seqTokE)) { if (NumberUtil.isIntegerDigits(seqTokS) && NumberUtil.isIntegerDigits(seqTokE)) { int s = Integer.parseInt(seqTokS); int e = Integer.parseInt(seqTokE); int[] intSeq = NumberUtil.constructSequence(s, e, delta); // Default is not to pad numbers in the seq int padlen = 0; // If a number starts with a zero, maintain zero-padded length // in generated tokens. if (seqTokS.startsWith("0") || seqTokE.startsWith("0")) { int len = seqTokS.length(); // Check if the zero-padded numbers are the same length if (seqTokE.length() != len) throw new IllegalArgumentException(String.format( "Can't generate sequence with different length " + "zero-padded numbers %s and %s.", seqTokS, seqTokE)); padlen = len; } // Zero-pad the numbers as necessary and add to result list for (int i : intSeq) seq.add(pre + NumberUtil.padNumbers(i, padlen)); } // Roman numbers, allowing lower case else if (NumberUtil.isNormalisedRomanNumber(StringUtils.upperCase(seqTokS)) && NumberUtil.isNormalisedRomanNumber(StringUtils.upperCase(seqTokE))) { List<String> romSeq = NumberUtil.constructRomanSequence(seqTokS, seqTokE, delta); // Convert the numbers back to Roman and add to result list for (String s : romSeq) seq.add(pre + s); } // Alphabetic identifiers else { List<String> tokSeq = NumberUtil.constructAlphabeticSequence(seqTokS, seqTokE, delta); // Convert the numbers back to Roman and add to result list for (String s : tokSeq) seq.add(pre + s); } return seq; }
From source file:org.meruvian.yama.service.security.DefaultUserDetailsService.java
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userManager.getUserByUsername(username); if (user != null) { boolean enabled = user.getLogInformation().getActiveFlag() == LogInformation.ACTIVE; List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); Page<? extends Role> roles = userManager.findRoleByUser(user, null); for (Role role : roles) { authorities.add(new SimpleGrantedAuthority(StringUtils.upperCase(role.getName()))); }/*from ww w. j av a 2 s . c o m*/ DefaultUserDetails details = new DefaultUserDetails(user.getUsername(), user.getPassword(), enabled, true, true, true, authorities); details.setId(user.getId()); details.setUser(new DefaultUser(user)); return details; } return null; }