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

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

Introduction

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

Prototype

public static boolean containsNone(String str, String invalidChars) 

Source Link

Document

Checks that the String does not contain certain characters.

Usage

From source file:org.openanzo.rdf.MemVariable.java

/**
 * Static factory method that uses an WeakHashMap cache to reuse {@link MemVariable} objects for variables with the same name.
 * /*w ww. j ava  2s  .  c o m*/
 * @param variableName
 *            name of variable
 * @return {@link MemVariable} for given name
 */
static public MemVariable createVariable(String variableName) {
    if (variableName.startsWith("?")) {
        throw new AnzoRuntimeException(ExceptionConstants.CLIENT.VARIABLE_START_QUESTION, variableName);
    }
    if (!StringUtils.containsNone(variableName, " \t\n\r\f")) {
        throw new AnzoRuntimeException(ExceptionConstants.CLIENT.VARIABLE_NO_SPACES, variableName);
    }
    SoftReference<MemVariable> ref = cache.get(variableName);
    MemVariable var = (ref != null) ? ref.get() : null;
    if (var == null) {
        var = new MemVariable(variableName);
        cache.put(variableName, new SoftReference<MemVariable>(var));
    }
    return var;
}

From source file:org.openehr.rm.datatypes.text.DvText.java

static boolean validValue(String value) {
    return StringUtils.isNotEmpty(value) && StringUtils.containsNone(value, "\n\r");
}

From source file:org.openlegacy.utils.StringUtil.java

public static String nullsToSpaces(String value) {
    char[] chars = new char[] { 0 };
    if (StringUtils.containsNone(value, chars)) {
        return value;
    }//from w  w  w. jav  a  2  s . c o m
    return nullsToSpaces(value.toCharArray());
}

From source file:org.polymap.catalog.h2.actions.CreateH2Action.java

public void run(IAction action) {
    try {/*from   w  ww . java2  s  .c om*/
        InputDialog dialog = new InputDialog(PolymapWorkbench.getShellToParentOn(),
                "Eine neue, persnliche H2-Datenbank anlegen",
                "Whlen Sie den Namen der Datenbank.\nVerwenden Sie mglichst eine Vorsilbe mit ihrem Namen.",
                Polymap.instance().getUser().getName() + "-datenbank", new IInputValidator() {
                    public String isValid(String newText) {
                        return StringUtils.containsNone(newText, "/\\@") ? null
                                : "Folgende Buchstaben sind nicht erlaubt: /\\@";
                    }
                });

        if (dialog.open() == Window.OK) {

            Map<String, Serializable> params = new HashMap();
            params.put(H2DataStoreFactory.DBTYPE.key, "h2");
            params.put(JDBCDataStoreFactory.NAMESPACE.key, "http://www.polymap.org/" + dialog.getValue());
            params.put(H2DataStoreFactory.DATABASE.key, dialog.getValue());
            params.put(H2DataStoreFactory.USER.key, "polymap");

            org.polymap.catalog.h2.data.H2DataStoreFactory factory = H2ServiceExtension.getFactory();
            JDBCDataStore ds = factory.createDataStore(params);
            try {
                String[] typeNames = ds.getTypeNames();
                log.info("H2: " + Arrays.asList(typeNames));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }

            String url = ((BasicDataSource) ds.getDataSource()).getUrl();
            log.info("URL: " + url);

            H2ServiceImpl service = (H2ServiceImpl) new H2ServiceExtension().createService(null, params);
            //                H2ServiceImpl service = new H2ServiceImpl( 
            //                        H2ServiceExtension.toURL( url ), params );
            CatalogPluginSession.instance().getLocalCatalog().add(service);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.polymap.core.data.feature.recordstore.catalog.CreateRDataStoreAction.java

public void run(IAction action) {
    try {//from w  w w .j  a v a  2s  .c o  m
        InputDialog dialog = new InputDialog(PolymapWorkbench.getShellToParentOn(), i18n("dialogTitle"),
                i18n("dialogMsg"), i18n("dbName", Polymap.instance().getUser().getName()),
                new IInputValidator() {
                    public String isValid(String newText) {
                        return StringUtils.containsNone(newText, "/\\@") ? null : i18n("validationError");
                    }
                });

        if (dialog.open() == Window.OK) {

            Map<String, Serializable> params = new HashMap();
            params.put(RDataStoreFactory.DBTYPE.key, (Serializable) RDataStoreFactory.DBTYPE.sample);
            params.put(RDataStoreFactory.DATABASE.key, dialog.getValue());

            RDataStoreFactory factory = RServiceExtension.factory();
            RDataStore ds = factory.createNewDataStore(params);
            try {
                List<Name> typeNames = ds.getNames();
                log.info("RDataStore: " + typeNames);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }

            RServiceImpl service = (RServiceImpl) new RServiceExtension().createService(null, params);
            CatalogPluginSession.instance().getLocalCatalog().add(service);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.polymap.core.data.feature.recordstore.catalog.RConnectionPage.java

@Override
public void modifyText(ModifyEvent e) {
    // getState().getErrors().clear();
    dbname = ((Text) e.getSource()).getText();

    setErrorMessage(null);//  w  w w . java2s.  com
    setPageComplete(true);

    if (!StringUtils.containsNone(dbname, "/\\@")) {
        setErrorMessage(i18n("validationError"));
        setPageComplete(false);
    }

    getWizard().getContainer().updateButtons();
}

From source file:org.projectforge.core.BaseDao.java

/**
 * If the search string starts with "'" then the searchString will be returned without leading "'". If the search string consists only of
 * alphanumeric characters and allowed chars and spaces the wild card character '*' will be appended for enable ...* search. Otherwise the
 * searchString itself will be returned.
 * @param searchString// w ww  .  ja  v  a  2s.  c om
 * @param andSearch If true then all terms must match (AND search), otherwise OR will used (default)
 * @see #ALLOWED_CHARS
 * @see #ALLOWED_BEGINNING_CHARS
 * @see #ESCAPE_CHARS
 * @return The modified search string or the original one if no modification was done.
 */
public static String modifySearchString(final String searchString, final boolean andSearch) {
    if (searchString == null) {
        return "";
    }
    if (searchString.startsWith("'") == true) {
        return searchString.substring(1);
    }
    for (int i = 0; i < searchString.length(); i++) {
        final char ch = searchString.charAt(i);
        if (Character.isLetterOrDigit(ch) == false && Character.isWhitespace(ch) == false) {
            final String allowed = (i == 0) ? ALLOWED_BEGINNING_CHARS : ALLOWED_CHARS;
            if (allowed.indexOf(ch) < 0) {
                return searchString;
            }
        }
    }
    final String[] tokens = StringUtils.split(searchString, ' ');
    final StringBuffer buf = new StringBuffer();
    boolean first = true;
    for (final String token : tokens) {
        if (first == true) {
            first = false;
        } else {
            buf.append(" ");
        }
        if (ArrayUtils.contains(luceneReservedWords, token) == false) {
            final String modified = modifySearchToken(token);
            if (tokens.length > 1 && andSearch == true
                    && StringUtils.containsNone(modified, ESCAPE_CHARS) == true) {
                buf.append("+");
            }
            buf.append(modified);
            if (modified.endsWith("*") == false && StringUtils.containsNone(modified, ESCAPE_CHARS) == true) {
                if (andSearch == false || tokens.length > 1) {
                    // Don't append '*' if used by SearchForm and only one token is given. It's will be appended automatically by BaseDao before the
                    // search is executed.
                    buf.append('*');
                }
            }
        } else {
            buf.append(token);
        }
    }
    return buf.toString();
}

From source file:org.sonar.core.persistence.DbTester.java

/**
 * Returns the number of rows in the table. Example:
 * <pre>int issues = countTable("issues")</pre>
 *//*from   ww  w . ja  v  a  2s  . c o  m*/
public int countRowsOfTable(String tableName) {
    Preconditions.checkArgument(StringUtils.containsNone(tableName, " "),
            "Parameter must be the name of a table. Got " + tableName);
    return countSql("select count(*) from " + tableName);
}

From source file:org.sonar.db.AbstractDbTester.java

protected int countRowsOfTable(String tableName, ConnectionSupplier connectionSupplier) {
    checkArgument(StringUtils.containsNone(tableName, " "),
            "Parameter must be the name of a table. Got " + tableName);
    return countSql("select count(1) from " + tableName.toLowerCase(Locale.ENGLISH), connectionSupplier);
}

From source file:pt.ist.fenix.task.updateData.fixNames.DBField2Cap.java

/**
 * Checks that a string does not contain special characters (only
 * alphanumeric ones)./*from   www  . j a  va  2s .c o m*/
 * 
 * @param string
 *            the string to check
 * @return <code>true</code> if the strings contains a special character
 */
private static boolean containsNoneSpecialChars(String string) {
    return StringUtils.containsNone(string, specialChars);
}