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

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

Introduction

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

Prototype

public static String defaultString(final String str) 

Source Link

Document

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

 StringUtils.defaultString(null)  = "" StringUtils.defaultString("")    = "" StringUtils.defaultString("bat") = "bat" 

Usage

From source file:ch.qos.logback.decoder.cli.Main.java

/**
 * Entry point for command-line interface
 *
 * @param args the command-line parameters
 *//* w w w .j a v a  2s  . c o m*/
static public void main(String[] args) {
    MainArgs mainArgs = null;
    try {
        mainArgs = new MainArgs(args);

        // handle help and version queries
        if (mainArgs.queriedHelp()) {
            mainArgs.printUsage();
        } else if (mainArgs.queriedVersion()) {
            mainArgs.printVersion();

            // normal processing
        } else {
            if (mainArgs.isDebugMode()) {
                enableVerboseLogging();
            }

            BufferDecoder decoder = new BufferDecoder();
            decoder.setLayoutPattern(mainArgs.getLayoutPattern());

            BufferedReader reader = null;
            if (StringUtils.defaultString(mainArgs.getInputFile()).isEmpty()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
            } else {
                reader = new BufferedReader(new FileReader(mainArgs.getInputFile()));
            }

            decoder.decode(reader);
        }
    } catch (Exception e) {
        System.err.println("error: " + e.getMessage());
    }
}

From source file:com.netsteadfast.greenstep.tools.BusinessProcessManagementDeleteTools.java

public static void main(String args[]) {
    if (args == null || args.length < 1) {
        printDetails();/*from  w w w .  j  a v  a 2 s.  com*/
        System.exit(1);
    }
    boolean force = false;
    String resourceId = args[1];
    String forceStr = StringUtils.defaultString(args[0]).trim().toLowerCase();
    if ("true".equals(forceStr)) {
        force = true;
    }
    try {
        BackgroundProgramUserUtils.login();
        BusinessProcessManagementUtils.deleteDeployment(resourceId, force);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            BackgroundProgramUserUtils.logout();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    System.exit(1);
}

From source file:com.netsteadfast.greenstep.tools.LostPasswordTools.java

public static void main(String args[]) {
    if (args == null || args.length < 2) {
        printDetails();// w  w  w . j ava  2 s. co  m
        System.exit(1);
    }
    String op = StringUtils.defaultString(args[0]).trim();
    String account = StringUtils.defaultString(args[1]).trim();
    String mail = "";
    if ("".equals(op) || "".equals(account)) {
        printDetails();
        System.exit(1);
    }
    if ("2".equals(op) && args.length != 3) {
        printDetails();
        System.exit(1);
    }
    if ("2".equals(op)) {
        mail = StringUtils.defaultString(args[2]).trim();
    }
    System.out.println("account: " + account);
    System.out.println("operation: " + op);
    System.out.println("mail: " + mail);
    try {
        generateNewPassword(op, account, mail);
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    System.exit(1);
}

From source file:com.github.achatain.nopasswordauthentication.utils.ExtendedStringUtils.java

public static String obfuscate(String str, int visible) {
    String defaultStr = StringUtils.defaultString(str);
    if (defaultStr.length() > visible)
        return StringUtils.overlay(defaultStr, STARS, 0, defaultStr.length() - visible);
    return STARS;
}

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

public ChannelTableNameEntry(String name) {
    this.name = StringUtils.defaultString(name);
}

From source file:io.knotx.knot.service.service.ServiceAttributeUtil.java

private static String extract(String attributeName, int groupIndex) {
    Objects.requireNonNull(attributeName);

    Matcher matcher = ATTR_PATTERN.matcher(attributeName);
    if (matcher.matches()) {
        String namespace = matcher.group(groupIndex);
        return StringUtils.defaultString(namespace);
    } else {//  ww w. j  a  v  a2  s.  c  o  m
        throw new InvalidAttributeException(attributeName);
    }

}

From source file:de.micromata.genome.gwiki.page.impl.wiki.filter.GWikiServeEtagElementFilter.java

public static String createEtag(GWikiContext wikiContext, GWikiElement el) {
    if (el == null || el.getElementInfo().getMetaTemplate().isCachable() == false) {
        return null;
    }/*from  www.  j a  v  a  2s.c  om*/
    String wikiEtag = wikiContext.getWikiWeb().geteTagWiki();
    String ret = StringUtils
            .defaultString(el.getElementInfo().getProps().getStringValue(GWikiPropKeys.MODIFIEDAT));
    String version = StringUtils
            .defaultString(el.getElementInfo().getProps().getStringValue(GWikiPropKeys.VERSION));
    String uid = StringUtils.defaultString(
            wikiContext.getWikiWeb().getDaoContext().getAuthorization().getCurrentUserName(wikiContext), "");

    return ret + version + wikiEtag + uid;
}

From source file:controllers.base.SessionedAction.java

public static boolean isOwnerOf(Context ctx, PersistentObject object) {
    if (ctx == null) {
        ctx = Validate.notNull(Context.current());
    }//from  w ww .ja  va2 s  . c  o  m

    return StringUtils.defaultString(object.getOwnerId()).equals(getUsername(ctx));
}

From source file:com.netsteadfast.greenstep.util.MailClientUtils.java

public static String getDefaultFrom() {
    if (formTL.get() == null) {
        formTL.set(SystemSettingConfigureUtils.getMailDefaultFromValue());
    }//from   ww w . jav  a 2  s .c  om
    return StringUtils.defaultString(formTL.get());
}

From source file:com.netsteadfast.greenstep.util.MailClientUtils.java

public static boolean getEnable() {
    if (enableTL.get() == null) {
        enableTL.set(SystemSettingConfigureUtils.getMailEnableValue());
    }//w w  w  .  j  a va 2s  . c om
    return StringUtils.defaultString(enableTL.get()).trim().equals(YesNo.YES);
}