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.eclipse.jubula.client.ui.validator.cell.PortCellEditorValidator.java
/** * {@inheritDoc}/*ww w . ja v a 2s. c o m*/ */ public String isValid(Object value) { try { int portValue = Integer.parseInt(ObjectUtils.toString(value)); if (portValue < Constants.MIN_PORT_NUMBER || portValue > Constants.MAX_PORT_NUMBER) { return NLS.bind(Messages.ValidationPortErrorInvalidPortNumber, m_i18nArguments); } return null; } catch (NumberFormatException nfe) { // Fall through } return NLS.bind(Messages.ValidationPortErrorInvalidPortNumber, m_i18nArguments); }
From source file:org.eclipse.jubula.client.ui.views.TestresultSummaryView.java
/** * Adds a "Language" column to the given viewer. * @param tableViewer The viewer to which the column will be added. *//*w w w . j a v a 2 s . c o m*/ private void addLanguageColumn(TableViewer tableViewer) { TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE); column.getColumn().setWidth(0); column.getColumn().setImage(IconConstants.LANGUAGE_IMAGE); column.getColumn().setText(TESTRESULT_SUMMARY_LANGUAGE); column.getColumn().setMoveable(true); column.setLabelProvider(new TestresultSummaryViewColumnLabelProvider() { public String getText(Object element) { return ObjectUtils.toString(((ITestResultSummaryPO) element).getTestsuiteLanguage()); } }); createMenuItem(m_headerMenu, column.getColumn()); new ColumnViewerSorter(tableViewer, column) { @Override protected int doCompare(Viewer viewer, Object e1, Object e2) { return getCommonsComparator().compare(((ITestResultSummaryPO) e1).getTestsuiteLanguage(), ((ITestResultSummaryPO) e2).getTestsuiteLanguage()); } }; }
From source file:org.eclipse.jubula.client.ui.views.TestresultSummaryView.java
/** * Adds a "Comment Title" column to the given viewer. * @param tableViewer The viewer to which the column will be added. */// w w w .j a v a 2 s . co m private void addCommentTitleColumn(TableViewer tableViewer) { TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE); column.getColumn().setWidth(200); column.getColumn().setText(TESTRESULT_SUMMARY_COMMENT_TITLE); column.getColumn().setMoveable(true); column.setLabelProvider(new TestresultSummaryViewColumnLabelProvider() { public String getText(Object element) { return ObjectUtils.toString(((ITestResultSummaryPO) element).getCommentTitle()); } }); createMenuItem(m_headerMenu, column.getColumn()); new ColumnViewerSorter(tableViewer, column) { @Override protected int doCompare(Viewer viewer, Object e1, Object e2) { return getCommonsComparator().compare(((ITestResultSummaryPO) e1).getCommentTitle(), ((ITestResultSummaryPO) e2).getCommentTitle()); } }; }
From source file:org.eclipse.smarthome.binding.homematic.handler.HomematicThingHandler.java
/** * Sets a thing property with a datapoint value. *///www . ja va2 s . c o m private void setProperty(Map<String, String> properties, HmChannel channelZero, String propertyName, String datapointName) { HmDatapoint dp = channelZero .getDatapoint(new HmDatapointInfo(HmParamsetType.VALUES, channelZero, datapointName)); if (dp != null) { properties.put(propertyName, ObjectUtils.toString(dp.getValue())); } }
From source file:org.eclipse.smarthome.binding.homematic.handler.HomematicThingHandler.java
/** * Converts the value of the datapoint to a State, updates the channel and also sets the thing status if necessary. *//*www. j a va 2 s . c o m*/ private void updateChannelState(final HmDatapoint dp, Channel channel) throws IOException, GatewayNotAvailableException, ConverterException { if (dp.isTrigger()) { if (dp.getValue() != null) { triggerChannel(channel.getUID(), ObjectUtils.toString(dp.getValue())); } } else if (isLinked(channel)) { loadHomematicChannelValues(dp.getChannel()); TypeConverter<?> converter = ConverterFactory.createConverter(channel.getAcceptedItemType()); State state = converter.convertFromBinding(dp); if (state != null) { updateState(channel.getUID(), state); } else { logger.debug("Failed to get converted state from datapoint '{}'", dp.getName()); } } }
From source file:org.eclipse.smarthome.binding.homematic.internal.communicator.CcuGateway.java
@Override protected void setVariable(HmDatapoint dp, Object value) throws IOException { String strValue = StringUtils.replace(ObjectUtils.toString(value), "\"", "\\\""); if (dp.isStringType()) { strValue = "\"" + strValue + "\""; }//from w w w .j a v a 2 s .com HmResult result = sendScriptByName("setVariable", HmResult.class, new String[] { "variable_name", "variable_state" }, new String[] { dp.getInfo(), strValue }); if (!result.isValid()) { throw new IOException("Unable to set CCU variable " + dp.getInfo()); } }
From source file:org.eclipse.smarthome.binding.homematic.internal.communicator.parser.CommonRpcParser.java
/** * Converts the object to a string. */ protected String toString(Object object) { return StringUtils.trimToNull(ObjectUtils.toString(object)); }
From source file:org.eclipse.smarthome.binding.homematic.internal.communicator.parser.CommonRpcParser.java
/** * Converts the object to a integer./*from www. j av a 2s .com*/ */ protected Integer toInteger(Object object) { if (object == null || object instanceof Integer) { return (Integer) object; } try { return Double.valueOf(ObjectUtils.toString(object)).intValue(); } catch (NumberFormatException ex) { logger.debug("Failed converting {} to a Double", object, ex); return null; } }
From source file:org.eclipse.smarthome.binding.homematic.internal.communicator.parser.CommonRpcParser.java
/** * Converts the object to a double.//from w w w . j av a 2 s . c om */ protected Double toDouble(Object object) { if (object == null || object instanceof Double) { return (Double) object; } try { return Double.valueOf(ObjectUtils.toString(object)); } catch (NumberFormatException ex) { logger.debug("Failed converting {} to a Double", object, ex); return null; } }
From source file:org.eclipse.smarthome.binding.homematic.internal.communicator.parser.CommonRpcParser.java
/** * Converts the object to a number./*from w w w . ja v a2 s .co m*/ */ protected Number toNumber(Object object) { if (object == null || object instanceof Number) { return (Number) object; } try { return NumberUtils.createNumber(ObjectUtils.toString(object)); } catch (NumberFormatException ex) { logger.debug("Failed converting {} to a Number", object, ex); return null; } }