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) 

Source Link

Document

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" 

Usage

From source file:com.yucheng.cmis.pub.util.NewStringUtils.java

/**
 * <p>Joins the elements of the provided <code>Iterator</code> into
 * a single String containing the provided elements.</p>
 *
 * <p>No delimiter is added before or after the list.
 * A <code>null</code> separator is the same as an empty String ("").</p>
 *
 * <p>See the examples here: {@link #join(Object[],String)}. </p>
 *
 * @param iterator  the <code>Iterator</code> of values to join together, may be null
 * @param separator  the separator character to use, null treated as ""
 * @return the joined String, <code>null</code> if null iterator input
 *///w w w .j  a v a2s .co  m
public static String join(Iterator iterator, String separator) {

    // handle null, zero and one elements before building a buffer
    if (iterator == null) {
        return null;
    }
    if (!iterator.hasNext()) {
        return EMPTY;
    }
    Object first = iterator.next();
    if (!iterator.hasNext()) {
        return ObjectUtils.toString(first);
    }

    // two or more elements
    StringBuffer buf = new StringBuffer(256); // Java default is 16, probably too small
    if (first != null) {
        buf.append(first);
    }

    while (iterator.hasNext()) {
        if (separator != null) {
            buf.append(separator);
        }
        Object obj = iterator.next();
        if (obj != null) {
            buf.append(obj);
        }
    }
    return buf.toString();
}

From source file:com.test.stringtest.StringUtils.java

/**
 * <p>Joins the elements of the provided <code>Iterator</code> into
 * a single String containing the provided elements.</p>
 *
 * <p>No delimiter is added before or after the list. Null objects or empty
 * strings within the iteration are represented by empty strings.</p>
 *
 * <p>See the examples here: {@link #join(Object[],char)}. </p>
 *
 * @param iterator  the <code>Iterator</code> of values to join together, may be null
 * @param separator  the separator character to use
 * @return the joined String, <code>null</code> if null iterator input
 * @since 2.0//from w  w  w  . ja va 2 s.  co  m
 */
public static String join(Iterator iterator, char separator) {

    // handle null, zero and one elements before building a buffer
    if (iterator == null) {
        return null;
    }
    if (!iterator.hasNext()) {
        return EMPTY;
    }
    Object first = iterator.next();
    if (!iterator.hasNext()) {
        return ObjectUtils.toString(first);
    }

    // two or more elements
    StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
    if (first != null) {
        buf.append(first);
    }

    while (iterator.hasNext()) {
        buf.append(separator);
        Object obj = iterator.next();
        if (obj != null) {
            buf.append(obj);
        }
    }

    return buf.toString();
}

From source file:com.test.stringtest.StringUtils.java

/**
 * <p>Joins the elements of the provided <code>Iterator</code> into
 * a single String containing the provided elements.</p>
 *
 * <p>No delimiter is added before or after the list.
 * A <code>null</code> separator is the same as an empty String ("").</p>
 *
 * <p>See the examples here: {@link #join(Object[],String)}. </p>
 *
 * @param iterator  the <code>Iterator</code> of values to join together, may be null
 * @param separator  the separator character to use, null treated as ""
 * @return the joined String, <code>null</code> if null iterator input
 *//*w  ww  . j  a va  2 s . c  o m*/
public static String join(Iterator iterator, String separator) {

    // handle null, zero and one elements before building a buffer
    if (iterator == null) {
        return null;
    }
    if (!iterator.hasNext()) {
        return EMPTY;
    }
    Object first = iterator.next();
    if (!iterator.hasNext()) {
        return ObjectUtils.toString(first);
    }

    // two or more elements
    StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
    if (first != null) {
        buf.append(first);
    }

    while (iterator.hasNext()) {
        if (separator != null) {
            buf.append(separator);
        }
        Object obj = iterator.next();
        if (obj != null) {
            buf.append(obj);
        }
    }
    return buf.toString();
}

From source file:org.amplafi.flow.flowproperty.FixedFlowPropertyValueProvider.java

/**
 * @return the value as a string.
 */
public String getDefaultString() {
    return ObjectUtils.toString(getDefaultObject());
}

From source file:org.amplafi.flow.FlowUtils.java

/**
 * Converts each passed key value pair to the form: <em>key='value'</em>
 * and adds the result into the given list.
 *
 * @param values the list in which to include the key value pairs
 * @param keyValues the key value pairs/*w ww .  j a  v a  2s. co  m*/
 */
public void addInitialValues(List<String> values, Object... keyValues) {
    for (int i = 0; i < keyValues.length; i += 2) {
        if (keyValues[i] != null) {
            values.add(keyValues[i].toString() + "='" + ObjectUtils.toString(keyValues[i + 1]) + "'");
        }
    }
}

From source file:org.amplafi.flow.impl.DefaultFlowValuesMap.java

@Override
public String toString() {
    return ObjectUtils.toString(map);
}

From source file:org.amplafi.flow.impl.DefaultFlowValuesMapKey.java

@Override
public String toString() {
    if (stringValue == null) {
        if (isNotBlank(namespace)) {
            stringValue = namespace + NAMESPACE_SEPARATOR + ObjectUtils.toString(key);
        } else {//  w w  w . j a va 2s. c  om
            stringValue = ObjectUtils.toString(key);
        }
    }
    return stringValue;
}

From source file:org.amplafi.flow.web.components.FlowEntryPoint.java

public String getClassName() {
    if (isDynamic()) {
        return FL_ENTRYPOINT_HTML_CLASS + " fl-async noanimation " + ObjectUtils.toString(getHtmlClass());
    } else {//from ww w. ja v  a2s  .c om
        return FL_ENTRYPOINT_HTML_CLASS + " " + ObjectUtils.toString(getHtmlClass());
    }
}

From source file:org.amplafi.json.renderers.BooleanJsonRenderer.java

public IJsonWriter toJson(IJsonWriter jsonWriter, Boolean o) {
    return jsonWriter.append(ObjectUtils.toString(o));
}

From source file:org.andromda.cartridges.gui.GuiUtils.java

/**
 * Indicates if the given element is read-only or not.
 * /*ww w  .j  av  a  2s .  com*/
 * @param element the element to check.
 * @return true/false
 */
public static boolean isReadOnly(final ModelElementFacade element) {

    boolean readOnly = false;

    if (element != null) {

        final Object value = element.findTaggedValue(GuiProfile.TAGGEDVALUE_INPUT_READONLY);

        readOnly = Boolean.valueOf(ObjectUtils.toString(value)).booleanValue();

    }

    return readOnly;

}