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

This code example shows how to use the following methods: getIterator
	/** 
	 * @tests java.text.AttributedCharacterIterator#last() 
	 */ 
	public void test_last() { 
		String test = "Test 23ring";
		AttributedString attrString = new AttributedString(test);
		AttributedCharacterIterator it = attrString.getIterator();
		assertEquals("Wrong last1", 'g', it.last());
		it = attrString.getIterator(null, 0, 3);
		assertEquals("Wrong last2", 's', it.last());
		it = attrString.getIterator(null, 2, 8);
		assertEquals("Wrong last3", 'r', it.last());
		it = attrString.getIterator(null, 0, 0);
		assertTrue("Wrong last4", it.last() == CharacterIterator.DONE);
	} 
 
	/** 
	 * @tests java.text.AttributedCharacterIterator#next() 
	 */ 
	public void test_next() { 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addAttribute, getIterator
        String str = "If this text is >" + target + "< the test passed.";
        int length = str.length();
        int start = str.indexOf(target);
        int limit = start + target.length();
 
        AttributedString astr = new AttributedString(str);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL);
 
        astr.addAttribute(TextAttribute.BIDI_EMBEDDING,
                         new Integer(-3),
                         start,
                         limit);
 
        Bidi bidi = new Bidi(astr.getIterator());
 
        if (bidi.getRunCount() != 6) { // runs of spaces and angles at embedding bound,s and final period, each get level 1
            throw new Error("Bidi embedding processing failed");
        } 
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addAttribute
 
    } 
 
    protected void setUp() { 
 
        AttributedString as = new AttributedString(string);
 
        as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE,
                "GERMAN"); 
        as.addAttribute(AttributedCharacterIterator.Attribute.READING,
                "READ"); 
        as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE,
                "ENGLISH"); 
 
        it = as.getIterator();
    } 
 
    protected void tearDown() { 
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getIterator
	/** 
	 * @tests java.text.AttributedCharacterIterator#last() 
	 */ 
	public void test_last() { 
		String test = "Test 23ring";
		AttributedString attrString = new AttributedString(test);
		AttributedCharacterIterator it = attrString.getIterator();
		assertEquals("Wrong last1", 'g', it.last());
		it = attrString.getIterator(null, 0, 3);
		assertEquals("Wrong last2", 's', it.last());
		it = attrString.getIterator(null, 2, 8);
		assertEquals("Wrong last3", 'r', it.last());
		it = attrString.getIterator(null, 0, 0);
		assertTrue("Wrong last4", it.last() == CharacterIterator.DONE);
	} 
 
	/** 
	 * @tests java.text.AttributedCharacterIterator#next() 
	 */ 
	public void test_next() { 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addAttribute
     * java.text.AttributedString.addAttribute(AttributedCharacterIterator, 
     *        Object) 
     */ 
    public void test_addAttributeLjava_text_AttributedCharacterIterator$AttributeLjava_lang_Object() { 
        // regression for Harmony-1244 
        AttributedString as = new AttributedString("123", new WeakHashMap());
 
        as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "english");
        as.addAttribute(AttributedCharacterIterator.Attribute.INPUT_METHOD_SEGMENT,
                                                                "input method"); 
        as.addAttribute(AttributedCharacterIterator.Attribute.READING, "reading");
 
        try { 
            as.addAttribute(null, new TreeSet());
            fail("should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected 
        } 
        try { 
            as.addAttribute(null, null);

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 AttributedString Methods: