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

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

Introduction

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

Prototype

String EMPTY

To view the source code for org.apache.commons.lang3 StringUtils EMPTY.

Click Source Link

Document

The empty String "" .

Usage

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.SignTest.java

@Test(expected = IllegalArgumentException.class)
public void testMnemonicCannotBeEmpty() {
    new Sign.Builder().setId(0).setName(FOOTBALL).setNameLocaleDe(FUSSBALL).setMnemonic(StringUtils.EMPTY)
            .setStarred(false).setLearningProgress(0).create();
}

From source file:com.norconex.commons.wicket.markup.html.chart.jqplot.PlotPanel.java

public PlotPanel(String id, PlotData plotData, boolean minified) {
    super(id);/*from  w  ww.  j a va 2s .co  m*/
    setOutputMarkupId(true);

    WebMarkupContainer plotDiv = new WebMarkupContainer("plot");
    plotDiv.setOutputMarkupId(true);
    add(plotDiv);
    String plotId = plotDiv.getMarkupId();

    //XXX hack to get minified version should be done better
    if (minified) {
        AxisOptions xaxis = plotData.getOptions().getAxes().getXaxis();
        Integer val = xaxis.getNumberTicks();
        int numberTicks = 0;
        if (val != null) {
            numberTicks = val;
        }
        if (numberTicks > 0) {
            numberTicks = (int) Math.ceil((float) numberTicks / 2f);
        }
        xaxis.setNumberTicks(numberTicks);
    }

    String code = "";
    if (plotData != null) {
        //--- Options ---
        String options = "{}";
        if (plotData.getOptions() != null) {
            options = plotData.getOptions().toString();
        }
        //--- Series ---
        String series = "[]";
        if (plotData.getSeries() != null) {
            series = "[" + StringUtils.join(plotData.getSeries(), ", ") + "]";
        }
        //--- pre/post JS ---
        String preJs = plotData.getPreJavascript();
        if (preJs == null) {
            preJs = StringUtils.EMPTY;
        }
        String postJs = plotData.getPostJavascript();
        if (postJs == null) {
            postJs = StringUtils.EMPTY;
        }

        //--- Plot Code ---
        code = "$(document).ready(function(){" + preJs + "  $.jqplot.config.enablePlugins = true;"
                + "  var plot = $.jqplot('" + plotId + "', " + series + ", " + options + ");"
                + "  $(window).resize(function() {" + "    if (plot) { "
                + "      $.each(plot.series, function(index, series) {" + "        series.barWidth = undefined;"
                + "      });" + "      plot.replot();" + "    }" + "  });" + postJs + "});";
    }
    Label script = new Label("script", code);
    script.setEscapeModelStrings(false);
    addOrReplace(script);
}

From source file:info.magnolia.ui.form.field.converter.BaseIdentifierToPathConverter.java

@Override
public String convertToPresentation(String uuid, Class<? extends String> targetType, Locale locale)
        throws ConversionException {
    String res = StringUtils.EMPTY;
    if (StringUtils.isBlank(uuid)) {
        return res;
    }/*from ww  w  . ja  va 2  s  . c  om*/
    try {
        Session session = MgnlContext.getJCRSession(workspace);
        res = session.getNodeByIdentifier(uuid).getPath();
    } catch (RepositoryException e) {
        log.error("Unable to convert UUID to Path", e);
    }
    return res;
}

From source file:com.sunchenbin.store.feilong.core.io.MimeTypeUtil.java

/**
 *  content type by file name./*from  w  w  w  . java2 s .co m*/
 * 
 * <p>
 * <b>Very incomplete function. As of Java 7, html, pdf and jpeg extensions return the correct mime-type but js and css return null!
 * </b>
 * </p>
 * 
 * <p>
 * I tried Apache Tika but it is huge with tons of dependencies, <br>
 * URLConnection doesn't use the bytes of the files, <br>
 * {@link MimetypesFileTypeMap} also just looks at files names,and I couldn't move to Java 7.
 * </p>
 * 
 * @param fileName
 *            the file name
 * @return the content type by file name
 * @see java.net.URLConnection#getFileNameMap()
 * @see javax.activation.MimetypesFileTypeMap#getContentType(java.io.File)
 * @see java.net.FileNameMap#getContentTypeFor(String)
 * @see org.apache.commons.io.FilenameUtils#getExtension(String)
 * @see java.net.URLConnection#guessContentTypeFromName(String)
 * @see java.net.URLConnection#guessContentTypeFromStream(java.io.InputStream)
 * @see "java.nio.file.Files#probeContentType(java.nio.file.Path)"
 */
public static String getContentTypeByFileName(String fileName) {

    String extension = FilenameUtils.getExtension(fileName);
    if (Validator.isNullOrEmpty(extension)) {
        return StringUtils.EMPTY;
    }

    // 1. first use java's build-in utils
    //??? mimetable? "content.types.user.table" ,?? java  lib/content-types.properties 
    FileNameMap fileNameMap = URLConnection.getFileNameMap();
    String contentType = fileNameMap.getContentTypeFor(fileName);

    // 2. nothing found -> lookup our in extension map to find types like ".doc" or ".docx"
    if (Validator.isNullOrEmpty(contentType)) {
        contentType = fileExtensionMap.get(extension.toLowerCase());
    }

    return contentType;
}

From source file:com.github.lburgazzoli.examples.karaf.hz.cmd.HazelcastListCommand.java

/**
 *
 * @param instance// w  w  w.  j a va  2  s. co  m
 * @throws Exception
 */
public void doExecuteMemberList(HazelcastInstance instance) throws Exception {

    ShellTable table = new ShellTable();
    table.column("ID");
    table.column("Host");
    table.column("Port");
    table.column("Local");
    ;

    for (Member m : instance.getCluster().getMembers()) {
        table.addRow().addContent(m.getUuid(), m.getSocketAddress().getHostName(),
                m.getSocketAddress().getPort(), m.localMember() ? "*" : StringUtils.EMPTY);
    }

    table.print(System.out);
}

From source file:com.tojc.ormlite.android.framework.MatcherPatternTest.java

public void testIsValid_should_return_true_if_pattern_is_empty() {
    // given/*ww w .  j av a 2s. co m*/
    TableInfo tableInfo = new TableInfo(ClassUnderTestWithAnnotations.class);
    SubType subType = SubType.ITEM;
    String pattern = StringUtils.EMPTY;
    int patternCode = 1;

    // when
    matcherPattern = new MatcherPattern(tableInfo, subType, pattern, patternCode);

    // then
    assertTrue(matcherPattern.isValid(DEBUG));
}

From source file:com.omnigon.aem.handlebars.helpers.MomentHelper.java

public static String format(String pattern, Date date) {
    if (StringUtils.isBlank(pattern) || date == null) {
        return StringUtils.EMPTY;
    }//from  ww w . ja  va  2  s.co m
    DateFormat dateFormat = new SimpleDateFormat(pattern);
    return dateFormat.format(date);
}

From source file:me.ineson.demo.app.MainController.java

/**
 * @param form//from   w  w  w.  j a v  a  2 s  .c  om
 * @param session
 * @return
 */
@RequestMapping(value = "/login", method = RequestMethod.POST)
public @ResponseBody String login(@ModelAttribute("login") LoginForm form, HttpSession session) {
    log.info("User " + form.getUsername() + " attempting to login");
    String response = StringUtils.EMPTY;

    String serviceUrl = config.getStringManadtory(Config.SERVICE_ENDPOINT_URL);
    User user = SERVICE_ENDPOINT_CLIENT.login(serviceUrl, form.getUsername(), form.getPassword());

    if (user != null) {
        session.setAttribute(SecurityContext.ATTRIBUTE_NAME, new SecurityContext(user));
    } else {
        response = "Login failed, username or password was incorrect.";
    }

    return response;
}

From source file:com.quatico.base.aem.test.common.ResourceTestDriver.java

@Test
public void aResourceWithEmptyPathReturnsRootResource() throws Exception {
    Resource actual = testObj.aResource(StringUtils.EMPTY);

    assertEquals("/", actual.getPath());
}

From source file:it.cnr.ilc.latmorphwebapp.ProxyHandler.java

private String getPath(final HttpServletRequest request) {
    try {/*from  ww w  . ja  v  a 2  s .c  o  m*/
        return StringUtils.replace(new URI(request.getRequestURI()).getPath(), "//", "/");
    } catch (final URISyntaxException e) {
        return StringUtils.EMPTY;
    }
}