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:mitm.common.security.cms.SignerIdentifierImpl.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();

    sb.append("Issuer: ");
    sb.append(ObjectUtils.toString(issuer));
    sb.append(SystemUtils.LINE_SEPARATOR);
    sb.append("Serial number: ");
    sb.append(BigIntegerUtils.hexEncode(serialNumber, ""));
    sb.append(SystemUtils.LINE_SEPARATOR);
    sb.append("SubjectKeyIdentifier: ");
    sb.append(HexUtils.hexEncode(subjectKeyIdentifier));

    return sb.toString();
}

From source file:com.dattack.naming.StandaloneJndiTest.java

@Test
public void testLookupInvalidContextAndName() 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, INVALID_OBJECT_NAME);
    final Object obj = context.lookup(name);
    fail(String.format("This test must fail because the name '%s' not exists (object: %s)", INVALID_CONTEXT,
            ObjectUtils.toString(obj)));
}

From source file:de.codesourcery.eve.apiclient.cache.FilesystemResponseCacheTest.java

protected void assertCacheDirEmpty() {

    final String[] files = tmpDir.list();
    if (files.length > 0) {
        throw new AssertionFailedError("Cache dir should be empty but contains " + ObjectUtils.toString(files));
    }//  w w  w.ja v  a 2  s. co  m
}

From source file:com.manydesigns.elements.options.DefaultSelectionProvider.java

public void ensureActive(Object... values) {
    Row row = null;// w w  w  .java  2s  .c o  m
    ListIterator<Row> iterator = rows.listIterator();
    while (iterator.hasNext()) {
        Row current = iterator.next();
        boolean found = true;
        for (int i = 0; i < fieldCount; i++) {
            if (!ObjectUtils.equals(values[i], current.getValues()[i])) {
                found = false;
                break;
            }
        }
        if (found) {
            row = new Row(values, current.getLabels(), true);
            iterator.set(row);
            break;
        }
    }
    if (row == null) {
        String[] labels = new String[fieldCount];
        for (int i = 0; i < fieldCount; i++) {
            labels[i] = ObjectUtils.toString(values[i]);
        }
        row = new Row(values, labels, true);
        rows.add(row);
    }
}

From source file:com.projity.field.DynamicSelect.java

public Object getValue(Object arg0) throws InvalidChoiceException {
    if (arg0 == null)
        return null;
    String name = arg0.toString();
    if (StringUtils.isEmpty(name))
        return null;
    Object result = find(name, null);
    if (result == null && (!isAllowNull() || name != EMPTY))
        throw new InvalidChoiceException(ObjectUtils.toString(name));
    return result;
}

From source file:de.codesourcery.eve.skills.util.XMLMapperTest.java

private void assertArrayEquals(float[] expected, float[] actual) {

    boolean result;
    if (expected == null || actual == null) {
        result = expected == actual;/*  w w w. ja  va2  s .  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.swordlord.gozer.databinding.DataBinding.java

public Object getFormattedValue(DataRowBase rowCurrent) {
    Object oValue = null;//  w w w.  ja  v a  2s . c om

    // First, find correct row!
    if (_dataBindingField.isForeignKey()) {
        LinkedList<DataBindingElement> elements = rowCurrent
                .getFKeyDisplayPath(_dataBindingField.getFieldName());

        DataRowBase rowFKey = getResolvedRow(elements, rowCurrent);

        oValue = getRawValue(rowFKey, elements.getLast().getPathElement());
    } else if ((_dataBindingMember.getDataBindingPathName().split("\\.").length > 1)) {
        // based on row, find referenced row
        if (_dataBindingField._strTableName.equals(rowCurrent.getTableName()))
            oValue = getRawValue(rowCurrent);
        else
            oValue = getRawValue(getResolvedRow(rowCurrent));
    } else {
        // then, read value from row
        oValue = getRawValue(rowCurrent);
    }

    String strFormattedValue = null;

    DataTypeFormat format = _dataBindingField.getDataFormat();
    if ((format == null) || (format instanceof EmptyTypeFormat)) {
        return ObjectUtils.toString(oValue);

    } else {
        try {
            if (oValue == null)
                strFormattedValue = null;
            else
                strFormattedValue = format.getFieldFormat().format(oValue);
        } catch (Exception ex) {
            LOG.debug(ex.getMessage());
            strFormattedValue = "";
        }
    }

    return strFormattedValue;
}

From source file:com.projity.field.DynamicSelect.java

public Object getKey(Object arg0) {
    return ObjectUtils.toString(arg0);
}

From source file:mitm.application.djigzo.ws.impl.CertificateValidatorWSImpl.java

@Override
@StartTransaction//from  ww  w.j  a va  2 s  .  c  o m
public CertificateValidatorResult checkValidityForSigning(CertificateStore store, String thumbprint)
        throws WebServiceCheckedException {
    try {
        X509Certificate certificate = getCertificate(store, thumbprint);

        CertificateValidatorResult validatorResult = checkValidity(certificate);

        if (validatorResult.isValid()) {
            /*
             * Certificate is trusted etc. now check if it can be used for 
             * S/MIME signatures
             */
            CertificateValidator validator = new IsValidForSMIMESigning();

            if (!validator.isValid(certificate)) {
                validatorResult = new CertificateValidatorResult(false /* not valid */,
                        validatorResult.isTrusted(), validatorResult.isRevoked(),
                        validatorResult.isBlackListed(), validatorResult.isWhiteListed(),
                        "Certificate cannot be used for S/MIME signatures. "
                                + ObjectUtils.toString(validator.getFailureMessage()));
            }
        }

        return validatorResult;
    } catch (WebServiceCheckedException e) {
        logger.error("checkValidityForSigning failed.", e);

        throw new WebServiceCheckedException(WSExceptionUtils.getExceptionMessage(e));
    } catch (CertificateException e) {
        logger.error("checkValidityForSigning failed.", e);

        throw new WebServiceCheckedException(WSExceptionUtils.getExceptionMessage(e));
    } catch (RuntimeException e) {
        logger.error("checkValidityForSigning failed.", e);

        throw new WebServiceCheckedException(WSExceptionUtils.getExceptionMessage(e));
    }
}

From source file:com.eyeq.pivot4j.ui.aggregator.AbstractAggregator.java

/**
 * @param cell/*from w w  w .  ja va  2 s.c o m*/
 * @return
 */
protected NumberFormat getNumberFormat(Cell cell) {
    NumberFormat format = null;

    String pattern = ObjectUtils.toString(cell.getPropertyValue(StandardCellProperty.FORMAT_STRING));
    if (pattern != null && !"Standard".equals(pattern)) {
        try {
            format = new DecimalFormat(pattern);
        } catch (IllegalArgumentException e) {
            if (logger.isWarnEnabled()) {
                logger.warn("Illegal number format : " + pattern);
            }
        }
    }

    if (format == null) {
        format = DecimalFormat.getNumberInstance();
    }

    return format;
}