List of usage examples for org.springframework.util StringUtils capitalize
public static String capitalize(String str)
From source file:com.lpm.fanger.commons.util.Reflections.java
/** * Setter, ???//w w w .j av a 2 s . co m * ???.??. */ public static void invokeSetter(Object obj, String propertyName, Object value) { Object object = obj; String[] names = StringUtils.split(propertyName, "."); if (names == null || names.length == 0) return; for (int i = 0; i < names.length; i++) { if (i < names.length - 1) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); } else { String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); invokeMethodByName(object, setterMethodName, new Object[] { value }); } } }
From source file:com.kazuki43zoo.jpetstore.component.validation.RepeatedFieldValidator.java
public void initialize(RepeatedField constraintAnnotation) { this.field = constraintAnnotation.field(); this.repeatedField = "repeated" + StringUtils.capitalize(field); this.message = constraintAnnotation.message(); }
From source file:com.indusborn.ui.validators.ConfirmValidator.java
public void initialize(Confirm constraintAnnotation) { field = constraintAnnotation.field(); matches = constraintAnnotation.matches(); if (matches == null || matches.length() == 0) { matches = "confirm" + StringUtils.capitalize(field); }/*from w ww.j a va 2s .com*/ message = constraintAnnotation.message(); }
From source file:mercury.DTO.java
@Override public JSONObject toJSONObject(Properties properties) { JSONObject json = new JSONObject(); try {//ww w. j a v a 2 s. com Class clazz = this.getClass(); for (Field field : clazz.getDeclaredFields()) { String name = field.getName(); Method getter = clazz.getDeclaredMethod("get" + StringUtils.capitalize(name)); if (getter != null) { Object value = getter.invoke(this); if (value != null) { if (value instanceof Collection) { Collection col = (Collection) value; for (Object item : col) { if (item == null) { continue; } if (item instanceof DTO) { json.append(name, ((DTO) item).toJSONObject(null)); } else if (item instanceof String) { json.append(name, ((String) item).trim()); } else { json.append(name, item); } } } else if (value instanceof DTO) { json.putOpt(name, ((DTO) value).toJSONObject(properties)); } else if (value instanceof String) { json.putOpt(name, ((String) value).trim()); } else { json.putOpt(name, value); } } } } } catch (Exception e) { } return json; }
From source file:com.gopivotal.cla.testutil.ToStringTestUtils.java
/** * Asserts that an instance has a {@code toString()} method that renders the class name and the values of the * specified {@code fields}/*from ww w .ja va2 s.c o m*/ * * @param fields The names of the fields to require in the {@code toString() method} */ public void assertToString(String... keys) { String s = this.control.toString(); assertTrue("control does not start with simple class name", s.startsWith(this.control.getClass().getSimpleName())); for (String key : keys) { boolean contains = s.contains(String.format("%s=", key)) || s.contains(String.format("get%s()=", StringUtils.capitalize(key))); assertTrue(String.format("control does not contain key '%s', '%s'", key, s), contains); } }
From source file:io.spring.initializr.util.VersionProperty.java
/** * Return a camel cased representation of this instance. * @return the property in camel case format *//*from w ww .j a va 2 s . c o m*/ public String toCamelCaseFormat() { String[] tokens = this.property.split("\\-|\\."); StringBuilder sb = new StringBuilder(); for (int i = 0; i < tokens.length; i++) { String part = tokens[i]; if (i > 0) { part = StringUtils.capitalize(part); } sb.append(part); } return sb.toString(); }
From source file:org.usergrid.mongo.commands.MongoCommand.java
@SuppressWarnings("unchecked") public static MongoCommand getCommand(String commandName) { MongoCommand command = commands.get(commandName); if (command != null) { return command; }//ww w.j a va 2 s . c o m String clazz = "org.usergrid.mongo.commands." + StringUtils.capitalize(commandName); Class<MongoCommand> cls = null; try { cls = (Class<MongoCommand>) Class.forName(clazz); } catch (ClassNotFoundException e) { logger.error("Couldn't find command class", e); } try { if (cls != null) { command = cls.newInstance(); } } catch (Exception e) { logger.error("Couldn't find instantiate class", e); } if (command != null) { MongoCommand oldCommand = commands.putIfAbsent(commandName, command); if (oldCommand != null) { command = oldCommand; } } else { logger.warn("Mongo command handler not found for " + commandName); } return command; }
From source file:com.phoenixnap.oss.ramlapisync.data.ApiDocumentMetadata.java
/** * /* www. j a v a 2s. c o m*/ * @param document The resource pointing to the document to be represented * @param docSuffix The portion of the filename that should be removed for Title generation */ public ApiDocumentMetadata(ResourceInfo document, String docSuffix) { this.document = document; String name = document.getResourceName(); String title = name; if (name.contains("/") && !name.endsWith("/")) { name = name.substring(name.lastIndexOf("/") + 1); title = StringUtils.capitalize(name).replace(docSuffix, ""); } this.path = name; this.title = title; }
From source file:org.jasig.ssp.util.importer.job.domain.RawItem.java
public Map<String, String> getRecordAsPropertyMap() { Map<String, String> recordAsProperty = new HashMap<String, String>(); for (String columnName : record.keySet()) { String[] particles = columnName.split("_"); String propertyName = particles[0].toLowerCase(); for (Integer i = 1; i < particles.length; i++) { propertyName += StringUtils.capitalize(particles[i]); }//from w ww . j av a2s .c om recordAsProperty.put(propertyName, record.get(columnName)); } return recordAsProperty; }
From source file:org.shept.persistence.provider.hibernate.HibernateUtils_old.java
/** * Checking if it is a new model/*from w w w.j ava 2s . c o m*/ * If the index is a compound index we must check all components if they are all non null * @param index * @return */ public static boolean isNewModel(HibernateDaoSupport dao, Object model) { final Object index = getIdValue(dao, model); final List<Field> nulls = new ArrayList<Field>(); if (index == null) return true; ReflectionUtils.doWithFields(index.getClass(), new ReflectionUtils.FieldCallback() { public void doWith(Field field) { try { Method idMth = ReflectionUtils.findMethod(index.getClass(), "get" + StringUtils.capitalize(field.getName())); Object value = ReflectionUtils.invokeMethod(idMth, index); if (value == null) { nulls.add(field); } } catch (Exception ex) { // ignore all Exception here as they are quit frequent // e.g. serialVersionUid e.t.c. or do better filtering // TODO better eliminate error cases } } }); return nulls.size() > 0; }