use of java.text.StringCharacterIterator in project intellij-community by JetBrains.
the class Strings method isCapitalized.
public static boolean isCapitalized(@NotNull String text, @NotNull TextRange range) {
if (range.getLength() == 0)
return false;
CharacterIterator it = new StringCharacterIterator(text, range.getStartOffset() + 1, range.getEndOffset(), range.getStartOffset() + 1);
boolean lowCase = true;
for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
lowCase = Character.isLowerCase(c);
}
return Character.isUpperCase(text.charAt(range.getStartOffset())) && lowCase;
}
use of java.text.StringCharacterIterator in project Activiti by Activiti.
the class BpmnXMLUtil method parseDelimitedList.
public static List<String> parseDelimitedList(String s) {
List<String> result = new ArrayList<String>();
if (StringUtils.isNotEmpty(s)) {
StringCharacterIterator iterator = new StringCharacterIterator(s);
char c = iterator.first();
StringBuilder strb = new StringBuilder();
boolean insideExpression = false;
while (c != StringCharacterIterator.DONE) {
if (c == '{' || c == '$') {
insideExpression = true;
} else if (c == '}') {
insideExpression = false;
} else if (c == ',' && !insideExpression) {
result.add(strb.toString().trim());
strb.delete(0, strb.length());
}
if (c != ',' || (insideExpression)) {
strb.append(c);
}
c = iterator.next();
}
if (strb.length() > 0) {
result.add(strb.toString().trim());
}
}
return result;
}
use of java.text.StringCharacterIterator in project intellij-community by JetBrains.
the class StubBuildingVisitor method parseMethodSignature.
private MethodInfo parseMethodSignature(String signature, String[] exceptions) throws ClsFormatException {
MethodInfo result = new MethodInfo();
CharacterIterator iterator = new StringCharacterIterator(signature);
result.typeParameters = SignatureParsing.parseTypeParametersDeclaration(iterator, myMapping);
if (iterator.current() != '(')
throw new ClsFormatException();
iterator.next();
if (iterator.current() == ')') {
result.argTypes = ContainerUtil.emptyList();
} else {
result.argTypes = ContainerUtil.newSmartList();
while (iterator.current() != ')' && iterator.current() != CharacterIterator.DONE) {
result.argTypes.add(SignatureParsing.parseTypeString(iterator, myMapping));
}
if (iterator.current() != ')')
throw new ClsFormatException();
}
iterator.next();
result.returnType = SignatureParsing.parseTypeString(iterator, myMapping);
result.throwTypes = null;
while (iterator.current() == '^') {
iterator.next();
if (result.throwTypes == null)
result.throwTypes = ContainerUtil.newSmartList();
result.throwTypes.add(SignatureParsing.parseTypeString(iterator, myMapping));
}
if (exceptions != null && (result.throwTypes == null || exceptions.length > result.throwTypes.size())) {
// a signature may be inconsistent with exception list - in this case, the more complete list takes precedence
result.throwTypes = ContainerUtil.map(exceptions, name -> myMapping.fun(name));
}
return result;
}
use of java.text.StringCharacterIterator in project adempiere by adempiere.
the class CharacterFilter method process.
/**
Perform the filtering operation.
*/
public String process(String to_process) {
if (to_process == null || to_process.length() == 0)
return "";
StringBuffer bs = new StringBuffer(to_process.length() + 50);
StringCharacterIterator sci = new StringCharacterIterator(to_process);
String tmp = null;
for (char c = sci.first(); c != CharacterIterator.DONE; c = sci.next()) {
tmp = String.valueOf(c);
if (hasAttribute(tmp))
tmp = (String) this.get(tmp);
int ii = c;
if (ii > 255)
tmp = "&#" + ii + ";";
bs.append(tmp);
}
return (bs.toString());
}
use of java.text.StringCharacterIterator in project jena by apache.
the class TurtleValidate method checkValidPrefixPart.
/* http://www.w3.org/TeamSubmission/turtle/#sec-grammar-grammar
* [27] qname ::= prefixName? ':' name?
* [30] nameStartChar ::= [A-Z] | "_" | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
* [31] nameChar ::= nameStartChar | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
* [32] name ::= nameStartChar nameChar*
* [33] prefixName ::= ( nameStartChar - '_' ) nameChar*
*/
protected static boolean checkValidPrefixPart(String s) {
if (s.length() == 0)
return true;
CharacterIterator cIter = new StringCharacterIterator(s);
char ch = cIter.first();
if (!checkNameStartChar(ch))
return false;
if (// Can't start with _ (bnodes labels handled separately)
ch == '_')
return false;
return checkNameTail(cIter);
}
Aggregations