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

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

Introduction

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

Prototype

public static boolean isNotEmpty(final CharSequence cs) 

Source Link

Document

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

 StringUtils.isNotEmpty(null)      = false StringUtils.isNotEmpty("")        = false StringUtils.isNotEmpty(" ")       = true StringUtils.isNotEmpty("bob")     = true StringUtils.isNotEmpty("  bob  ") = true 

Usage

From source file:io.fabric8.maven.enricher.standard.MavenScmEnricher.java

@Override
public Map<String, String> getAnnotations(Kind kind) {
    Map<String, String> annotations = new HashMap<>();
    if (kind.isController() || kind == Kind.SERVICE) {
        MavenProject rootProject = getProject();
        if (hasScm(rootProject)) {
            Scm scm = rootProject.getScm();
            String connectionUrl = scm.getConnection();
            String devConnectionUrl = scm.getDeveloperConnection();
            String url = scm.getUrl();
            String tag = scm.getTag();

            if (StringUtils.isNotEmpty(connectionUrl)) {
                annotations.put(SCM_CONNECTION, connectionUrl);
            }/*from  w  ww  .j  a  va2s .  c  o  m*/
            if (StringUtils.isNotEmpty(devConnectionUrl)) {
                annotations.put(SCM_DEVELOPER_CONNECTION, devConnectionUrl);
            }
            if (StringUtils.isNotEmpty(tag)) {
                annotations.put(SCM_TAG, tag);
            }
            if (StringUtils.isNotEmpty(url)) {
                annotations.put(SCM_URL, url);
            }
        }
    }
    return annotations;
}

From source file:cn.mrdear.pay.util.WebUtils.java

/**
 * ??// w  ww  .  j a  va2s .c  o m
 *
 * @param query
 *            
 * @param encoding
 *            ??
 * @return ?
 */
public static Map<String, String> parse(String query, String encoding) {

    Charset charset;
    if (StringUtils.isNotEmpty(encoding)) {
        charset = Charset.forName(encoding);
    } else {
        charset = Charset.forName("UTF-8");
    }
    List<NameValuePair> nameValuePairs = URLEncodedUtils.parse(query, charset);
    Map<String, String> parameterMap = new HashMap<String, String>();
    for (NameValuePair nameValuePair : nameValuePairs) {
        parameterMap.put(nameValuePair.getName(), nameValuePair.getValue());
    }
    return parameterMap;
}

From source file:com.bellman.bible.service.common.FileManager.java

public static Properties readPropertiesFile(String folder, String filename) {
    Properties returnProperties = new Properties();

    Resources resources = CurrentActivityHolder.getInstance().getApplication().getResources();
    AssetManager assetManager = resources.getAssets();
    if (!filename.endsWith(DOT_PROPERTIES)) {
        filename = filename + DOT_PROPERTIES;
    }//  w  w  w.  j  ava 2  s  .  c  o m
    if (StringUtils.isNotEmpty(folder)) {
        filename = folder + File.separator + filename;
    }

    // Read from the /assets directory
    InputStream inputStream = null;
    try {
        // check to see if a user has created his own reading plan with this name
        inputStream = assetManager.open(filename);

        returnProperties.load(inputStream);
        log.debug("The properties are now loaded from: " + filename);
    } catch (IOException e) {
        System.err.println("Failed to open property file:" + filename);
        e.printStackTrace();
    } finally {
        IOUtil.close(inputStream);
    }
    return returnProperties;
}

From source file:com.xylocore.copybook.runtime.converters.SimpleDateFormatDateConverter.java

/**
 * FILLIN
 * 
 * @param       aPattern
 */
public SimpleDateFormatDateConverter(String aPattern) {
    assert StringUtils.isNotEmpty(aPattern);

    pattern = aPattern;
}

From source file:com.glaf.ui.web.springmvc.MxPanelController.java

@RequestMapping("/content")
public ModelAndView content(@RequestParam(value = "pid", required = true) String panelId, ModelMap modelMap) {

    Panel panel = null;// w w  w.  jav a  2s. c om

    if (StringUtils.isNotEmpty(panelId)) {
        panel = panelService.getPanel(panelId);
    }

    if (panel != null) {
        modelMap.addAttribute("panel", panel);
    }

    String x_view = ViewProperties.getString("sys_panel.content");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/modules/ui/panel/content", modelMap);

}

From source file:com.founder.fix.fixflow.editor.language.json.converter.BpmnJsonConverterUtil.java

public static String getElementId(JsonNode objectNode) {
    String elementId = null;/*from  w  ww .  ja v a  2 s.com*/
    if (StringUtils.isNotEmpty(getPropertyValueAsString(PROPERTY_OVERRIDE_ID, objectNode))) {
        elementId = getPropertyValueAsString(PROPERTY_OVERRIDE_ID, objectNode).trim();
    } else {
        elementId = objectNode.get(EDITOR_SHAPE_ID).asText();
    }

    return elementId;
}

From source file:com.glaf.survey.web.springmvc.SurveyController.java

@RequestMapping("/choose")
public ModelAndView choose(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }/* w  w  w  . ja  v  a 2s.co m*/

    String x_view = ViewProperties.getString("survey.choose");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/modules/survey/choose_survey", modelMap);
}

From source file:alfio.controller.api.SpecialPriceApiController.java

@RequestMapping("/events/{eventName}/categories/{categoryId}/link-codes")
public List<SendCodeModification> linkAssigneeToCodes(@PathVariable("eventName") String eventName,
        @PathVariable("categoryId") int categoryId, @RequestParam("file") MultipartFile file,
        Principal principal) throws IOException {

    Validate.isTrue(StringUtils.isNotEmpty(eventName));
    try (InputStreamReader isr = new InputStreamReader(file.getInputStream())) {
        CSVReader reader = new CSVReader(isr);
        List<SendCodeModification> content = reader.readAll().stream().map(line -> {
            Validate.isTrue(line.length >= 4);
            return new SendCodeModification(StringUtils.trimToNull(line[0]), line[1], line[2], line[3]);
        }).collect(Collectors.toList());
        return specialPriceManager.linkAssigneeToCode(content, eventName, categoryId, principal.getName());
    }/*from   w w  w  .  j  a  va 2s.com*/
}

From source file:com.keybox.manage.util.SSHUtil.java

/**
 * returns the system's public key/*from   w w w. j  a va  2s .c o  m*/
 *
 * @return system's public key
 */
public static String getPublicKey() {

    String publicKey = PUB_KEY;
    //check to see if pub/pvt are defined in properties
    if (StringUtils.isNotEmpty(AppConfig.getProperty(PRIVATE_KEY))
            && StringUtils.isNotEmpty(AppConfig.getProperty(PUBLIC_KEY))) {
        publicKey = AppConfig.getProperty(PUBLIC_KEY);
    }
    //read pvt ssh key
    File file = new File(publicKey);
    try {
        publicKey = FileUtils.readFileToString(file);
    } catch (Exception ex) {
        log.error(ex.toString(), ex);
    }

    return publicKey;
}

From source file:io.lavagna.config.DispatcherServletInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    super.onStartup(servletContext);

    // initialize cookie
    if (StringUtils.isNotEmpty(System.getProperty(CookieNames.PROPERTY_NAME))) {
        CookieNames.updatePrefix(System.getProperty(CookieNames.PROPERTY_NAME));
    }/*  www  .j a v a  2  s  .  c  o m*/
    //

    //definition order = execution order, the first executed filter is HSTSFilter
    addFilter(servletContext, "HSTSFilter", HSTSFilter.class, "/*");

    addFilter(servletContext, "CSFRFilter", CSFRFilter.class, "/*");

    addFilter(servletContext, "RememberMeFilter", RememberMeFilter.class, "/*");

    addFilter(servletContext, "AnonymousUserFilter", AnonymousUserFilter.class, "/*");

    addFilter(servletContext, "SecurityFilter", SecurityFilter.class, "/*");

    addFilter(servletContext, "ETagFilter", ShallowEtagHeaderFilter.class, "*.js", "*.css", //
            "/", "/project/*", "/admin/*", "/me/", //
            "*.html", "*.woff", "*.eot", "*.svg", "*.ttf");

    addFilter(servletContext, "GzipFilter", GzipFilter.class, "*.js", "*.css", //
            "/", "/project/*", "/admin/*", "/me/", //
            "/api/self", "/api/board/*", "/api/project/*");

    servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
    servletContext.getSessionCookieConfig().setHttpOnly(true);
    servletContext.getSessionCookieConfig().setName(CookieNames.getSessionCookieName());
}