Search in sources :

Example 31 with StringCharacterIterator

use of java.text.StringCharacterIterator in project robovm by robovm.

the class CollatorTest method assertGetCollationElementIteratorCharacterIterator.

private void assertGetCollationElementIteratorCharacterIterator(Locale l, String s, Integer... offsets) {
    RuleBasedCollator coll = (RuleBasedCollator) Collator.getInstance(l);
    CharacterIterator it = new StringCharacterIterator(s);
    assertCollationElementIterator(coll.getCollationElementIterator(it), offsets);
}
Also used : RuleBasedCollator(java.text.RuleBasedCollator) StringCharacterIterator(java.text.StringCharacterIterator) StringCharacterIterator(java.text.StringCharacterIterator) CharacterIterator(java.text.CharacterIterator)

Example 32 with StringCharacterIterator

use of java.text.StringCharacterIterator in project adempiere by adempiere.

the class StringFilter method split.

/**
        Need a way to parse the stream so we can do string comparisons instead
        of character comparisons.
    */
private String[] split(String to_split) {
    if (to_split == null || to_split.length() == 0) {
        String[] array = new String[0];
        return array;
    }
    StringBuffer sb = new StringBuffer(to_split.length() + 50);
    StringCharacterIterator sci = new StringCharacterIterator(to_split);
    int length = 0;
    for (char c = sci.first(); c != CharacterIterator.DONE; c = sci.next()) {
        if (String.valueOf(c).equals(" "))
            length++;
        else if (sci.getEndIndex() - 1 == sci.getIndex())
            length++;
    }
    String[] array = new String[length];
    length = 0;
    String tmp = new String();
    for (char c = sci.first(); c != CharacterIterator.DONE; c = sci.next()) {
        if (String.valueOf(c).equals(" ")) {
            array[length] = tmp;
            tmp = new String();
            length++;
        } else if (sci.getEndIndex() - 1 == sci.getIndex()) {
            tmp = tmp + String.valueOf(sci.last());
            array[length] = tmp;
            tmp = new String();
            length++;
        } else
            tmp += String.valueOf(c);
    }
    return (array);
}
Also used : StringCharacterIterator(java.text.StringCharacterIterator)

Example 33 with StringCharacterIterator

use of java.text.StringCharacterIterator in project drill by apache.

the class Text method utf8Length.

/**
   * For the given string, returns the number of UTF-8 bytes required to encode the string.
   *
   * @param string
   *          text to encode
   * @return number of UTF-8 bytes required to encode
   */
public static int utf8Length(String string) {
    CharacterIterator iter = new StringCharacterIterator(string);
    char ch = iter.first();
    int size = 0;
    while (ch != CharacterIterator.DONE) {
        if ((ch >= 0xD800) && (ch < 0xDC00)) {
            // surrogate pair?
            char trail = iter.next();
            if ((trail > 0xDBFF) && (trail < 0xE000)) {
                // valid pair
                size += 4;
            } else {
                // invalid pair
                size += 3;
                // rewind one
                iter.previous();
            }
        } else if (ch < 0x80) {
            size++;
        } else if (ch < 0x800) {
            size += 2;
        } else {
            // ch < 0x10000, that is, the largest char value
            size += 3;
        }
        ch = iter.next();
    }
    return size;
}
Also used : StringCharacterIterator(java.text.StringCharacterIterator) CharacterIterator(java.text.CharacterIterator) StringCharacterIterator(java.text.StringCharacterIterator)

Example 34 with StringCharacterIterator

use of java.text.StringCharacterIterator in project jena by apache.

the class N3JenaWriterCommon method checkNamePart.

protected static boolean checkNamePart(String s) {
    if (s.length() == 0)
        return true;
    CharacterIterator cIter = new StringCharacterIterator(s);
    char ch = cIter.first();
    if (!checkNameStartChar(ch))
        return false;
    return checkNameTail(cIter);
}
Also used : StringCharacterIterator(java.text.StringCharacterIterator) CharacterIterator(java.text.CharacterIterator) StringCharacterIterator(java.text.StringCharacterIterator)

Example 35 with StringCharacterIterator

use of java.text.StringCharacterIterator in project jena by apache.

the class TurtleValidate method checkValidNamePart.

protected static boolean checkValidNamePart(String s) {
    if (s.length() == 0)
        return true;
    CharacterIterator cIter = new StringCharacterIterator(s);
    char ch = cIter.first();
    if (!checkNameStartChar(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