下面列出了org.apache.commons.lang3.StringUtils#isAllUpperCase ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void validatePropertyName(Object oldPropertyName, Object propertyName, Integer ciTypeId) {
if (propertyName != null) {
String propertyNameStr = (String)propertyName;
if (CmdbConstants.MYSQL_SCHEMA_KEYWORDS.contains(propertyNameStr.trim().toUpperCase())) {
throw new InvalidArgumentException(String.format("Invalid property name [%s] as it is database key words.", propertyNameStr));
}
if (!propertyNameStr.equals(oldPropertyName) && ciTypeAttrRepository.existsByPropertyNameAndCiTypeId(propertyNameStr, ciTypeId)) {
throw new InvalidArgumentException(String.format("Property name [%s] already existed for ciType [%s(%d)]", propertyNameStr, getCiTypeName(ciTypeId), ciTypeId));
}
if (propertyNameStr.length() > CmdbConstants.MAX_LENGTH_OF_COLUMN) {
throw new InvalidArgumentException(String.format("Field propertyName [%s] is too long, max length is [%d]", propertyNameStr, CmdbConstants.MAX_LENGTH_OF_COLUMN));
}
if (!Pattern.matches("[a-zA-Z0-9_]+", propertyNameStr)) {
throw new InvalidArgumentException(String.format("Field propertyName [%s] must be composed by letters, '_' or numbers", propertyNameStr));
}
if (StringUtils.isAllUpperCase(propertyNameStr.toString().substring(0, 1))) {
throw new InvalidArgumentException(String.format("Field propertyName [%s] must be start with lowercase.", propertyNameStr));
}
}
}
private boolean matchesToTextTransform(String word, String textTransform)
{
if (word.isEmpty())
{
return true;
}
switch (textTransform)
{
case "uppercase":
return StringUtils.isAllUpperCase(word);
case "lowercase":
return StringUtils.isAllLowerCase(word);
case "capitalize":
return Character.isUpperCase(word.charAt(0));
default:
return false;
}
}
public Token(String surface, String norm, String pos) {
this.surface = surface;
this.norm = norm;
this.pos = pos;
negation = false;
if (surface.matches(elongatedRegex))
elongated = true;
else
elongated = false;
if (surface.matches(punctuationRegex))
punctuation = true;
else
punctuation = false;
if (surface.matches(lettersRegex))
letters = true;
else
letters = false;
if (StringUtils.isAllUpperCase(surface))
allCaps = true;
else
allCaps = false;
}
public static String toOracleName(String s) {
StringBuilder result = new StringBuilder();
String currChar;
if (s != null && !s.isEmpty()) {
for (int i = 0; i < s.length(); i++) {
currChar = s.substring(i, i + 1);
if (i != 0 && StringUtils.isAllUpperCase(currChar)) {
result.append("_" + currChar);
} else {
result.append(currChar);
}
}
}
return result.toString().toUpperCase().replaceAll("\\_\\_", "_");
}
@Override
public boolean evaluate(Object var, JinjavaInterpreter interpreter, Object... args) {
if (!(var instanceof String || var instanceof SafeString)) {
return false;
}
return StringUtils.isAllUpperCase(var.toString());
}
@Override
public void validate(JsonValue value) {
super.validate(value);
if (!StringUtils.isAllUpperCase(value.asString())) {
throw new IllegalArgumentException(value + " is not uppercase.");
}
}
private static String cleanName(String x) {
x = StringUtils.normalizeSpace(x).trim();
// if we get all upper names, Capitalize them
if (StringUtils.isAllUpperCase(StringUtils.deleteWhitespace(x))) {
x = StringUtils.capitalize(x.toLowerCase());
}
return x;
}
@Override
protected boolean handle(CharSequence str) {
return StringUtils.isAllUpperCase(str);
}
/**Some common pre-processing stuff*/
public String getProcessed(String str){
StringTokenizer st = new StringTokenizer(str);
String current;
String toreturn = "";
boolean isSpecial = false;
while (st.hasMoreTokens()){
current = st.nextToken();
String backup = current;
current = replaceEmoticons(current); // current is altered to "happy"/"sad"
current = replaceTwitterFeatures(current); // i.e. links, mentions, hash-tags
// current = replaceConsecutiveLetters(current); // replaces more than 2 repetitive letters with 2
current = replaceNegation(current); // if current is a negation word, then current = "negation"
for (int i=0; i<exclamationsymbol.size(); i++){
if (current.contains(exclamationsymbol.get(i)) && current.contains(dotsymbol.get(i))){
current="dotsymbol exclamationsymbol";
} else if (current.contains(exclamationsymbol.get(i))){
current="exclamationsymbol";
} else if (current.contains(dotsymbol.get(i))){
current="dotsymbol";
}
}
if (StringUtils.isAllUpperCase(backup.replaceAll("[^A-Za-z]", "")) && backup.replaceAll("[^A-Za-z]", "").length()>3){
isSpecial = true;
current = backup.replaceAll("[^A-Za-z]", "").toLowerCase();
}
if (backup.contains("#")){
isSpecial = true;
current = backup.substring(backup.indexOf("#")+1);
}
if (backup.replaceAll("[^A-Za-z]", "").length()>0 && containsRepetitions(backup.replaceAll("[^A-Za-z]", ""))){
isSpecial = true;
current = replaceConsecutiveLetters(backup);
}
if ( (current.contains("hashtagsymbol") || current.contains("urlinksymbol") || current.contains("negation") || current.contains("usermentionsymbol") || current.contains("consecutivesymbol") || current.contains("dotsymbol") || current.contains("exclamationsymbol") || current.contains("alcapital")) )
isSpecial = true;
if (isSpecial==true)
toreturn = toreturn.concat(" "+current);
isSpecial = false;
}
return toreturn;
}