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:io.wcm.devops.conga.generator.MessagePrefixLoggerFacade.java

private String prefix(String txt) {
    return messagePrefix + StringUtils.defaultString(txt);
}

From source file:ca.simplegames.micro.MicroFilter.java

@Override
public Object init(Object config) throws Exception {
    FilterConfig filterConfig = (FilterConfig) config;
    ServletContext servletContext = filterConfig.getServletContext();

    micro = new Micro(servletContext.getRealPath("/"), servletContext,
            StringUtils.defaultString(((FilterConfig) config).getInitParameter("userClassPaths")));

    return this;
}

From source file:com.mirth.connect.client.ui.components.rsta.ac.MirthFunctionCompletion.java

public MirthFunctionCompletion(CompletionProvider provider, FunctionReference reference) {
    super(provider, reference.getFunctionDefinition().getName(),
            MirthXmlUtil.encode(StringUtils.defaultString(reference.getFunctionDefinition().getReturnType())));
    this.id = reference.getId();
    this.contextSet = reference.getContextSet();
    setShortDescription(reference.getDescription());
    setReturnValueDescription(reference.getFunctionDefinition().getReturnDescription());

    List<Parameter> list = new ArrayList<Parameter>();
    if (CollectionUtils.isNotEmpty(reference.getFunctionDefinition().getParameters())) {
        for (com.mirth.connect.model.Parameter param : reference.getFunctionDefinition().getParameters()) {
            Parameter parameter = new Parameter(param.getType(), param.getName());
            parameter.setDescription(param.getDescription());
            list.add(parameter);/*  w  w w  .  ja  v a 2s  .com*/
        }
    }
    setParams(list);

    this.iconName = reference.getIconName();
    this.deprecated = reference.isDeprecated();
}

From source file:ca.uhn.fhir.model.primitive.StringDt.java

public String getValueNotNull() {
    return StringUtils.defaultString(getValue());
}

From source file:io.wcm.handler.media.testcontext.DummyAppTemplate.java

private DummyAppTemplate(String templatePath) {
    this.templatePath = templatePath;

    // build resource type from template path
    String resourceTypeFromPath = null;
    final Pattern TEMPLATE_PATH_PATTERN = Pattern.compile("^/apps/([^/]+)/templates(/.*)?/([^/]+)$");
    Matcher templateParts = TEMPLATE_PATH_PATTERN.matcher(templatePath);
    if (templateParts.matches()) {
        resourceTypeFromPath = "/apps/" + templateParts.group(1) + "/components"
                + StringUtils.defaultString(templateParts.group(2)) + "/page/" + templateParts.group(3);
    }//from  ww  w  .  j  a  va  2  s  . c  om

    this.resourceType = resourceTypeFromPath;
}

From source file:io.wcm.wcm.parsys.controller.CssBuilder.java

@Override
public String toString() {
    return StringUtils.defaultString(build());
}

From source file:com.github.achatain.nopasswordauthentication.admin.AdminServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String action = StringUtils.defaultString(req.getParameter(ACTION));

    switch (action) {
    case ACTION_RESET:
        AppSettings.reset();/*from ww w.  ja v a 2  s . c  o m*/
        ServletResponseUtils.writeJsonResponse(resp, "action", "reset");
        break;
    default:
        ServletResponseUtils.writeJsonResponse(resp, "action", "unknown");
        break;
    }
}

From source file:com.netsteadfast.greenstep.webservice.impl.HelloServiceImpl.java

@WebMethod
@POST/*ww w  .  j a v  a  2s  .  com*/
@Path("/hello/")
@Override
public String play(@WebParam(name = "message") String message) throws Exception {
    return Constants.getSystem() + ":" + StringUtils.defaultString(message);
}

From source file:io.wcm.devops.conga.generator.plugins.fileheader.AbstractFileHeader.java

@Override
public final Void apply(FileContext file, FileHeaderContext context) {
    String lineBreak = StringUtils.defaultString(getLineBreak());
    try {/* w  w w. ja  v a  2 s.  c  om*/
        String content = FileUtils.readFileToString(file.getFile(), file.getCharset());

        List<String> sanitizedCommentLines;
        if (context.getCommentLines() == null) {
            sanitizedCommentLines = ImmutableList.of();
        } else {
            sanitizedCommentLines = context.getCommentLines().stream().map(line -> sanitizeComment(line))
                    .filter(line -> line != null)
                    .map(line -> StringUtils.defaultString(getCommentLinePrefix()) + line + lineBreak)
                    .collect(Collectors.toList());
        }

        int insertPosition = getInsertPosition(content);

        content = StringUtils.substring(content, 0, insertPosition)
                + StringUtils.defaultString(getCommentBlockStart())
                + StringUtils.join(sanitizedCommentLines, "") + StringUtils.defaultString(getCommentBlockEnd())
                + StringUtils.defaultString(getBlockSuffix()) + StringUtils.substring(content, insertPosition);

        file.getFile().delete();
        FileUtils.write(file.getFile(), content, file.getCharset());
    } catch (IOException ex) {
        throw new GeneratorException("Unable to add file header to " + FileUtil.getCanonicalPath(file), ex);
    }
    return null;
}

From source file:com.netsteadfast.greenstep.sys.StopOrReloadCXFServlet.java

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String success = YesNo.NO;/*from   w w  w .j a v  a 2 s .  c o  m*/
    String message = "time out, cannot work!";
    String type = StringUtils.defaultString(request.getParameter("type")).trim();
    String value = StringUtils.defaultString(request.getParameter("value")).trim();
    try {
        long now = System.currentTimeMillis();
        long before = CxfServerBean.getBeforeValue(value);
        if (now - before <= 30000) {
            if ("restart".equals(type)) {
                CxfServerBean.restart();
                success = YesNo.YES;
                message = "restart, success!";
            }
            if ("shutdown".equals(type)) {
                CxfServerBean.shutdown();
                success = YesNo.YES;
                message = "shutdown, success!";
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        message = StringEscapeUtils.escapeJavaScript(e.getMessage());
    } finally {
        response.getWriter().println("{\"success\" : \"" + success + "\", \"message\" : \"" + message + "\"}");
    }
}