本文整理汇总了Java中org.apache.commons.lang.StringUtils.length方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.length方法的具体用法?Java StringUtils.length怎么用?Java StringUtils.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.StringUtils
的用法示例。
在下文中一共展示了StringUtils.length方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPermissions
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static ArrayList<String> getPermissions(int id) throws SQLException{
PreparedStatement stmt = plugin.getDb().getConnection().prepareStatement("SELECT permissions FROM ranks WHERE id = "+id+" LIMIT 1");
ResultSet set = stmt.executeQuery();
set.next();
String s = set.getString("permissions");
String[] permissions = new String[(StringUtils.isEmpty(s)?1:StringUtils.length(s)+1)];
if(StringUtils.isNotEmpty(s)){permissions = s.split("\\s+");}
ArrayList<String> perms = new ArrayList<>();
perms.addAll(Arrays.asList(permissions));
return perms;
}
示例2: writeDataInFile
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private void writeDataInFile(List<String[]> fileDataList, String filePath) {
if (filePath != null) {
if (StringUtils.length(ConvertHexValues.parseHex(delimiter)) == 1
&& StringUtils.length(ConvertHexValues.parseHex(quoteCharactor)) == 1) {
try (FileWriter fileWriter = new FileWriter(filePath);
CSVWriter writer = new CSVWriter(fileWriter,
ConvertHexValues.parseHex(delimiter).toCharArray()[0], ConvertHexValues.parseHex(
quoteCharactor).toCharArray()[0])) {
writer.writeAll(fileDataList, false);
showMessage("Data exported to " + filePath + " successfully.", INFORMATION, SWT.ICON_INFORMATION);
} catch (IOException e1) {
showMessage(Messages.ERROR_MESSAGE, ERROR, SWT.ICON_ERROR);
}
}
}
}
示例3: getBriefFromCommentText
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
protected String getBriefFromCommentText(String commentText) {
int index = StringUtils.indexOf(commentText, '\n');
if (index != -1) {
commentText = StringUtils.substring(commentText, 0, index);
}
index = StringUtils.indexOfAny(commentText, ".!?。!?…");
if (index > 0) {
commentText = StringUtils.substring(commentText, 0, index);
}
if (StringUtils.length(commentText) > 8) {
commentText = StringUtils.substring(commentText, 0, 8) + "…";
}
return commentText;
}
示例4: validateDelimiterAndQuoteCharactorProperty
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private boolean validateDelimiterAndQuoteCharactorProperty(String textBoxValue, String textBoxValue2,
ControlDecoration singleCharactorDecorator, ControlDecoration duplicateDecorator) {
if (StringUtils.length(ConvertHexValues.parseHex(textBoxValue)) == 1) {
enableAndDisableOkButtonIfAnyDecoratorIsVisible();
if (!(textBoxValue.equalsIgnoreCase(",") || textBoxValue.equalsIgnoreCase("\""))
&& !textBoxValue.equalsIgnoreCase(textBoxValue2)) {
warningLabel.setText(Messages.WARNING_MESSAGE);
warningLabel.setVisible(true);
warningImageLabel.setVisible(true);
hideDelimiterAndQuoteCharactorDecorator();
if (StringUtils.length(ConvertHexValues.parseHex(textBoxValue2)) > 1) {
getButton(0).setEnabled(false);
}
else
{
getButton(0).setEnabled(true);
enableAndDisableOkButtonIfAnyDecoratorIsVisible();
}
return false;
} else {
if (textBoxValue.equalsIgnoreCase(textBoxValue2)) {
duplicateDecorator.show();
getButton(0).setEnabled(false);
return false;
} else {
showWarningMessage(textBoxValue, textBoxValue2);
duplicateDecorator.hide();
enableAndDisableOkButtonIfAnyDecoratorIsVisible();
return true;
}
}
} else {
if (!textBoxValue.isEmpty()) {
singleCharactorDecorator.show();
getButton(0).setEnabled(false);
}
return false;
}
}
示例5: validateDelimiter
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private Notification validateDelimiter(){
Notification notification = new Notification();
if(StringUtils.isNotBlank(delimiterEditor.getStringValue()) &&delimiterEditor.getStringValue().equalsIgnoreCase(quoteEditor.getStringValue())){
notification.addError(Messages.DELIMITER_VALUE_MATCH_ERROR);
}
if(StringUtils.length(ConvertHexValues.parseHex(delimiterEditor.getStringValue())) != 1){
notification.addError(Messages.DELIMITER_SINGLE_CHARACTOR_ERROR_MESSAGE);
}
return notification;
}
示例6: validateQuoteCharacter
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private Notification validateQuoteCharacter(){
Notification notification = new Notification();
if(StringUtils.isNotBlank(quoteEditor.getStringValue()) && quoteEditor.getStringValue().equalsIgnoreCase(delimiterEditor.getStringValue())){
notification.addError(Messages.QUOTE_VALUE_MATCH_ERROR);
}
if(StringUtils.length(ConvertHexValues.parseHex(quoteEditor.getStringValue())) != 1){
notification.addError(Messages.QUOTE_SINGLE_CHARACTOR_ERROR_MESSAGE);
}
return notification;
}
示例7: parseHex
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* This method converts input hex-value into its equivalent character.
*
* @param input
* , hex-value e.g. \x21 for !
* @return string, if given input is valid hex-value then its equivalent character is returned else input is
* returned as it is.
*/
public static String parseHex(String input) {
final int NO_OF_DIGITS = 2;
if (StringUtils.isBlank(input) || StringUtils.length(input) < NO_OF_DIGITS + 2)
return input;
// Added support for \\t
if (input.contains("\\t")) {
input = input.replace("\\t", "\\x09");
}
String[] tokens = input.split("\\\\x");
String hex;
String temp;
boolean startsWithHex = input.startsWith("\\x");
for (int counter = 0; counter < tokens.length; counter++) {
if (counter == 0 && !startsWithHex)
continue;
if (tokens[counter].equals(""))
continue;
temp = tokens[counter];
hex = temp.substring(0, NO_OF_DIGITS);
temp = temp.substring(NO_OF_DIGITS, temp.length());
try {
tokens[counter] = hexToChar(hex) + temp;
} catch (NumberFormatException numberFormatException) {
tokens[counter] = hex + temp;
}
}
String result = "";
for (String token : tokens) {
result = result + token;
}
return result;
}