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:com.controlj.addon.weather.util.HTTPHelper.java
private String encodeParams(Map<String, Object> params) { if (params == null) return null; List<NameValuePair> qparams = new ArrayList<NameValuePair>(); for (Map.Entry<String, Object> entry : params.entrySet()) qparams.add(new BasicNameValuePair(entry.getKey(), ObjectUtils.toString(entry.getValue()))); return URLEncodedUtils.format(qparams, "UTF-8"); }
From source file:com.eyeq.pivot4j.ui.property.ConditionalProperty.java
@Override public String getValue(RenderContext context) { if (values == null) { return null; }// ww w . j a v a 2 s. co m String value = null; for (ConditionalValue conditionValue : values) { if (conditionValue.getCondition().matches(context)) { value = conditionValue.getValue(); } } if (value == null) { value = defaultValue; } if (value != null) { ExpressionEvaluator evaluator = context.getExpressionEvaluator(); value = ObjectUtils.toString(evaluator.evaluate(value, context.getExpressionContext())); } return value; }
From source file:net.mumie.coursecreator.gui.ClassChooser.java
/** * Vector of all Classes//from w w w. j a v a2s . co m * @return */ private Vector getClassList() { Vector list = new Vector(); Map classes = this.fetchELClassIndex(); if (classes.size() == 0) return list; for (Iterator iter = classes.keySet().iterator(); iter.hasNext();) { String path = (String) iter.next(); ELClassWrapper el = new ELClassWrapper(ObjectUtils.toString(classes.get(path)), path); list.add(el); } return list; }
From source file:com.dattack.naming.standalone.StandaloneContextFactory.java
private static Context loadInitialContext(final Hashtable<?, ?> environment) // NOPMD by cvarela throws NamingException { LOGGER.debug("loadInitialContext: {}", environment); final CompositeConfiguration configuration = getConfiguration(environment); final Object configDir = getResourcesDirectory(configuration); final File dir = FilesystemUtils.locateFile(ObjectUtils.toString(configDir)); if ((dir != null) && dir.exists()) { return createInitialContext(dir, environment, configuration); }//from w ww.j ava 2s. c o m throw new ConfigurationException( String.format("JNDI configuration error: directory not exists '%s'", configDir)); }
From source file:com.dattack.dbping.log.CSVFileLogWriter.java
private String format(final LogHeader header) { String data = null;/*from w w w .j a va 2 s. c om*/ synchronized (csvBuilder) { csvBuilder.comment(); final List<String> keys = new ArrayList<>(header.getProperties().keySet()); Collections.sort(keys); for (final String key : keys) { csvBuilder.comment(new StringBuilder() // .append(normalize(ObjectUtils.toString(key))) // .append(": ") // .append(normalize(ObjectUtils.toString(header.getProperties().get(key)))) // .toString() // ); } csvBuilder.comment("SQL Sentences:"); for (final SqlCommandBean sentence : header.getPingTaskBean().getSqlStatementList()) { sentence.accept(new SqlCommandVisitor() { @Override public void visite(final SqlScriptBean command) { csvBuilder.comment(new StringBuilder().append(" ").append(command.getLabel()).append(": ") .toString()); for (final SqlStatementBean item : command.getStatementList()) { csvBuilder.comment(new StringBuilder().append(" |-- ").append(item.getLabel()) .append(": ").append(normalize(item.getSql())).toString()); } } @Override public void visite(final SqlStatementBean command) { csvBuilder.comment(new StringBuilder().append(" ").append(command.getLabel()).append(": ") .append(normalize(command.getSql())).toString()); } }); } csvBuilder.comment() // .append("date") // .append("task-name") // .append("thread-name") // .append("iteration") // .append("sql-label") // .append("rows") // .append("connection-time") // .append("first-row-time") // .append("total-time") // .append("message").eol(); data = csvBuilder.toString(); csvBuilder.clear(); } return data; }
From source file:mitm.common.security.cms.KeyTransRecipientIdImpl.java
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ObjectUtils.toString(issuer)); sb.append("/"); sb.append(BigIntegerUtils.hexEncode(serialNumber, "")); sb.append("/"); sb.append(HexUtils.hexEncode(subjectKeyIdentifier, "")); return sb.toString(); }
From source file:de.hybris.platform.cockpit.model.editor.impl.InitiativeCollectionUIEditorFixed.java
protected UIEditor createSingleValueEditor(final Map<String, ? extends Object> parameters) { String editorCode = PropertyEditorDescriptor.SINGLE; if (parameters.containsKey(SINGLE_VALUE_EDITOR_CODE)) { editorCode = ObjectUtils.toString(parameters.get(SINGLE_VALUE_EDITOR_CODE)); }//w w w . jav a 2 s . c om return getSingleValueEditorDescriptor().createUIEditor(editorCode); }
From source file:com.dattack.naming.StandaloneJndiTest.java
@Test public void testLookupInvalidContext() throws NamingException { exception.expect(NamingException.class); exception.expectMessage(String.format("Invalid subcontext '%s' in context '/'", INVALID_CONTEXT)); final InitialContext context = new InitialContext(); final String name = getCompositeName(INVALID_CONTEXT, VALID_OBJECT_NAME); final Object obj = context.lookup(name); fail(String.format("This test must fail because the name '%s' not exists in context '/' (object: %s)", INVALID_CONTEXT, ObjectUtils.toString(obj))); }
From source file:de.codesourcery.eve.skills.util.XMLMapperTest.java
private void assertArrayEquals(int[] expected, int[] actual) { boolean result; if (expected == null || actual == null) { result = expected == actual;/* w ww.j a v a 2s . co m*/ } else { if (expected.length != actual.length) { result = false; } else { for (int i = 0; i < expected.length; i++) { if (!ObjectUtils.equals(expected[i], actual[i])) { throw new AssertionFailedError("expected: " + ObjectUtils.toString(expected) + " , got: " + ObjectUtils.toString(actual)); } } return; } } if (!result) { throw new AssertionFailedError( "expected: " + ObjectUtils.toString(expected) + " , got: " + ObjectUtils.toString(actual)); } }
From source file:com.norconex.collector.http.filter.impl.RegexHeaderFilter.java
@Override public boolean acceptDocument(String url, HttpMetadata headers) { if (StringUtils.isBlank(regex)) { return getOnMatch() == OnMatch.INCLUDE; }//from w w w . ja v a2 s.c o m Collection<String> values = headers.getStrings(header); for (Object value : values) { String strVal = ObjectUtils.toString(value); if (pattern.matcher(strVal).matches()) { return getOnMatch() == OnMatch.INCLUDE; } } return getOnMatch() == OnMatch.EXCLUDE; }