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:com.glaf.core.web.springmvc.MxSystemMailConfigController.java

@RequestMapping
public ModelAndView config(ModelMap modelMap, HttpServletRequest request) {
    String jx_view = request.getParameter("jx_view");

    if (StringUtils.isNotEmpty(jx_view)) {
        return new ModelAndView(jx_view, modelMap);
    }/*from ww  w .  j  av a2s  .co  m*/

    String x_view = ViewProperties.getString("sys_mail.config");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }
    return new ModelAndView("/modules/sys/mail/config", modelMap);
}

From source file:com.huacainfo.ace.workflow.mapper.EventInfoMapper.java

protected void mapProperties(Object element) {
    Event event = (Event) element;
    if (CollectionUtils.isNotEmpty(event.getEventDefinitions())) {
        EventDefinition eventDef = event.getEventDefinitions().get(0);
        if (eventDef instanceof TimerEventDefinition) {
            TimerEventDefinition timerDef = (TimerEventDefinition) eventDef;
            if (StringUtils.isNotEmpty(timerDef.getTimeDate())) {
                createPropertyNode("Timer date", timerDef.getTimeDate());
            }/*ww  w  .jav  a  2  s . com*/
            if (StringUtils.isNotEmpty(timerDef.getTimeDuration())) {
                createPropertyNode("Timer duration", timerDef.getTimeDuration());
            }
            if (StringUtils.isNotEmpty(timerDef.getTimeDuration())) {
                createPropertyNode("Timer cycle", timerDef.getTimeCycle());
            }

        } else if (eventDef instanceof SignalEventDefinition) {
            SignalEventDefinition signalDef = (SignalEventDefinition) eventDef;
            if (StringUtils.isNotEmpty(signalDef.getSignalRef())) {
                createPropertyNode("Signal ref", signalDef.getSignalRef());
            }

        } else if (eventDef instanceof MessageEventDefinition) {
            MessageEventDefinition messageDef = (MessageEventDefinition) eventDef;
            if (StringUtils.isNotEmpty(messageDef.getMessageRef())) {
                createPropertyNode("Message ref", messageDef.getMessageRef());
            }

        } else if (eventDef instanceof ErrorEventDefinition) {
            ErrorEventDefinition errorDef = (ErrorEventDefinition) eventDef;
            if (StringUtils.isNotEmpty(errorDef.getErrorCode())) {
                createPropertyNode("Error code", errorDef.getErrorCode());
            }
        }
    }
    createListenerPropertyNodes("Execution listeners", event.getExecutionListeners());
}

From source file:de.micromata.genome.gwiki.web.tags.WikiLinkTag.java

@Override
public int doEndTag() throws JspException {
    // JspContext jc = getJspContext();
    final GWikiContext wctx = getWikiContext();
    if (StringUtils.isNotEmpty(titleKey) == true) {
        title = wctx.getWikiWeb().getI18nProvider().translate(wctx, titleKey);
    }//from w w w. j a  v a  2 s .  c  o m
    String url = wctx.renderLocalUrl(pageId, title, urlParams);
    try {
        pageContext.getOut().print(url);
    } catch (IOException ex) {
        throw new JspException(ex);
    }
    return EVAL_PAGE;
}

From source file:net.cloudkit.enterprises.infrastructure.freemarker.method.AbbreviateMethod.java

@Override
@SuppressWarnings("rawtypes")
public Object exec(List arguments) {
    if ((arguments != null) && (!arguments.isEmpty()) && (arguments.get(0) != null)
            && (StringUtils.isNotEmpty(arguments.get(0).toString()))) {
        Integer localInteger = null;
        String str = null;/* w w  w. ja  va2  s  . c  o  m*/
        if (arguments.size() == 2) {
            if (arguments.get(1) != null) {
                localInteger = Integer.valueOf(arguments.get(1).toString());
            }
        } else if (arguments.size() > 2) {
            if (arguments.get(1) != null) {
                localInteger = Integer.valueOf(arguments.get(1).toString());
            }
            if (arguments.get(2) != null) {
                str = arguments.get(2).toString();
            }
        }
        return new SimpleScalar(abbreviate(arguments.get(0).toString(), localInteger, str));
    }
    return null;
}

From source file:de.openali.odysseus.chart.factory.util.AxisUtils.java

/**
 * @return axis id from referencing type
 */// w  w w  .jav a 2  s.  c  om
public static String getIdentifier(final ReferencingType type) {
    if (type == null) {
        return null;
    }
    final String ref = type.getRef();
    if (StringUtils.isNotEmpty(ref))
        return ref;

    final String url = type.getUrl();
    final RETokenizer tokenizer = new RETokenizer(new Pattern(".*#"), url); //$NON-NLS-1$

    return StringUtils.chomp(tokenizer.nextToken());
}

From source file:com.hybris.mobile.utility.RegexUtil.java

/**
 * Try to identify and return a product code from the value and according to the different regex
 * /*  w w  w.  j  av a  2s.  co  m*/
 * @param value
 * @return
 */
public static String getProductCode(String value) {
    String productCode = "";

    // Getting the hybris product code regex patterns
    String[] listRegexProducts = Hybris.getAppContext().getResources()
            .getStringArray(R.array.regex_hybris_product);

    if (listRegexProducts != null) {

        boolean isProductMatching = false;
        int i = 0;

        // We continue while we have no match for the value
        while (!isProductMatching && i < listRegexProducts.length) {

            Pattern productPattern = Pattern.compile(listRegexProducts[i]);

            productCode = applyPattern(productPattern, value, 1).get(0);

            isProductMatching = StringUtils.isNotEmpty(productCode);

            i++;
        }

    }

    return productCode;

}

From source file:com.glaf.jbpm.util.ExpressionUtils.java

public static List<Object> getValues(ExecutionContext ctx, Element elements) {
    List<Object> values = new java.util.ArrayList<Object>();
    ContextInstance contextInstance = ctx.getContextInstance();
    Object rowId = contextInstance.getVariable(Constant.PROCESS_ROWID);
    if (elements != null) {
        Map<String, Object> dataMap = (Map<String, Object>) CustomFieldInstantiator.getValue(Map.class,
                elements);//  w  w  w . ja  v a 2 s  .  c  o  m
        java.util.Date now = new java.util.Date();
        Set<Entry<String, Object>> entrySet = dataMap.entrySet();
        for (Entry<String, Object> entry : entrySet) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (key == null || value == null) {
                continue;
            }
            if (value instanceof String && StringUtils.isNotEmpty(value.toString())) {
                String tmp = (String) value;
                if ("#{processInstanceId}".equals(tmp)) {
                    value = contextInstance.getProcessInstance().getId();
                } else if ("#{taskInstanceId}".equals(tmp)) {
                    TaskInstance taskInstance = ctx.getTaskInstance();
                    if (taskInstance != null) {
                        value = taskInstance.getId();
                    }
                } else if ("#{taskName}".equals(tmp)) {
                    Task task = ctx.getTask();
                    if (task != null) {
                        value = task.getName();
                    } else {
                        if (ctx.getTaskInstance() != null) {
                            value = ctx.getTaskInstance().getName();
                        }
                    }
                } else if (tmp.equals("now()")) {
                    value = new java.sql.Date(now.getTime());
                } else if (tmp.equals("date()")) {
                    value = new java.sql.Date(now.getTime());
                } else if (tmp.equals("time()")) {
                    value = new java.sql.Time(now.getTime());
                } else if (tmp.equals("timestamp()")) {
                    value = new java.sql.Timestamp(now.getTime());
                } else if (tmp.equals("dateTime()")) {
                    value = new java.sql.Timestamp(now.getTime());
                } else if (tmp.equals("currentTimeMillis()")) {
                    value = System.currentTimeMillis();
                } else if (tmp.equals("#{rowId}")) {
                    value = rowId;
                } else if (tmp.equals("#{uuid}")) {
                    value = UUID32.getUUID();
                } else if (tmp.equals("#{actorId}")) {
                    value = ctx.getJbpmContext().getActorId();
                } else if (tmp.equals("#{status}")) {
                    value = contextInstance.getVariable("status");
                } else if (tmp.startsWith("#P{") && tmp.endsWith("}")) {
                    tmp = StringTools.replaceIgnoreCase(tmp, "#P{", "");
                    tmp = StringTools.replaceIgnoreCase(tmp, "}", "");
                    value = contextInstance.getVariable(tmp);
                } else if (tmp.startsWith("#{") && tmp.endsWith("}")) {
                    Map<String, Object> params = new java.util.HashMap<String, Object>();
                    Map<String, Object> vars = contextInstance.getVariables();
                    if (vars != null && vars.size() > 0) {
                        Iterator<String> it = vars.keySet().iterator();
                        while (it.hasNext()) {
                            String variableName = it.next();
                            if (params.get(variableName) == null) {
                                Object object = contextInstance.getVariable(variableName);
                                params.put(variableName, object);
                            }
                        }
                    }
                    value = DefaultExpressionEvaluator.evaluate(tmp, params);
                }
            }
            values.add(value);
        }
    }
    return values;
}

From source file:com.msg.wmTestHelper.metaModel.AbstractExtractor.java

/**
 * Extracts a <code><value></code> element where the attribute name is like elementName.
 *
 * @param element     the XML element.//  w  ww . j a  v a2 s  .c  o  m
 * @param elementName the name attribute value.
 * @return
 */
protected String extractPlainValue(Element element, String elementName) {
    Node nodeStepLabel = element.selectSingleNode(".//value[@name='" + elementName + "']");

    if (nodeStepLabel != null && StringUtils.isNotEmpty(nodeStepLabel.getText())) {
        return nodeStepLabel.getText();
    }

    log.warn("Value '{}' not given for element {} {}", elementName, element.getUniquePath(),
            element.getDocument().getName());
    return StringUtils.EMPTY;
}

From source file:com.glaf.dts.web.springmvc.MxDtsTaskController.java

@RequestMapping
public ModelAndView list(HttpServletRequest request, ModelMap modelMap) {
    String jx_view = request.getParameter("jx_view");
    RequestUtils.setRequestParameterToAttribute(request);
    if (StringUtils.isNotEmpty(jx_view)) {
        return new ModelAndView(jx_view, modelMap);
    }/*www.  j av a2 s  .co  m*/

    String x_view = ViewProperties.getString("dts_task.list");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }
    return new ModelAndView("/bi/dts/task/list", modelMap);
}

From source file:com.activiti.web.rest.client.modelinfo.AbstractInfoMapper.java

protected void createPropertyNode(String name, String value) {
    if (StringUtils.isNotEmpty(value)) {
        ObjectNode propertyNode = objectMapper.createObjectNode();
        propertyNode.put("name", name);
        propertyNode.put("value", value);
        propertiesNode.add(propertyNode);
    }//from   w w w. j a v a 2s  .c  o m
}