Search in sources :

Example 11 with StringCharacterIterator

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;
}
Also used : StringCharacterIterator(java.text.StringCharacterIterator) StringCharacterIterator(java.text.StringCharacterIterator) CharacterIterator(java.text.CharacterIterator)

Example 12 with StringCharacterIterator

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;
}
Also used : StringCharacterIterator(java.text.StringCharacterIterator) ArrayList(java.util.ArrayList)

Example 13 with StringCharacterIterator

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;
}
Also used : ArrayUtil(com.intellij.util.ArrayUtil) Array(java.lang.reflect.Array) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContainerUtil(com.intellij.util.containers.ContainerUtil) ModifierFlags(com.intellij.psi.impl.cache.ModifierFlags) PsiNameHelper(com.intellij.psi.PsiNameHelper) TypeInfo(com.intellij.psi.impl.cache.TypeInfo) Map(java.util.Map) Logger(com.intellij.openapi.diagnostic.Logger) Pair.pair(com.intellij.openapi.util.Pair.pair) LanguageLevel(com.intellij.pom.java.LanguageLevel) BitUtil.isSet(com.intellij.util.BitUtil.isSet) com.intellij.psi.impl.java.stubs(com.intellij.psi.impl.java.stubs) CharacterIterator(java.text.CharacterIterator) StringUtil(com.intellij.openapi.util.text.StringUtil) StringRef(com.intellij.util.io.StringRef) Set(java.util.Set) IOException(java.io.IOException) ClsFormatException(com.intellij.util.cls.ClsFormatException) StringCharacterIterator(java.text.StringCharacterIterator) CommonClassNames(com.intellij.psi.CommonClassNames) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) com.intellij.psi.impl.java.stubs.impl(com.intellij.psi.impl.java.stubs.impl) Function(com.intellij.util.Function) Pair(com.intellij.openapi.util.Pair) org.jetbrains.org.objectweb.asm(org.jetbrains.org.objectweb.asm) PsiFileStub(com.intellij.psi.stubs.PsiFileStub) StubElement(com.intellij.psi.stubs.StubElement) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) StringCharacterIterator(java.text.StringCharacterIterator) CharacterIterator(java.text.CharacterIterator) StringCharacterIterator(java.text.StringCharacterIterator) ClsFormatException(com.intellij.util.cls.ClsFormatException)

Example 14 with StringCharacterIterator

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());
}
Also used : StringCharacterIterator(java.text.StringCharacterIterator)

Example 15 with StringCharacterIterator

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);
}
Also used : StringCharacterIterator(java.text.StringCharacterIterator) StringCharacterIterator(java.text.StringCharacterIterator) CharacterIterator(java.text.CharacterIterator)

Aggregations

StringCharacterIterator (java.text.StringCharacterIterator)41 CharacterIterator (java.text.CharacterIterator)20 Nullable (org.jetbrains.annotations.Nullable)3 ClsFormatException (com.intellij.util.cls.ClsFormatException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Logger (com.intellij.openapi.diagnostic.Logger)1 Pair (com.intellij.openapi.util.Pair)1 Pair.pair (com.intellij.openapi.util.Pair.pair)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LanguageLevel (com.intellij.pom.java.LanguageLevel)1 CommonClassNames (com.intellij.psi.CommonClassNames)1 PsiNameHelper (com.intellij.psi.PsiNameHelper)1 ModifierFlags (com.intellij.psi.impl.cache.ModifierFlags)1 TypeInfo (com.intellij.psi.impl.cache.TypeInfo)1 com.intellij.psi.impl.java.stubs (com.intellij.psi.impl.java.stubs)1 com.intellij.psi.impl.java.stubs.impl (com.intellij.psi.impl.java.stubs.impl)1 PsiFileStub (com.intellij.psi.stubs.PsiFileStub)1 StubElement (com.intellij.psi.stubs.StubElement)1