FieldPosition setEndIndex - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for FieldPosition setEndIndex method.

This code example shows how to use the following methods:getEndIndex, setBeginIndex, setEndIndex
                -1, fpos.getBeginIndex());
    } 
 
    public void test_setEndIndexI() { 
        // Test for method void java.text.FieldPosition.setEndIndex(int) 
        FieldPosition fpos = new FieldPosition(1);
        fpos.setEndIndex(3);
        fpos.setBeginIndex(2);
        assertEquals("EndIndex should have been set to 3", 3, fpos
                .getEndIndex());
 
        fpos.setEndIndex(Integer.MAX_VALUE);
        assertEquals("endIndex should have been set to Integer.MAX_VALUE",
                Integer.MAX_VALUE, fpos.getEndIndex());
 
        fpos.setEndIndex(-1);
        assertEquals("endIndex should have been set to -1",
                -1, fpos.getEndIndex());
    } 
} 

7
CodeRank
This code example shows how to use the following methods:getEndIndex, setBeginIndex, setEndIndex
                -1, fpos.getBeginIndex());
    } 
 
    public void test_setEndIndexI() { 
        // Test for method void java.text.FieldPosition.setEndIndex(int) 
        FieldPosition fpos = new FieldPosition(1);
        fpos.setEndIndex(3);
        fpos.setBeginIndex(2);
        assertEquals("EndIndex should have been set to 3", 3, fpos
                .getEndIndex());
 
        fpos.setEndIndex(Integer.MAX_VALUE);
        assertEquals("endIndex should have been set to Integer.MAX_VALUE",
                Integer.MAX_VALUE, fpos.getEndIndex());
 
        fpos.setEndIndex(-1);
        assertEquals("endIndex should have been set to -1",
                -1, fpos.getEndIndex());
    } 
} 

7
CodeRank
This code example shows how to use the following methods:getEndIndex, setBeginIndex, setEndIndex
                -1, fpos.getBeginIndex());
    } 
 
    public void test_setEndIndexI() { 
        // Test for method void java.text.FieldPosition.setEndIndex(int) 
        FieldPosition fpos = new FieldPosition(1);
        fpos.setEndIndex(3);
        fpos.setBeginIndex(2);
        assertEquals("EndIndex should have been set to 3", 3, fpos
                .getEndIndex());
 
        fpos.setEndIndex(Integer.MAX_VALUE);
        assertEquals("endIndex should have been set to Integer.MAX_VALUE",
                Integer.MAX_VALUE, fpos.getEndIndex());
 
        fpos.setEndIndex(-1);
        assertEquals("endIndex should have been set to -1",
                -1, fpos.getEndIndex());
    } 
} 

7
CodeRank
This code example shows how to use the following methods:getEndIndex, setBeginIndex, setEndIndex
	/** 
	 * @tests java.text.FieldPosition#setEndIndex(int) 
	 */ 
	public void test_setEndIndexI() { 
		// Test for method void java.text.FieldPosition.setEndIndex(int) 
		FieldPosition fpos = new FieldPosition(1);
		fpos.setEndIndex(3);
		fpos.setBeginIndex(2);
		assertEquals("EndIndex should have been set to 3",
				3, fpos.getEndIndex());
	} 
 
	/** 
	 * @tests java.text.FieldPosition#toString() 
	 */ 
	public void test_toString() { 
		// Test for method java.lang.String java.text.FieldPosition.toString() 
		FieldPosition fpos = new FieldPosition(1);
		fpos.setBeginIndex(2);
		fpos.setEndIndex(3);
6
CodeRank
This code example shows how to use the following methods:getEndIndex, setBeginIndex, setEndIndex
                -1, fpos.getBeginIndex());
    } 
 
    public void test_setEndIndexI() { 
        // Test for method void java.text.FieldPosition.setEndIndex(int) 
        FieldPosition fpos = new FieldPosition(1);
        fpos.setEndIndex(3);
        fpos.setBeginIndex(2);
        assertEquals("EndIndex should have been set to 3", 3, fpos
                .getEndIndex());
 
        fpos.setEndIndex(Integer.MAX_VALUE);
        assertEquals("endIndex should have been set to Integer.MAX_VALUE",
                Integer.MAX_VALUE, fpos.getEndIndex());
 
        fpos.setEndIndex(-1);
        assertEquals("endIndex should have been set to -1",
                -1, fpos.getEndIndex());
    } 
} 

6
CodeRank
This code example shows how to use the following methods:setBeginIndex, setEndIndex
     */ 
    @Override 
    public StringBuffer format(Fraction fraction, StringBuffer toAppendTo,
            FieldPosition pos) {
 
        pos.setBeginIndex(0);
        pos.setEndIndex(0);
 
        int num = fraction.getNumerator();
        int den = fraction.getDenominator();
        int whole = num / den;
        num = num % den;
 
        if (whole != 0) {
            getWholeFormat().format(whole, toAppendTo, pos);
            toAppendTo.append(' ');
            num = Math.abs(num);
        } 
        getNumeratorFormat().format(num, toAppendTo, pos);
        toAppendTo.append(" / ");

6
CodeRank
This code example shows how to use the following methods:setBeginIndex, setEndIndex
     */ 
    @Override 
    public StringBuffer format(final BigFraction fraction,
                               final StringBuffer toAppendTo, final FieldPosition pos) {
 
        pos.setBeginIndex(0);
        pos.setEndIndex(0);
 
        BigInteger num = fraction.getNumerator();
        BigInteger den = fraction.getDenominator();
        BigInteger whole = num.divide(den);
        num = num.remainder(den);
 
        if (!BigInteger.ZERO.equals(whole)) {
            getWholeFormat().format(whole, toAppendTo, pos);
            toAppendTo.append(' ');
            if (num.compareTo(BigInteger.ZERO) < 0) {
                num = num.negate();
            } 
        } 

6
CodeRank
This code example shows how to use the following methods:setBeginIndex, setEndIndex
     * @return the value passed in as toAppendTo. 
     */ 
    public StringBuffer format(final Fraction fraction,
                               final StringBuffer toAppendTo, final FieldPosition pos) {
 
        pos.setBeginIndex(0);
        pos.setEndIndex(0);
 
        getNumeratorFormat().format(fraction.getNumerator(), toAppendTo, pos);
        toAppendTo.append(" / ");
        getDenominatorFormat().format(fraction.getDenominator(), toAppendTo,
            pos);
 
        return toAppendTo;
    } 
 
    /** 
     * Formats an object and appends the result to a StringBuffer. <code>obj</code> must be either a 
     * {@link Fraction} object or a {@link Number} object.  Any other type of 
     * object will result in an {@link IllegalArgumentException} being thrown. 
6
CodeRank
This code example shows how to use the following methods:setBeginIndex, setEndIndex
     * @return the value passed in as toAppendTo. 
     */ 
    public StringBuffer format(final BigFraction BigFraction,
                               final StringBuffer toAppendTo, final FieldPosition pos) {
 
        pos.setBeginIndex(0);
        pos.setEndIndex(0);
 
        getNumeratorFormat().format(BigFraction.getNumerator(), toAppendTo, pos);
        toAppendTo.append(" / ");
        getDenominatorFormat().format(BigFraction.getDenominator(), toAppendTo, pos);
 
        return toAppendTo;
    } 
 
    /** 
     * Formats an object and appends the result to a StringBuffer. 
     * <code>obj</code> must be either a  {@link BigFraction} object or a 
     * {@link BigInteger} object or a {@link Number} object. Any other type of 
     * object will result in an {@link IllegalArgumentException} being thrown. 
6
CodeRank
This code example shows how to use the following methods:setBeginIndex, setEndIndex
     */ 
    @Override 
    public StringBuffer format(Fraction fraction, StringBuffer toAppendTo,
            FieldPosition pos) {
 
        pos.setBeginIndex(0);
        pos.setEndIndex(0);
 
        int num = fraction.getNumerator();
        int den = fraction.getDenominator();
        int whole = num / den;
        num = num % den;
 
        if (whole != 0) {
            getWholeFormat().format(whole, toAppendTo, pos);
            toAppendTo.append(' ');
            num = Math.abs(num);
        } 
        getNumeratorFormat().format(num, toAppendTo, pos);
        toAppendTo.append(" / ");

5
CodeRank
setEndIndex Method Overview
Sets the end index.
See Code Examples for other Java 8 FieldPosition Methods: