Java 8 StringCharacterIterator - 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 StringCharacterIterator class.

This code example shows how to use the following methods:current, getBeginIndex, getEndIndex, getIndex, next
            fail("Assert 0: no null pointer");
        } catch (NullPointerException e) {
            // expected 
        } 
         
        StringCharacterIterator it = new StringCharacterIterator("testing");
		assertEquals("Wrong begin index", 0, it.getBeginIndex());
		assertEquals("Wrong end index", 7, it.getEndIndex());
		assertEquals("Wrong current index", 0, it.getIndex());
		assertEquals("Wrong current char", 't', it.current());
		assertEquals("Wrong next char", 'e', it.next());
    } 
 
    /** 
     * @tests java.text.StringCharacterIterator#StringCharacterIterator(java.lang.String, 
     *        int) 
     */ 
    public void test_ConstructorLjava_lang_StringI() { 
        StringCharacterIterator it = new StringCharacterIterator("testing", 3);
		assertEquals("Wrong begin index", 0, it.getBeginIndex());
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:current, getBeginIndex, getEndIndex, getIndex, next
            fail("Assert 0: no null pointer");
        } catch (NullPointerException e) {
            // expected 
        } 
         
        StringCharacterIterator it = new StringCharacterIterator("testing");
		assertEquals("Wrong begin index", 0, it.getBeginIndex());
		assertEquals("Wrong end index", 7, it.getEndIndex());
		assertEquals("Wrong current index", 0, it.getIndex());
		assertEquals("Wrong current char", 't', it.current());
		assertEquals("Wrong next char", 'e', it.next());
    } 
 
    /** 
     * @tests java.text.StringCharacterIterator#StringCharacterIterator(java.lang.String, 
     *        int) 
     */ 
    public void test_ConstructorLjava_lang_StringI() { 
        StringCharacterIterator it = new StringCharacterIterator("testing", 3);
		assertEquals("Wrong begin index", 0, it.getBeginIndex());
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:current, next
        out.append(_enc((byte)(in[off + 1] << 2 & 0x3c | in[off + 2] >>> 6 & 3)));
        out.append(_enc((byte)(in[off + 2] & 0x3f)));
    } 
 
    private static void decodeChars(StringCharacterIterator it, byte out[], int off) {
        byte b1 = _dec(it.current());
        byte b2 = _dec(it.next());
        byte b3 = _dec(it.next());
        byte b4 = _dec(it.next());
        it.next();
        byte b5 = (byte)(b1 << 2 | b2 >> 4);
        byte b6 = (byte)(b2 << 4 | b3 >> 2);
        byte b7 = (byte)(b3 << 6 | b4);
        out[off] = b5;
        out[off + 1] = b6;
        out[off + 2] = b7;
    } 
 
    private static char _enc(byte c) {
        return (char)((c & 0x3f) + 32);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:first
   * Creates a new ERXCommandLineTokenizer. 
   *  
   * @param line the line to parse 
   */ 
  public ERXCommandLineTokenizer(String line) {
    _iterator = new StringCharacterIterator(line);
    reset(); 
  } 
 
  protected void reset() { 
    _state = TokenizerState.Whitespace;
    _iterator.first();
  } 
 
  /** 
   * Returns true if there are more tokens on the line. 
   *  
   * @return true if there are more tokens on the line, false if not 
   */ 
  public boolean hasMoreElements() { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    assertSameBreaks(text, offset, length, offset, expected, actual);
  } 
   
  public void assertSameBreaks(String text, int offset, int length, int current, BreakIterator expected, BreakIterator actual) {
    assertSameBreaks(new StringCharacterIterator(text, offset, offset+length, current), 
                     new StringCharacterIterator(text, offset, offset+length, current), 
                     expected, 
                     actual);
  } 
 
  /** Asserts that two breakiterators break the text the same way */ 
  public void assertSameBreaks(CharacterIterator one, CharacterIterator two, BreakIterator expected, BreakIterator actual) {
    expected.setText(one);
    actual.setText(two);
 
    assertEquals(expected.current(), actual.current());
 
    // next() 
    int v = expected.current();
    while (v != BreakIterator.DONE) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        int iter = NativeBreakIterator.getWordInstanceImpl(where.toString());
        return new RuleBasedBreakIterator(iter, BI_WORD_INSTANCE);
    } 
 
    public void setText(String newText) {
        setText(new StringCharacterIterator(newText));
    } 
 
    public abstract boolean isBoundary(int offset);
 
    public abstract int preceding(int offset);
     
    public abstract Object clone();
 
    public abstract int current(); 
 
    public abstract int first(); 
 
    public abstract int following(int offset);
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:first
     *             {@link #writeChars(String s)} or another write method instead. 
     */ 
    @Deprecated 
    @Override 
    public void writeBytes( String str ) {
        CharacterIterator iter = new StringCharacterIterator(str);
        for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
            writeByte(c);
        } 
    } 
 
    /** 
     * Writes every character in the string <code>s</code>, to the output stream, in order, two bytes per character. If 
     * <code>s</code> is <code>null</code>, a <code>NullPointerException</code> is thrown. If <code>s.length</code> is zero, then 
     * no characters are written. Otherwise, the character <code>s[0]</code> is written first, then <code>s[1]</code>, and so on; 
     * the last character written is <code>s[s.length-1]</code>. For each character, two bytes are actually written, low-order 
     * byte first, in exactly the manner of the <code>writeChar</code> method. 
     *  
     * @param str the string value to be written. 
     */ 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        try { 
            iterator.setText((CharacterIterator) null);
            fail();
        } catch (NullPointerException e) {
        } 
        CharacterIterator it = new StringCharacterIterator("abc");
        iterator.setText(it);
        assertSame(it, iterator.getText());
    } 
 
    /* 
     * Class under test for void setText(String) 
     */ 
    public void testSetTextString() { 
        try { 
            iterator.setText((String) null);
            fail();
        } catch (NullPointerException e) {
        } 
        iterator.setText("abc");
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:first
public class CommandLineTokenizer implements Enumeration {
	private StringCharacterIterator myIterator;
	private int myState;
	 
	public CommandLineTokenizer(String _line) {
		myIterator = new StringCharacterIterator(_line);
		reset(); 
	} 
	 
	public void reset() { 
		myState = 1;
		myIterator.first();
	} 
	 
	public boolean hasMoreElements() { 
		return hasMoreTokens(); 
	} 
	 
	public boolean hasMoreTokens() { 
		return (myIterator.current() != CharacterIterator.DONE);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
     */ 
    public GVTGlyphVector createGlyphVector(FontRenderContext frc,
                                            char[] chars) {
 
        StringCharacterIterator sci =
            new StringCharacterIterator(new String(chars));
        GlyphVector gv = awtFont.createGlyphVector(frc, chars);
        return new AWTGVTGlyphVector(gv, this, scale, sci);
    } 
 
    /** 
     * Returns a new GlyphVector object created with the specified 
     * CharacterIterator and the specified FontRenderContext. 
     */ 
    public GVTGlyphVector createGlyphVector(FontRenderContext frc,
                                            CharacterIterator ci) {
 
        if (ci instanceof AttributedCharacterIterator) {
            AttributedCharacterIterator aci = (AttributedCharacterIterator)ci;
            if (ArabicTextHandler.containsArabic(aci)) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 StringCharacterIterator Questions & Answers:

See Code Examples for Java 8 StringCharacterIterator Methods: