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

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

Introduction

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

Prototype

public static String trimToNull(String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null.

Usage

From source file:ch.entwine.weblounge.contentrepository.impl.index.ContentRepositoryIndex.java

/**
 * Removes all entries for the given resource uri from the index and returns
 * <code>true</code>. If the resource is not part of the index,
 * <code>false</code> is returned.
 * //from w ww  .  j ava 2s .  c  o  m
 * @param uri
 *          the resource uri
 * @return <code>true</code> if the resource was deleted
 * @throws IOException
 *           if updating the index fails
 * @throws ContentRepositoryException
 *           if deleting the resource fails
 */
public synchronized boolean delete(ResourceURI uri)
        throws IOException, ContentRepositoryException, IllegalArgumentException {
    getIdentifier(uri);
    StringUtils.trimToNull(uri.getPath());
    uri.getVersion();

    // Finally, delete the entry
    return searchIdx.delete(uri);
}

From source file:ips1ap101.lib.base.BaseBundle.java

private static String getString(String key) {
    if (StringUtils.isNotBlank(key)) {
        try {/*w  ww  .  j ava2s . c o  m*/
            return StringUtils.trimToNull(resourceBundle.getString(key));
        } catch (MissingResourceException e) {
        }
    }
    return null;
}

From source file:com.egt.core.util.STP.java

public static Object getObjeto(String string) {
    Object objeto = null;//from   w  w  w . j a va2s.com
    String cadena = StringUtils.trimToNull(string);
    if (cadena == null) {
        return null;
    }
    if (StringUtils.isNumeric(cadena)) {
        objeto = getObjeto(cadena, EnumTipoDatoPar.ENTERO);
    }
    if (objeto == null && StringUtils.isNumeric(cadena)) {
        objeto = getObjeto(cadena, EnumTipoDatoPar.ENTERO_GRANDE);
    }
    if (objeto == null && cadena.startsWith(Global.PREFIJO_STRING_ID_RECURSO)) {
        String substr = cadena.substring(1);
        if (StringUtils.isNumeric(substr)) {
            objeto = getObjeto(substr, EnumTipoDatoPar.ENTERO_GRANDE);
        }
    }
    if (objeto == null) {
        objeto = getObjeto(cadena, EnumTipoDatoPar.NUMERICO);
    }
    if (objeto == null) {
        objeto = getObjeto(cadena, EnumTipoDatoPar.FECHA_HORA);
    }
    if (objeto == null) {
        objeto = getObjeto(cadena, EnumTipoDatoPar.ALFANUMERICO);
    }
    return objeto;
}

From source file:ips1ap101.lib.core.util.STP.java

public static Object getObjeto(String string) {
    Object objeto = null;//  w w  w.  j  av a2s  . c o  m
    String cadena = StringUtils.trimToNull(string);
    if (cadena == null) {
        return null;
    }
    if (StringUtils.isNumeric(cadena)) {
        objeto = getObjeto(cadena, TipoDatoParEnumeration.ENTERO);
    }
    if (objeto == null && StringUtils.isNumeric(cadena)) {
        objeto = getObjeto(cadena, TipoDatoParEnumeration.ENTERO_GRANDE);
    }
    if (objeto == null && cadena.startsWith(Global.PREFIJO_STRING_ID_RECURSO)) {
        String substr = cadena.substring(1);
        if (StringUtils.isNumeric(substr)) {
            objeto = getObjeto(substr, TipoDatoParEnumeration.ENTERO_GRANDE);
        }
    }
    if (objeto == null) {
        objeto = getObjeto(cadena, TipoDatoParEnumeration.NUMERICO);
    }
    if (objeto == null) {
        objeto = getObjeto(cadena, TipoDatoParEnumeration.FECHA_HORA);
    }
    if (objeto == null) {
        objeto = getObjeto(cadena, TipoDatoParEnumeration.ALFANUMERICO);
    }
    return objeto;
}

From source file:mitm.djigzo.web.pages.portal.secure.Signup.java

protected void onActivate(String email, long timestamp, String mac) {
    this.email = StringUtils.trimToNull(email);
    this.timestamp = timestamp;
    this.mac = StringUtils.trimToNull(mac);
}

From source file:com.haulmont.cuba.web.app.folders.FolderEditWindow.java

protected void commit() {
    SearchFolder folder = (SearchFolder) FolderEditWindow.this.folder;
    if (StringUtils.trimToNull(nameField.getValue()) == null) {
        String msg = messages.getMainMessage("folders.folderEditWindow.emptyName");
        App.getInstance().getWindowManager().showNotification(msg, Frame.NotificationType.TRAY);
        return;/*  w ww.ja va2  s . c  o  m*/
    }
    folder.setName(nameField.getValue());
    folder.setTabName(tabNameField.getValue());

    if (sortOrderField.getValue() == null || "".equals(sortOrderField.getValue())) {
        folder.setSortOrder(null);
    } else {
        String value = sortOrderField.getValue();
        int sortOrder;
        try {
            sortOrder = Integer.parseInt(value);
        } catch (NumberFormatException e) {
            String msg = messages.getMainMessage("folders.folderEditWindow.invalidSortOrder");
            App.getInstance().getWindowManager().showNotification(msg, Frame.NotificationType.WARNING);
            return;
        }
        folder.setSortOrder(sortOrder);
    }

    Object parent = parentSelect.getValue();
    if (parent instanceof Folder)
        folder.setParent((Folder) parent);
    else
        folder.setParent(null);

    folder.setApplyDefault(Boolean.valueOf(applyDefaultCb.getValue().toString()));
    if (globalCb != null) {
        if (BooleanUtils.isTrue(globalCb.getValue())) {
            folder.setUser(null);
        } else {
            folder.setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
        }
    } else {
        folder.setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
    }

    if (presentation != null) {
        folder.setPresentation((Presentation) presentation.getValue());
    }

    FolderEditWindow.this.commitHandler.run();

    close();
}

From source file:com.hmsinc.epicenter.webapp.remoting.AbstractRemoteService.java

/**
 * @param value//from w w w.  jav  a2  s  .c o m
 * @return
 */
protected static Collection<Long> splitStringToIdList(final String idList) {
    Set<Long> ret = null;
    try {

        final String value = StringUtils.trimToNull(codec.decode(idList));
        if (value != null) {
            ret = new HashSet<Long>();
            for (String v : value.split(",")) {
                if (StringUtils.isNumeric(v)) {
                    ret.add(Long.valueOf(v));
                }
            }
        }
    } catch (DecoderException e) {
        throw new IllegalArgumentException(e);
    }
    return ret;
}

From source file:com.bluexml.side.form.utils.DOMUtil.java

/**
 * Retrieves a specific element based on tag name anywhere below a node with the additional
 * condition that its text content is not empty.
 * /*www  .ja  v a 2 s  .c  om*/
 * @param rootElt
 *            the root of the tree to search
 * @param tagName
 * @return the first Element that matches the tagName
 */
public static Element getElementInDescentByNameNonNull(Element rootElt, String tagName) {
    Element res = null;
    if (rootElt != null) {
        List<Element> children = getAllChildren(rootElt);
        res = getOneElementByTagName(children, tagName);
        if (res != null) {
            if (StringUtils.trimToNull(res.getTextContent()) != null) {
                return res;
            }
            return null;
        }
        for (Element elt : children) {
            res = getElementInDescentByNameNonNull(elt, tagName);
            if (res != null) {
                return res;
            }
        }
    }
    return null;
}

From source file:com.bluexml.side.Workflow.modeler.diagram.dialogs.ActionEditDialog.java

/**
 * Initialize the content of the widgets
 *//*  w  w w . jav  a2  s  .  co  m*/
protected void loadData() {

    String expression = action.getExpression();
    if (StringUtils.trimToNull(expression) == null) {
        Script s = null;
        if (action.getScript().size() > 0) {
            s = action.getScript().get(0);
        } else {
            script = false;
        }
        if (s != null && s.getExpression() != null) {
            this.expression = s.getExpression();
        }

    } else {
        this.expression = expression;
        script = false;
    }
    if (inEnterpriseVersion()) {
        javaClassTxt = defaultsJavaClasses.get(0);
        if (action.getJavaClass() != null && action.getJavaClass().length() > 0) {
            javaClassTxt = action.getJavaClass().replaceAll("\"", "");
        }
    }

}

From source file:ch.entwine.weblounge.common.impl.request.RequestUtils.java

/**
 * Checks if the parameter <code>parameter</code> is present in the request
 * and is not equal to the empty string. In this case, the parameter itself is
 * returned, <code>null</code> otherwise.
 * <p>//from  ww w. j  a va  2  s. co  m
 * Note that this method includes the check for <tt>hidden</tt> parameters.
 * 
 * @param request
 *          the weblounge request
 * @param parameter
 *          the parameter name
 * @return the parameter value or <code>null</code> if the parameter is not
 *         available
 */
public static String getParameter(WebloungeRequest request, String parameter) {
    String p = request.getParameter(parameter);
    if (p != null) {
        try {
            p = decode(p, "utf-8");
        } catch (UnsupportedEncodingException e) {
            logger.error("Encoding 'utf-8' is not supported on this platform");
        }
    }
    return StringUtils.trimToNull(p);
}