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, String defaultStr) 

Source Link

Document

Returns either the passed in String, or if the String is null, the value of defaultStr.

Usage

From source file:info.magnolia.cms.taglibs.util.StrToObj.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *///  w  ww.  ja va  2 s. co  m
public int doEndTag() {
    String str = getBodyContent().getString();
    if (StringUtils.isNotEmpty(str)) {
        String[] obj = str.split(StringUtils.defaultString(this.delims, "\n")); //$NON-NLS-1$
        pageContext.setAttribute(this.var, obj, PageContext.PAGE_SCOPE);

    } else {
        pageContext.setAttribute(this.var, StringUtils.EMPTY, PageContext.PAGE_SCOPE);
    }
    return EVAL_PAGE;
}

From source file:jp.co.nemuzuka.controller.ChangeProjectController.java

@Override
protected Navigation execute() throws Exception {

    //??/*w  w  w. jav a 2  s  .com*/
    String projectKey = StringUtils.defaultString(asString("projectKey"), "");
    String mobile = StringUtils.defaultString(asString("mobile"), "");

    //???????
    service.setUserInfo(projectKey, userService.getCurrentUser().getEmail(), getUserInfo());
    if (mobile.equals("true")) {
        return forward("/mobile/bts/");
    }
    return forward("/bts/");
}

From source file:info.jtrac.wicket.IndividualHeadPanel.java

/**
 * Constructor./*  w w w  .ja  v  a 2 s .  c  o  m*/
 */
public IndividualHeadPanel() {
    super("individual");

    final Map<String, String> configMap = getJtrac().loadAllConfig();
    Image img = new Image("icon");
    img.add(new AttributeModifier("src", true, new AbstractReadOnlyModel() {
        private static final long serialVersionUID = 1L;

        @Override
        public final Object getObject() {
            // based on some condition return the image source
            String url = configMap.get("jtrac.header.picture");
            if (StringUtils.isBlank(url)) {
                String urlbase = StringUtils.defaultString(configMap.get("jtrac.url.base"),
                        RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot());
                return urlbase + "/resources/jtrac-logo.gif";
            } else
                return url;
        }
    }));
    add(img);
    String message = configMap.get("jtrac.header.text");
    if ((message == null) || ("".equals(message)))
        add(new Label("message", "JTrac - Open Source Issue Tracking System"));
    else if ((message != null) && ("no".equals(message)))
        add(new Label("message", ""));
    else
        add(new Label("message", message));
}

From source file:info.magnolia.cms.filters.MultipartRequestFilter.java

/**
 * Adds all request paramaters as request attributes.
 * @param request HttpServletRequest/*from   ww  w .j  a  va 2s.  co m*/
 */
private static void parseParameters(HttpServletRequest request) throws IOException {
    MultipartForm form = new MultipartForm();
    String encoding = StringUtils.defaultString(request.getCharacterEncoding(), "UTF-8"); //$NON-NLS-1$
    MultipartRequest multi = new MultipartRequest(request, Path.getTempDirectoryPath(), MAX_FILE_SIZE, encoding,
            null);
    Enumeration params = multi.getParameterNames();
    while (params.hasMoreElements()) {
        String name = (String) params.nextElement();
        String value = multi.getParameter(name);
        form.addParameter(name, value);
        String[] s = multi.getParameterValues(name);
        if (s != null) {
            form.addparameterValues(name, s);
        }
    }
    Enumeration files = multi.getFileNames();
    while (files.hasMoreElements()) {
        String name = (String) files.nextElement();
        form.addDocument(name, multi.getFilesystemName(name), multi.getContentType(name), multi.getFile(name));
    }
    request.setAttribute(MultipartForm.REQUEST_ATTRIBUTE_NAME, form);
}

From source file:com.nagarro.core.populator.HttpRequestUserSignUpDTOPopulator.java

@Override
public void populate(final HttpServletRequest source, final UserSignUpWsDTO target) throws ConversionException {
    Assert.notNull(source, "Parameter source cannot be null.");
    Assert.notNull(target, "Parameter target cannot be null.");

    target.setUid(StringUtils.defaultString(source.getParameter(UID), target.getUid()));
    target.setPassword(StringUtils.defaultString(source.getParameter(PASSWORD), target.getPassword()));
    target.setTitleCode(StringUtils.defaultString(source.getParameter(TITLECODE), target.getTitleCode()));
    target.setFirstName(StringUtils.defaultString(source.getParameter(FIRSTNAME), target.getFirstName()));
    target.setLastName(StringUtils.defaultString(source.getParameter(LASTNAME), target.getLastName()));
}

From source file:de.hybris.platform.acceleratorservices.urlencoder.impl.DefaultUrlEncoderService.java

@Override
public String getUrlEncodingPattern() {
    final String encodingAttributes = getSessionService()
            .getAttribute(AcceleratorServicesConstants.URL_ENCODING_ATTRIBUTES);
    return StringUtils.defaultString(encodingAttributes, "");
}

From source file:com.marvelution.bamboo.plugins.sonar.tasks.web.conditions.SonarResultWebItemCondition.java

/**
 * {@inheritDoc}/*w  w w  .j  a v  a  2  s  .  com*/
 */
@Override
public boolean shouldDisplay(Map<String, Object> context) {
    String key = StringUtils.defaultString((String) context.get("planKey"), (String) context.get("buildKey"));
    if (StringUtils.isNotBlank(key)) {
        for (Job job : getAllJobsByKey(key)) {
            if (Iterables.any(job.getBuildDefinition().getTaskDefinitions(), SonarPredicates.isSonarTask())) {
                return true;
            }
        }
    }
    return false;
}

From source file:com.bstek.dorado.view.resolver.PageOutputUtils.java

public static void outputException(Writer writer, Throwable throwable) throws IOException {
    writer.append("<h1 style=\"font-size:12pt; color:red\">");
    OutputUtils.outputString(writer,/*  w  w w  .j a  v a  2 s. c o  m*/
            StringUtils.defaultString(throwable.getMessage(), throwable.getClass().getName()));
    writer.append("</h1>\n");
    writer.append("<ul>\n");
    StackTraceElement[] stes = throwable.getStackTrace();
    for (int i = 0; i < stes.length; i++) {
        StackTraceElement ste = stes[i];
        writer.append("<li>").append("at ");
        OutputUtils.outputString(writer, ste.toString());
        writer.append("</li>\n");
    }
    writer.append("</ul>\n");
}

From source file:com.acc.populator.HttpRequestCustomerDataPopulator.java

@Override
public void populate(final HttpServletRequest source, final CustomerData target) throws ConversionException {
    Assert.notNull(source, "Parameter source cannot be null.");
    Assert.notNull(target, "Parameter target cannot be null.");

    target.setTitleCode(StringUtils.defaultString(source.getParameter(TITLECODE), target.getTitleCode()));
    target.setFirstName(StringUtils.defaultString(source.getParameter(FIRSTNAME), target.getFirstName()));
    target.setLastName(StringUtils.defaultString(source.getParameter(LASTNAME), target.getLastName()));

    if (source.getParameter(CURRENCY) != null) {
        final CurrencyData currency = new CurrencyData();
        currency.setIsocode(source.getParameter(CURRENCY));
        target.setCurrency(currency);//  www.  j  a v  a2s  .  c  o  m
    }

    if (source.getParameter(LANGUAGE) != null) {
        final LanguageData language = new LanguageData();
        language.setIsocode(source.getParameter(LANGUAGE));
        target.setLanguage(language);
    }

}

From source file:com.struts2ext.json.SerializationParams.java

public SerializationParams(HttpServletResponse response, String encoding, boolean wrapWithComments,
        String serializedJSON, boolean smd, boolean gzip, boolean noCache, int statusCode, int errorCode,
        boolean prefix, String contentType, String wrapPrefix, String wrapSuffix) {
    this.response = response;
    this.encoding = encoding;
    this.wrapWithComments = wrapWithComments;
    this.serializedJSON = serializedJSON;
    this.smd = smd;
    this.gzip = gzip;
    this.noCache = noCache;
    this.statusCode = statusCode;
    this.errorCode = errorCode;
    this.prefix = prefix;
    this.contentType = StringUtils.defaultString(contentType, DEFAULT_CONTENT_TYPE);
    this.wrapPrefix = wrapPrefix;
    this.wrapSuffix = wrapSuffix;
}