List of usage examples for org.apache.commons.lang ObjectUtils toString
public static String toString(Object obj, String nullStr)
Gets the toString
of an Object
returning a specified text if null
input.
ObjectUtils.toString(null, null) = null ObjectUtils.toString(null, "null") = "null" ObjectUtils.toString("", "null") = "" ObjectUtils.toString("bat", "null") = "bat" ObjectUtils.toString(Boolean.TRUE, "null") = "true"
From source file:com.linkedin.bowser.core.exceptions.QueryRuntimeException.java
public QueryRuntimeException(String errorType, int line, int charPositionInLine, String text, String message) { super(String.format("%s: line %d, pos %d: %s", errorType, line, charPositionInLine, ObjectUtils.toString(message, "").trim())); _line = line;//from w w w.j av a 2 s . co m _charPositionInLine = charPositionInLine; _text = text; }
From source file:com.opengamma.language.config.ConfigurationFactoryBean.java
public String getConfigurationURI() { return ObjectUtils.toString(_configurationUri, null); }
From source file:com.alibaba.tamper.process.DebugValueProcess.java
@Override public Object process(Object value, ValueProcessInvocation invocation) throws BeanMappingException { BeanMappingField currentField = invocation.getContext().getCurrentField(); if (currentField.isMapping() == false && invocation.getContext().getBeanObject().getBehavior().isDebug() && logger.isDebugEnabled()) { StringBuilder builder = new StringBuilder(); builder.append("srcName[" + currentField.getSrcField().getName()); builder.append("],srcClass[" + ObjectUtils.toString(currentField.getSrcField().getClazz(), "null")); builder.append("],targetName[" + currentField.getTargetField().getName()); builder.append(/* w ww. j a v a2 s .c om*/ "],targetClass[" + ObjectUtils.toString(currentField.getTargetField().getClazz(), "null")); if (StringUtils.isNotEmpty(currentField.getDefaultValue())) { builder.append("],[defaultValue=" + currentField.getDefaultValue()); } if (StringUtils.isNotEmpty(currentField.getConvertor())) { builder.append("],[convertor=" + currentField.getConvertor()); } if (StringUtils.isNotEmpty(currentField.getScript())) { builder.append("],[script=" + currentField.getScript()); } builder.append("], Value = " + ObjectUtils.toString(value, "null")); logger.debug(builder.toString()); } return invocation.proceed(value); // }
From source file:com.baasbox.controllers.ScriptInvoker.java
@With({ UserOrAnonymousCredentialsFilter.class, ConnectToDBFilter.class, ExtractQueryParameters.class }) public static Result invoke(String name, String path) { ODocument serv = null;//from ww w. j a v a 2s. c o m if (request().body().asText() != null && request().body().isMaxSizeExceeded())//fixes issue_561 return badRequest("Too much data! The maximum is " + ObjectUtils .toString(BBConfiguration.configuration.getString("parsers.text.maxLength"), "128KB")); try { serv = ScriptingService.get(name, true, true); } catch (ScriptException e) { return status(503, "Script is in an invalid state"); } if (serv == null) { return notFound("Script does not exists"); } JsonNode reqAsJson = serializeRequest(path, request()); try { ScriptResult result = ScriptingService.invoke(ScriptCall.rest(serv, reqAsJson)); return status(result.status(), result.content()); } catch (ScriptEvalException e) { if (DbHelper.getConnection() != null && !DbHelper.getConnection().isClosed() && DbHelper.isInTransaction()) DbHelper.rollbackTransaction(); BaasBoxLogger.error("Error evaluating script", e); return status(CustomHttpCode.PLUGIN_INTERNAL_ERROR.getBbCode(), ExceptionUtils.getFullStackTrace(e)); // return internalServerError(ExceptionUtils.getFullStackTrace(e)); } // catch (IllegalStateException e){ // return internalServerError("script returned invalid json response"); // } }
From source file:com.opengamma.core.config.impl.ConfigItem.java
/** * Obtains an item that wraps the underlying object. * <p>//from w ww . java 2 s. c om * The name will be extracted if the target object has a {@code getName} method. * * @param <T> the type of the item * @param object the underlying object, not null * @return the item, not null */ public static <T> ConfigItem<T> of(final T object) { final ConfigItem<T> item = new ConfigItem<T>(object); if (object instanceof Bean) { final Bean bean = (Bean) object; if (bean.metaBean().metaPropertyExists("name")) { item.setName(ObjectUtils.toString(bean.property("name").get(), null)); } } else if (object != null) { try { item.setName((String) object.getClass().getMethod("getName").invoke(object)); } catch (final Exception ex) { // ignore } } return item; }
From source file:mitm.common.util.CollectionUtils.java
/** * Converts the collection to an array of Strings by calling org.apache.commons.lang.ObjectUtils on each item. * If items is null null will be returned. If an item is null the item will be "nullString". *//*from w ww. jav a 2 s . co m*/ public static String[] toStringArray(Collection<?> items, String nullString) { if (items == null) { return null; } String[] result = new String[items.size()]; int i = 0; for (Object obj : items) { result[i] = ObjectUtils.toString(obj, nullString); i++; } return result; }
From source file:mitm.common.util.CollectionUtils.java
/** * Converts the collection to a List of Strings by calling org.apache.commons.lang.ObjectUtils on each item. If * items is null an empty List will be returned (i.e., a non-null List instance is always returned). If an item is * null the item will be "nullString"./* w w w .j av a2 s . com*/ * * @param items * @return */ public static ArrayList<String> toStringList(Collection<?> items, String nullString) { int size = items != null ? items.size() : 0; ArrayList<String> sl = new ArrayList<String>(size); if (items != null) { for (Object obj : items) { sl.add(ObjectUtils.toString(obj, nullString)); } } return sl; }
From source file:net.lmxm.ute.gui.components.FilesTableModel.java
@Override public void setValueAt(final Object value, final int row, final int column) { final FileReference fileReference = rowData.get(row); final String valueString = ObjectUtils.toString(value, ""); if (column == 0) { fileReference.setName(valueString); } else {/*from ww w. ja v a2 s. co m*/ throw new IllegalArgumentException("Column index does not exist"); // TODO } fireTableCellUpdated(row, column); // Add a blank row if needed if (!rowData.get(rowData.size() - 1).isEmpty()) { rowData.add(new FileReference()); } }
From source file:com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerChoiceParameterDefinition.java
/** * Return default parameter value - used by trigger mechanism. *//*from w w w. ja va 2 s. c o m*/ @Override public ParameterValue getDefaultParameterValue() { Object firstElement = null; // Ensure list does exist and is not empty! Otherwise return null if (getChoices() != null && getChoices().size() > 0) { firstElement = getChoices().get(0); } StringParameterValue stringParameterValue = new StringParameterValue(getName(), ObjectUtils.toString(firstElement, null)); return stringParameterValue; }
From source file:mitm.common.security.crl.X509CRLEntryInspector.java
/** * Returns a string representation of the crlEntry */// ww w . jav a 2 s. c o m public static String toString(X509CRLEntry crlEntry) { Date revocationDate = crlEntry.getRevocationDate(); String reason; try { reason = ObjectUtils.toString(getReason(crlEntry), ""); } catch (IOException e) { reason = ""; } return getSerialNumberHex(crlEntry) + "\t" + (revocationDate != null ? DateFormatUtils.ISO_DATE_FORMAT.format(revocationDate) : "") + "\t" + reason; }