Java Code Examples for org.apache.commons.lang3.StringUtils.isAlphanumeric()

The following are Jave code examples for showing how to use isAlphanumeric() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lazycat   File: GUIUtil.java   View Source Code Vote up 7 votes
public static boolean checkAlphaNumeric(JTextField tf, String input) {
	String text = tf.getText().trim();
	if (text.length() == 0)
		return true;

	if (!StringUtils.isAlphanumeric(text)) {
		JOptionPane.showMessageDialog(null, input + "ֻ����Ӣ�ĺ�������ɣ�����ֻ����ӦΪ��ͷ");
		tf.grabFocus();
		return false;
	}
	if (text.length() != 0 && !StringUtils.isAlpha(String.valueOf(text.charAt(0)))) {
		JOptionPane.showMessageDialog(null, input + "ֻ����Ӣ�ĺ�������ɣ�����ֻ��Ӣ�Ŀ�ͷ");
		tf.grabFocus();
		return false;
	}
	return true;

}
 
Example 2
Project: csap-core   File: ServiceBaseParser.java   View Source Code Vote up 6 votes
private boolean isAlphaNumeric ( StringBuffer resultsBuf, ObjectNode serviceMetersDefinition, String name ) {
	if ( !StringUtils.isAlphanumeric( name ) ) {

		ObjectNode metricSettings = (ObjectNode) serviceMetersDefinition.get( name );
		metricSettings.put( "errors", true );

		updateServiceParseResults( resultsBuf, CSAP.CONFIG_PARSE_WARN,
			getErrorHeader()
					+ "Invalid attribute name: " + name
					+ ", must be alphaNumeric only. Removing" );

		return false;

	}
	return true;
}
 
Example 3
Project: csap-core   File: DefinitionRequests.java   View Source Code Vote up 5 votes
private void verifyNewServiceName ( ReleasePackage currentPackageModel, String newName )
		throws IOException {
	ArrayList<String> currentServices = corePortals.getServices( currentPackageModel );

	if ( !StringUtils.isAlphanumeric( newName ) ) {
		throw new IOException( "Service names must be alpha numeric only, with no spaces or other special characters: " + newName );
	}

	if ( currentServices.contains( newName ) ) {
		throw new IOException( "Found existing service, try another name: " + newName );
	}
}
 
Example 4
Project: cyberduck   File: B2DirectoryFeature.java   View Source Code Vote up 5 votes
@Override
public boolean isSupported(final Path workdir, final String name) {
    if(workdir.isRoot()) {
        if(StringUtils.isNotBlank(name)) {
            return StringUtils.isAlphanumeric(name);
        }
    }
    return true;
}
 
Example 5
Project: cyberduck   File: SwiftDirectoryFeature.java   View Source Code Vote up 5 votes
@Override
public boolean isSupported(final Path workdir, final String name) {
    if(workdir.isRoot()) {
        if(StringUtils.isNotBlank(name)) {
            return StringUtils.isAlphanumeric(name);
        }
    }
    return true;
}
 
Example 6
Project: cyberduck   File: AzureDirectoryFeature.java   View Source Code Vote up 5 votes
@Override
public boolean isSupported(final Path workdir, final String name) {
    if(workdir.isRoot()) {
        if(StringUtils.isNotBlank(name)) {
            return StringUtils.isAlphanumeric(name);
        }
    }
    return true;
}
 
Example 7
Project: cyberduck   File: ApplescriptTerminalService.java   View Source Code Vote up 5 votes
protected String escape(final String path) {
    final StringBuilder escaped = new StringBuilder();
    for(char c : path.toCharArray()) {
        if(StringUtils.isAlphanumeric(String.valueOf(c))) {
            escaped.append(c);
        }
        else {
            escaped.append("\\").append(c);
        }
    }
    return escaped.toString();
}
 
Example 8
Project: cyberduck   File: Archive.java   View Source Code Vote up 5 votes
/**
 * Escape blank
 *
 * @param path Filename
 * @return Escaped whitespace in path
 */
protected String escape(final String path) {
    final StringBuilder escaped = new StringBuilder();
    for(char c : path.toCharArray()) {
        if(StringUtils.isAlphanumeric(String.valueOf(c))
                || c == Path.DELIMITER) {
            escaped.append(c);
        }
        else {
            escaped.append("\\").append(c);
        }
    }
    return escaped.toString();
}