use of java.text.CharacterIterator 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.CharacterIterator 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.CharacterIterator 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);
}
use of java.text.CharacterIterator in project jena by apache.
the class N3JenaWriterCommon method checkPrefixPart.
/* 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 checkPrefixPart(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);
}
use of java.text.CharacterIterator in project jdk8u_jdk by JetBrains.
the class DictionaryBasedBreakIterator method handleNext.
/**
* This is the implementation function for next().
*/
@Override
protected int handleNext() {
CharacterIterator text = getText();
// and possibly regenerate the cache
if (cachedBreakPositions == null || positionInCache == cachedBreakPositions.length - 1) {
// start by using the inherited handleNext() to find a tentative return
// value. dictionaryCharCount tells us how many dictionary characters
// we passed over on our way to the tentative return value
int startPos = text.getIndex();
dictionaryCharCount = 0;
int result = super.handleNext();
// for the new range
if (dictionaryCharCount > 1 && result - startPos > 1) {
divideUpDictionaryRange(startPos, result);
} else // otherwise, the value we got back from the inherited fuction
// is our return value, and we can dump the cache
{
cachedBreakPositions = null;
return result;
}
}
// and return it
if (cachedBreakPositions != null) {
++positionInCache;
text.setIndex(cachedBreakPositions[positionInCache]);
return cachedBreakPositions[positionInCache];
}
// SHOULD NEVER GET HERE!
return -9999;
}
Aggregations