List of usage examples for org.springframework.util StringUtils capitalize
public static String capitalize(String str)
From source file:xyz.autumnn.exam.springsocial.controller.signup.SignupController.java
@RequestMapping(value = "/signup", method = RequestMethod.GET) public SignupForm signupForm(WebRequest request) { Connection<?> connection = providerSignInUtils.getConnectionFromSession(request); if (connection != null) { request.setAttribute("message", "Your " + StringUtils.capitalize(connection.getKey().getProviderId()) + " account is not associated with a Spring Social Showcase account. If you're new, please sign up.", WebRequest.SCOPE_REQUEST); return SignupForm.fromProviderUser(connection.fetchUserProfile()); } else {/*from ww w .j a v a 2 s. co m*/ return new SignupForm(); } }
From source file:net.nan21.dnet.core.presenter.converter.ReflookupResolver.java
/** * Get the getter for the ds-field with the given name. * /* w w w . j a v a 2 s . c om*/ * @param fieldName * @return * @throws Exception */ private Method _getDsGetter(String fieldName) throws Exception { return ReflectionUtils.findMethod(this.modelClass, "get" + StringUtils.capitalize(fieldName)); }
From source file:com.consol.citrus.admin.converter.AbstractObjectConverter.java
/** * Adds new endpoint property./*from w w w . ja va 2 s.c o m*/ * @param fieldName * @param definition * @param defaultValue * @param required */ protected Property property(String fieldName, S definition, String defaultValue, boolean required) { return property(fieldName, StringUtils.capitalize(fieldName), definition, defaultValue, required); }
From source file:net.nan21.dnet.core.presenter.converter.ReflookupResolver.java
/** * Get the setter for the ds-field with the given name. * /* w w w . j a v a 2 s.co m*/ * @param fieldName * @return * @throws Exception */ private Method _getDsSetter(String fieldName) throws Exception { return this.modelClass.getMethod("set" + StringUtils.capitalize(fieldName), this._getDsField(fieldName).getType()); }
From source file:com.springsource.greenhouse.signup.SignupController.java
/** * Render a signup form to the person as HTML in their web browser. *//* ww w . j av a 2s. c o m*/ @RequestMapping(value = "/signup", method = RequestMethod.GET) public SignupForm signupForm(WebRequest request) { Connection<?> connection = ProviderSignInUtils.getConnection(request); if (connection != null) { request.setAttribute("message", new Message(MessageType.INFO, "Your " + StringUtils.capitalize(connection.getKey().getProviderId()) + " account is not associated with a Greenhouse account. If you're new, please sign up."), WebRequest.SCOPE_REQUEST); return SignupForm.fromProviderUser(connection.fetchUserProfile()); } else { return new SignupForm(); } }
From source file:mercury.RootJsonHandler.java
protected <T extends DTO> T populateDtoFromJson(String jsonData, T dto) { try {/*from ww w . j a v a2 s .c o m*/ JSONObject json = new JSONObject(jsonData); Class clazz = dto.getClass(); for (Field field : clazz.getDeclaredFields()) { try { String name = field.getName(); Class fieldClass = field.getType(); Object value = null; if (fieldClass.equals(String.class)) { value = json.has(name) ? json.getString(name) : null; } else if (fieldClass.equals(Integer.class)) { try { value = json.has(name) ? json.getInt(name) : null; } catch (Exception e) { value = -1; } } else if (fieldClass.equals(Float.class)) { String sValue = json.has(name) ? json.getString(name).replaceAll(",", ".") : null; value = sValue != null ? Float.valueOf(sValue) : null; } else if (fieldClass.equals(Date.class)) { value = json.has(name) ? json.getString(name) : null; value = value != null ? this.dateFormatter.parse((String) value) : null; } if (value == null) { continue; } Method setter = clazz.getDeclaredMethod("set" + StringUtils.capitalize(name), fieldClass); if (setter != null) { setter.invoke(dto, value); } } catch (Exception e) { continue; } } } catch (JSONException je) { } return dto; }
From source file:com.aw.swing.mvp.cmp.pick.PickManager.java
private static String getPickName(String attrName) { String pickName = ActionNames.ACTION_PICK + StringUtils.capitalize(attrName); return pickName; }
From source file:org.bpmscript.web.BpmScriptCookieController.java
@SuppressWarnings("unchecked") protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType(contentType); String requestUri = request.getRequestURI(); String definitionName = null; String methodName = null;/* w ww . j a v a 2 s. co m*/ String split[] = request.getRequestURI().split("/"); if (requestUri.endsWith("/")) { definitionName = split[split.length - 1]; methodName = defaultIndexName; } else { definitionName = split[split.length - 2]; methodName = split[split.length - 1].split("\\.")[0]; } String correlationIdParam = null; String cookieName = cookiePrefix + StringUtils.capitalize(definitionName) + StringUtils.capitalize(methodName); Cookie[] cookies = request.getCookies(); for (Cookie cookie : cookies) { String name = cookie.getName(); if (cookieName.equals(name)) { correlationIdParam = cookie.getValue(); } } String timeoutParam = request.getParameter("timeout"); long timeout = defaultTimeout; if (timeoutParam != null) { try { timeout = Integer.parseInt(timeoutParam); } catch (NumberFormatException e) { log.debug(e); } } try { SerializableHttpServletRequest serializableHttpServletRequest = new SerializableHttpServletRequest( request); if (correlationIdParam == null) { Object result = null; String conversationId = null; Object message = bpmScriptFacade.call(definitionName, methodName, timeout, serializableHttpServletRequest); if (message instanceof IInvocationMessage) { IInvocationMessage conversationMessage = (IInvocationMessage) message; result = conversationMessage.getArgs()[0]; conversationId = conversationMessage.getCorrelationId(); } else { result = message; } if (result instanceof Map) { Map<String, Object> map = (Map<String, Object>) result; if (conversationId != null) { map.put("conversationId", conversationId); response.addCookie(new Cookie(cookieName, conversationId)); } ModelAndView modelAndView = new ModelAndView((String) map.get("view"), map); return modelAndView; } else { throw new Exception("result must be a map or a conversation"); } } else { IInvocationMessage conversationMessage = null; conversationMessage = (IInvocationMessage) conversationCorrelator.call(correlationIdParam, timeout, serializableHttpServletRequest); if (conversationMessage != null) { Map<String, Object> result = (Map<String, Object>) conversationMessage.getArgs()[0]; String conversationId = conversationMessage.getCorrelationId(); result.put("conversationId", conversationId); String replyTo = conversationMessage.getReplyTo(); Cookie cookie = new Cookie(cookieName, conversationId); if (replyTo == null) { cookie.setMaxAge(0); } response.addCookie(cookie); ModelAndView modelAndView = new ModelAndView((String) result.get("view"), result); return modelAndView; } else { Cookie cookie = new Cookie(cookieName, ""); cookie.setMaxAge(0); response.addCookie(cookie); throw new Exception("Did not get a response for message " + correlationIdParam); } } } catch (Throwable e) { if (e instanceof Exception) { throw (Exception) e; } else { throw new Exception(e); } } }
From source file:io.spring.initializr.metadata.InitializrConfiguration.java
/** * Generate a suitable application name based on the specified name. If no suitable * application name can be generated from the specified {@code name}, the * {@link Env#getFallbackApplicationName()} is used instead. * <p>//from ww w . j av a 2s . com * No suitable application name can be generated if the name is {@code null} or if it * contains an invalid character for a class identifier. * @param name The the source name * @return the generated application name * @see Env#getFallbackApplicationName() * @see Env#getInvalidApplicationNames() */ public String generateApplicationName(String name) { if (!StringUtils.hasText(name)) { return this.env.fallbackApplicationName; } String text = splitCamelCase(name.trim()); // TODO: fix this String result = unsplitWords(text); if (!result.endsWith("Application")) { result = result + "Application"; } String candidate = StringUtils.capitalize(result); if (hasInvalidChar(candidate) || this.env.invalidApplicationNames.contains(candidate)) { return this.env.fallbackApplicationName; } else { return candidate; } }