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

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

Introduction

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

Prototype

public static boolean isNotEmpty(String str) 

Source Link

Document

Checks if a String is not empty ("") and not null.

Usage

From source file:com.haulmont.cuba.gui.xml.layout.loaders.TextFieldLoader.java

@Override
public void loadComponent() {
    super.loadComponent();

    loadMaxLength(resultComponent, element);
    loadTrimming(resultComponent, element);

    String datatypeAttribute = element.attributeValue("datatype");
    if (StringUtils.isNotEmpty(datatypeAttribute)) {
        Datatype datatype = Datatypes.get(datatypeAttribute);
        resultComponent.setDatatype(datatype);
    }/*from w  w  w  . j ava2 s . c  om*/

    resultComponent.setFormatter(loadFormatter(element));

    loadInputPrompt(resultComponent, element);
    loadCaseConversion(resultComponent, element);
    loadTextChangeEventProperties(resultComponent, element);
}

From source file:de.pawlidi.openaletheia.utils.exec.ProcessExecutor.java

/**
 * Execute given system command with arguments.
 * //from www .j a v a 2 s  .co  m
 * @param command
 *            to execute
 * @param args
 *            as command arguments
 * @return command output as String, null otherwise
 */
public static String executeCommand(final String command, String... args) {
    if (StringUtils.isNotEmpty(command)) {

        // create string output for executor
        ProcessStringOutput processOutput = new ProcessStringOutput(PROCESS_OUTPUT_LEVEL);
        // create external process
        Executor executor = createExecutor(processOutput);

        // create command line without any arguments
        final CommandLine commandLine = new CommandLine(command);

        if (ArrayUtils.isNotEmpty(args)) {
            // add command arguments
            commandLine.addArguments(args);
        }
        int exitValue = -1;

        try {
            // execute command
            exitValue = executor.execute(commandLine);
        } catch (IOException e) {
            // ignore exception
        }

        if (!executor.isFailure(exitValue)) {
            return processOutput.getOutput();
        }
    }
    return null;
}

From source file:com.cyclopsgroup.tornado.security.entity.User.java

/**
 * @return Full name/*from w w  w  . j  a v a2s.c  o m*/
 */
public String getDisplayName() {
    StringBuffer sb = new StringBuffer(getFirstName());
    if (StringUtils.isNotEmpty(getMiddleName())) {
        sb.append(' ').append(getMiddleName());
    }
    return sb.append(' ').append(getLastName()).toString();
}

From source file:com.cloudera.nav.sdk.client.SSLUtils.java

/**
 * Whether the given urlString has TLS enabled
 * @param urlString/* w w  w.  j  ava 2  s.co m*/
 */
public static boolean isSSL(String urlString) {
    Preconditions.checkArgument(StringUtils.isNotEmpty(urlString));
    return urlString.startsWith("https://");
}

From source file:com.acc.storefront.util.MetaSanitizerUtil.java

/**
 * Takes a string of words, removes duplicates and returns a comma separated list of keywords as a String
 * /* w  ww.j  a v a 2 s .  c  om*/
 * @param keywords
 *           Keywords to be sanitized
 * @return String of comma separated keywords
 */
public static String sanitizeKeywords(final String keywords) {
    final String clean = (StringUtils.isNotEmpty(keywords) ? Jsoup.parse(keywords).text() : ""); // Clean html
    final String[] cleaned = StringUtils.split(clean.replace("\"", "")); // Clean quotes

    // Remove duplicates
    String noDupes = "";
    for (final String word : cleaned) {
        if (!noDupes.contains(word)) {
            noDupes += word + ",";
        }
    }
    if (!noDupes.isEmpty()) {
        noDupes = noDupes.substring(0, noDupes.length() - 1);
    }
    return noDupes;
}

From source file:com.haulmont.cuba.desktop.gui.data.DesktopContainerHelper.java

/**
 * Checks for the presence of component description
 *
 * @param component component to check/*from  www . j  a va  2s .c  o  m*/
 * @return <b>true</b> if the component has a description, and <b>false</b> otherwise
 */
public static boolean hasExternalDescription(Component component) {
    if (component instanceof Field && !(component instanceof DesktopCheckBox)) {
        final String description = ((Field) component).getDescription();
        if (StringUtils.isNotEmpty(description)) {
            return true;
        }
    }
    return false;
}

From source file:gov.nih.nci.cabig.caaers.service.synchronizer.ParticipantSynchronizer.java

@Override
public void preMigrate(Participant dbParticipant, Participant xmlParticipant,
        DomainObjectImportOutcome<Participant> outcome) {

    dbParticipant.setFirstName(xmlParticipant.getFirstName());
    dbParticipant.setLastName(xmlParticipant.getLastName());
    if (xmlParticipant.getMiddleName() != null && StringUtils.isNotEmpty(xmlParticipant.getMiddleName())) {
        dbParticipant.setMiddleName(xmlParticipant.getMiddleName());
    }/*from www .jav a2 s .co m*/
    if (xmlParticipant.getMaidenName() != null && StringUtils.isNotEmpty(xmlParticipant.getMaidenName())) {
        dbParticipant.setMaidenName(xmlParticipant.getMaidenName());
    }
    dbParticipant.setDateOfBirth(xmlParticipant.getDateOfBirth());
    if (xmlParticipant.getGender() != null && StringUtils.isNotEmpty(xmlParticipant.getGender())) {
        dbParticipant.setGender(xmlParticipant.getGender());
    }
    if (xmlParticipant.getEthnicity() != null && StringUtils.isNotEmpty(xmlParticipant.getEthnicity())) {
        dbParticipant.setEthnicity(xmlParticipant.getEthnicity());
    }
    if (xmlParticipant.getRace() != null && StringUtils.isNotEmpty(xmlParticipant.getRace())) {
        dbParticipant.setRace(xmlParticipant.getRace());
    }
}

From source file:com.bfd.harpc.main.ConfigHelper.java

/**
 * ??/*from   w ww .  j  ava2  s. c  o  m*/
 * <p>
 * 
 * @param configObject
 *            ?
 * @param configPrefix
 *            ??
 * @param configuration
 *            {@link PropertiesConfiguration}
 * @throws RpcException
 */
public static void initConfig(Object configObject, String configPrefix, PropertiesConfiguration configuration)
        throws RpcException {
    Method[] methods = configObject.getClass().getMethods();
    for (Method method : methods) {
        if (method.getName().length() > 3 && method.getName().startsWith("set")
                && method.getParameterTypes().length == 1) {
            String attribute = method.getName().substring(3);
            char ch = attribute.charAt(0);
            attribute = Character.toLowerCase(ch) + attribute.substring(1);
            String value = configuration.getProperty(configPrefix + attribute, "");

            try {
                if (StringUtils.isNotEmpty(value)) {
                    Type type = method.getParameterTypes()[0];
                    if (type == boolean.class) {
                        method.invoke(configObject, Boolean.valueOf(value));
                    } else if (type == int.class) {
                        method.invoke(configObject, Integer.valueOf(value));
                    } else if (type == long.class) {
                        method.invoke(configObject, Long.valueOf(value));
                    } else {
                        method.invoke(configObject, value);
                    }
                }
            } catch (Exception e) {
                LOGGER.error("Init config error", e);
                throw new RpcException(RpcException.CONFIG_EXCEPTION, e);
            }
        }
    }
}

From source file:com.qcloud.project.macaovehicle.service.impl.CarOwnerPurchaseServiceImpl.java

@Override
public boolean add(CarOwnerPurchase carOwnerPurchase) {

    long id = autoIdGenerator.get(ID_KEY);
    carOwnerPurchase.setId(id);/*from   ww  w  .  jav  a  2s .  c o  m*/
    if (StringUtils.isNotEmpty(carOwnerPurchase.getLicense())) {
        carOwnerPurchase.setLicense(fileSDKClient.uidToUrl(carOwnerPurchase.getLicense()));
    }
    if (StringUtils.isNotEmpty(carOwnerPurchase.getTax())) {
        carOwnerPurchase.setTax(fileSDKClient.uidToUrl(carOwnerPurchase.getTax()));
    }
    if (StringUtils.isNotEmpty(carOwnerPurchase.getLetter())) {
        carOwnerPurchase.setLetter(fileSDKClient.uidToUrl(carOwnerPurchase.getLetter()));
    }
    return carOwnerPurchaseDao.add(carOwnerPurchase);
}

From source file:com.haulmont.cuba.gui.xml.layout.loaders.MaskedFieldLoader.java

@Override
public void loadComponent() {
    super.loadComponent();

    String mask = element.attributeValue("mask");
    if (StringUtils.isNotEmpty(mask)) {
        resultComponent.setMask(loadResourceString(mask));
    }/*from  w ww .  j  av a  2 s.  co  m*/
    String valueModeStr = element.attributeValue("valueMode");
    if (StringUtils.isNotEmpty(valueModeStr)) {
        resultComponent.setValueMode(ValueMode.valueOf(valueModeStr.toUpperCase()));
    }
}