Example usage for org.apache.commons.lang ObjectUtils toString

List of usage examples for org.apache.commons.lang ObjectUtils toString

Introduction

In this page you can find the example usage for org.apache.commons.lang ObjectUtils toString.

Prototype

public static String toString(Object obj, String nullStr) 

Source Link

Document

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" 

Usage

From source file:net.lmxm.ute.gui.components.MavenArtifactsTableModel.java

@Override
public void setValueAt(final Object value, final int row, final int column) {
    final MavenArtifact artifact = artifacts.get(row);
    final String valueString = ObjectUtils.toString(value, "");

    if (column == 0) {
        artifact.setCoordinates(valueString);
    } else if (column == 1) {
        artifact.setTargetName(valueString);
    } else {/*  ww w.j  a va 2 s  .co m*/
        throw new IllegalArgumentException("Column index does not exist"); // TODO
    }

    fireTableCellUpdated(row, column);

    // Add a blank row if needed
    if (!artifacts.get(artifacts.size() - 1).isEmpty()) {
        artifacts.add(new MavenArtifact());
    }
}

From source file:net.lmxm.ute.gui.components.RenameFilesTableModel.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 if (column == 1) {
        fileReference.setTargetName(valueString);
    } else {//  w  ww . j av  a  2 s  .  com
        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:net.lmxm.ute.gui.components.FindReplacePatternsTableModel.java

@Override
public void setValueAt(final Object value, final int row, final int column) {
    final FindReplacePattern findReplacePattern = rowData.get(row);
    final String valueString = ObjectUtils.toString(value, "");

    if (column == 0) {
        findReplacePattern.setFind(valueString);
    } else if (column == 1) {
        findReplacePattern.setReplace(valueString);
    } else {//from www .  j av  a2  s . c  om
        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 FindReplacePattern());
    }
}

From source file:com.seitenbau.jenkins.plugins.dynamicparameter.ChoiceParameterDefinition.java

/**
 * Return default parameter value - used by trigger mechanism.
 *///from  w w  w  .j  ava 2s .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.util.CollectionUtils.java

/**
 * Converts the collection to a Set of Strings by calling org.apache.commons.lang.ObjectUtils on each item of items. 
 * If items is null an empty Set will be returned (i.e., a non-null Set instance is always returned). If an item is 
 * null the item will be "nullString"./*  w  ww .  j  a  v  a2s  . c  o m*/
 * 
 * @param items
 * @return
 */
public static LinkedHashSet<String> toStringSet(Collection<?> items, String nullString) {
    int size = items != null ? items.size() : 0;

    LinkedHashSet<String> set = new LinkedHashSet<String>(size);

    if (items != null) {
        for (Object obj : items) {
            set.add(ObjectUtils.toString(obj, nullString));
        }
    }

    return set;
}

From source file:com.redhat.rcm.maven.plugin.buildmetadata.util.ManifestHelper.java

private Manifest createManifestInstance(final Properties buildMetaDataProperties) {
    final Manifest manifest = new Manifest();
    final Attributes attributes = fetchAttributes(manifest);
    manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
    for (final Map.Entry<Object, Object> entry : buildMetaDataProperties.entrySet()) {
        final String key = ObjectUtils.toString(entry.getKey(), null);
        if (key.length() > MANIFEST_KEY_MAX_LENGTH) {
            continue;
        }/* ww w .  j  av  a2  s  . co  m*/

        final String normalizedKey = normalize(key);
        final String value = ObjectUtils.toString(entry.getValue(), null);

        attributes.putValue(normalizedKey, value);
    }

    return manifest;
}

From source file:com.seitenbau.jenkins.plugins.dynamicparameter.BaseParameterDefinition.java

/**
 * Get the script result as a string.//from  w w  w  .ja va  2s  .c  om
 * @return the default value generated by the script or {@code null}
 */
public final String getScriptResultAsString(Map<String, String> parameters) {
    Object value = executeScript(parameters);
    return ObjectUtils.toString(value, null);
}

From source file:mitm.common.security.ctl.CTLEntryEntity.java

@Override
public void setStatus(CTLEntryStatus status) {
    nameValues.put(STATUS_PROPERTY_NAME, ObjectUtils.toString(status, null));
}

From source file:com.siberhus.web.ckeditor.CkeditorTagConfig.java

public CkeditorTagConfig(HttpServletRequest request, Map<String, Object> attrs) {

    CkeditorConfig cfg = CkeditorConfigurationHolder.config();

    this.contextPath = request.getContextPath();
    // this.basePath =
    // PluginUtils.getPluginResourcePath(this.contextPath,this.PLUGIN_NAME)
    this.basePath = this.contextPath;
    this.connectorsPrefix = cfg.connectors().prefix();
    this.defaultFileBrowser = cfg.defaultFileBrowser();
    this.fileBrowser = this.defaultFileBrowser;
    this.skipAllowedItemsCheck = cfg.skipAllowedItemsCheck();
    this.localConfig = new HashMap<String, String>();
    createOrRetrieveConfig(request);/*  w w  w  .  j a  v a 2s. com*/
    if (attrs != null) {
        String val = null;
        if ((val = String.valueOf(attrs.remove("name"))) != null) {
            this.instanceName = val;
        }
        if ((val = String.valueOf(attrs.remove("id"))) != null) {
            this.instanceId = val;
        } else {
            this.instanceId = this.instanceName;
        }
        if ((val = ObjectUtils.toString(attrs.remove("userSpace"), null)) != null) {
            this.userSpace = val;
        }
        if ((val = ObjectUtils.toString(attrs.remove("append"), null)) != null) {
            this.append = Boolean.valueOf(val);
        }
        if ((val = ObjectUtils.toString(attrs.remove("fileBrowser"), null)) != null) {
            this.fileBrowser = val;
        }
        if ((val = ObjectUtils.toString(attrs.remove("showThumbs"), null)) != null) {
            this.showThumbs = Boolean.valueOf(val);
        }
        if ((val = ObjectUtils.toString(attrs.remove("type"), null)) != null) {
            this.type = val;
        }
        if ((val = ObjectUtils.toString(attrs.remove("target"), null)) != null) {
            this.target = val;
        }
        if ((val = ObjectUtils.toString(attrs.remove("removeInstance"), null)) != null) {
            this.removeInstance = Boolean.valueOf(val);
        }
        addConfigItem(attrs, true);
    }
}

From source file:com.facultyshowcase.app.ui.UIUtil.java

public static void writeProperty(EntityUtilWriter writer, String htmlClass, String label, Object object) {
    writeContainerBeginning(writer, htmlClass);

    writeLabel(writer, htmlClass, label);

    writer.append("<span ");
    writer.appendEscapedAttribute(CLASS, CmsHTMLClassNames.convertClassName(PROP + " " + htmlClass));
    writer.append(">");
    writer.appendEscapedData(ObjectUtils.toString(object, StringUtils.EMPTY));
    writer.append("</span>");

    writeContainerEnd(writer);/*from w w w.j  a  va2 s .c  om*/

}