Example usage for org.apache.commons.lang StringUtils defaultString

List of usage examples for org.apache.commons.lang StringUtils defaultString

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils defaultString.

Prototype

public static String defaultString(String str) 

Source Link

Document

Returns either the passed in String, or if the String is null, an empty String ("").

Usage

From source file:MainClass.java

public static void main(String[] args) {
    //Takes Object input and returns Empty String if null.
    System.out.println("6) Return default string >>>" + "**" + StringUtils.defaultString(null) + "**");

}

From source file:net.erdfelt.android.sdkfido.util.CompareUtil.java

private static CollationKey asKey(String str) {
    return collator.getCollationKey(StringUtils.defaultString(str));
}

From source file:com.greenline.guahao.biz.manager.partners.xm.converter.XmConverter.java

public static XmOrderDO convertToXmOrderDO(OrderDO o, String xmUserId, String accessToken) {
    XmOrderDO xo = null;/* w w w  .j a v  a  2  s  . c om*/
    if (null != o) {
        xo = new XmOrderDO();
        xo.setAccessToken(accessToken); // ?
        xo.setUserId(xmUserId);// ??
        xo.setOrderDepartment(StringUtils.defaultString(o.getHospDepartmentName())); // ??
        xo.setOrderDoctor(StringUtils.defaultString(o.getExpertName()));// ??
        xo.setOrderHospital(StringUtils.defaultString(o.getHosptialName()));// ??
        xo.setOrderId(StringUtils.defaultString(o.getOrderNo()));// ??
        xo.setOrderName(XmConstants.ORDER_NAME);// ???
        xo.setOrderPlace0(StringUtils.defaultString(o.getFetchAddress())); // ???
        xo.setOrderPlace1(StringUtils.defaultString(o.getClinicAddress())); // ?
        xo.setOrderPrice(null == o.getClinicFee() ? 0
                : new BigDecimal(o.getClinicFee()).divide(new BigDecimal(100)).setScale(2).doubleValue()); // ????
        xo.setOrderPriceInfo(xo.getOrderPlace0());// ?
        xo.setOrderShipType(StringUtils.defaultString(o.getClinicTypeName())); // 
        xo.setOrderShortInfo(getOrderShortInfo(xo));// ???<=32
        xo.setOrderStartTime(parseTimeToSecondFromYyyyMMdd(o.getClinicDate())); // 
        xo.setOrderStatus(switchOrderStatus(o.getStatus())); // ??
        xo.setOrderTime(parseTimeToSecond(o.getCreatedTime())); // ?
        xo.setOrderUrl(getOrderDetailUrl(xo)); // ??
    }
    return xo;
}

From source file:com.feedzai.fos.impl.weka.WekaClassifierFactory.java

/**
 * @param modelConfig model config should contain the wanted classifier
 * @return instantiated classifier/*from   w  ww.  j a  va2s  .c o  m*/
 * @throws FOSException if it has failed to create a classifier
 */
public static Classifier create(ModelConfig modelConfig) throws FOSException {
    checkNotNull(modelConfig, "Model config cannot be null");

    String classifierNames = modelConfig.getProperty(WekaModelConfig.CLASSIFIER_IMPL);

    try {
        Classifier classifier = (Classifier) Class
                .forName(modelConfig.getProperty(WekaModelConfig.CLASSIFIER_IMPL)).newInstance();

        classifier.setOptions(weka.core.Utils.splitOptions(
                StringUtils.defaultString(modelConfig.getProperty(WekaModelConfig.CLASSIFIER_CONFIG))));

        return classifier;
    } catch (Exception e) {
        throw new FOSException(e);
    }
}

From source file:com.mirth.connect.client.ui.ConnectorTypeData.java

@Override
public String toString() {
    if (decoration != null) {
        return (transportName + " " + StringUtils.defaultString(decoration.getSuffix())).trim();
    } else {/*from w w w . j  av a2 s .  c om*/
        return transportName;
    }
}

From source file:dk.dma.epd.common.prototype.layers.msi.MsiNmInfoPanel.java

/**
 * Display a msi-nm message//from   ww w  . ja  va 2 s.  c o  m
 * @param message
 */
public void showMsiInfo(MsiNmNotification message) {
    String text = "";
    if (message != null && message.get().getDescs().size() > 0) {
        text = StringUtils.defaultString(message.get().getDescs().get(0).getTitle());
    }
    showText(text);
}

From source file:de.thischwa.pmcms.view.context.object.Utils.java

/**
 * @return Html escaped 'string', or '', if string is empty.
 *///w  w  w.  jav a 2  s  .  c om
public static String escape(final String string) {
    return StringUtils.defaultString(StringEscapeUtils.escapeHtml(string));
}

From source file:com.redhat.rhn.frontend.xmlrpc.packages.PackageHelper.java

/**
 * Utility method to convert a package to a map.
 * @param pkg The package to convert// w ww.j  a va  2s.c o  m
 * @param user The user requesting the package conversion (used in calculating the
 * providing_channels attribute)
 * @return Returns a map representation of a package
 */
public static Map packageToMap(Package pkg, User user) {

    Map pkgMap = new HashMap();

    // deal with the providing channels first
    DataResult dr = PackageManager.providingChannels(user, pkg.getId());
    List channelLabels = new ArrayList();
    for (Iterator itr = dr.iterator(); itr.hasNext();) {
        Map map = (Map) itr.next();
        channelLabels.add(map.get("label"));
    }
    pkgMap.put("providing_channels", channelLabels);

    // now deal with the actual package object.
    if (pkg.getPackageName() == null) {
        addEntry(pkgMap, "name", "");
    } else {
        addEntry(pkgMap, "name", StringUtils.defaultString(pkg.getPackageName().getName()));
    }
    if (pkg.getPackageEvr() == null) {
        addEntry(pkgMap, "epoch", "");
        addEntry(pkgMap, "version", "");
        addEntry(pkgMap, "release", "");
    } else {
        PackageEvr evr = pkg.getPackageEvr();
        addEntry(pkgMap, "epoch", StringUtils.defaultString(evr.getEpoch()));
        addEntry(pkgMap, "version", StringUtils.defaultString(evr.getVersion()));
        addEntry(pkgMap, "release", StringUtils.defaultString(evr.getRelease()));
    }

    if (pkg.getPackageArch() == null) {
        addEntry(pkgMap, "arch_label", "");
    } else {
        addEntry(pkgMap, "arch_label", pkg.getPackageArch().getLabel());
    }
    addEntry(pkgMap, "id", pkg.getId());
    addEntry(pkgMap, "build_host", StringUtils.defaultString(pkg.getBuildHost()));
    addEntry(pkgMap, "description", StringUtils.defaultString(pkg.getDescription()));
    addEntry(pkgMap, "checksum", StringUtils.defaultString(pkg.getChecksum().getChecksum()));
    addEntry(pkgMap, "checksum_type",
            StringUtils.defaultString(pkg.getChecksum().getChecksumType().getLabel()));
    addEntry(pkgMap, "vendor", StringUtils.defaultString(pkg.getVendor()));
    addEntry(pkgMap, "summary", StringUtils.defaultString(pkg.getSummary()));
    addEntry(pkgMap, "cookie", StringUtils.defaultString(pkg.getCookie()));
    addEntry(pkgMap, "license", StringUtils.defaultString(pkg.getCopyright()));
    addEntry(pkgMap, "path", StringUtils.defaultString(pkg.getPath()));
    addEntry(pkgMap, "file", StringUtils.defaultString(pkg.getFile()));
    addEntry(pkgMap, "build_date", Translator.date2String(pkg.getBuildTime()));
    addEntry(pkgMap, "last_modified_date", Translator.date2String(pkg.getLastModified()));

    Long sz = pkg.getPackageSize();
    addEntry(pkgMap, "size", (sz == null) ? "" : String.valueOf(sz));

    sz = pkg.getPayloadSize();
    addEntry(pkgMap, "payload_size", (sz == null) ? "" : String.valueOf(sz));

    return pkgMap;
}

From source file:com.redhat.rhn.manager.kickstart.IpAddress.java

/**
 *
 * @param ipIn Ip Address in String Form
 *///from w  ww.  ja  va  2s.  c o  m
public IpAddress(String ipIn) {
    this();
    if (StringUtils.isEmpty(ipIn)) {
        throw new InvalidIpAddressException(StringUtils.defaultString(ipIn));
    }

    String[] soctets = StringUtils.split(ipIn, ".");
    if (soctets.length == 4) {
        try {
            for (int i = 0; i < 4; i++) {
                setOctet(i, new Long(soctets[i]));
            }
        } catch (NumberFormatException num) {
            throw new InvalidIpAddressException(ipIn);
        }
    } else {
        throw new InvalidIpAddressException(ipIn);
    }
}

From source file:com.joshlong.activiti.coordinator.registration1.distribution.producer.RegistrationProducerMain.java

/**
 * generates new processes in response to a read-line
 * @param ctx//ww  w .ja  va  2 s.c  o  m
 * @throws Throwable
 */
static void doReadLine(ApplicationContext ctx) throws Throwable {
    ProcessEngine processEngine = ctx.getBean(ProcessEngine.class);

    String line;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    while (true) {
        System.out.println("which customer would you like to start a fulfillment "
                + "process for? Enter it, then hit <Enter>:");
        line = reader.readLine();
        Integer customerId = Integer.parseInt(StringUtils.defaultString(line).trim());
        Map<String, Object> vars = Collections.singletonMap("customerId", (Object) customerId);
        processEngine.getRuntimeService().startProcessInstanceByKey("customer-fullfillment-process", vars);
    }
}