List of usage examples for org.apache.commons.lang ObjectUtils toString
public static String toString(Object obj)
Gets the toString
of an Object
returning an empty string ("") if null
input.
ObjectUtils.toString(null) = "" ObjectUtils.toString("") = "" ObjectUtils.toString("bat") = "bat" ObjectUtils.toString(Boolean.TRUE) = "true"
From source file:org.pivot4j.ui.property.SimpleRenderProperty.java
/** * @see org.pivot4j.ui.property.RenderProperty#getValue(org.pivot4j.ui.RenderContext) *//*from www. j a v a 2s . co m*/ @Override public Object getValue(RenderContext context) { if (context == null) { throw new NullArgumentException("context"); } if (value == null) { return null; } ExpressionEvaluator evaluator = context.getExpressionEvaluator(); return ObjectUtils.toString(evaluator.evaluate(value, context.getExpressionContext())); }
From source file:org.pivot4j.util.RenderPropertyUtils.java
/** * @param name// www .j a va 2s . c o m * @param category * @param defaultValue * @param context * @return */ public static String getString(String name, String category, String defaultValue, RenderContext context) { if (name == null) { throw new NullArgumentException("name"); } if (category == null) { throw new NullArgumentException("category"); } if (context == null) { throw new NullArgumentException("context"); } Object value = getValue(name, category, null, context); String stringValue = StringUtils.trimToNull(ObjectUtils.toString(value)); if (stringValue == null) { stringValue = defaultValue; } return stringValue; }
From source file:org.pivot4j.util.RenderPropertyUtils.java
/** * @param name/* w w w .j a v a2 s. c o m*/ * @param category * @param defaultValue * @param context * @return */ public static Integer getInteger(String name, String category, Integer defaultValue, RenderContext context) { if (name == null) { throw new NullArgumentException("name"); } if (category == null) { throw new NullArgumentException("category"); } if (context == null) { throw new NullArgumentException("context"); } Integer intValue = defaultValue; Object value = getValue(name, category, defaultValue, context); if (value instanceof Integer) { intValue = (Integer) value; } else { value = StringUtils.trimToNull(ObjectUtils.toString(value)); if (value != null) { intValue = Integer.parseInt((String) value); } } return intValue; }
From source file:org.pivot4j.util.RenderPropertyUtils.java
/** * @param name//ww w. ja va 2 s . c o m * @param category * @param defaultValue * @param context * @return */ public static Float getFloat(String name, String category, Float defaultValue, RenderContext context) { if (name == null) { throw new NullArgumentException("name"); } if (category == null) { throw new NullArgumentException("category"); } if (context == null) { throw new NullArgumentException("context"); } Float floatValue = defaultValue; Object value = getValue(name, category, defaultValue, context); if (value instanceof Float) { floatValue = (Float) value; } else { value = StringUtils.trimToNull(ObjectUtils.toString(value)); if (value != null) { floatValue = Float.parseFloat((String) value); } } return floatValue; }
From source file:org.pivot4j.util.RenderPropertyUtils.java
/** * @param name//from ww w . j a v a 2 s .c o m * @param category * @param defaultValue * @param context * @return */ public static Double getDouble(String name, String category, Double defaultValue, RenderContext context) { if (name == null) { throw new NullArgumentException("name"); } if (category == null) { throw new NullArgumentException("category"); } if (context == null) { throw new NullArgumentException("context"); } Double doubleValue = defaultValue; Object value = getValue(name, category, defaultValue, context); if (value instanceof Double) { doubleValue = (Double) value; } else { value = StringUtils.trimToNull(ObjectUtils.toString(value)); if (value != null) { doubleValue = Double.parseDouble((String) value); } } return doubleValue; }
From source file:org.pivot4j.util.RenderPropertyUtils.java
/** * @param name//from www . j a va2s . c om * @param category * @param defaultValue * @param context * @return */ public static Boolean getBoolean(String name, String category, Boolean defaultValue, RenderContext context) { if (name == null) { throw new NullArgumentException("name"); } if (category == null) { throw new NullArgumentException("category"); } if (context == null) { throw new NullArgumentException("context"); } Boolean booleanValue = defaultValue; Object value = getValue(name, category, defaultValue, context); if (value instanceof Boolean) { booleanValue = (Boolean) value; } else { value = StringUtils.trimToNull(ObjectUtils.toString(value)); if (value != null) { booleanValue = Boolean.parseBoolean((String) value); } } return booleanValue; }
From source file:org.projectforge.web.core.JsonBuilder.java
/** * @param obj * @return * @see ObjectUtils#toString(Object) */ protected String formatValue(Object obj) { return ObjectUtils.toString(obj); }
From source file:org.projectforge.web.wicket.autocompletion.PFAutoCompleteTextField.java
/** * Uses ObjectUtils.toString(Object) as default. * @param value/* ww w . j av a2 s .c o m*/ * @return */ protected String formatValue(final T value) { return ObjectUtils.toString(value); }
From source file:org.reusables.dbunit.autocomplete.AutoCompletionDataset.java
private Object generateValue(final AutoCompletionColumn column, final Object orgValue, final AutoCompletionRules rules) { if (orgValue instanceof String) { final String str = (String) orgValue; final String prefix = rules.getGenPrefixPlusSeparator(); final String postfix = rules.getGenPostfix(); if (str.length() > prefix.length() + postfix.length() && str.startsWith(prefix) && (StringUtils.isEmpty(postfix) || str.endsWith(postfix))) { final String orgValueStr = str; return StringUtils.substring(orgValueStr, prefix.length(), orgValueStr.length() - postfix.length()); }//from www . j ava 2s . co m } final Integer randomValue = getRandomValue(column); final String value = StringUtils.defaultString(column.getValue()); switch (column.getType()) { case NUMBER: return randomValue != null ? randomValue : value; case FK: case PK: case STRING: return String.format("%s%s", value, ObjectUtils.toString(randomValue)); } return ITable.NO_VALUE; }
From source file:org.sakaiproject.site.tool.SiteAction.java
private List getLtiToolGroup(String groupName, File moreInfoDir, Site site) { List ltiSelectedTools = selectedLTITools(site); List ltiTools = new ArrayList(); List<Map<String, Object>> allTools; if (site == null) allTools = m_ltiService.getTools(null, null, 0, 0); else//from ww w. ja v a 2 s.c o m allTools = m_ltiService.getToolsDao(null, null, 0, 0, site.getId()); if (allTools != null && !allTools.isEmpty()) { for (Map<String, Object> tool : allTools) { Set keySet = tool.keySet(); String toolIdString = ObjectUtils.toString(tool.get(m_ltiService.LTI_ID)); boolean toolStealthed = "1".equals(ObjectUtils.toString(tool.get(m_ltiService.LTI_VISIBLE))); boolean ltiToolSelected = ltiSelectedTools.contains(toolIdString); try { // in Oracle, the lti tool id is returned as BigDecimal, which cannot be casted into Integer directly Integer ltiId = Integer.valueOf(toolIdString); if (ltiId != null) { String ltiToolId = ltiId.toString(); if (ltiToolId != null && (!toolStealthed || ltiToolSelected)) { String relativeWebPath = null; MyTool newTool = new MyTool(); newTool.title = tool.get("title").toString(); newTool.id = LTITOOL_ID_PREFIX + ltiToolId; newTool.description = (String) tool.get("description"); newTool.group = groupName; relativeWebPath = getMoreInfoUrl(moreInfoDir, ltiToolId); if (relativeWebPath != null) { newTool.moreInfo = relativeWebPath; } // SAK16600 should this be a property or specified in toolOrder.xml? newTool.required = false; newTool.selected = ltiToolSelected; ltiTools.add(newTool); } } } catch (NumberFormatException e) { M_log.error(this + " Cannot cast tool id String " + toolIdString + " into integer value."); } } } return ltiTools; }