Example usage for org.apache.commons.lang StringUtils stripToNull

List of usage examples for org.apache.commons.lang StringUtils stripToNull

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils stripToNull.

Prototype

public static String stripToNull(String str) 

Source Link

Document

Strips whitespace from the start and end of a String returning null if the String is empty ("") after the strip.

Usage

From source file:com.egt.core.db.util.InterpreteSqlOracle.java

@Override
public String getComandoSelect(String comando, int limite) {
    Bitacora.trace(InterpreteSqlOracle.class, "getComandoSelect", comando, limite);
    int i, j, k;/*from w w w.j  a  va  2s  . co m*/
    String select = StringUtils.stripToNull(comando);
    if (select != null && limite > 0) {
        String query = select.toUpperCase();
        String where = "WHERE";
        String limit = "(ROWNUM <= " + limite + ")";
        i = StringUtils.indexOf(query, where);
        j = i + where.length();
        if (i > 0) {
            select = select.substring(0, j) + " " + limit + " AND " + select.substring(j);
            Bitacora.trace("{0}", select);
        } else {
            String order = " ORDER BY ";
            i = StringUtils.indexOf(query, order);
            if (i > 0) {
                select = select.substring(0, i) + " " + where + " " + limit + select.substring(i);
                Bitacora.trace("{0}", select);
            } else {
                select += " " + where + " " + limit;
                Bitacora.trace("{0}", select);
            }
        }
    }
    return select;
}

From source file:gov.nih.nci.calims2.taglib.form.FormWidgetTag.java

/**
 * @param alt the alt to set
 */
public void setAlt(String alt) {
    this.alt = StringUtils.stripToNull(alt);
}

From source file:com.adobe.acs.tools.test_page_generator.impl.Parameters.java

public Parameters(SlingHttpServletRequest request) throws JSONException {

    final String data = request.getParameter("json");

    JSONObject json = new JSONObject(data);

    rootPath = json.optString("rootPath", "");
    template = json.optString("template", "");
    total = json.optInt("total", 0);
    bucketSize = json.optInt("bucketSize", DEFAULT_BUCKET_SIZE);
    bucketType = json.optString("bucketType", DEFAULT_BUCKET_TYPE);
    saveThreshold = json.optInt("saveThreshold", DEFAULT_SAVE_THRESHOLD);

    properties = new HashMap<String, Object>();

    JSONArray jsonArray = json.getJSONArray("properties");

    if (jsonArray != null) {
        for (int i = 0; i < jsonArray.length(); i++) {
            final JSONObject item = jsonArray.getJSONObject(i);

            boolean isMulti = item.optBoolean("multi", false);
            String name = item.optString("name", "");

            if (StringUtils.isNotBlank(name)) {
                if (isMulti) {
                    final List<String> values = new ArrayList<String>();
                    for (String value : StringUtils.split(item.optString("value", ""), ",")) {
                        final String tmp = StringUtils.stripToNull(value);
                        if (tmp != null) {
                            values.add(value);
                        }/*from  ww  w  .  j ava  2 s.  com*/
                    }

                    properties.put(name, values.toArray(new String[values.size()]));
                } else {
                    String value = item.optString("value", "");
                    properties.put(name, value);
                }
            }
        }
    }
}

From source file:com.vecna.taglib.processor.JspAnnotationsProcessor.java

/**
 * Build a JSP tag model object from an annotated tag class
 * @param type tag class//from   w  w  w  . ja  va  2  s.c  o  m
 * @return JSP tag model
 */
public JspTagModel getTagMetadata(Class<?> type) {
    JspTagModel metadata = new JspTagModel();
    JspTag jspTagAnnotation = type.getAnnotation(JspTag.class);
    metadata.bodyContent = jspTagAnnotation.bodyContent();
    metadata.name = jspTagAnnotation.name();
    metadata.tagClass = type.getName();
    metadata.dynamicAttributes = jspTagAnnotation.dynamicAttributes();

    for (JspVariable jspVariableAnnotation : jspTagAnnotation.variables()) {
        JspVariableModel variable = new JspVariableModel();
        variable.declare = jspVariableAnnotation.declare();

        variable.nameFromAttribute = StringUtils.stripToNull(jspVariableAnnotation.nameFromAttribute());
        variable.nameGiven = StringUtils.stripToNull(jspVariableAnnotation.nameGiven());

        variable.scope = jspVariableAnnotation.scope();
        variable.variableClass = jspVariableAnnotation.variableClass().getName();
        metadata.variables.add(variable);
    }

    for (PropertyDescriptor pd : PropertyUtils.getPropertyDescriptors(type)) {
        s_log.debug("processing property {}", pd.getName());
        if (pd.getWriteMethod() != null && pd.getWriteMethod().isAnnotationPresent(JspAttribute.class)) {
            s_log.debug("attribute metadata present on {}", pd.getName());
            JspAttributeModel attr = new JspAttributeModel();
            attr.name = pd.getName();
            attr.type = pd.getPropertyType().getName();
            JspAttribute jspAttributeAnnotation = pd.getWriteMethod().getAnnotation(JspAttribute.class);
            attr.required = jspAttributeAnnotation.required();
            attr.rtExprValue = jspAttributeAnnotation.rtExprValue();
            attr.fragment = jspAttributeAnnotation.fragment();

            attr.deferredMethod = jspAttributeAnnotation.deferredMethod() ? true : null;
            attr.deferredValue = jspAttributeAnnotation.deferredValue() ? true : null;

            metadata.attributes.add(attr);
        }
    }

    return metadata;
}

From source file:gov.nih.nci.calims2.taglib.form.FormWidgetTag.java

/**
 * @param altKey the altKey to set
 */
public void setAltKey(String altKey) {
    this.altKey = StringUtils.stripToNull(altKey);
}

From source file:gov.nih.nci.calims2.taglib.form.NumberTag.java

/**
 * @param min the min to set
 */
public void setMin(String min) {
    this.min = StringUtils.stripToNull(min);
}

From source file:com.redhat.jenkins.plugins.ci.CIBuildTrigger.java

@DataBoundConstructor
public CIBuildTrigger(String selector, String providerName, MessagingProviderOverrides overrides,
        List<MsgCheck> checks) {
    super();//from  w  w w  .  j a  v  a  2s . c  o  m
    this.selector = StringUtils.stripToNull(selector);
    this.providerName = providerName;
    this.overrides = overrides;
    if (checks == null) {
        checks = new ArrayList<MsgCheck>();
    }
    this.checks = checks;
}

From source file:gov.nih.nci.calims2.taglib.form.NumberTag.java

/**
 * @param max the max to set
 */
public void setMax(String max) {
    this.max = StringUtils.stripToNull(max);
}

From source file:com.adobe.acs.commons.users.impl.Ace.java

@SuppressWarnings("squid:S3776")
public Ace(String raw) throws EnsureAuthorizableException {
    String[] segments = StringUtils.split(raw, PARAM_DELIMITER);

    for (String segment : segments) {
        AbstractMap.SimpleEntry<String, String> entry = ParameterUtil.toSimpleEntry(segment,
                KEY_VALUE_SEPARATOR);//from  w  ww  .j av a  2  s.  c o m

        if (entry == null) {
            continue;
        }
        if (StringUtils.equals(PROP_TYPE, entry.getKey())) {
            this.type = StringUtils.stripToNull(entry.getValue());
        } else if (StringUtils.equals(PROP_PATH, entry.getKey())) {
            this.path = StringUtils.stripToNull(entry.getValue());
        } else if (StringUtils.equals(PROP_REP_GLOB, entry.getKey())) {
            this.repGlob = StringUtils.stripToEmpty(entry.getValue());
        } else if (StringUtils.equals(PROP_REP_NT_NAMES, entry.getKey())) {
            this.repNtNames.addAll(Arrays
                    .asList(StringUtils.split(StringUtils.stripToEmpty(entry.getValue()), LIST_SEPARATOR)));
        } else if (StringUtils.equals(PROP_REP_ITEM_NAMES, entry.getKey())) {
            this.repItemNames.addAll(Arrays
                    .asList(StringUtils.split(StringUtils.stripToEmpty(entry.getValue()), LIST_SEPARATOR)));
        } else if (StringUtils.equals(PROP_REP_PREFIXES, entry.getKey())) {
            this.repPrefixes.addAll(Arrays
                    .asList(StringUtils.split(StringUtils.stripToEmpty(entry.getValue()), LIST_SEPARATOR)));
        } else if (StringUtils.equals(PROP_PRIVILEGES, entry.getKey())) {
            for (String privilege : StringUtils.split(entry.getValue(), LIST_SEPARATOR)) {
                privilege = StringUtils.stripToNull(privilege);
                if (privilege != null) {
                    this.privilegeNames.add(privilege);
                }
            }
        }
    }

    validate(this.type, this.path, this.privilegeNames);
}

From source file:gov.nih.nci.calims2.taglib.form.FormWidgetTag.java

/**
 * @param id the id to set
 */
public void setId(String id) {
    this.id = StringUtils.stripToNull(id);
}