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:de.fhg.iais.asc.ui.parts.HarvesterPanel.java
private void init(final MyCortexModel myCortexModel) { // OAI-PMH URL this.oaipmhTextField = new JTextField(20); this.retrieveInformationButton = LocalizedUI.createButton("Contact_Repository", new ActionListener() { @Override/*www. ja va 2 s .c o m*/ public void actionPerformed(ActionEvent e) { MetadataFormatsAndSetNamesRetriever retriever = new MetadataFormatsAndSetNamesRetriever( HarvesterPanel.this.oaipmhTextField.getText(), myCortexModel.getConfig().getASCState(), myCortexModel.getConfig().get(AscConfiguration.OAIPMH_PROXYHOST, ""), //$NON-NLS-1$ Integer.valueOf(myCortexModel.getConfig().get(AscConfiguration.OAIPMH_PROXYPORT, 0))); String[] metadataformats = retriever.listMetadataFormats(); HarvesterPanel.this.oaipmhMetadataComboBox.removeAllItems(); for (String metadataformat : metadataformats) { HarvesterPanel.this.oaipmhMetadataComboBox.addItem(metadataformat); } HarvesterPanel.this.availableSets = retriever.listSets(); if (metadataformats.length == 0 && HarvesterPanel.this.availableSets == null) { // get the frame the panel is embedded in Component currentComponent = HarvesterPanel.this; while (currentComponent.getParent() != null && !(currentComponent instanceof JFrame)) { currentComponent = currentComponent.getParent(); } final JFrame parentFrame = currentComponent instanceof JFrame ? (JFrame) currentComponent : null; LocalizedOptionPane.showMessageDialog(parentFrame, "UnableToContactRepository", JOptionPane.ERROR_MESSAGE); return; } } }); this.add("OAI-PMH_URL", this.oaipmhTextField, this.retrieveInformationButton); this.oaipmhMetadataComboBox = this.add("Metadata_format", new JComboBox()); this.oaipmhMetadataComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object item = HarvesterPanel.this.oaipmhMetadataComboBox.getSelectedItem(); myCortexModel.setSelectedMetadataFolder(ObjectUtils.toString(item, null)); } }); this.oaipmhMetadataFormatLabel = this.getLastLabel(); this.setsTextField = this.add("Sets", createSetsTextField()); this.harvestingStrategyComboBox = this.add("Harvesting_Strategy", new JComboBox(HARVEST_STRATEGIES)); this.harvestingStrategyComboBox.setSelectedIndex(0); this.fromDateTextField = this.add("From_date", new DatePickerJTextField()); this.untilDateTextField = this.add("Until_date", new DatePickerJTextField()); this.inboxfolder = myCortexModel.getConfig().get(INBOX, MyCortex.DEFAULT_REPOSITORY_LOCATION + "/asc/inbox"); //$NON-NLS-1$ this.outboxfolder = myCortexModel.getConfig().get(OUTBOX, MyCortex.DEFAULT_REPOSITORY_LOCATION + "/asc/outbox"); //$NON-NLS-1$ }
From source file:com.asakusafw.cleaner.log.LogMessageManager.java
/** * ???//w ww. jav a2s .c o m * * @param messageArgs * @return ?? */ private Object[] toStringMessageArgs(Object[] messageArgs) { if (messageArgs == null) { return messageArgs; } Object[] messageArgsConverted = new Object[messageArgs.length]; for (int i = 0; i < messageArgs.length; i++) { Object obj = messageArgs[i]; if (obj == null) { messageArgsConverted[i] = null; } else if (obj.getClass().isArray()) { messageArgsConverted[i] = ArrayUtils.toString(obj); } else if (obj instanceof Long || obj instanceof Integer || obj instanceof BigDecimal) { messageArgsConverted[i] = ObjectUtils.toString(obj, "null"); } else { messageArgsConverted[i] = messageArgs[i]; } } return messageArgsConverted; }
From source file:com.opengamma.master.historicaltimeseries.impl.DataHistoricalDataPointsResource.java
/** * Builds a URI for the corrections resource. * //w ww . jav a 2 s . c o m * @param baseUri the base URI, not null * @param objectId the object identifier, not null * @param fromDateInclusive the start date, may be null * @param toDateInclusive the end date, may be null * @return the URI, not null */ public static URI uriRemovals(URI baseUri, ObjectIdentifiable objectId, LocalDate fromDateInclusive, LocalDate toDateInclusive) { UriBuilder bld = UriBuilder.fromUri(baseUri).path("/dataPoints/{dpId}/removals/{startDate}/{endDate}"); return bld.build(objectId.getObjectId(), ObjectUtils.toString(fromDateInclusive, ""), ObjectUtils.toString(toDateInclusive, "")); }
From source file:com.fiveamsolutions.nci.commons.audit.DefaultProcessor.java
private String getValueString(Collection<?> value) { if (value == null) { return null; }//from www .j a v a 2 s .c o m String sep = ""; StringBuffer sb = new StringBuffer(); for (Object a : value) { if (sb.length() > AuditLogDetail.VALUE_LENGTH) { break; } sb.append(sep); sep = ","; if (isPersistent(a)) { sb.append(getId(a)); } else { escape(sb, ObjectUtils.toString(decomposeIi(a), null)); } } return StringUtils.abbreviate(sb.toString(), AuditLogDetail.VALUE_LENGTH); }
From source file:mitm.application.djigzo.impl.UserPropertiesImpl.java
@Override public void setUserLocality(UserLocality locality) throws HierarchicalPropertiesException { this.setProperty(getFullPropertyName(LOCALITY), ObjectUtils.toString(locality, null), PropertyRegistry.getInstance().isEncrypted(getFullPropertyName(LOCALITY))); }
From source file:com.fiveamsolutions.nci.commons.audit.DefaultProcessor.java
/** * Produces a string formatted as follows "(String.valueOf(k),String.valueOf(v)) , * (String.valueOf(k),String.valueOf(v)), ...". * @param map/*from ww w .j a va 2 s.com*/ * @return a value string of the provided map */ @SuppressWarnings("PMD.ConsecutiveLiteralAppends") private String getValueString(Map<?, ?> map) { if (map == null) { return null; } String sep = ""; StringBuffer sb = new StringBuffer(); for (Object k : map.keySet()) { if (sb.length() > AuditLogDetail.VALUE_LENGTH) { break; } Object v = map.get(k); if (isPersistent(k)) { k = getId(k); } if (v == null) { v = ""; } else if (isPersistent(v)) { v = getId(v); } sb.append(sep); sb.append('('); escape(sb, ObjectUtils.toString(k, null)); sb.append(','); escape(sb, ObjectUtils.toString(v, null)); sb.append(')'); sep = ","; } return StringUtils.abbreviate(sb.toString(), AuditLogDetail.VALUE_LENGTH); }
From source file:com.fiveamsolutions.nci.commons.audit.DefaultProcessor.java
/** * @param detail the detail entry for the property change to process. * @param oldVal value before the property changed. * @param newVal value after the property changed. *//*from w w w.j av a 2s.c om*/ protected void processDetailObject(AuditLogDetail detail, Object oldVal, Object newVal) { String o, n; if (isPersistent(oldVal)) { o = getId(oldVal).toString(); } else { o = ObjectUtils.toString(oldVal, null); } if (isPersistent(newVal)) { n = getId(newVal).toString(); } else { n = ObjectUtils.toString(newVal, null); } processDetailString(detail, o, n); }
From source file:mitm.application.djigzo.impl.UserPropertiesImpl.java
@Override public void setRelayBounceMode(RelayBounceMode mode) throws HierarchicalPropertiesException { this.setProperty(getFullPropertyName(RELAY_BOUNCE_MODE), ObjectUtils.toString(mode, null), PropertyRegistry.getInstance().isEncrypted(getFullPropertyName(RELAY_BOUNCE_MODE))); }
From source file:nl.strohalm.cyclos.taglibs.AbstractEscapeTag.java
public void setValue(final Object value) { this.value = StringUtils.trimToNull(ObjectUtils.toString(value, "")); }
From source file:org.amplafi.flow.flowproperty.FlowPropertyDefinitionImpl.java
@Override public <T> String serialize(T object) { if (this.getDataClassDefinition().getFlowTranslator() == null) { return null; } else {// w ww .j av a 2 s . co m try { Object serialized = this.getDataClassDefinition().serialize(this, object); return ObjectUtils.toString(serialized, null); } catch (FlowPropertySerializationNotPossibleException e) { return null; } } }