Java 8 CharacterIterator - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CharacterIterator class.

This code example shows how to use the following methods:getBeginIndex, getEndIndex
This code example shows how to use the following methods:getBeginIndex, getEndIndex, getIndex, setIndex
        } 
    } 
     
 
    public int moveIndex(int delta){
        int length = iterator.getEndIndex() - iterator.getBeginIndex(); 
        int idx = iterator.getIndex()+delta;
         
        if(idx < 0) {
            idx = 0;
        } else if(idx > length) {
            idx = length;
        } 
        return iterator.setIndex(idx);
    } 
     
    /** 
     * @see UCharacterIterator#getCharacterIterator() 
     */ 
    public CharacterIterator getCharacterIterator(){
6
CodeRank
This code example shows how to use the following methods:getEndIndex, last, next
    return iter;
  } 
 
  public int last () 
  { 
    iter.last();
    // Go past the last character. 
    iter.next();
    return iter.getEndIndex();
  } 
 
  public int next (int n)
  { 
    int r = iter.getIndex ();
    if (n > 0)
      { 
	while (n > 0 && r != DONE)
	  { 
	    r = next ();
	    --n;
6
CodeRank
This code example shows how to use the following methods:getBeginIndex, getEndIndex, setIndex, clone
     * @param stop the index of the first character after the subinterval 
     */ 
    public AttributedCharacterSpanIterator(AttributedCharacterIterator aci, 
                                           int start, int stop) {
        this.aci = aci;
        end = Math.min(aci.getEndIndex(), stop);
        begin = Math.max(aci.getBeginIndex(), start);
        this.aci.setIndex(begin);
    } 
 
    //From java.text.AttributedCharacterIterator 
 
    /** 
     * Get the keys of all attributes defined on the iterator's text range. 
     */ 
    public Set getAllAttributeKeys() {
        return aci.getAllAttributeKeys();
        // FIXME: not if there are atts outside the substring! 
    } 
 

6
CodeRank
This code example shows how to use the following methods:getEndIndex, last, next
    return iter;
  } 
 
  public int last () 
  { 
    iter.last();
    // Go past the last character. 
    iter.next();
    return iter.getEndIndex();
  } 
 
  public int next (int n)
  { 
    int r = iter.getIndex ();
    if (n > 0)
      { 
        while (n > 0 && r != DONE)
          { 
            r = next ();
            --n;
6
CodeRank
This code example shows how to use the following methods:getBeginIndex, getEndIndex, getIndex, setIndex
        } 
    } 
     
 
    public int moveIndex(int delta){
        int length = iterator.getEndIndex() - iterator.getBeginIndex(); 
        int idx = iterator.getIndex()+delta;
         
        if(idx < 0) {
            idx = 0;
        } else if(idx > length) {
            idx = length;
        } 
        return iterator.setIndex(idx);
    } 
     
    /** 
     * @see UCharacterIterator#getCharacterIterator() 
     */ 
    public CharacterIterator getCharacterIterator(){
5
CodeRank
This code example shows how to use the following methods:getIndex, next, setIndex
 
        return kanji;
    } 
 
    private Character iteratorPeek(CharacterIterator iterator) {
        int currentIndex = iterator.getIndex();
        Character peeked = iterator.next();
        iterator.setIndex(currentIndex);
        return peeked;
    } 
 
    private String digitToKanji(char digit) {
        String digitString;
        switch (digit) {
            case '0': 
                digitString = J_0;
                break; 
            case '1': 
                digitString = J_1;
                break; 
5
CodeRank
This code example shows how to use the following methods:getBeginIndex, getEndIndex, getIndex, setIndex
     * @see #getTarget 
     * @stable ICU 2.4 
     */ 
    public void setTarget(CharacterIterator text)
    { 
        if (text == null || text.getEndIndex() == text.getIndex()) {
            throw new IllegalArgumentException("Illegal null or empty text");
        } 
         
        targetText = text;
        targetText.setIndex(targetText.getBeginIndex());
        matchLength = 0;
        m_reset_ = true;
        m_isForwardSearching_ = true;
        if (breakIterator != null) {
            breakIterator.setText(targetText);
        } 
    } 
 
    // public getters ---------------------------------------------------- 
5
CodeRank
This code example shows how to use the following methods:current, first, next, previous
 
    public Object read(CharacterIterator ci, int start) {
        it = ci;
        switch (start) {
        case FIRST:
            c = it.first();
            break; 
        case CURRENT:
            c = it.current();
            break; 
        case NEXT:
            c = it.next();
            break; 
        } 
        return read(); 
    } 
 
    public Object read(CharacterIterator it) {
        return read(it, NEXT);
    } 

5
CodeRank
This code example shows how to use the following methods:getBeginIndex, getEndIndex
 
    /** 
     * @see UCharacterIterator#getLength() 
     */ 
    public int getLength() { 
        return (iterator.getEndIndex() - iterator.getBeginIndex());
    } 
 
    /** 
     * @see UCharacterIterator#getIndex() 
     */ 
    public int getIndex() { 
        return iterator.getIndex();
    } 
 
    /** 
     * @see UCharacterIterator#next() 
     */ 
    public int next() { 
        int i = iterator.current();
5
CodeRank

Related Java 8 CharacterIterator Questions & Answers:

See Code Examples for Java 8 CharacterIterator Methods: